Projection defines an interface for different ways of mapping between s2 and r2 Points. It can also define the coordinate wrapping behavior along each axis.
| 24 | // Projection defines an interface for different ways of mapping between s2 and r2 Points. |
| 25 | // It can also define the coordinate wrapping behavior along each axis. |
| 26 | type Projection interface { |
| 27 | // Project converts a point on the sphere to a projected 2D point. |
| 28 | Project(p Point) r2.Point |
| 29 | |
| 30 | // Unproject converts a projected 2D point to a point on the sphere. |
| 31 | // |
| 32 | // If wrapping is defined for a given axis (see below), then this method |
| 33 | // should accept any real number for the corresponding coordinate. |
| 34 | Unproject(p r2.Point) Point |
| 35 | |
| 36 | // FromLatLng is a convenience function equivalent to Project(LatLngToPoint(ll)), |
| 37 | // but the implementation is more efficient. |
| 38 | FromLatLng(ll LatLng) r2.Point |
| 39 | |
| 40 | // ToLatLng is a convenience function equivalent to LatLngFromPoint(Unproject(p)), |
| 41 | // but the implementation is more efficient. |
| 42 | ToLatLng(p r2.Point) LatLng |
| 43 | |
| 44 | // Interpolate returns the point obtained by interpolating the given |
| 45 | // fraction of the distance along the line from A to B. |
| 46 | // Fractions < 0 or > 1 result in extrapolation instead. |
| 47 | Interpolate(f float64, a, b r2.Point) r2.Point |
| 48 | |
| 49 | // WrapDistance reports the coordinate wrapping distance along each axis. |
| 50 | // If this value is non-zero for a given axis, the coordinates are assumed |
| 51 | // to "wrap" with the given period. For example, if WrapDistance.Y == 360 |
| 52 | // then (x, y) and (x, y + 360) should map to the same Point. |
| 53 | // |
| 54 | // This information is used to ensure that edges takes the shortest path |
| 55 | // between two given points. For example, if coordinates represent |
| 56 | // (latitude, longitude) pairs in degrees and WrapDistance().Y == 360, |
| 57 | // then the edge (5:179, 5:-179) would be interpreted as spanning 2 degrees |
| 58 | // of longitude rather than 358 degrees. |
| 59 | // |
| 60 | // If a given axis does not wrap, its WrapDistance should be set to zero. |
| 61 | WrapDistance() r2.Point |
| 62 | |
| 63 | // WrapDestination that wraps the coordinates of B if necessary in order to |
| 64 | // obtain the shortest edge AB. For example, suppose that A = [170, 20], |
| 65 | // B = [-170, 20], and the projection wraps so that [x, y] == [x + 360, y]. |
| 66 | // Then this function would return [190, 20] for point B (reducing the edge |
| 67 | // length in the "x" direction from 340 to 20). |
| 68 | WrapDestination(a, b r2.Point) r2.Point |
| 69 | |
| 70 | // We do not support implementations of this interface outside this package. |
| 71 | privateInterface() |
| 72 | } |
| 73 | |
| 74 | // PlateCarreeProjection defines the "plate carree" (square plate) projection, |
| 75 | // which converts points on the sphere to (longitude, latitude) pairs. |
no outgoing calls
no test coverage detected
searching dependent graphs…