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

GeoJsonTooltip warn for GeometryCollection #988

Merged
merged 135 commits into from
Dec 9, 2018
Merged
Show file tree
Hide file tree
Changes from 130 commits
Commits
Show all changes
135 commits
Select commit Hold shift + click to select a range
287ac36
Update features.py
jtbaker Jun 15, 2018
2491e19
Cleaned up code linting for this commit.
jtbaker Jun 15, 2018
6290a5b
Update features.py
jtbaker Jun 15, 2018
fda9729
Further linting.
jtbaker Jun 15, 2018
bde7a2b
Hopefully last linting.
jtbaker Jun 15, 2018
b5f9282
Update features.py
jtbaker Jun 15, 2018
8e5168c
Update features.py
jtbaker Jun 16, 2018
73b1f4d
Update features.py
jtbaker Jun 16, 2018
d03bf2f
lint
jtbaker Jun 16, 2018
8ce80a6
lint
jtbaker Jun 16, 2018
bb325f4
lint
jtbaker Jun 16, 2018
bd2a12f
lint
jtbaker Jun 16, 2018
c73686e
lint
jtbaker Jun 16, 2018
5b9cb8b
lint
jtbaker Jun 16, 2018
5525df0
Update features.py
jtbaker Jun 16, 2018
cc89971
Update features.py
jtbaker Jun 16, 2018
bb825f0
Update features.py
jtbaker Jun 19, 2018
5c9c425
More lint checking.
jtbaker Jun 19, 2018
16d44f0
Update features.py
jtbaker Jun 19, 2018
2fb3437
Update features.py
jtbaker Jun 19, 2018
9933f58
Update features.py
jtbaker Jun 19, 2018
c8d404d
Update features.py
jtbaker Jun 19, 2018
90d7de9
Update features.py
jtbaker Jun 19, 2018
bfd277b
Merge pull request #1 from python-visualization/master
jtbaker Jun 23, 2018
84811a0
PC-2018.1.2 <jasonbaker@Earl.local Overwrite remote https://github.co…
jtbaker Jun 23, 2018
76c9622
PC-2018.1.2 <jasonbaker@Earl.local Create baseRefactoring.xml, Intell…
jtbaker Jun 23, 2018
f69bb30
Revert "PC-2018.1.2 <jasonbaker@Earl.local Create baseRefactoring.xml…
jtbaker Jun 23, 2018
cf116fe
Revert "PC-2018.1.2 <jasonbaker@Earl.local Overwrite remote https://g…
jtbaker Jun 23, 2018
f9e3eb8
PC-2018.1.2 <jasonbaker@Earl.local Update vcs.xml
jtbaker Jun 24, 2018
d9f4109
PC-2018.1.2 <jasonbaker@Earl.local Merge branch 'master'
jtbaker Jun 24, 2018
ac3e03e
PC-2018.1.2 <jasonbaker@Earl.local Create code.style.schemes, laf.xml…
jtbaker Jun 24, 2018
3dc30cb
Updated code for line length limitation, verbiage, and indentations.
jtbaker Jun 24, 2018
25e80a1
Merge pull request #2 from jtbaker/New-Tooltip
jtbaker Jun 24, 2018
405245c
Merge branch 'patch-2' into master
jtbaker Jun 24, 2018
ee8c427
Merge pull request #3 from jtbaker/master
jtbaker Jun 24, 2018
12e04f8
Missed a line remove when resolving conflicts.
jtbaker Jun 24, 2018
5a00b8b
Updated code for line length limitation, verbiage, and indentations.
jtbaker Jun 24, 2018
f40d145
Merge pull request #4 from jtbaker/New-Tooltip
jtbaker Jun 24, 2018
e1431a2
PC-2018.1.2 <jasonbaker@Earl.local Update Default.xml
jtbaker Jun 24, 2018
86b29df
PC-2018.1.2 <jasonbaker@Earl.local Create editor.xml
jtbaker Jun 24, 2018
844ec5b
PC-2018.1.2 <jasonbaker@Earl.local Merge branch 'master'
jtbaker Jun 24, 2018
9364c3f
Updated code for line length limitation, verbiage, and indentations.
jtbaker Jun 24, 2018
b95f840
Merge branch 'patch-2' into New-Tooltip
jtbaker Jun 24, 2018
856aa80
Merge pull request #5 from jtbaker/New-Tooltip
jtbaker Jun 24, 2018
7eaa85e
Merge pull request #6 from jtbaker/patch-2
jtbaker Jun 24, 2018
e4978be
Updated code for line length limitation, verbiage, and indentations.
jtbaker Jun 24, 2018
1e5242f
Updated code for line length limitation, verbiage, and indentations.
jtbaker Jun 24, 2018
de5606a
PC-2018.1.2 <jasonbaker@Earl.local Create laf.xml, filetypes.xml, key…
jtbaker Jun 28, 2018
76af841
PC-2018.1.2 <jasonbaker@Earl.local Create github_settings.xml, Defaul…
jtbaker Jun 29, 2018
31a7685
PC-2018.1.2 <jasonbaker@Earl.local Create git.xml
jtbaker Jun 29, 2018
c0ea0b5
PC-2018.1.2 <jasonbaker@Earl.local Create ui.lnf.xml, Default.xml
jtbaker Jul 10, 2018
8fa9122
PC-2018.1.2 <jasonbaker@Earl.local Update Default.xml
jtbaker Jul 10, 2018
2478531
PC-2018.1.2 <jasonbaker@Earl.local Create diff.xml
jtbaker Jul 15, 2018
eac16da
PC-2018.1.2 <jasonbaker@Earl.local Update github_settings.xml
jtbaker Jul 17, 2018
0725b4b
Update features.py
jtbaker Jun 15, 2018
99db68d
Cleaned up code linting for this commit.
jtbaker Jun 15, 2018
200155b
Update features.py
jtbaker Jun 15, 2018
f7cee1b
Further linting.
jtbaker Jun 15, 2018
9b5ecc8
Hopefully last linting.
jtbaker Jun 15, 2018
4e54b19
Update features.py
jtbaker Jun 15, 2018
6ef92db
Update features.py
jtbaker Jun 16, 2018
1f3c402
Update features.py
jtbaker Jun 16, 2018
f860855
lint
jtbaker Jun 16, 2018
292d54d
lint
jtbaker Jun 16, 2018
7a7ee05
lint
jtbaker Jun 16, 2018
cdda09d
lint
jtbaker Jun 16, 2018
bbfbb49
lint
jtbaker Jun 16, 2018
98e7f45
lint
jtbaker Jun 16, 2018
461bf11
Update features.py
jtbaker Jun 16, 2018
875c6ba
Update features.py
jtbaker Jun 16, 2018
3eb8816
Update features.py
jtbaker Jun 19, 2018
c2fa01e
More lint checking.
jtbaker Jun 19, 2018
9226117
Update features.py
jtbaker Jun 19, 2018
e5e3e48
Update features.py
jtbaker Jun 19, 2018
9d00638
Update features.py
jtbaker Jun 19, 2018
46a8f05
Update features.py
jtbaker Jun 19, 2018
a530153
Update features.py
jtbaker Jun 19, 2018
f8eea8a
PC-2018.1.2 <jasonbaker@Earl.local Overwrite remote https://github.co…
jtbaker Jun 23, 2018
3f9ebab
PC-2018.1.2 <jasonbaker@Earl.local Create baseRefactoring.xml, Intell…
jtbaker Jun 23, 2018
812ec07
Revert "PC-2018.1.2 <jasonbaker@Earl.local Create baseRefactoring.xml…
jtbaker Jun 23, 2018
f3e66a4
Revert "PC-2018.1.2 <jasonbaker@Earl.local Overwrite remote https://g…
jtbaker Jun 23, 2018
a3d9af2
PC-2018.1.2 <jasonbaker@Earl.local Create code.style.schemes, laf.xml…
jtbaker Jun 24, 2018
4c5f94a
Updated code for line length limitation, verbiage, and indentations.
jtbaker Jun 24, 2018
1774c1b
Updated code for line length limitation, verbiage, and indentations.
jtbaker Jun 24, 2018
aad6580
PC-2018.1.2 <jasonbaker@Earl.local Update Default.xml
jtbaker Jun 24, 2018
2d536db
PC-2018.1.2 <jasonbaker@Earl.local Create editor.xml
jtbaker Jun 24, 2018
9098a75
Updated code for line length limitation, verbiage, and indentations.
jtbaker Jun 24, 2018
0be87d5
Updated code for line length limitation, verbiage, and indentations.
jtbaker Jun 24, 2018
919f7d9
Merge branch 'master' of https://github.com/jtbaker/folium
jtbaker Jul 17, 2018
cc74c27
Rebasing my master.
jtbaker Jul 17, 2018
cba08d6
PC-2018.1.2 <jasonbaker@Earl.local Create vcs.xml
jtbaker Jul 19, 2018
bd51b9e
PC-2018.1.2 <jasonbaker@Earl.local Merge branch 'master'
jtbaker Jul 27, 2018
09b410a
PC-2018.1.2 <jasonbaker@Earl.local Create ide.general.xml
jtbaker Jul 31, 2018
742d5e3
PC-2018.1.2 <jasonbaker@Earl.local Update ide.general.xml
jtbaker Jul 31, 2018
888096c
Merge pull request #20 from python-visualization/master
jtbaker Jul 31, 2018
6ae615b
PC-2018.1.2 <jasonbaker@Earl.local Merge branch 'master'
jtbaker Aug 11, 2018
8493787
PC-2018.1.2 <jasonbaker@Earl.local Update Default.xml Create code.sty…
jtbaker Aug 19, 2018
a2d4206
PC-2018.1.2 <jasonbaker@Earl.local Update filetypes.xml
jtbaker Sep 1, 2018
61e61e6
PC-2018.1.2 <jasonbaker@Earl.local Create ignore.xml
jtbaker Sep 5, 2018
6824b32
Merge pull request #24 from python-visualization/master
jtbaker Sep 6, 2018
7a3ffb5
PC-2018.1.2 <jasonbaker@Earl.local Merge branch 'master'
jtbaker Sep 8, 2018
49970a2
PC-2018.1.2 <jasonbaker@Earl.local Update vcs.xml
jtbaker Sep 11, 2018
28ddf28
PC-2018.1.2 <jasonbaker@Earl.local Update vcs.xml
jtbaker Sep 29, 2018
7ebceb8
PC-2018.1.2 <jasonbaker@Earl.local Update ignore.xml
jtbaker Sep 29, 2018
04bbcc4
Merge pull request #25 from python-visualization/master
jtbaker Oct 14, 2018
0d14fe6
Update GeoJsonTooltip to warn user about incompatibility if a tooltip
jtbaker Oct 14, 2018
ecce466
Delete git.xml
jtbaker Oct 14, 2018
1f01ff5
Delete keymap.xml
jtbaker Oct 14, 2018
ab64d08
Delete laf.xml
jtbaker Oct 14, 2018
e4cfdef
Delete code.style.schemes
jtbaker Oct 14, 2018
7732c10
Delete Default.xml
jtbaker Oct 14, 2018
eb61a00
Delete vcs.xml
jtbaker Oct 14, 2018
fe884d6
Delete ui.lnf.xml
jtbaker Oct 14, 2018
d392d09
Delete github_settings.xml
jtbaker Oct 14, 2018
3694a40
Delete debugger.xml
jtbaker Oct 14, 2018
1d5cfa0
Delete diff.xml
jtbaker Oct 14, 2018
8fce636
Delete filetypes.xml
jtbaker Oct 14, 2018
f5bfa3e
Delete ide.general.xml
jtbaker Oct 14, 2018
60a1220
Delete Default.xml
jtbaker Oct 14, 2018
7ba38b3
Delete ignore.xml
jtbaker Oct 14, 2018
b7bebed
Fixes for whitespace, and separate lines for import.
jtbaker Oct 14, 2018
bb3b9db
Merge remote-tracking branch 'origin/GeoJsonTooltipUpdate' into GeoJs…
jtbaker Oct 14, 2018
d909e4b
Rework Warning lines, and split `geom_collection` list comprehension
jtbaker Oct 15, 2018
071b220
Rework check to class method.
jtbaker Oct 16, 2018
2bdfb99
Add file with GeometryCollection geometry for test.
jtbaker Oct 29, 2018
2a09446
Refactor warning for more general feature warning since not all featu…
jtbaker Oct 29, 2018
7ecb4fe
Add Test for GeometryCollection warning with GeoJsonTooltip.
jtbaker Oct 29, 2018
19f6d9b
Stickler fixes.
jtbaker Oct 29, 2018
4aebbc9
Stickler fixes.
jtbaker Oct 29, 2018
4a8eec2
Stickler fixes.
jtbaker Oct 29, 2018
d913b41
Stickler fixes.
jtbaker Oct 29, 2018
bf68fa9
Filepath name fix for CI integration.
jtbaker Oct 29, 2018
8de05c3
Change test to subclass method. Sorry for the delay on this @Conengmo.
jtbaker Nov 20, 2018
cf71841
Merge branch 'master' into GeoJsonTooltipUpdate
ocefpaf Nov 20, 2018
0d23dec
Merge remote-tracking branch 'upstream/master' into GeoJsonTooltipUpdate
jtbaker Nov 28, 2018
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
15 changes: 15 additions & 0 deletions folium/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from __future__ import (absolute_import, division, print_function)

