Closed kraktus closed 7 months ago
Hello, thanks for the great crate.
A nice-to-have feature-flag would be to allow directly converting geojson::PolygonType to geo::Polygon. I don't know in which create it should live. I assume it's reasonably frequent to use those two together
geojson::PolygonType
geo::Polygon
for now doing that:
fn vec_to_line(vec: &Vec<Vec<f64>>) -> LineString<f64> { vec.iter() .map(|coord| (coord[0], coord[1])) .collect::<Vec<_>>() .into() } fn polygon_to_polygon(polygon: &PolygonType) -> geo::Polygon { let mut copy_vec = polygon.clone(); let holes = copy_vec.split_off(1); let line = vec_to_line(©_vec[0]); geo::Polygon::new(line, holes.iter().map(vec_to_line).collect()) }
https://docs.rs/geojson/latest/geojson/#use-geojson-with-other-crates-by-converting-to-geo-types
Thanks 👍
Hello, thanks for the great crate.
A nice-to-have feature-flag would be to allow directly converting
geojson::PolygonType
togeo::Polygon
. I don't know in which create it should live. I assume it's reasonably frequent to use those two togetherfor now doing that: