|
| 1 | +# Manifolds |
| 2 | + |
| 3 | +A manifold is, mathematically, a description of some space that is locally Euclidean (i.e., locally flat). |
| 4 | +All geographic projections, and the surface of the sphere and ellipsoid, fall under this category of space - |
| 5 | +and these are all the spaces that are relevant to geographic geometry. |
| 6 | + |
| 7 | +## What manifolds are available? |
| 8 | + |
| 9 | +GeometryOps has three [`Manifold`](@ref) types: [`Planar`](@ref), [`Spherical`](@ref), and [`Geodesic`](@ref). |
| 10 | + |
| 11 | +- `Planar()` is, as the name suggests, a perfectly Cartesian, usually 2-dimensional, space. The shortest path from one point to another is a straight line. |
| 12 | +- `Spherical(; radius)` describes points on the surface of a sphere of a given radius. |
| 13 | + The most convenient sphere for geometry processing is the unit sphere, but one can also use |
| 14 | + the sphere of the Earth for e.g. projections. |
| 15 | +- `Geodesic(; semimajor_axis, inv_flattening)` describes points on the surface of a flattened ellipsoid, |
| 16 | + similar to the Earth. The parameters describe the curvature and shape of the ellipsoid, and are equivalent |
| 17 | + to the flags `+a` and `+f` in Proj's ellipsoid specification. The default values are the values of the WGS84 |
| 18 | + ellipsoid. |
| 19 | + |
| 20 | + For `Geodesic`, we need an `AbstractGeodesic` that can wrap representations from Proj.jl and SphericalGeodesics.jl. |
| 21 | + |
| 22 | +The idea here is that the manifold describes how the geometry needs to be treated. |
| 23 | + |
| 24 | +## Why this is needed |
| 25 | + |
| 26 | +The classical problem this is intended to solve is that in GIS, latitude and longitude coordinates |
| 27 | +are often treated as planar coordinates, when they in fact live on the sphere/ellipsoid, and must be |
| 28 | +treated as such. For example, computing the area of the USA on the lat/long plane yields a result of `1116`, |
| 29 | +which is plainly nonsensical. |
| 30 | + |
| 31 | +## How this is done |
| 32 | + |
| 33 | +In order to avoid this, we've introduced three complementary CRS-related systems to the JuliaGeo ecosystem. |
| 34 | + |
| 35 | +1. GeoInterface's `crstrait`. This is a method that returns the ideal CRS _type_ of a geometry, either Cartesian or Geographic. |
| 36 | +2. Proj's `PreparedCRS` type, which extracts ellipsoid parameters and the nature of the projection from a coordinate reference system, and |
| 37 | + caches the results in a struct. This allows GeometryOps to quickly determine the correct manifold to use for a given geometry. |
| 38 | +3. GeometryOps's `Manifold` type, which defines the surface on which to perform operations. This is what allows GeometryOps to perform |
| 39 | + calculations correctly depending on the nature of the geometry. |
| 40 | + |
| 41 | + |
| 42 | +The way this flow works, is that when you load a geometry using GeoDataFrames, its CRS is extracted and parsed into a `PreparedCRS` type. |
| 43 | +This is then used to determine the manifold to use for the geometry, and the geometry is converted to the manifold's coordinate system. |
| 44 | + |
| 45 | +There is a table of known geographic coordinate systems in GeoFormatTypes.jl, and anything else is assumed to be |
| 46 | +a Cartesian or planar coordinate system. CRStrait is used as the cheap determinant, but PreparedCRS is more general and better to use if possible. |
| 47 | + |
| 48 | +When GeometryOps sees a geometry, it first checks its CRS to see if it is a geographic coordinate system. If it is, it uses the `PreparedCRS`, or falls back to `crstrait` and geographic defaults to determine the manifold. |
| 49 | + |
| 50 | +## Algorithms and manifolds |
| 51 | + |
| 52 | +Algorithms define what operation is performed on the geometry; however, the choice of algorithm can also depend on the manifold. L'Huilier's algorithm for the area of a polygon is not applicable to the plane, but is applicable to either the sphere or ellipsoid, for example. |
0 commit comments