import json
import warnings

from branca.colormap import LinearColormap
from branca.element import (Element, Figure, JavascriptLink, MacroElement)
Expand Down Expand Up @@ -704,10 +705,24 @@ def __init__(self, fields, aliases=None, labels=True,
# noqa outside of type checking.
self.style = style

def warn_for_geometry_collections(self):
"""Checks for GeoJson GeometryCollection features to warn user about incompatibility."""
geom_collections = [
feature.get('properties') if feature.get('properties') is not None else key
for key, feature in enumerate(self._parent.data['features'])
if feature['geometry']['type'] == 'GeometryCollection'
]
if any(geom_collections):
warnings.warn(
"GeoJsonTooltip is not configured to render tooltips for GeoJson GeometryCollection geometries. "
"Please consider reworking these features: {} to MultiPolygon for full functionality.\n"
"https://tools.ietf.org/html/rfc7946#page-9".format(geom_collections), UserWarning)

def render(self, **kwargs):
"""Renders the HTML representation of the element."""
if isinstance(self._parent, GeoJson):
keys = tuple(self._parent.data['features'][0]['properties'].keys())
self.warn_for_geometry_collections()
elif isinstance(self._parent, TopoJson):
obj_name = self._parent.object_path.split('.')[-1]
keys = tuple(self._parent.data['objects'][obj_name][
Expand Down
1 change: 1 addition & 0 deletions tests/kuntarajat.geojson

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions tests/test_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

import os

import warnings

from branca.element import Element
from branca.six import text_type

Expand Down Expand Up @@ -104,3 +106,15 @@ def test_color_line():
opacity=1)
m.add_child(color_line)
m._repr_html_()


# GeoJsonTooltip GeometryCollection
def test_geojson_tooltip():

Choose a reason for hiding this comment

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

E302 expected 2 blank lines, found 1

m = folium.Map([30.5, -97.5], zoom_start=10)
folium.GeoJson("./kuntarajat.geojson",
tooltip=folium.GeoJsonTooltip(fields=['code','name'])

Choose a reason for hiding this comment

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

E231 missing whitespace after ','

).add_to(m)
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter('always')
m._repr_html_()
assert isinstance(w[-1].category, UserWarning), "GeoJsonTooltip GeometryCollection test failed."