Skip to content

Commit

Permalink
Merge pull request #1710 from tilezen/zerebubuth/1331-access-surface
Browse files Browse the repository at this point in the history
Drop many "detail" tags on minor roads at mid zooms.
  • Loading branch information
zerebubuth authored Nov 28, 2018
2 parents 10a779c + 502c0a6 commit b29ccd6
Show file tree
Hide file tree
Showing 6 changed files with 418 additions and 41 deletions.
37 changes: 25 additions & 12 deletions integration-test/1170-very-early-paths-and-bike-routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,55 +130,68 @@ def test_bay_trail_rcn(self):
self.load_fixtures([
'http://www.openstreetmap.org/way/44422697',
'http://www.openstreetmap.org/relation/325779',
], clip=self.tile_bbox(10, 164, 396))
], clip=self.tile_bbox(13, 1313, 3172))

# keeps bicycle_network at zoom 13
self.assert_has_feature(
10, 164, 396, 'roads',
13, 1313, 3172, 'roads',
{'kind': 'path', 'is_bicycle_related': True,
'bicycle_network': 'rcn'})

# keeps is_bicycle_related at zoom 10
self.assert_has_feature(
10, 164, 396, 'roads',
{'kind': 'path', 'is_bicycle_related': True,
'bicycle_network': type(None)})

def test_residential_with_regional_route(self):
# Hyltebjerg Allé residential road with rcn in Copenhagen
self.load_fixtures([
'https://www.openstreetmap.org/way/2860759',
'https://www.openstreetmap.org/relation/2087590',
], clip=self.tile_bbox(10, 547, 320))

# keep bicycle_network until 13
self.assert_has_feature(
10, 547, 320, 'roads',
13, 4379, 2563, 'roads',
{'kind': 'minor_road', 'is_bicycle_related': True,
'bicycle_network': 'rcn'})

# keep the is_bicycle_related at lower zooms
self.assert_has_feature(
10, 547, 320, 'roads',
{'kind': 'minor_road', 'is_bicycle_related': True,
'bicycle_network': type(None)})

def test_living_street_with_local_route(self):
# lcn in Seattle (living street that would only be visible at zoom 13
# otherwise) at zoom 11
# lcn in Seattle - LCN only visible at zoom 16
self.load_fixtures([
'https://www.openstreetmap.org/way/6477775',
'https://www.openstreetmap.org/relation/3541926',
], clip=self.tile_bbox(11, 327, 715))
], clip=self.tile_bbox(16, 10492, 22900))

self.assert_has_feature(
11, 327, 715, 'roads',
16, 10492, 22900, 'roads',
{'kind': 'minor_road', 'bicycle_network': 'lcn'})

def test_kirkham_street_lcn(self):
# Kirkham Street lcn in San Francisco at zoom 11
# Kirkham Street lcn in San Francisco at zoom 16
self.load_fixtures([
'https://www.openstreetmap.org/way/89802424',
'https://www.openstreetmap.org/relation/32313',
], clip=self.tile_bbox(11, 327, 791))
], clip=self.tile_bbox(16, 10471, 25334))

self.assert_has_feature(
11, 327, 791, 'roads',
16, 10471, 25334, 'roads',
{'kind': 'minor_road', 'bicycle_network': 'lcn'})

def test_asiatisk_plads_service_road_lcn(self):
# Asiatisk Plads service road with lcn in Copenhagen
self.load_fixtures([
'https://www.openstreetmap.org/way/164049387',
'https://www.openstreetmap.org/relation/6199242',
], clip=self.tile_bbox(11, 1095, 641))
], clip=self.tile_bbox(16, 35059, 20513))

self.assert_has_feature(
11, 1095, 641, 'roads',
16, 35059, 20513, 'roads',
{'kind': 'minor_road', 'bicycle_network': 'lcn'})
40 changes: 22 additions & 18 deletions integration-test/1175-bicycle-route-refs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,38 @@
class BicycleRouteRefs(FixtureTest):

def test_lcn45(self):
# https://www.openstreetmap.org/way/417389551
# lcn_ref=45
# https://www.openstreetmap.org/relation/32310
# type=route, route=bicycle, network=lcn, ref=45
self.load_fixtures(['https://www.openstreetmap.org/way/417389551',
'https://www.openstreetmap.org/relation/32310'],
clip=self.tile_bbox(10, 163, 395))
import dsl

z, x, y = (16, 10481, 25336)

self.generate_fixtures(
dsl.way(417389551, dsl.tile_diagonal(z, x, y), {
'source': 'openstreetmap.org',
'highway': 'tertiary',
'cycleway': 'lane',
'lcn_ref': '45',
}),
dsl.relation(32310, {
'type': 'route',
'route': 'bicycle',
'network': 'lcn',
'ref': '45',
}, ways=[417389551]),
)

self.assert_has_feature(
16, 10481, 25336, 'roads',
z, x, y, 'roads',
{'id': 417389551,
'bicycle_network': None,
'bicycle_shield_text': '45',
'all_bicycle_networks': None,
'all_bicycle_shield_texts': ['45']})

# make sure the all_* lists are gone by zoom 12 on major roads, but
# the "most important", singular network & shield text remain at
# earlier zooms
self.assert_has_feature(
10, 163, 395, 'roads',
{'bicycle_network': None,
'bicycle_shield_text': '45'})

# make sure the properties are gone by zoom 15
self.assert_no_matching_feature(
12, 655, 1583, 'roads',
z-1, x//2, y//2, 'roads',
{'all_bicycle_networks': None})

