[][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:

…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:

  • 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.

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 use geo::prelude::*.

Macros

line_string

Creates a LineString containing the given coordinates.

point

Creates a Point from the given coordinates.

polygon

Creates a Polygon containing the given coordinates.

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 Points of a Geometry.

Extremes

A container for indices of the minimum and maximum Points of a Geometry.

GeometryCollection

A collection of Geometry types.

Line

A line segment made up of exactly two Points.

LineString

An ordered collection of two or more Coordinates, representing a path between locations.

MultiLineString

A collection of LineStrings.

MultiPoint

A collection of Points.

MultiPolygon

A collection of Polygons.

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 Coordinates.

Triangle

A bounded 2D area whose three vertices are defined by Coordinates.

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

CoordinateType

The type of an x or y value of a point/coordinate.

ToGeoDeprecated