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

Geojson: allow null geometry objects #1858

Merged
merged 3 commits into from
Jan 21, 2024

Conversation

hansthen
Copy link
Collaborator

@hansthen hansthen commented Jan 8, 2024

GeoJson objects can have null geometry members according to the standard. However, if we pass a null value to folium, this will cause an error in m.get_bounds().

See https://datatracker.ietf.org/doc/html/rfc7946#section-3.2

A Feature object has a member with the name "geometry". The value of the geometry member SHALL be either a Geometry object as defined above or . . . a JSON null value.

See https://datatracker.ietf.org/doc/html/rfc7946#section-3.2

A Feature object has a member with the name "geometry".  The value
of the geometry member SHALL be either a Geometry object as
defined above or . . . a JSON null value.
@Conengmo Conengmo self-requested a review January 10, 2024 09:51
@Conengmo Conengmo changed the title Fix error for geojson objects with null geometry objects Geojson: allow null geometry objects Jan 21, 2024
@Conengmo Conengmo merged commit c18677f into python-visualization:main Jan 21, 2024
12 checks passed
@Conengmo
Copy link
Member

Thanks @hansthen! Nice enhancement, good PR. I wanted to merge it now already, but I was also thinking it would be nice to have a test case for this null case in iter_coords. That way we can prevent regressions in the future. If you have the time for it, that would be very welcome. But I didn't want to hold up this PR for that, so I already merged it. Thanks again!

@hansthen
Copy link
Collaborator Author

I do not have a lot of time this week, but I will put it on my bucket list. If I remember correctly I also promised to add more tests to the leaflet-realtime plugin.

hansthen added a commit to hansthen/folium that referenced this pull request Jan 24, 2024
* GeoJson objects can have null geometry objects

See https://datatracker.ietf.org/doc/html/rfc7946#section-3.2

A Feature object has a member with the name "geometry".  The value
of the geometry member SHALL be either a Geometry object as
defined above or . . . a JSON null value.

* Missed an instance geometry cannot be null

* Handle empty geojson features
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants