()
| 22 | ) |
| 23 | |
| 24 | func 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 | |
| 69 | func ExamplePolygonFromOrientedLoops() { |
| 70 | // Let's define three loops, in format World Geodetic System 1984, |
nothing calls this directly
no test coverage detected
searching dependent graphs…