MCPcopy
hub / github.com/golang/geo / ExampleRect_DistanceToLatLng

Function ExampleRect_DistanceToLatLng

s2/example_test.go:24–67  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

22)
23
24func ExampleRect_DistanceToLatLng() {
25 r := s2.RectFromLatLng(s2.LatLngFromDegrees(-1, -1)).AddPoint(s2.LatLngFromDegrees(1, 1))
26
27 printDist := func(lat, lng float64) {
28 fmt.Printf("%f\n", r.DistanceToLatLng(s2.LatLngFromDegrees(lat, lng))/s1.Degree)
29 }
30
31 fmt.Println("Distances next to the rectangle.")
32 printDist(-2, 0)
33 printDist(0, -2)
34 printDist(2, 0)
35 printDist(0, 2)
36
37 fmt.Println("Distances beyond the corners of the rectangle.")
38 printDist(-2, -2)
39 printDist(-2, 2)
40 printDist(2, 2)
41 printDist(2, -2)
42
43 fmt.Println("Distance within the rectangle.")
44 printDist(0, 0)
45 printDist(0.5, 0)
46 printDist(0, 0.5)
47 printDist(-0.5, 0)
48 printDist(0, -0.5)
49
50 // Output:
51 // Distances next to the rectangle.
52 // 1.000000
53 // 1.000000
54 // 1.000000
55 // 1.000000
56 // Distances beyond the corners of the rectangle.
57 // 1.413962
58 // 1.413962
59 // 1.413962
60 // 1.413962
61 // Distance within the rectangle.
62 // 0.000000
63 // 0.000000
64 // 0.000000
65 // 0.000000
66 // 0.000000
67}
68
69func ExamplePolygonFromOrientedLoops() {
70 // Let's define three loops, in format World Geodetic System 1984,

Callers

nothing calls this directly

Calls 4

RectFromLatLngFunction · 0.92
LatLngFromDegreesFunction · 0.92
DistanceToLatLngMethod · 0.80
AddPointMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…