-
Notifications
You must be signed in to change notification settings - Fork 120
/
1638-modify-poni-zooms.py
166 lines (130 loc) · 4.08 KB
/
1638-modify-poni-zooms.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
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,
})