Add expressway tagging to the transportation layer (#1313)

Fixes #1148 

This PR adds expressway tagging to the `transportation` layer, by setting `expressway=1` for non-motorway roads tagged `expressway=yes`, and omitting the tag otherwise.  Additionally, I've added a few unit tests to verify that the expressway tagging is being imported and updated into the intermediate tables.

Here is an example of expressway tagging on US-1 in Rhode Island, USA:

![image](https://user-images.githubusercontent.com/3254090/143501278-db3671b2-2efa-4998-bffd-9ddfec63579b.png)
pull/1309/head
Brian Sperlongano 2021-11-26 01:55:20 -05:00 zatwierdzone przez GitHub
rodzic ec74480414
commit 7f23feab88
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
8 zmienionych plików z 82 dodań i 22 usunięć

Wyświetl plik

@ -159,6 +159,10 @@ surface_field: &surface
key: surface key: surface
name: surface name: surface
type: string type: string
expressway_field: &expressway
key: expressway
name: expressway
type: bool
tables: tables:
# etldoc: imposm3 -> osm_highway_linestring # etldoc: imposm3 -> osm_highway_linestring
@ -206,6 +210,7 @@ tables:
- *mtb_scale - *mtb_scale
- *sac_scale - *sac_scale
- *surface - *surface
- *expressway
mapping: mapping:
highway: highway:
- motorway - motorway

Wyświetl plik

@ -22,6 +22,7 @@ CREATE OR REPLACE FUNCTION layer_transportation(bbox geometry, zoom_level int)
service text, service text,
access text, access text,
toll int, toll int,
expressway int,
layer int, layer int,
level int, level int,
indoor int, indoor int,
@ -61,6 +62,7 @@ SELECT osm_id,
NULLIF(service, '') AS service, NULLIF(service, '') AS service,
access, access,
CASE WHEN toll = TRUE THEN 1 END AS toll, CASE WHEN toll = TRUE THEN 1 END AS toll,
CASE WHEN highway NOT IN ('', 'motorway') AND expressway = TRUE THEN 1 END AS expressway,
NULLIF(layer, 0) AS layer, NULLIF(layer, 0) AS layer,
"level", "level",
CASE WHEN indoor = TRUE THEN 1 END AS indoor, CASE WHEN indoor = TRUE THEN 1 END AS indoor,
@ -86,6 +88,7 @@ FROM (
is_bridge, is_bridge,
is_tunnel, is_tunnel,
is_ford, is_ford,
NULL::boolean AS expressway,
NULL::boolean AS is_ramp, NULL::boolean AS is_ramp,
NULL::int AS is_oneway, NULL::int AS is_oneway,
NULL AS man_made, NULL AS man_made,
@ -118,6 +121,7 @@ FROM (
is_bridge, is_bridge,
is_tunnel, is_tunnel,
is_ford, is_ford,
NULL::boolean AS expressway,
NULL::boolean AS is_ramp, NULL::boolean AS is_ramp,
NULL::int AS is_oneway, NULL::int AS is_oneway,
NULL AS man_made, NULL AS man_made,
@ -150,6 +154,7 @@ FROM (
is_bridge, is_bridge,
is_tunnel, is_tunnel,
is_ford, is_ford,
NULL::boolean AS expressway,
NULL::boolean AS is_ramp, NULL::boolean AS is_ramp,
NULL::int AS is_oneway, NULL::int AS is_oneway,
NULL AS man_made, NULL AS man_made,
@ -182,6 +187,7 @@ FROM (
is_bridge, is_bridge,
is_tunnel, is_tunnel,
is_ford, is_ford,
expressway,
NULL::boolean AS is_ramp, NULL::boolean AS is_ramp,
NULL::int AS is_oneway, NULL::int AS is_oneway,
NULL AS man_made, NULL AS man_made,
@ -214,6 +220,7 @@ FROM (
is_bridge, is_bridge,
is_tunnel, is_tunnel,
is_ford, is_ford,
expressway,
NULL::boolean AS is_ramp, NULL::boolean AS is_ramp,
NULL::int AS is_oneway, NULL::int AS is_oneway,
NULL AS man_made, NULL AS man_made,
@ -246,6 +253,7 @@ FROM (
is_bridge, is_bridge,
is_tunnel, is_tunnel,
is_ford, is_ford,
expressway,
NULL::boolean AS is_ramp, NULL::boolean AS is_ramp,
NULL::int AS is_oneway, NULL::int AS is_oneway,
NULL AS man_made, NULL AS man_made,
@ -278,6 +286,7 @@ FROM (
is_bridge, is_bridge,
is_tunnel, is_tunnel,
is_ford, is_ford,
expressway,
NULL::boolean AS is_ramp, NULL::boolean AS is_ramp,
NULL::int AS is_oneway, NULL::int AS is_oneway,
NULL AS man_made, NULL AS man_made,
@ -310,6 +319,7 @@ FROM (
is_bridge, is_bridge,
is_tunnel, is_tunnel,
is_ford, is_ford,
expressway,
NULL::boolean AS is_ramp, NULL::boolean AS is_ramp,
NULL::int AS is_oneway, NULL::int AS is_oneway,
NULL AS man_made, NULL AS man_made,
@ -347,6 +357,7 @@ FROM (
is_bridge, is_bridge,
is_tunnel, is_tunnel,
is_ford, is_ford,
expressway,
is_ramp, is_ramp,
is_oneway, is_oneway,
man_made, man_made,
@ -399,6 +410,7 @@ FROM (
NULL::boolean AS is_bridge, NULL::boolean AS is_bridge,
NULL::boolean AS is_tunnel, NULL::boolean AS is_tunnel,
NULL::boolean AS is_ford, NULL::boolean AS is_ford,
NULL::boolean AS expressway,
NULL::boolean AS is_ramp, NULL::boolean AS is_ramp,
NULL::int AS is_oneway, NULL::int AS is_oneway,
NULL AS man_made, NULL AS man_made,
@ -434,6 +446,7 @@ FROM (
NULL::boolean AS is_bridge, NULL::boolean AS is_bridge,
NULL::boolean AS is_tunnel, NULL::boolean AS is_tunnel,
NULL::boolean AS is_ford, NULL::boolean AS is_ford,
NULL::boolean AS expressway,
NULL::boolean AS is_ramp, NULL::boolean AS is_ramp,
NULL::int AS is_oneway, NULL::int AS is_oneway,
NULL AS man_made, NULL AS man_made,
@ -469,6 +482,7 @@ FROM (
is_bridge, is_bridge,
is_tunnel, is_tunnel,
is_ford, is_ford,
NULL::boolean AS expressway,
is_ramp, is_ramp,
is_oneway, is_oneway,
NULL AS man_made, NULL AS man_made,
@ -503,6 +517,7 @@ FROM (
is_bridge, is_bridge,
is_tunnel, is_tunnel,
is_ford, is_ford,
NULL::boolean AS expressway,
is_ramp, is_ramp,
is_oneway, is_oneway,
NULL AS man_made, NULL AS man_made,
@ -537,6 +552,7 @@ FROM (
is_bridge, is_bridge,
is_tunnel, is_tunnel,
is_ford, is_ford,
NULL::boolean AS expressway,
is_ramp, is_ramp,
is_oneway, is_oneway,
NULL AS man_made, NULL AS man_made,
@ -572,6 +588,7 @@ FROM (
is_bridge, is_bridge,
is_tunnel, is_tunnel,
is_ford, is_ford,
NULL::boolean AS expressway,
is_ramp, is_ramp,
is_oneway, is_oneway,
NULL AS man_made, NULL AS man_made,
@ -607,6 +624,7 @@ FROM (
is_bridge, is_bridge,
is_tunnel, is_tunnel,
is_ford, is_ford,
NULL::boolean AS expressway,
is_ramp, is_ramp,
is_oneway, is_oneway,
NULL AS man_made, NULL AS man_made,
@ -640,6 +658,7 @@ FROM (
is_bridge, is_bridge,
is_tunnel, is_tunnel,
is_ford, is_ford,
NULL::boolean AS expressway,
is_ramp, is_ramp,
is_oneway, is_oneway,
NULL AS man_made, NULL AS man_made,
@ -672,6 +691,7 @@ FROM (
is_bridge, is_bridge,
is_tunnel, is_tunnel,
is_ford, is_ford,
NULL::boolean AS expressway,
is_ramp, is_ramp,
is_oneway, is_oneway,
NULL AS man_made, NULL AS man_made,
@ -704,6 +724,7 @@ FROM (
is_bridge, is_bridge,
is_tunnel, is_tunnel,
is_ford, is_ford,
NULL::boolean AS expressway,
is_ramp, is_ramp,
is_oneway, is_oneway,
NULL AS man_made, NULL AS man_made,
@ -737,6 +758,7 @@ FROM (
is_bridge, is_bridge,
is_tunnel, is_tunnel,
is_ford, is_ford,
NULL::boolean AS expressway,
is_ramp, is_ramp,
is_oneway, is_oneway,
NULL AS man_made, NULL AS man_made,
@ -777,6 +799,7 @@ FROM (
END AS is_bridge, END AS is_bridge,
FALSE AS is_tunnel, FALSE AS is_tunnel,
FALSE AS is_ford, FALSE AS is_ford,
NULL::boolean AS expressway,
FALSE AS is_ramp, FALSE AS is_ramp,
FALSE::int AS is_oneway, FALSE::int AS is_oneway,
man_made, man_made,

Wyświetl plik

@ -162,6 +162,10 @@ layer:
description: | description: |
Whether this is a toll road, based on the [`toll`](http://wiki.openstreetmap.org/wiki/Key:toll) tag. Whether this is a toll road, based on the [`toll`](http://wiki.openstreetmap.org/wiki/Key:toll) tag.
values: [0, 1] values: [0, 1]
expressway:
description: |
Whether this is an expressway, based on the [`expressway`](http://wiki.openstreetmap.org/wiki/Key:expressway) tag.
values: [1]
layer: layer:
description: | description: |
Original value of the [`layer`](http://wiki.openstreetmap.org/wiki/Key:layer) tag. Original value of the [`layer`](http://wiki.openstreetmap.org/wiki/Key:layer) tag.
@ -196,7 +200,7 @@ layer:
datasource: datasource:
geometry_field: geometry geometry_field: geometry
srid: 900913 srid: 900913
query: (SELECT geometry, class, subclass, network, oneway, ramp, brunnel, service, access, toll, layer, level, indoor, bicycle, foot, horse, mtb_scale, surface FROM layer_transportation(!bbox!, z(!scale_denominator!))) AS t query: (SELECT geometry, class, subclass, network, oneway, ramp, brunnel, service, access, toll, expressway, layer, level, indoor, bicycle, foot, horse, mtb_scale, surface FROM layer_transportation(!bbox!, z(!scale_denominator!))) AS t
schema: schema:
- ./network_type.sql - ./network_type.sql
- ./class.sql - ./class.sql

Wyświetl plik

@ -82,6 +82,7 @@ SELECT (ST_Dump(ST_LineMerge(ST_Collect(geometry)))).geom AS geometry,
is_bridge, is_bridge,
is_tunnel, is_tunnel,
is_ford, is_ford,
expressway,
min(z_order) as z_order, min(z_order) as z_order,
bicycle, bicycle,
foot, foot,
@ -95,7 +96,7 @@ SELECT (ST_Dump(ST_LineMerge(ST_Collect(geometry)))).geom AS geometry,
layer layer
FROM osm_highway_linestring_gen_z11 FROM osm_highway_linestring_gen_z11
-- mapping.yaml pre-filter: motorway/trunk/primary/secondary/tertiary, with _link variants, construction, ST_IsValid() -- mapping.yaml pre-filter: motorway/trunk/primary/secondary/tertiary, with _link variants, construction, ST_IsValid()
GROUP BY highway, network, construction, is_bridge, is_tunnel, is_ford, bicycle, foot, horse, mtb_scale, sac_scale, access, toll, layer GROUP BY highway, network, construction, is_bridge, is_tunnel, is_ford, expressway, bicycle, foot, horse, mtb_scale, sac_scale, access, toll, layer
) /* DELAY_MATERIALIZED_VIEW_CREATION */; ) /* DELAY_MATERIALIZED_VIEW_CREATION */;
CREATE INDEX IF NOT EXISTS osm_transportation_merge_linestring_gen_z11_geometry_idx CREATE INDEX IF NOT EXISTS osm_transportation_merge_linestring_gen_z11_geometry_idx
ON osm_transportation_merge_linestring_gen_z11 USING gist (geometry); ON osm_transportation_merge_linestring_gen_z11 USING gist (geometry);
@ -111,6 +112,7 @@ SELECT ST_Simplify(geometry, ZRes(12)) AS geometry,
is_bridge, is_bridge,
is_tunnel, is_tunnel,
is_ford, is_ford,
expressway,
z_order, z_order,
bicycle, bicycle,
foot, foot,
@ -138,6 +140,7 @@ SELECT ST_Simplify(geometry, ZRes(11)) AS geometry,
is_bridge, is_bridge,
is_tunnel, is_tunnel,
is_ford, is_ford,
expressway,
z_order, z_order,
bicycle, bicycle,
foot, foot,
@ -164,13 +167,14 @@ SELECT ST_Simplify(ST_LineMerge(ST_Collect(geometry)), ZRes(10)) AS geometry,
is_bridge, is_bridge,
is_tunnel, is_tunnel,
is_ford, is_ford,
expressway,
min(z_order) as z_order min(z_order) as z_order
FROM osm_transportation_merge_linestring_gen_z9 FROM osm_transportation_merge_linestring_gen_z9
WHERE (highway IN ('motorway', 'trunk', 'primary') OR WHERE (highway IN ('motorway', 'trunk', 'primary') OR
construction IN ('motorway', 'trunk', 'primary')) construction IN ('motorway', 'trunk', 'primary'))
AND ST_IsValid(geometry) AND ST_IsValid(geometry)
AND access IS NULL AND access IS NULL
GROUP BY highway, network, construction, is_bridge, is_tunnel, is_ford GROUP BY highway, network, construction, is_bridge, is_tunnel, is_ford, expressway
) /* DELAY_MATERIALIZED_VIEW_CREATION */; ) /* DELAY_MATERIALIZED_VIEW_CREATION */;
CREATE INDEX IF NOT EXISTS osm_transportation_merge_linestring_gen_z8_geometry_idx CREATE INDEX IF NOT EXISTS osm_transportation_merge_linestring_gen_z8_geometry_idx
ON osm_transportation_merge_linestring_gen_z8 USING gist (geometry); ON osm_transportation_merge_linestring_gen_z8 USING gist (geometry);
@ -186,6 +190,7 @@ SELECT ST_Simplify(geometry, ZRes(9)) AS geometry,
is_bridge, is_bridge,
is_tunnel, is_tunnel,
is_ford, is_ford,
expressway,
z_order z_order
FROM osm_transportation_merge_linestring_gen_z8 FROM osm_transportation_merge_linestring_gen_z8
-- Current view: motorway/trunk/primary -- Current view: motorway/trunk/primary

Wyświetl plik

@ -37,6 +37,7 @@
<nd ref="500011" /> <nd ref="500011" />
<nd ref="500012" /> <nd ref="500012" />
<tag k="highway" v="trunk"/> <tag k="highway" v="trunk"/>
<tag k="expressway" v="yes"/>
<tag k="name" v="OpenMapTiles Trunk"/> <tag k="name" v="OpenMapTiles Trunk"/>
</way> </way>
<way id="5002" version="1" timestamp="2019-01-01T00:00:00Z" visible="true"> <way id="5002" version="1" timestamp="2019-01-01T00:00:00Z" visible="true">

Wyświetl plik

@ -133,6 +133,13 @@ BEGIN
INSERT INTO omt_test_failures VALUES(500, 'import', 'osm_transportation_linestring z9 import tags expected 1, got ' || cnt); INSERT INTO omt_test_failures VALUES(500, 'import', 'osm_transportation_linestring z9 import tags expected 1, got ' || cnt);
END IF; END IF;
SELECT COUNT(*) INTO cnt FROM osm_transportation_merge_linestring_gen_z9
WHERE highway = 'trunk'
AND expressway = TRUE;
IF cnt < 1 THEN
INSERT INTO omt_test_failures VALUES(500, 'import', 'osm_transportation_linestring z9 import expressway expected >=1, got ' || cnt);
END IF;
-- Same-named road split into 3 parts, because the middle segment is tagged toll=yes -- Same-named road split into 3 parts, because the middle segment is tagged toll=yes
SELECT COUNT(*) INTO cnt FROM osm_transportation_name_linestring WHERE tags->'name' = 'OpenMapTiles Secondary 3'; SELECT COUNT(*) INTO cnt FROM osm_transportation_name_linestring WHERE tags->'name' = 'OpenMapTiles Secondary 3';
IF cnt <> 2 THEN IF cnt <> 2 THEN

Wyświetl plik

@ -55,6 +55,14 @@ BEGIN
INSERT INTO omt_test_failures VALUES(500, 'update', 'osm_transportation_linestring unsplit road count expected 1, got ' || cnt); INSERT INTO omt_test_failures VALUES(500, 'update', 'osm_transportation_linestring unsplit road count expected 1, got ' || cnt);
END IF; END IF;
-- Verify expressway tag updated
SELECT COUNT(*) INTO cnt FROM osm_transportation_merge_linestring_gen_z9
WHERE highway = 'primary'
AND expressway = TRUE;
IF cnt < 1 THEN
INSERT INTO omt_test_failures VALUES(500, 'import', 'osm_transportation_linestring z9 update expressway expected >=1, got ' || cnt);
END IF;
-- Verify tags changed -- Verify tags changed
SELECT COUNT(*) INTO cnt FROM osm_transportation_merge_linestring_gen_z9 SELECT COUNT(*) INTO cnt FROM osm_transportation_merge_linestring_gen_z9
WHERE is_tunnel = TRUE WHERE is_tunnel = TRUE

Wyświetl plik

@ -5,6 +5,13 @@
Change tags Change tags
--> -->
<modify> <modify>
<way id="5002" version="1" timestamp="2019-01-01T00:00:00Z" visible="true">
<nd ref="500021" />
<nd ref="500022" />
<tag k="highway" v="primary"/>
<tag k="expressway" v="yes"/>
<tag k="name" v="OpenMapTiles Primary"/>
</way>
<!-- Change tags --> <!-- Change tags -->
<way id="5003" version="2" timestamp="2020-01-02T00:00:00Z" visible="true"> <way id="5003" version="2" timestamp="2020-01-02T00:00:00Z" visible="true">
<nd ref="500031" /> <nd ref="500031" />