-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More ergonomic FeatureCollection with properties creation #170
Comments
One approach is to split the concern into two:
|
This is a fun case study in API design! For context: Originally, the zonebuilder geojson output code looked like this: zonebuilders/zonebuilder-rust@0ec7209 1
IIRC, there was a little consternation at this point - I believe the thought was along the lines of, "I already have a bunch of polygons, I just want to turn them into geojson, this should be easier". So, my internal monologue was something like:
In response to that, I opened #163 (implemented in #165). Then in zonebuilders/zonebuilder-rust@853b9fd, the zonebuilder code adopted it, and was made to look like this: 2
However, when @dabreegster added labeling to zonebuilder, which indeed required passing properties along with the geometric data. Reverting the code to something a little more like the original code. 3
|
FWIW, I like @rmanoka's proposal. |
Yes, me too! |
Thanks for providing more context @michaelkirk . The let fc: FeatureCollection = zones.iter().map(|name, poly| {
// Produce a feature
}).collect();
fc.into() // Assuming function output type is declared as GeoJson This leaves the following couple pts. to discuss.
|
That sounds great, thanks for laying it out @rmanoka! |
This will work once georust/geojson#170 is resolved
I was looking at the new ZoneBuilder functionality, and this comment from @dabreegster caught my eye, and the RStar
GeomWithData
method addresses a similar need.Ideally, we'd have some
FeatureCollection::from
impls that accept e.g. a vec (or anyimpl iterator
) of structs with a property field (anything that can be used to build aserde_json::Map
) and aInto<geo::Geometry>
field, or a vec-of-vecs, vec-of-tuples, tuple-of-vecs &c.The text was updated successfully, but these errors were encountered: