Skip to content

Commit bc8c87e

Browse files
authored
Merge pull request #1198 from tilezen/nvkelso/1170-earlier-bike-roads
earlier bike roads (and walking routes)
2 parents d3a0725 + 3612214 commit bc8c87e

File tree

8 files changed

+220
-62
lines changed

8 files changed

+220
-62
lines changed

data/functions.sql

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -638,9 +638,12 @@ BEGIN
638638
RETURN (
639639
SELECT
640640
MIN(
641-
CASE WHEN hstore(tags)->'network' IN ('iwn', 'nwn', 'icn','ncn') THEN 11
642-
WHEN hstore(tags)->'network' IN ('rwn', 'rcn') THEN 12
643-
WHEN hstore(tags)->'network' IN ('lwn', 'lcn') THEN 13
641+
CASE WHEN hstore(tags)->'network' IN ('icn', 'ncn') THEN 8
642+
WHEN hstore(tags)->'network' IN ('iwn', 'nwn') THEN 9
643+
WHEN hstore(tags)->'network' IN ('rcn') THEN 10
644+
WHEN hstore(tags)->'network' IN ('rwn') THEN 11
645+
WHEN hstore(tags)->'network' IN ('lcn') THEN 11
646+
WHEN hstore(tags)->'network' IN ('lwn') THEN 12
644647
ELSE NULL
645648
END
646649
)
@@ -898,7 +901,7 @@ BEGIN
898901
END;
899902
$$ LANGUAGE plpgsql IMMUTABLE;
900903

901-
--- Identifies and returns the min_zoom for gates
904+
--- Identifies and returns the min_zoom for gates
902905
--- given the highway level of gate location
903906
CREATE OR REPLACE FUNCTION mz_get_min_zoom_highway_level_gate(val_osm_id BIGINT)
904907
RETURNS SMALLINT AS $$

data/migrations/v1.3.0-line.sql

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
UPDATE planet_osm_line
2+
SET mz_road_level = mz_calculate_min_zoom_roads(planet_osm_line.*)
3+
WHERE
4+
(tags -> 'highway' IN ( 'trunk_link', 'primary_link', 'secondary_link', 'tertiary_link',
5+
'residential', 'unclassified', 'road', 'living_street', 'pedestrian',
6+
'path', 'track', 'cycleway', 'bridleway', 'footway', 'steps',
7+
'service' ) OR
8+
tags -> 'whitewater' = 'portage_way')
9+
AND mz_calculate_min_zoom_roads(planet_osm_line.*) IS NOT NULL;

docs/layers.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,10 +1103,10 @@ To improve performance, some road segments are merged at low and mid-zooms. To f
11031103

11041104
#### Road Transportation `kind_detail` values and zoom ranges:
11051105

1106-
**Roads** from **OpenStreetMap** are shown starting at zoom 8 with `motorway`, `trunk`, `primary`. `secondary` are added starting at zoom 10, with `motorway_link`, `tertiary` added at zoom 11. Zoom 12 sees addition of `trunk_link`, `residential`, `unclassified`, and `road`, and internationally and nationally significant paths (`path`, `footway`, `steps`). Zoom 13 adds `primary_link`, `secondary_link`, `raceway`, `track`, `pedestrian`, `living_street`, `cycleway` and `bridleway` and regionally significant and/or named or designated paths. Zoom 14 adds `tertiary_link`, all remaining `path`, `footway`, and `steps`, `corridor`, and `alley` service roads. By zoom 15 all remaining service roads are added, including `driveway`, `parking_aisle`, `drive_through`.
1107-
11081106
**Roads** from **Natural Earth** are used at low zooms below 8. Road `kind_detail` values are limited to `motorway`, `trunk`, `primary`, `secondary`, `tertiary`.
11091107

1108+
**Roads** from **OpenStreetMap** are shown starting at zoom 8 with `motorway`, `trunk`, `primary`. `secondary` are added starting at zoom 10, with `motorway_link`, `tertiary` added at zoom 11. Zoom 12 sees addition of `trunk_link`, `residential`, `unclassified`, and `road`. Zoom 13 adds `primary_link`, `secondary_link`, `raceway`, `track`, `pedestrian`, `living_street`, `cycleway` and `bridleway`. Zoom 14 adds `tertiary_link`, all remaining `path`, `footway`, and `steps`, `corridor`, and `alley` service roads. By zoom 15 all remaining service roads are added, including `driveway`, `parking_aisle`, `drive_through`. Internationally and nationally significant paths (`path`, `footway`, `steps`) are added at zoom 9, regionally significant paths are added at zoom 11, locally significant at zoom 12, and named or designated paths at zoom 13. Internationally and nationally significant bicycle routes are added at zoom 8, regionally significant bike routes at zoom 10, and locally significant at zoom 11.
1109+
11101110
**Ferries** from both Natural Earth and OpenStreetMap are shown starting at zoom 5 with `kind` values of `ferry`.
11111111

11121112
![image](images/mapzen-vector-tile-docs-roads-railway.png)
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# highway=path, with route inter-national
2+
# GR5-Grand Traverse de Jura between France and Switzerland
3+
# https://www.openstreetmap.org/way/285975282
4+
# https://www.openstreetmap.org/relation/6009161
5+
assert_has_feature(
6+
9, 265, 179, 'roads',
7+
{ 'kind': 'path', 'walking_network': 'iwn' } )
8+
9+
# highway=path, with route national (Pacific Crest Trail) at zoom 9
10+
# https://www.openstreetmap.org/way/236361475
11+
# https://www.openstreetmap.org/relation/1225378
12+
assert_has_feature(
13+
9, 86, 197, 'roads',
14+
{ 'kind': 'path', 'walking_network': 'nwn' } )
15+
16+
# highway=path, with route regional (Merced Pass Trail) at zoom 11
17+
# https://www.openstreetmap.org/way/373491941
18+
# https://www.openstreetmap.org/relation/5549623
19+
assert_has_feature(
20+
11, 343, 792, 'roads',
21+
{ 'kind': 'path', 'walking_network': 'rwn' } )
22+
23+
# highway=unclassified, with route local (Grant Avenue) at zoom 12
24+
# part of The Barbary Coast Trail in San Francisco
25+
# https://www.openstreetmap.org/way/91181758
26+
# https://www.openstreetmap.org/relation/6322028
27+
assert_has_feature(
28+
12, 655, 1582, 'roads',
29+
{ 'kind': 'minor_road', 'walking_network': 'lwn' } )
30+
31+
# Way: North Sea Cycle Route - part Netherlands (1977662)
32+
# A really long highway=cycleway
33+
# https://www.openstreetmap.org/way/35568189
34+
# https://www.openstreetmap.org/relation/1977662
35+
# https://www.openstreetmap.org/relation/1975739
36+
# https://www.openstreetmap.org/relation/5294
37+
# https://www.openstreetmap.org/relation/537418
38+
assert_has_feature(
39+
8, 131, 83, 'roads',
40+
{ 'kind': 'path', 'is_bicycle_related': True, 'bicycle_network': 'icn' })
41+
42+
# Ferry between Denmark and Germany, icn
43+
# https://www.openstreetmap.org/way/128631318
44+
# https://www.openstreetmap.org/relation/721738
45+
assert_has_feature(
46+
8, 136, 81, 'roads',
47+
{ 'kind': 'ferry', 'is_bicycle_related': True, 'bicycle_network': 'icn' })
48+
49+
# Søndervangsvej minor road in Denmark as national cycle route
50+
# https://www.openstreetmap.org/way/149701891
51+
# https://www.openstreetmap.org/relation/349521
52+
assert_has_feature(
53+
8, 136, 79, 'roads',
54+
{ 'kind': 'minor_road', 'is_bicycle_related': True, 'bicycle_network': 'ncn' })
55+
56+
# Part of Bay Trail in South (San Francisco) Bay
57+
# way is marked rcn=yes, and part of a proper bike relation
58+
# http://www.openstreetmap.org/way/44422697
59+
# http://www.openstreetmap.org/relation/325779
60+
assert_has_feature(
61+
10, 164, 396, 'roads',
62+
{ 'kind': 'path', 'is_bicycle_related': True, 'bicycle_network': 'rcn' })
63+
64+
# Hyltebjerg Allé residential road with rcn in Copenhagen
65+
# https://www.openstreetmap.org/way/2860759
66+
# https://www.openstreetmap.org/relation/2087590
67+
assert_has_feature(
68+
10, 547, 320, 'roads',
69+
{ 'kind': 'minor_road', 'is_bicycle_related': True, 'bicycle_network': 'rcn' })
70+
71+
# lcn in Seattle (living street that would only be visible at zoom 13 otherwise) at zoom 11
72+
# https://www.openstreetmap.org/way/6477775
73+
# https://www.openstreetmap.org/relation/3541926
74+
assert_has_feature(
75+
11, 327, 715, 'roads',
76+
{ 'kind': 'minor_road', 'bicycle_network': 'lcn' })
77+
78+
# Kirkham Street lcn in San Francisco at zoom 11
79+
# https://www.openstreetmap.org/way/89802424
80+
# https://www.openstreetmap.org/relation/32313
81+
assert_has_feature(
82+
11, 327, 791, 'roads',
83+
{ 'kind': 'minor_road', 'bicycle_network': 'lcn' })
84+
85+
# Asiatisk Plads service road with lcn in Copenhagen
86+
# https://www.openstreetmap.org/way/164049387
87+
# https://www.openstreetmap.org/relation/6199242
88+
assert_has_feature(
89+
11, 1095, 641, 'roads',
90+
{ 'kind': 'minor_road', 'bicycle_network': 'lcn' })

integration-test/1175-bicycle-route-refs.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@
1111
'all_bicycle_shield_texts': ['45'] })
1212

