Skip to content

Commit

Permalink
Refactor geojson, see georust/geojson#162
Browse files Browse the repository at this point in the history
  • Loading branch information
Robinlovelace committed Apr 14, 2021
1 parent 6e57cdf commit 853b9fd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ edition = "2018"

[dependencies]
geo = { version = "0.17.1", features=["use-serde"] }
geojson = { version = "0.22.0", features=["geo-types"] }
geojson = { version = "0.23.0", features=["geo-types"] }
serde_json = { version = "1.0.0" }
structopt = "0.3.21"
22 changes: 6 additions & 16 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ use geo::{map_coords::MapCoordsInplace, LineString, Point, Polygon};
use geojson::{Feature, FeatureCollection, GeoJson, Geometry};
use std::convert::TryInto;
use std::default::Default;
use std::iter::FromIterator;


// use std::path::PathBuf;
use structopt::StructOpt;
Expand Down Expand Up @@ -120,22 +122,10 @@ pub fn clockboard(
round(polygon, params.precision);
}

let features: Vec<Feature> = polygons
.iter()
.map(|poly| Feature {
bbox: None,
geometry: Some(Geometry::from(poly)),
id: None,
properties: None,
foreign_members: None,
})
.collect();

let fc = FeatureCollection {
bbox: None,
features,
foreign_members: None,
};
let gc = geo::GeometryCollection::from_iter(polygons);
let fc = geojson::FeatureCollection::from(&gc);
let gj = GeoJson::from(fc);
gj

let gj = GeoJson::from(fc);
gj
Expand Down

0 comments on commit 853b9fd

Please sign in to comment.