-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
GeoJsonTooltip warn for GeometryCollection #988
Conversation
Added a new Tooltip class to reference GeoJson feature properties, with tests, documentation, and examples. It's flexible, and can take field names, aliases, that can be turned on/off with the 'labels' boolean, a 'sticky' property, and can incorporate Javascript's .toLocaleString() functionality if desired. The same string can be passed for each object with the 'text' variable as well if you'd rather not use the 'fields'. Also updated the GeoJson JS template to reference this Tooltip object, and added a test to make sure that the values passed exist in the properties.
Further linting.
Seems like maybe the f-string usage in the geojson fields assertion check is causing the build failure. Testing normal string concatenation.
Reverted accidental vega_parse change.
Fixed docstring indentation.
Updating Tooltip docstring broke 120 char line limit.
Removed trailing white space.
Updating my fork to current Master.
…iLang.xml, ide.general.xml, Default.xml, project.default.xml, diff.xml, git.xml, other.xml, jdk.table.xml, Default.xml, code.style.schemes, find.xml, ui.lnf.xml, laf.xml, filetypes.xml, projectView.xml, vcs.xml, editor.codeinsight.xml, notifications.xml, keymap.xml, editor.xml, github_settings.xml, debugger.xml
…, IntelliLang.xml, ide.general.xml, Default.xml, project.default.xml, diff.xml, git.xml, other.xml, jdk.table.xml, Default.xml, code.style.schemes, find.xml, ui.lnf.xml, laf.xml, filetypes.xml, projectView.xml, vcs.xml, editor.codeinsight.xml, notifications.xml, keymap.xml, editor.xml, github_settings.xml, debugger.xml" This reverts commit 76c9622.
…ithub.com/jtbaker/folium to local" This reverts commit 84811a0.
Conflicts: vcs.xml
onto separate lines so it is more readable.
Ok, that sounds fine to me. To clarify, do you envision it as a validation function that lives in |
I was thinking simply a class method. The code is only for GeoJsonTooltip, so moving it to some common place such as utilities is not needed. |
folium/features.py
Outdated
warnings.warn( | ||
"GeoJsonTooltip is not configured to render tooltips for GeoJson GeometryCollection geometries. " | ||
"Please consider reworking feature IDs {} to MultiPolygon for full functionality.\n" | ||
"https://tools.ietf.org/html/rfc7946#page-9""".format(geom_collections), UserWarning) |
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.
Note that there are still three "s here.
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.
Whoops! Fixed.
Fix last string quote from triple to single.
There is one more thing I would like to do in this PR: add a test that verifies the warning is triggered when a geometry collection is used. That way we can be confident the validation function is right, also in the future. It's hard to see if a validation function is working properly without a test, because it's trigger might be rare. Is that something you want to try @jtbaker? If not that's okay, I can pick it up or we'll leave it out. |
@@ -104,3 +106,14 @@ def test_color_line(): | |||
opacity=1) | |||
m.add_child(color_line) | |||
m._repr_html_() | |||
|
|||
def test_geojson_tooltip(): |
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.
E302 expected 2 blank lines, found 1
tests/test_features.py
Outdated
|
||
def test_geojson_tooltip(): | ||
m = folium.Map([30.5, -97.5], zoom_start=10) | ||
geojson = folium.GeoJson("./kuntarajat.geojson", |
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.
F841 local variable 'geojson' is assigned to but never used
tests/test_features.py
Outdated
m = folium.Map([30.5, -97.5], zoom_start=10) | ||
geojson = folium.GeoJson("./kuntarajat.geojson", | ||
tooltip=folium.GeoJsonTooltip( | ||
fields=['code','name'] |
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.
E231 missing whitespace after ','
tests/test_features.py
Outdated
with warnings.catch_warnings(record=True) as w: | ||
warnings.simplefilter('always') | ||
m._repr_html_() | ||
assert isinstance(w[-1].category, UserWarning), "GeoJsonTooltip GeometryCollection test failed." |
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.
W292 no newline at end of file
tests/test_features.py
Outdated
def test_geojson_tooltip(): | ||
m = folium.Map([30.5, -97.5], zoom_start=10) | ||
folium.GeoJson("./kuntarajat.geojson", | ||
tooltip=folium.GeoJsonTooltip(fields=['code','name']) |
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.
E127 continuation line over-indented for visual indent
E231 missing whitespace after ','
tests/test_features.py
Outdated
def test_geojson_tooltip(): | ||
m = folium.Map([30.5, -97.5], zoom_start=10) | ||
folium.GeoJson("./kuntarajat.geojson", | ||
tooltip=folium.GeoJsonTooltip(fields=['code','name']) |
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.
E231 missing whitespace after ','
Looks good @jtbaker! This is what I had in mind. Unfortunately the test is not working yet in the Travis build. Here is the error:
It seems the The first is to use a The second is to check recorded warnings, like you did. But in their example the don't use Can you try any of these two methods to get the test working? |
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.
This looks good Jason! Unfortunately the test is currently failing due to an unrelated problem. I already made a fix and will open a PR with it. Should be quick to merge, after than we can update this PR and merge this.
Merged! Thanks Jason. Merging upstream master into your branch went well I see. |
Closes #929. Checks geometry types for
GeometryCollection
s, stores the feature IDs of any in a list, and warns the user of incompatibility, and suggests refactoring toMultiPolygon
geometry type.