Skip to content
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

Map_Coords/(Other Map_* operations) loses data and affects original referenced object #136

Open
mike-sosa-sofarocean opened this issue Oct 2, 2019 · 3 comments

Comments

@mike-sosa-sofarocean
Copy link

To reproduce the issue take a FeatureCollection that has the example feature
[{"geometry": {"coordinates": [-142.505993, 27.779555], "properties": {"dogs": 5, "cats": 6, "frogs": 7}, "type": "Point"}, "properties": {}, "type": "Feature"}]

Then if we run map_coords to divide each coordinate in half

# gj is our FeatureCollection object
gj_prime = geojson.utils.map_coords(lambda x: x / 2, gj)

Then gj_prime will have
{"geometry": {"coordinates": [-71.2529965, 13.8897775], "type": "Point"}, "properties": {}, "type": "Feature"}

which correctly applies the coordinate transformation but does not carry over the properties dictionary. Additionally if we look back at the original FeatureCollection gj, it will have also have the transformation applied to its coordinates, and properties dictionary lost.

This does not seem like the intended behavior (or at least should have a 'copy'/'in_place' kwarg) and additionally information during the operation should be preserved.

@arsdragonfly
Copy link

Can confirm. map_ functions should preserve properties.

@hhoeflin
Copy link

To add to this ... the returned object is not actually a "FeatureCollection" or "Feature" object, but instead the dictionary encoded version. In practice this can be seen e.g. during comparison, where one encodes coordinate-tuples to tuples, and not to lists - as in the example above.

@ferreteleco
Copy link

Is there any update on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants