-
-
Notifications
You must be signed in to change notification settings - Fork 122
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
Fix map_geometries() loss of feature IDs #128
Conversation
If a feature has an ID it should not be lost by mapping over it.
Codecov Report
@@ Coverage Diff @@
## master #128 +/- ##
==========================================
+ Coverage 93.33% 95.11% +1.78%
==========================================
Files 10 10
Lines 345 348 +3
Branches 69 70 +1
==========================================
+ Hits 322 331 +9
+ Misses 14 9 -5
+ Partials 9 8 -1
Continue to review full report at Codecov.
|
I don't know what codecov/patch is or why it is failing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's telling to improve the cov little bt more.
Hi @bryik, thank you for your contribution. However, I'm leaning against making this change, because I don't know that If you read the docstrings (the main comments directly under each function declaration) in https://github.com/jazzband/python-geojson/blob/master/geojson/utils.py then you will see that the various utility functions in this repo are only intended to return partial data, not a full representation of the input object. So, my understanding is that the utility functions are not intended to be a "put your object in one end and get it out the other transformed" functions, but "give me your object and I'll give you some transformed data you can add to it" functions. Would using them this way meet your needs? In other words, change the second half of your example to:
|
Hello @rayrrr. I'm not quite sure I understand your proposal. geojson_feature['mapped_geometry'] = geojson.utils.map_tuples(lambda t: t, geojson_feature) results in a {
"geometry": {
"coordinates": [-77.1291115237051, 38.7993076720178, 0],
"type": "Point"
},
"id": "0",
"mapped_geometry": {
"geometry": {
"coordinates": [-77.1291115237051, 38.7993076720178, 0],
"type": "Point"
},
"properties": {
"line": "blue",
"marker-col": "#0000ff",
"marker-sym": "rail-metro",
"name": "Van Dorn Street"
},
"type": "Feature"
},
"properties": {
"line": "blue",
"marker-col": "#0000ff",
"marker-sym": "rail-metro",
"name": "Van Dorn Street"
},
"type": "Feature"
} Are you saying that this behaviour is intended? |
Looking at the docs again, I see However, the docstring of |
@bryik your additional notes helpful, and you are correct. Merging your PR in its current form. I was basing my earlier comments off of misleading docstrings, sorry. The docs/docstrings for |
@rayrrr Happy to help :-) Thanks for the review and for maintaining this project! |
I noticed that a Feature passed to
geojson.utils.map_tuples()
loses it's ID. Here is a simple replication.The cause seems to be that IDs are not included in the dict returned by geojson.utils.map_geometry().
This PR: