Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3ce26ed

Browse files
authored
Merge pull request #10253 from gnestor/geojson
Add GeoJSON display class
2 parents 1f44501 + 37615ef commit 3ce26ed

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

IPython/core/display.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
__all__ = ['display', 'display_pretty', 'display_html', 'display_markdown',
2525
'display_svg', 'display_png', 'display_jpeg', 'display_latex', 'display_json',
2626
'display_javascript', 'display_pdf', 'DisplayObject', 'TextDisplayObject',
27-
'Pretty', 'HTML', 'Markdown', 'Math', 'Latex', 'SVG', 'JSON', 'Javascript',
27+
'Pretty', 'HTML', 'Markdown', 'Math', 'Latex', 'SVG', 'JSON', 'GeoJSON', 'Javascript',
2828
'Image', 'clear_output', 'set_matplotlib_formats', 'set_matplotlib_close',
2929
'publish_display_data', 'update_display', 'DisplayHandle']
3030

@@ -680,6 +680,25 @@ def _repr_json_(self):
680680
lib_t2 = """});
681681
"""
682682

683+
class GeoJSON(JSON):
684+
685+
@property
686+
def data(self):
687+
return self._data
688+
689+
@data.setter
690+
def data(self, data):
691+
if isinstance(data, str):
692+
data = json.loads(data)
693+
self._data = data
694+
695+
def _ipython_display_(self):
696+
bundle = {
697+
'application/geo+json': self.data,
698+
'text/plain': '<jupyterlab_geojson.GeoJSON object>'
699+
}
700+
display(bundle, raw=True)
701+
683702
class Javascript(TextDisplayObject):
684703

685704
def __init__(self, data=None, url=None, filename=None, lib=None, css=None):

0 commit comments

Comments
 (0)