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

Implement __geo_interface__ for relevant classes #621

Merged
merged 2 commits into from
Jun 16, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions ipyleaflet/leaflet.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,16 @@ def _get_data(self):

return self.data

@property
def __geo_interface__(self):
"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making a docstring! We need more of those.

Return a dict whose structure aligns to the GeoJSON format
For more information about the ``__geo_interface__``, see
https://gist.github.com/sgillies/2217756
"""

return self.data

def _apply_style(self, feature, style_callback):
if 'properties' not in feature:
feature['properties'] = {}
Expand Down Expand Up @@ -595,6 +605,16 @@ def _update_data(self, change):
def _get_data(self):
return json.loads(self.geo_dataframe.to_json())

@property
def __geo_interface__(self):
"""
Return a dict whose structure aligns to the GeoJSON format
For more information about the ``__geo_interface__``, see
https://gist.github.com/sgillies/2217756
"""

return self.geo_dataframe.__geo_interface__


class Choropleth(GeoJSON):
geo_data = Dict()
Expand Down