[−][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
 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 ChamberlainDuquette area.
Optional Features (these can be activated in your cargo.toml
)
The following optional features are available:
useproj
: enable coordinate conversion and transformation ofPoint
geometries using theproj
crateprojnetwork
: enables functionality forproj
crate's network grid. After enabling this feature, some further configuration is required to actually use the network grid.useserde
: enable serialisation of geometries usingserde
.
GeoJSON
If you wish to read or write GeoJSON
, use the geojson
crate, with the geotypes
feature activated.
This provides fallible conversions to geotypes
primitives such as Point
and Polygon
from geojson
Value
structs using the standard TryFrom
and TryInto
traits,
and conversion from geotypes
primitives to geojson
Value
structs using the From
trait.
Reexports
pub use crate::algorithm::*; 
Modules
algorithm  This module includes all the functions of geometric calculations 
prelude  A prelude which reexports 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 2dimensional Cartesian plane. 
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 twodimensional area. 
Rect  An axisaligned bounded 2D rectangle 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. 
Traits
CoordFloat  
CoordNum  The type of an x or y value of a point/coordinate. 
GeoFloat  A common numeric trait used for geo algorithms. 
GeoNum  
ToGeo  Deprecated 