package svgmap import ( "fmt" "math" "regexp" "strconv" "strings" "testing" "b612.me/astro/internal/geodata" ) var landGlobeCoordinatePattern = regexp.MustCompile(`[ML](-?[0-9.]+) (-?[0-9.]+)`) // renderGlobeLand 渲染球面底图并取回陆地的路径命令与画布。 func renderGlobeLand(t *testing.T, center geodata.GeoPoint) (Frame, string) { t.Helper() frame := Frame{ X: 30, Y: 30, Width: 640, Height: 640, Projection: ProjectionOrthographic, CenterLongitude: center.Longitude, CenterLatitude: center.Latitude, } var builder strings.Builder fmt.Fprintf(&builder, `%s`, frame.ClipDefinition("clip")) frame.WriteOcean(&builder) frame.WriteGraticule(&builder, "clip") frame.WriteLand(&builder, "clip") builder.WriteString(``) rendered := builder.String() const marker = ` radius+0.6 { t.Fatalf("%v: vertex %.1f,%.1f falls outside the disk", center, point[0], point[1]) } next := subpath[(index+1)%len(subpath)] if gap := math.Hypot(next[0]-point[0], next[1]-point[1]); gap > limit { t.Fatalf("%v: subpath edge of %.1f px (limit %.1f) between %.1f,%.1f and %.1f,%.1f", center, gap, limit, point[0], point[1], next[0], next[1]) } } } t.Logf("%v: subpaths=%d vertices=%d", center, len(subpaths), vertices) } }