1313
# make sure the all_* lists are gone by zoom 12 on major roads, but the "most
14-
# important" network & shield text remain until.
14+
# important", singular network & shield text remain at earlier zooms
1515
assert_has_feature(
1616
10, 163, 395, 'roads',
1717
{ 'bicycle_network': 'lcn',
1818
'bicycle_shield_text': '45' })
19+
1920
assert_no_matching_feature(
20-
10, 163, 395, 'roads',
21+
12, 655, 1583, 'roads',
2122
{ 'all_bicycle_networks': None })
2223
assert_no_matching_feature(
23-
10, 163, 395, 'roads',
24+
12, 655, 1583, 'roads',
2425
{ 'all_bicycle_shield_texts': None })

integration-test/1194-bus-route-refs.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,18 @@
3030
'all_bus_shield_texts': ['3', '3'] })
3131

3232
# make sure the all_* lists are gone by zoom 12 on major roads, but the "most
33-
# important" network & shield text remain until.
33+
# important", singular network & shield text remain at earlier zooms
3434
#
3535
# note that it doesn't matter what the bus shield is - that's data-dependent.
3636
# for the purposes of the test, we only care that there _is_ one.
3737
assert_has_feature(
3838
10, 163, 395, 'roads',
3939
{ 'bus_network': type(None),
4040
'bus_shield_text': None })
41+
4142
assert_no_matching_feature(
42-
10, 163, 395, 'roads',
43+
12, 654, 1583, 'roads',
4344
{ 'all_bus_networks': None })
4445
assert_no_matching_feature(
45-
10, 163, 395, 'roads',
46+
12, 654, 1583, 'roads',
4647
{ 'all_bus_shield_texts': None })

