geo 0.13.0

Geospatial primitives and algorithms
Documentation

The geo crate provides geospatial primitive types such as Coordinate, Point, LineString, and Polygon as well as their Multi– equivalents, and provides algorithms and operations such as:

  • Area and centroid calculation
  • Simplification and convex hull operations
  • Distance measurement
  • Intersection checks
  • Transformation to and from PostGIS types
  • Affine transforms such as rotation and translation.

The primitive types also provide the basis for other functionality in the Geo ecosystem, including:

…allowing these crates to interoperate; GeoJSON can readily be read from a file, deserialised, transformed to a local datum, modified, transformed back to WGS84, and serialised back to GeoJSON.

Operations available for primitive types can be found in the algorithm module, along with comprehensive usage examples.

While Geo is primarily intended to operate on planar geometries, some other useful algorithms are provided: Haversine, Frechet, and Vincenty distances, as well as Chamberlain-Duquette area.

Optional Features (these can be activated in your cargo.toml)

The following optional features are available:

  • from-postgis: convert Geometry types to and from PostGIS types.
  • use-proj: enable coordinate conversion and transformation of Point geometries using the proj crate
  • use-serde: enable serialisation of geometries using serde.

GeoJSON

If you wish to read or write GeoJSON, use the geojson crate, with the geo-types feature activated. This provides fallible conversions to geo-types primitives such as Point and Polygon from geojson Value structs using the standard TryFrom and TryInto traits, and conversion from geo-types primitives to geojson Value structs using the From trait.