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

Modify no-name PONI zooms #1727

Merged
merged 3 commits into from
Dec 13, 2018
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion docs/layers.md
Original file line number Diff line number Diff line change
Expand Up @@ -1064,7 +1064,7 @@ To resolve inconsistency in data tagging in OpenStreetMap we normalize several o
* `physician`
* `picnic_site`
* `picnic_table`
* `pitch`
* `pitch` - With `kind_detail` optionally describing the sport. Common values are `baseball`, `basketball`, `football`, `hockey`, `soccer, `tennis`.
* `place_of_worship` - _See planned bug fixes in [#1085](https://github.com/tilezen/vector-datasource/issues/1085)._
* `plant` - _See planned bug fixes in [#1085](https://github.com/tilezen/vector-datasource/issues/1085)._
* `plaque` - A memorial plaque.
Expand Down
166 changes: 166 additions & 0 deletions integration-test/1638-modify-poni-zooms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
# -*- encoding: utf-8 -*-
from . import FixtureTest


class ModifyPoniZoomsTest(FixtureTest):

def test_sports_pitch_with_name(self):
import dsl

z, x, y = (16, 0, 0)

self.generate_fixtures(
dsl.way(1, dsl.tile_box(z, x, y), {
'leisure': 'pitch',
'name': 'Foo pitch',
'source': u'openstreetmap.org',
}),
)

self.assert_has_feature(
z, x, y, 'pois', {
'id': 1,
'min_zoom': 16,
'kind': 'pitch',
})

def test_sports_pitch_no_name(self):
import dsl

z, x, y = (16, 0, 0)

self.generate_fixtures(
dsl.way(1, dsl.tile_box(z, x, y), {
'leisure': 'pitch',
'sport': 'basketball',
'source': u'openstreetmap.org',
}),
)

self.assert_has_feature(
z, x, y, 'pois', {
'id': 1,
'min_zoom': 17,
'kind': 'pitch',
})

def test_sports_pitch_no_name_volleyball(self):
import dsl

z, x, y = (16, 0, 0)

self.generate_fixtures(
dsl.way(1, dsl.tile_box(z, x, y), {
'leisure': 'pitch',
'sport': 'volleyball',
'source': u'openstreetmap.org',
}),
)

self.assert_has_feature(
z, x, y, 'pois', {
'id': 1,
'min_zoom': 17,
'kind': 'pitch',
})

def test_drinking_water(self):
import dsl

z, x, y = (16, 0, 0)

self.generate_fixtures(
dsl.way(1, dsl.tile_centre_shape(z, x, y), {
'amenity': 'drinking_water',
'source': 'openstreetmap.org',
}),
)

self.assert_has_feature(
z, x, y, 'pois', {
'kind': 'drinking_water',
'min_zoom': 18,
})

def _check_downgrade_poi(self, tags, kind, min_zoom):
import dsl

z, x, y = (16, 0, 0)

full_tags = tags.copy()
full_tags['source'] = 'openstreetmap.org'

# test without a name
self.generate_fixtures(
dsl.way(1, dsl.tile_box(z, x, y), full_tags),
)

self.assert_has_feature(
z, x, y, 'pois', {
'kind': kind,
'min_zoom': min_zoom,
})

# and with a name
full_tags['name'] = 'Some kind of name'
self.generate_fixtures(
dsl.way(1, dsl.tile_box(z, x, y), full_tags),
)

self.assert_has_feature(
z, x, y, 'pois', {
'kind': kind,
'name': full_tags['name'],
'min_zoom': lambda z: z < min_zoom,
})

def test_information(self):
self._check_downgrade_poi(
{'tourism': 'information'},
'information', 18)

def test_playground(self):
self._check_downgrade_poi(
{'leisure': 'playground'},
'playground', 18)

def test_bicycle_parking(self):
self._check_downgrade_poi(
{'amenity': 'bicycle_parking'},
'bicycle_parking', 19)

def test_toilets(self):
import dsl

z, x, y = (16, 0, 0)

self.generate_fixtures(
dsl.way(1, dsl.tile_centre_shape(z, x, y), {
'amenity': 'toilets',
'source': 'openstreetmap.org',
}),
)

self.assert_has_feature(
z, x, y, 'pois', {
'kind': 'toilets',
'min_zoom': 18,
})

def test_traffic_signals(self):
import dsl

z, x, y = (16, 0, 0)

self.generate_fixtures(
dsl.way(1, dsl.tile_centre_shape(z, x, y), {
'highway': 'traffic_signals',
'source': 'openstreetmap.org',
}),
)

self.assert_has_feature(
z, x, y, 'pois', {
'kind': 'traffic_signals',
'min_zoom': 18,
})
12 changes: 10 additions & 2 deletions integration-test/742-predictable-layers-pois.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,14 +244,22 @@ def test_plant_node(self):
14, 2777, 6374, 'pois',
{'id': 902365126, 'kind': 'plant', 'min_zoom': 14})

def test_pitch_node(self):
def test_pitch_node_named(self):
# Node:2442093493 pitch in POIS
self.generate_fixtures(dsl.way(2442093493, wkt_loads('POINT (-120.068494697136 38.93153745806469)'), {u'source': u'openstreetmap.org', u'sport': u'volleyball', u'leisure': u'pitch'})) # noqa
self.generate_fixtures(dsl.way(2442093493, wkt_loads('POINT (-120.068494697136 38.93153745806469)'), {u'source': u'openstreetmap.org', u'sport': u'volleyball', u'leisure': u'pitch', u'name': u'Volleyball pitch'})) # noqa

self.assert_has_feature(
16, 10910, 25062, 'pois',
{'id': 2442093493, 'kind': 'pitch', 'min_zoom': 16})

def test_pitch_node_unnamed_sport_in_whitelist(self):
# Node:2442093493 pitch in POIS
self.generate_fixtures(dsl.way(2442093493, wkt_loads('POINT (-120.068494697136 38.93153745806469)'), {u'source': u'openstreetmap.org', u'sport': u'basketball', u'leisure': u'pitch'})) # noqa

self.assert_has_feature(
16, 10910, 25062, 'pois',
{'id': 2442093493, 'kind': 'pitch', 'min_zoom': 17})

def test_protected_area_way(self):
# Way:296573403 protected_area in POIS
self.generate_fixtures(dsl.way(296573403, wkt_loads('POLYGON ((-122.337881380454 37.46030647731539, -122.312205194014 37.4782012886921, -122.306261490936 37.4712460869934, -122.305471692139 37.4703218054014, -122.306930915486 37.46908109410918, -122.305986696291 37.46778681678578, -122.309186136007 37.4640296993149, -122.312383329935 37.4668670556049, -122.335422422026 37.4510334112997, -122.336070376841 37.45204857134729, -122.336838616072 37.45326317958191, -122.336838616072 37.45401267259149, -122.3364523405 37.45493252058789, -122.335937336347 37.4561589194452, -122.335679879187 37.45769021398629, -122.336066064927 37.458678115507, -122.336838616072 37.45956382151758, -122.337881380454 37.46030647731539))'), {u'website': u'http://www.filoli.org/', u'natural': u'wood', u'name': u'Filioli Center', u'way_area': u'5.03752e+06', u'source': u'openstreetmap.org', u'historic': u'estate', u'operator': u'National Trust for Historic Preservation', u'boundary': u'protected_area', u'protect_class': u'22'})) # noqa
Expand Down
5 changes: 5 additions & 0 deletions integration-test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@ def match_distance(actual, expected):
misses[exp_k] = "%r not an instance of %r" % (v, exp_v)
distance += 1

elif callable(exp_v):
if not exp_v(v):
misses[exp_k] = "%r(%r) is not truthy" % (exp_v, v)
distance += 1

elif v != exp_v:
misses[exp_k] = "%r != %r" % (v, exp_v)
distance += 1
Expand Down
Loading