const SpheroidErrorFraction = 0.05
SpheroidErrorFraction is an error fraction to compensate for using a sphere to calculate the distance for what is actually a spheroid. The distance calculation has an error that is bounded by (2 * spheroid.Flattening)%. This 5% margin is pretty safe.
Area returns the area of a given Geography.
Azimuth returns the azimuth in radians of the segment defined by the given point geometries. The azimuth is angle is referenced from north, and is positive clockwise. North = 0; East = π/2; South = π; West = 3π/2. Returns nil if the two points are the same. Returns an error if any of the two Geography items are not points.
BestGeomProjection translates roughly to the ST_BestSRID function in PostGIS. It attempts to find the best projection for a bounding box into an accurate geometry-type projection.
The algorithm is described by ST_Buffer/ST_Intersection documentation (paraphrased):
It first determines the best SRID that fits the bounding box of the 2 geography objects (ST_Intersection only). It favors a north/south pole projection, then UTM, then LAEA for smaller zones, otherwise falling back to web mercator. If geography objects are within one half zone UTM but not the same UTM it will pick one of those. After the calculation is complete, it will fall back to WGS84 Geography.
Centroid returns the Centroid of a given Geography.
NOTE: In the case of (Multi)Polygon Centroid result, it doesn't mirror with PostGIS's result. We are using the same algorithm of dividing into triangles. However, The PostGIS implementation differs as it cuts triangles in a different way - namely, it fixes the first point in the exterior ring as the first point of the triangle, whereas we always update the reference point to be the first point of the ring when moving from one ring to another.
See: http://jennessent.com/downloads/Graphics_Shapes_Manual_A4.pdf#page=49 for more details.
Ideally, both implementations should provide the same result. However, the centroid of the triangles is the vectorized mean of all the points, not the actual projection in the Spherical surface, which causes a small inaccuracies. This inaccuracy will eventually grow if there is a substantial number of a triangle with a larger area.
CoveredBy returns whether geography A is covered by geography B. See Covers for limitations.
Covers returns whether geography A covers geography B.
This calculation is done on the sphere.
Due to minor inaccuracies and lack of certain primitives in S2, precision for Covers will be for up to 1cm.
Current limitations (which are also limitations in PostGIS): * POLYGON/LINESTRING only works as "contains" - if any point of the LINESTRING
touches the boundary of the polygon, we will return false but should be true - e.g. SELECT st_covers( 'multipolygon(((0.0 0.0, 1.0 0.0, 1.0 1.0, 0.0 1.0, 0.0 0.0)), ((1.0 0.0, 2.0 0.0, 2.0 1.0, 1.0 1.0, 1.0 0.0)))', 'linestring(0.0 0.0, 1.0 0.0)'::geography );
* Furthermore, LINESTRINGS that are covered in multiple POLYGONs inside
MULTIPOLYGON but NOT within a single POLYGON in the MULTIPOLYGON currently return false but should be true, e.g. SELECT st_covers( 'multipolygon(((0.0 0.0, 1.0 0.0, 1.0 1.0, 0.0 1.0, 0.0 0.0)), ((1.0 0.0, 2.0 0.0, 2.0 1.0, 1.0 1.0, 1.0 0.0)))', 'linestring(0.0 0.0, 2.0 0.0)'::geography );
DWithin returns whether a is within distance d of b, i.e. Distance(a, b) <= d. If A or B contains empty Geography objects, this will return false.
Distance returns the distance between geographies a and b on a sphere or spheroid. Returns a geo.EmptyGeometryError if any of the Geographies are EMPTY.
Intersects returns whether geography A intersects geography B. This calculation is done on the sphere. Precision of intersect measurements is up to 1cm.
Length returns length of a given Geography.
Perimeter returns the perimeter of a given Geography.
Project returns calculate a projected point given a source point, a distance and a azimuth.
Segmentize return modified Geography having no segment longer that given maximum segment length. This works by dividing each segment by a power of 2 to find the smallest power less than or equal to the segmentMaxLength.
UseSphereOrSpheroid indicates whether to use a Sphere or Spheroid for certain calculations.
const ( // UseSpheroid indicates to use the spheroid for calculations. UseSpheroid UseSphereOrSpheroid = true // UseSphere indicates to use the sphere for calculations. UseSphere UseSphereOrSpheroid = false )