-
Notifications
You must be signed in to change notification settings - Fork 120
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
Join countries and regions to Natural Earth for min and max zoom #1535
Merged
+2,361
−12
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f25422a
Add generation of OSM node tests to mktest.py.
zerebubuth bc5f2ab
* Add country, map unit and state/province polygon data from Natural …
zerebubuth d619307
Add test for NE data min/max zoom join to places.
zerebubuth 0f15855
Added country-based override for kind=country place labels.
zerebubuth e0d96da
Add support for min zoom defaults for regions based on the country th…
zerebubuth b1b89d6
Ooops, forgot to re-run unit tests after changing the default min zoo…
zerebubuth File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
# -*- coding: utf-8 -*- | ||
from . import FixtureTest | ||
|
||
|
||
class MinZoomFromNETest(FixtureTest): | ||
|
||
def setUp(self): | ||
import dsl | ||
|
||
super(MinZoomFromNETest, self).setUp() | ||
|
||
self.lon, self.lat = (-3.2765753, 54.7023545) | ||
|
||
self.generate_fixtures( | ||
# https://www.openstreetmap.org/node/838090640 | ||
dsl.point(838090640, (self.lon, self.lat), { | ||
'name': u'United Kingdom', | ||
'place': u'country', | ||
'population': u'61792000', | ||
'source': u'openstreetmap.org', | ||
'wikidata': u'Q145', | ||
'wikipedia': u'de:United Kingdom', # LOL, de: | ||
# NOTE: these aren't in the data from OSM, but are joined at | ||
# database query time from the Natural Earth data. | ||
'__ne_min_zoom': 1.7, | ||
'__ne_max_zoom': 6.7, | ||
}), | ||
) | ||
|
||
def test_uk_should_show_up_zooms_1_to_6(self): | ||
from tilequeue.tile import deg2num | ||
# should show up in zooms within the range 1-6 | ||
|
||
for zoom in xrange(1, 6): | ||
x, y = deg2num(self.lat, self.lon, zoom) | ||
self.assert_has_feature( | ||
zoom, x, y, 'places', { | ||
'id': 838090640, | ||
'min_zoom': 1.7, | ||
'max_zoom': 6.7, | ||
}) | ||
|
||
def test_uk_should_not_show_up_zoom_0(self): | ||
# shouldn't be in the zoom 0 tile because min_zoom >= 1 | ||
self.assert_no_matching_feature( | ||
0, 0, 0, 'places', {'id': 838090640}) | ||
|
||
def test_uk_should_not_show_up_zoom_7(self): | ||
# shouldn't be in the zoom 0 tile because max_zoom < 7 | ||
from tilequeue.tile import deg2num | ||
|
||
zoom = 7 | ||
x, y = deg2num(self.lat, self.lon, zoom) | ||
self.assert_no_matching_feature( | ||
zoom, x, y, 'places', {'id': 838090640}) | ||
|
||
|
||
class MinZoomFromAdminAreaBasedDefault(FixtureTest): | ||
|
||
def test_united_kingdom(self): | ||
# in the absence of data joined from NE, we should fall back to a | ||
# default based on the country that the label point is in. | ||
import dsl | ||
from tilequeue.tile import deg2num | ||
|
||
lon, lat = (-3.2765753, 54.7023545) | ||
z = 5 | ||
x, y = deg2num(lat, lon, z) | ||
|
||
self.generate_fixtures( | ||
dsl.is_in('GB', z, x, y), | ||
# https://www.openstreetmap.org/node/838090640 | ||
dsl.point(838090640, (lon, lat), { | ||
'name': u'United Kingdom', | ||
'place': u'country', | ||
'population': u'61792000', | ||
'source': u'openstreetmap.org', | ||
'wikidata': u'Q145', | ||
'wikipedia': u'de:United Kingdom', # LOL, de: | ||
}), | ||
) | ||
|
||
self.assert_has_feature( | ||
z, x, y, 'places', { | ||
'id': 838090640, | ||
'min_zoom': 1.7, | ||
'max_zoom': 6.7, | ||
}) | ||
|
||
def test_ne_min_zoom_should_override_default(self): | ||
import dsl | ||
from tilequeue.tile import deg2num | ||
|
||
lon, lat = (-3.2765753, 54.7023545) | ||
z = 5 | ||
x, y = deg2num(lat, lon, z) | ||
|
||
self.generate_fixtures( | ||
dsl.is_in('GB', z, x, y), | ||
# https://www.openstreetmap.org/node/838090640 | ||
dsl.point(838090640, (lon, lat), { | ||
'name': u'United Kingdom', | ||
'place': u'country', | ||
'population': u'61792000', | ||
'source': u'openstreetmap.org', | ||
'wikidata': u'Q145', | ||
'wikipedia': u'de:United Kingdom', # LOL, de: | ||
# NE joins should override defaults from location | ||
'__ne_min_zoom': 0, | ||
'__ne_max_zoom': 16, | ||
}), | ||
) | ||
|
||
self.assert_has_feature( | ||
z, x, y, 'places', { | ||
'id': 838090640, | ||
'min_zoom': 0, | ||
'max_zoom': 16, | ||
}) | ||
|
||
def test_wales(self): | ||
# wales is a country within the UK, but mapped as place=state. | ||
# should get a fallback from the states_provinces spreadsheet. | ||
import dsl | ||
|
||
z, x, y = (10, 501, 336) | ||
|
||
self.generate_fixtures( | ||
dsl.is_in('GB', z, x, y), | ||
# https://www.openstreetmap.org/node/2642288017 | ||
dsl.point(2642288017, (-3.73893, 52.2928116), { | ||
'is_in': u'United Kingdom, Europe', | ||
'name': u'Wales', | ||
'note': u'geographical centre of Wales', | ||
'place': u'state', | ||
'source': u'openstreetmap.org', | ||
}), | ||
) | ||
|
||
self.assert_has_feature( | ||
z, x, y, 'places', { | ||
'id': 2642288017, | ||
'min_zoom': 10, | ||
'max_zoom': 11, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
:)