Skip to content

Commit

Permalink
Enable, revise, and expand GeoJSON --> Geo conversion docs
Browse files Browse the repository at this point in the history
  • Loading branch information
urschrei committed Dec 21, 2017
1 parent b51f993 commit a3fad98
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ fn create_geo_multi_polygon<T>(multi_polygon_type: &Vec<PolygonType>) -> geo::Mu
.collect())
}

/// This trait provides fallible conversions from GeoJSON values to [Geo](https://docs.rs/geo) types
pub trait TryInto<T> {
type Err;
fn try_into(self) -> Result<T, Self::Err>;
Expand Down
12 changes: 10 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,15 @@
//! process_geojson(&geojson);
//! }
//! ```
//!
//! ## Conversion to Geo objects
//!
//! The [try_into](file:///Users/sth/dev/rust-geojson/target/doc/geojson/conversion/index.html) trait provides *fallible* conversions from GeoJSON Value structs
//! to [Geo](https://docs.rs/geo) types, allowing them to be measured or used in calculations. Note that
//! this conversion consumes the GeoJSON object, so you will not be able to match
//! by reference as in the example above. The [polylabel_cmd](https://github.com/urschrei/polylabel_cmd/blob/master/src/main.rs) crate contains an
//! implementation which may be useful if you wish to perfom these conversions.

extern crate serde;
#[macro_use]
Expand Down Expand Up @@ -222,8 +231,7 @@ pub use feature::Feature;
mod feature_collection;
pub use feature_collection::FeatureCollection;

/// Convert geo::types to geometry::Geometry
#[doc(hidden)]
/// Convert Geometries into [Geo](https://docs.rs/geo) types
pub mod conversion;

/// Error when reading a GeoJSON object from a str or Object
Expand Down

0 comments on commit a3fad98

Please sign in to comment.