integration-test/593-early-path.py

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
1-
tiles = [
2-
# highway=path, with route national (Pacific Crest Trail)
3-
# https://www.openstreetmap.org/way/236361475
4-
# https://www.openstreetmap.org/relation/1225378
5-
[11, 345, 790],
6-
# highway=path, with route regional (Merced Pass Trail)
7-
# https://www.openstreetmap.org/way/373491941
8-
# https://www.openstreetmap.org/relation/5549623
9-
[12, 687, 1584],
10-
# highway=path, with route regional (Merced Pass Trail)
11-
# https://www.openstreetmap.org/way/39996451
12-
# https://www.openstreetmap.org/relation/5549623
13-
[12, 688, 1584],
14-
# highway=path, no route, but has name (Upper Yosemite Falls Trail)
15-
# https://www.openstreetmap.org/way/162322353
16-
[13, 1374, 3166]
17-
]
1+
# highway=path, with route national (Pacific Crest Trail)
2+
# https://www.openstreetmap.org/way/236361475
3+
# https://www.openstreetmap.org/relation/1225378
4+
assert_has_feature(
5+
11, 345, 790, 'roads',
6+
{ 'walking_network': 'nwn',
7+
'walking_shield_text': 'PCT' })
188

19-
for z, x, y in tiles:
20-
assert_has_feature(
21-
z, x, y, 'roads',
22-
{'kind_detail': 'path', 'name': None})
9+
# highway=path, with route regional (Merced Pass Trail)
10+
# https://www.openstreetmap.org/way/373491941
11+
# https://www.openstreetmap.org/relation/5549623
12+
assert_has_feature(
13+
12, 687, 1584, 'roads',
14+
{'kind_detail': 'path', 'name': None, 'walking_network': None})
15+
16+
# highway=path, with route regional (Merced Pass Trail)
17+
# https://www.openstreetmap.org/way/39996451
18+
# https://www.openstreetmap.org/relation/5549623
19+
assert_has_feature(
20+
12, 688, 1584, 'roads',
21+
{'kind_detail': 'path', 'name': None, 'walking_network': None})
22+
23+
# highway=path, no route, but has name (Upper Yosemite Falls Trail)
24+
# https://www.openstreetmap.org/way/162322353
25+
assert_has_feature(
26+
13, 1374, 3166, 'roads',
27+
{'kind_detail': 'path', 'name': None})

queries.yaml

