georust / geojson

Library for serializing the GeoJSON vector GIS file format
https://crates.io/crates/geojson
Apache License 2.0
276 stars 60 forks source link

Add support for foreign members to FeatureWriter. #232

Closed dabreegster closed 1 year ago

dabreegster commented 1 year ago
dabreegster commented 1 year ago

Successfully using this in https://github.com/dabreegster/routing-engines/blob/c58cc43832714c3c2ca17105f184b2885313eddd/aggregate_routes/src/osm2network.rs#L350

michaelkirk commented 1 year ago

Hrmm... my inline comment got lost in the ether.

What would you think about changing the API slightly to avoid building up the intermediate JsonObject just to pass it in?

pub fn write_foreign_member(&mut self, key: &str, foreign_member: &JsonValue) -> Result<()>;
dabreegster commented 1 year ago

What would you think about changing the API slightly to avoid building up the intermediate JsonObject just to pass it in?

Good idea, done. It was an odd API before to only allow one of the calls. Writing one key at a time is much nicer.

dabreegster commented 1 year ago

This gets a little nicer to use if we allow the same value types as serde_json::to_writer.

Good point, thanks! Done