[−][src]Crate geo
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:
- Serialization to and from GeoJSON and WKT
- Coordinate transformation and projection
- Geocoding
- Working with GPS data
…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: convertGeometrytypes to and fromPostGIStypes.use-proj: enable coordinate conversion and transformation ofPointgeometries using theprojcrateuse-serde: enable serialisation of geometries usingserde.
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.
Re-exports
pub use crate::algorithm::*; |
Modules
| algorithm | This module includes all the functions of geometric calculations |
| prelude | A prelude which re-exports the traits for manipulating objects in this
crate. Typically imported with |
Macros
| line_string | Creates a |
| point | Creates a |
| polygon | Creates a |
Structs
| Coordinate | A lightweight struct used to store coordinates on the 2-dimensional Cartesian plane. |
| ExtremePoint | A container for the coordinates of the minimum and maximum |
| Extremes | A container for indices of the minimum and maximum |
| GeometryCollection | A collection of |
| Line | A line segment made up of exactly two |
| LineString | An ordered collection of two or more |
| MultiLineString | A collection of |
| MultiPoint | A collection of |
| MultiPolygon | A collection of |
| Point | A single point in 2D space. |
| Polygon | A bounded two-dimensional area. |
| Rect | A bounded 2D quadrilateral whose area is defined by minimum and maximum |
| Triangle | A bounded 2D area whose three vertices are defined by |
Enums
| Closest | The result of trying to find the closest spot on an object to a point. |
| Geometry | An enum representing any possible geometry type. |
Statics
| COORD_PRECISION |
Traits
| CoordinateType | The type of an x or y value of a point/coordinate. |
| ToGeo | Deprecated |