Lines changed: 78 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -502,45 +502,89 @@ post_process:
502502
params:
503503
source_layer: roads
504504
start_zoom: 0
505-
end_zoom: 14
506-
properties: [oneway, crossing, sidewalk, sidewalk_left, sidewalk_right, surface]
505+
end_zoom: 12
506+
properties:
507+
- bicycle
508+
- colour
509+
- foot
510+
- operator
511+
- route # NVK (2017425): this is a suspicious tag
512+
- route_name # NVK (2017425): this is a suspicious tag
513+
- sac_scale
514+
- state
515+
- surface
516+
- symbol
517+
- tracktype
518+
- type # NVK (2017425): this is a suspicious tag
519+
# drop certain road properties at lower zooms
507520
- fn: vectordatasource.transform.drop_properties
508521
params:
509522
source_layer: roads
510523
start_zoom: 0
511-
end_zoom: 14
524+
end_zoom: 13
512525
properties:
513-
- name
514-
- ref
515-
- network
516-
- shield_text
517-
- all_networks
518-
- all_shield_texts
519-
- bicycle_network
520-
- bicycle_shield_text
521526
- all_bicycle_networks
522527
- all_bicycle_shield_texts
523528
- all_walking_networks
524529
- all_walking_shield_texts
525-
- bus_network
526-
- bus_shield_text
527530
- all_bus_networks
528531
- all_bus_shield_texts
532+
# drop certain road properties at lower zooms
533+
- fn: vectordatasource.transform.drop_properties
534+
params:
535+
source_layer: roads
536+
start_zoom: 0
537+
end_zoom: 14
538+
properties:
539+
- ascent
540+
- crossing
541+
- descent
542+
- description
543+
- distance
544+
- horse
545+
- incline
546+
- motor_vehicle
547+
- oneway
548+
- oneway_bicycle
549+
- ramp
550+
- ramp_bicycle
551+
- roundtrip
552+
- segregated
553+
- sidewalk
554+
- sidewalk_left
555+
- sidewalk_right
556+
- sport
557+
- surface
558+
- trail_visibility
559+
# drop name and other properties on early paths to
560+
# allow more line merging (use walking network for labeling)
561+
- fn: vectordatasource.transform.drop_properties
562+
params:
563+
source_layer: roads
564+
start_zoom: 0
565+
end_zoom: 11
566+
properties:
567+
- name
568+
- ref
529569
where: >-
530-
(kind == 'rail' and zoom < 15) or
531-
(kind == 'minor_road' and zoom < 14) or
532-
(kind == 'major_road' and zoom < 7)
533-
# previous tests assume we keep walking network information until zoom 11
570+
kind == 'path'
534571
- fn: vectordatasource.transform.drop_properties
535572
params:
536573
source_layer: roads
537574
start_zoom: 0
538-
end_zoom: 10
575+
end_zoom: 14
539576
properties:
540-
- walking_network
541-
- walking_shield_text
577+
- name
578+
- ref
579+
- network
580+
- shield_text
581+
- all_networks
582+
- all_shield_texts
583+
- bus_network
584+
- bus_shield_text
542585
where: >-
543-
(kind == 'rail') or (kind == 'minor_road') or
586+
(kind == 'rail' and zoom < 15) or
587+
(kind == 'minor_road' and zoom < 14) or
544588
(kind == 'major_road' and zoom < 7)
545589
# this is a patch because we still want to drop name, network from major_road
546590
# features between zoom 7 and 10
@@ -553,12 +597,6 @@ post_process:
553597
- name
554598
- all_networks
555599
- all_shield_texts
556-
- all_bicycle_networks
557-
- all_bicycle_shield_texts
558-
- all_walking_networks
559-
- all_walking_shield_texts
560-
- all_bus_networks
561-
- all_bus_shield_texts
562600
where: >-
563601
kind == 'major_road'
564602
# this is a patch to get rid of name, but keep ref & network, for highways
@@ -585,6 +623,8 @@ post_process:
585623
- all_shield_texts
586624
- walking_network
587625
- walking_shield_text
626+
- bicycle_network
627+
- bicycle_shield_text
588628
where: >-
589629
kind == 'highway'
590630
# drop non-road shield stuff a good deal earlier.
@@ -594,8 +634,6 @@ post_process:
594634
start_zoom: 0
595635
end_zoom: 10
596636
properties:
597-
- bicycle_network
598-
- bicycle_shield_text
599637
- all_bicycle_networks
600638
- all_bicycle_shield_texts
601639
- all_walking_networks
@@ -606,6 +644,17 @@ post_process:
606644
- all_bus_shield_texts
607645
where: >-
608646
kind == 'highway'
647+
# drop walking network related properties on all roads early
648+
# as paths are only brought in at zoom 9 and these properties
649+
# on other kinds would prevent merging at zoom 8 and earlier
650+
- fn: vectordatasource.transform.drop_properties
651+
params:
652+
source_layer: roads
653+
start_zoom: 0
654+
end_zoom: 8
655+
properties:
656+
- walking_network
657+
- walking_shield_text
609658
- fn: vectordatasource.transform.update_parenthetical_properties
610659
params:
611660
source_layer: pois

0 commit comments

Comments
 (0)