pub fn quick_collection<T>(gj: &GeoJson) -> Result<GeometryCollection<T>>where
T: CoordFloat,
๐Deprecated since 0.24.1: use
geo_types::GeometryCollection::try_from(&geojson)
insteadExpand description
A shortcut for producing geo_types
GeometryCollection objects
from arbitrary valid GeoJSON input.
This function is primarily intended for easy processing of GeoJSON FeatureCollection
objects using the geo
crate, and sacrifices a little performance for convenience.
ยงExample
use geo_types::{Geometry, GeometryCollection, Point};
#[allow(deprecated)]
use geojson::{quick_collection, GeoJson};
let geojson_str = r#"
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [-1.0, 2.0]
}
}
]
}
"#;
let geojson = geojson_str.parse::<GeoJson>().unwrap();
// Turn the GeoJSON string into a geo_types GeometryCollection
#[allow(deprecated)]
let mut collection: GeometryCollection<f64> = quick_collection(&geojson).unwrap();
assert_eq!(collection[0], Geometry::Point(Point::new(-1.0, 2.0)))