self.assert_no_matching_feature(
12, 655, 1583, 'roads',
z-1, x//2, y//2, 'roads',
{'all_bicycle_shield_texts': None})
13 changes: 9 additions & 4 deletions integration-test/1252-roads-surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ def test_cobblestones(self):
15, 9371, 12546, 'roads',
{'id': 190536019, 'kind': 'minor_road', 'surface': 'cobblestone'})

# and that surface property stays at earlier zooms
# and that surface property is dropped at earlier zooms
self.assert_has_feature(
13, 2342, 3136, 'roads',
{'id': 190536019, 'kind': 'minor_road', 'surface': 'cobblestone'})
{'id': 190536019, 'kind': 'minor_road', 'surface': type(None)})

def test_asphalt(self):
# motorway in Kraków, Poland
Expand Down Expand Up @@ -51,6 +51,7 @@ def test_concrete_lanes(self):

# check at a bunch of lower zooms, where we're expecting the road to be
# merged, so be stricter with the set of properties we expect to see.
# we'd expect the surface tag to have been stripped off by now.
for z in (13, 11, 10, 9, 8):
delta_z = 15 - z
coord_scale = 2 ** delta_z
Expand All @@ -60,10 +61,14 @@ def test_concrete_lanes(self):
'kind_detail': 'track',
'is_bicycle_related': True,
'surface': 'concrete_lanes',
'bicycle_network': 'ncn',
'min_zoom': 8,
'bicycle_shield_text': 'D10',
}

if z >= 13:
props.update({
'bicycle_network': 'ncn',
'bicycle_shield_text': 'D10',
})

self.assert_has_feature(
z, 17456 / coord_scale, 10780 / coord_scale, 'roads', props)
157 changes: 157 additions & 0 deletions integration-test/1331-drop-road-properties.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
# -*- encoding: utf-8 -*-
from . import FixtureTest


class DropRoadPropertiesTest(FixtureTest):

def test_rcn(self):
# network_rcn:
# filter: { bicycle_network: rcn, $zoom: { max: 12 } }
# draw:
# mapzen_icon_library:
# visible: false
#
# roughly translates to: don't draw shields on RCN networks when
# zoom <= 12.
import dsl

z, x, y = (12, 2048, 2048)

self.generate_fixtures(
# note: use a major road type, so that the road still exists at
# low zooms.
dsl.way(1, dsl.tile_diagonal(z, x, y), {
'highway': u'trunk',
'source': u'openstreetmap.org',
}),
dsl.relation(2, {
'type': u'route',
'route': u'bicycle',
'network': u'rcn',
'ref': u'X',
'source': u'openstreetmap.org',
}, ways=[1]),
)

# should exist with all properties at zoom 12
self.assert_has_feature(
z, x, y, 'roads', {
'id': 1,
'kind': 'major_road',
'bicycle_network': u'rcn',
'bicycle_shield_text': u'X',
})

# should drop shield text property at zoom 11
self.assert_has_feature(
z-1, x//2, y//2, 'roads', {
'kind': 'major_road',
'bicycle_network': u'rcn',
'bicycle_shield_text': type(None),
})

# and drop everything by zoom 10
self.assert_has_feature(
z-2, x//4, y//4, 'roads', {
'kind': 'major_road',
'bicycle_network': type(None),
'bicycle_shield_text': type(None),
})

def test_track(self):
# tracks_network_rcn:
# filter: { $zoom: { max: 12 }, kind_detail: track }
# draw:
# mapzen_icon_library:
# visible: false
#
# roughly translates to: don't draw shields on tracks when zoom<=12.
import dsl

z, x, y = (13, 4096, 4096)

self.generate_fixtures(
dsl.way(1, dsl.tile_diagonal(z, x, y), {
'highway': u'track',
'surface': u'paved',
'source': u'openstreetmap.org',
}),
dsl.relation(2, {
'type': u'route',
'route': u'bicycle',
'network': u'icn',
'ref': u'X',
'source': u'openstreetmap.org',
}, ways=[1]),
)

# should exist with all properties at zoom 13
self.assert_has_feature(
z, x, y, 'roads', {
'id': 1,
'bicycle_network': u'icn',
'bicycle_shield_text': u'X',
'min_zoom': 11,
})

# should drop properties by zoom 12
self.assert_no_matching_feature(
z-1, x//2, y//2, 'roads', {
'bicycle_network': None,
})
self.assert_no_matching_feature(
z-1, x//2, y//2, 'roads', {
'bicycle_shield_text': None,
})

def test_lcn(self):
# network_lcn:
# filter: { bicycle_network: lcn, $zoom: { max: 15 } }
# draw:
# mapzen_icon_library:
# visible: false
#
# roughly translates to: don't draw shields on LCN networks when
# zoom < 15.
import dsl

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

self.generate_fixtures(
dsl.way(1, dsl.tile_diagonal(z, x, y), {
'highway': u'residential',
'source': u'openstreetmap.org',
}),
dsl.relation(2, {
'type': u'route',
'route': u'bicycle',
'network': u'lcn',
'ref': u'X',
'source': u'openstreetmap.org',
}, ways=[1]),
)

# should exist with all properties at zoom 15.
self.assert_has_feature(
z, x, y, 'roads', {
'id': 1,
'kind': 'minor_road',
'bicycle_network': u'lcn',
'bicycle_shield_text': u'X',
})

# should drop shield text by zoom 14
self.assert_has_feature(
z-1, x//2, y//2, 'roads', {
'kind': 'minor_road',
'bicycle_network': u'lcn',
'bicycle_shield_text': type(None),
})

# should drop everything by <= 13
self.assert_has_feature(
z-2, x//4, y//4, 'roads', {
'kind': 'minor_road',
'bicycle_network': type(None),
'bicycle_shield_text': type(None),
})
Loading

0 comments on commit b29ccd6

Please sign in to comment.