geoarrow_schema/
edges.rs

1use serde::{Deserialize, Serialize};
2
3/// The edge interpretation between explicitly defined vertices.
4///
5/// This does not affect format conversions (e.g., parsing `geoarrow.wkb` as
6/// `geoarrow.linestring`), but does affect distance, intersection, bounding, overlay, length, and
7/// area calculations. The `edges` key must be omitted to indicate planar/linear edges or be one
8/// of:
9///
10/// If the `edges` key is omitted, edges will be interpreted following the language of
11/// [Simple features access](https://www.opengeospatial.org/standards/sfa):
12///
13/// > **simple feature** feature with all geometric attributes described piecewise
14/// > by straight line or planar interpolation between sets of points (Section 4.19).
15///
16/// If an implementation only has support for a single edge interpretation (e.g.,
17/// a library with only planar edge support), an array with a different edge type
18/// may be imported without losing information if the geometries in the array
19/// do not contain edges (e.g., `geoarrow.point`, `geoarrow.multipoint`, a
20/// `geoarrow.wkb`/`geoarrow.wkt` that only contains points and multipoints, or any
21/// array that only contains empty geometries). For arrays that contain edges,
22/// the error introduced by ignoring the original edge interpretation is similar to
23/// the error introduced by applying a coordinate transformation to vertices (which
24/// is usually small but may be large or create invalid geometries, particularly if
25/// vertices are not closely spaced). Ignoring the original edge interpretation will
26/// silently introduce invalid and/or misinterpreted geometries for any edge that crosses
27/// the antimeridian (i.e., longitude 180/-180) when translating from non-planar
28/// to planar edges.
29///
30/// Implementations may implicitly import arrays with an unsupported edge type if the
31/// arrays do not contain edges. Implementations may otherwise import arrays with an
32/// unsupported edge type with an explicit opt-in from a user or if accompanied
33/// by a prominent warning.
34#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, Hash)]
35pub enum Edges {
36    /// Edges in the longitude-latitude dimensions follow a path calculated by
37    /// the fomula in Thomas, Paul D. Mathematical models for navigation systems. US Naval
38    /// Oceanographic Office, 1965 using the ellipsoid specified by the `"crs"`.
39    #[serde(rename = "andoyer")]
40    Andoyer,
41
42    /// Edges in the longitude-latitude dimensions follow a path calculated by the fomula in
43    /// [Karney, Charles FF. "Algorithms for geodesics." Journal of Geodesy 87 (2013):
44    /// 43-55](https://link.springer.com/content/pdf/10.1007/s00190-012-0578-z.pdf) and
45    /// [GeographicLib](https://geographiclib.sourceforge.io/) using the ellipsoid specified by the
46    /// `"crs"`. GeographicLib available via modern versions of PROJ.
47    #[serde(rename = "karney")]
48    Karney,
49
50    /// Edges in the longitude-latitude dimensions follow the
51    /// shortest distance between vertices approximated as the shortest distance
52    /// between the vertices on a perfect sphere. This edge interpretation is used by
53    /// [BigQuery Geography](https://cloud.google.com/bigquery/docs/geospatial-data#coordinate_systems_and_edges),
54    /// and [Snowflake Geography](https://docs.snowflake.com/en/sql-reference/data-types-geospatial).
55    ///
56    /// A common library for interpreting edges in this way is
57    /// [Google's s2geometry](https://github.com/google/s2geometry); a common formula
58    /// for calculating distances along this trajectory is the
59    /// [Haversine Formula](https://en.wikipedia.org/wiki/Haversine_formula).
60    #[serde(rename = "spherical")]
61    Spherical,
62
63    /// Edges in the longitude-latitude dimensions follow a path calculated by
64    /// the fomula in Thomas, Paul D. Spheroidal geodesics, reference systems, & local geometry.
65    /// US Naval Oceanographic Office, 1970 using the ellipsoid specified by the `"crs"`.
66    #[serde(rename = "thomas")]
67    Thomas,
68
69    /// Edges in the longitude-latitude dimensions follow a path calculated
70    /// using [Vincenty's formula](https://en.wikipedia.org/wiki/Vincenty%27s_formulae) and
71    /// the ellipsoid specified by the `"crs"`.
72    #[serde(rename = "vincenty")]
73    Vincenty,
74}