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
name: surface
type: string
expressway_field: &expressway
key: expressway
name: expressway
type: bool
tables:
# etldoc: imposm3 -> osm_highway_linestring
@ -206,6 +210,7 @@ tables:
- *mtb_scale
- *sac_scale
- *surface
- *expressway
mapping:
highway:
- motorway

Wyświetl plik

@ -11,25 +11,26 @@ $$ LANGUAGE SQL IMMUTABLE
CREATE OR REPLACE FUNCTION layer_transportation(bbox geometry, zoom_level int)
RETURNS TABLE
(
osm_id bigint,
geometry geometry,
class text,
subclass text,
network text,
ramp int,
oneway int,
brunnel text,
service text,
access text,
toll int,
layer int,
level int,
indoor int,
bicycle text,
foot text,
horse text,
mtb_scale text,
surface text
osm_id bigint,
geometry geometry,
class text,
subclass text,
network text,
ramp int,
oneway int,
brunnel text,
service text,
access text,
toll int,
expressway int,
layer int,
level int,
indoor int,
bicycle text,
foot text,
horse text,
mtb_scale text,
surface text
)
AS
$$
@ -61,6 +62,7 @@ SELECT osm_id,
NULLIF(service, '') AS service,
access,
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,
"level",
CASE WHEN indoor = TRUE THEN 1 END AS indoor,
@ -86,6 +88,7 @@ FROM (
is_bridge,
is_tunnel,
is_ford,
NULL::boolean AS expressway,
NULL::boolean AS is_ramp,
NULL::int AS is_oneway,
NULL AS man_made,
@ -118,6 +121,7 @@ FROM (
is_bridge,
is_tunnel,
is_ford,
NULL::boolean AS expressway,
NULL::boolean AS is_ramp,
NULL::int AS is_oneway,
NULL AS man_made,
@ -150,6 +154,7 @@ FROM (
is_bridge,
is_tunnel,
is_ford,
NULL::boolean AS expressway,
NULL::boolean AS is_ramp,
NULL::int AS is_oneway,
NULL AS man_made,
@ -182,6 +187,7 @@ FROM (
is_bridge,
is_tunnel,
is_ford,
expressway,
NULL::boolean AS is_ramp,
NULL::int AS is_oneway,
NULL AS man_made,
@ -214,6 +220,7 @@ FROM (
is_bridge,
is_tunnel,
is_ford,
expressway,
NULL::boolean AS is_ramp,
NULL::int AS is_oneway,
NULL AS man_made,
@ -246,6 +253,7 @@ FROM (
is_bridge,
is_tunnel,
is_ford,
expressway,
NULL::boolean AS is_ramp,
NULL::int AS is_oneway,
NULL AS man_made,
@ -278,6 +286,7 @@ FROM (
is_bridge,
is_tunnel,
is_ford,
expressway,
NULL::boolean AS is_ramp,
NULL::int AS is_oneway,
NULL AS man_made,
@ -310,6 +319,7 @@ FROM (
is_bridge,
is_tunnel,
is_ford,
expressway,
NULL::boolean AS is_ramp,
NULL::int AS is_oneway,
NULL AS man_made,
@ -347,6 +357,7 @@ FROM (
is_bridge,
is_tunnel,
is_ford,
expressway,
is_ramp,
is_oneway,
man_made,
@ -399,6 +410,7 @@ FROM (
NULL::boolean AS is_bridge,
NULL::boolean AS is_tunnel,
NULL::boolean AS is_ford,
NULL::boolean AS expressway,
NULL::boolean AS is_ramp,
NULL::int AS is_oneway,
NULL AS man_made,
@ -434,6 +446,7 @@ FROM (
NULL::boolean AS is_bridge,
NULL::boolean AS is_tunnel,
NULL::boolean AS is_ford,
NULL::boolean AS expressway,
NULL::boolean AS is_ramp,
NULL::int AS is_oneway,
NULL AS man_made,
@ -469,6 +482,7 @@ FROM (
is_bridge,
is_tunnel,
is_ford,
NULL::boolean AS expressway,
is_ramp,
is_oneway,
NULL AS man_made,
@ -503,6 +517,7 @@ FROM (
is_bridge,
is_tunnel,
is_ford,
NULL::boolean AS expressway,
is_ramp,
is_oneway,
NULL AS man_made,
@ -537,6 +552,7 @@ FROM (
is_bridge,
is_tunnel,
is_ford,
NULL::boolean AS expressway,
is_ramp,
is_oneway,
NULL AS man_made,
@ -572,6 +588,7 @@ FROM (
is_bridge,
is_tunnel,
is_ford,
NULL::boolean AS expressway,
is_ramp,
is_oneway,
NULL AS man_made,
@ -607,6 +624,7 @@ FROM (
is_bridge,
is_tunnel,
is_ford,
NULL::boolean AS expressway,
is_ramp,
is_oneway,
NULL AS man_made,
@ -640,6 +658,7 @@ FROM (
is_bridge,
is_tunnel,
is_ford,
NULL::boolean AS expressway,
is_ramp,
is_oneway,
NULL AS man_made,
@ -672,6 +691,7 @@ FROM (
is_bridge,
is_tunnel,
is_ford,
NULL::boolean AS expressway,
is_ramp,
is_oneway,
NULL AS man_made,
@ -704,6 +724,7 @@ FROM (
is_bridge,
is_tunnel,
is_ford,
NULL::boolean AS expressway,
is_ramp,
is_oneway,
NULL AS man_made,
@ -737,6 +758,7 @@ FROM (
is_bridge,
is_tunnel,
is_ford,
NULL::boolean AS expressway,
is_ramp,
is_oneway,
NULL AS man_made,
@ -777,6 +799,7 @@ FROM (
END AS is_bridge,
FALSE AS is_tunnel,
FALSE AS is_ford,
NULL::boolean AS expressway,
FALSE AS is_ramp,
FALSE::int AS is_oneway,
man_made,

Wyświetl plik

@ -162,6 +162,10 @@ layer:
description: |
Whether this is a toll road, based on the [`toll`](http://wiki.openstreetmap.org/wiki/Key:toll) tag.
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:
description: |
Original value of the [`layer`](http://wiki.openstreetmap.org/wiki/Key:layer) tag.
@ -196,7 +200,7 @@ layer:
datasource:
geometry_field: geometry
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:
- ./network_type.sql
- ./class.sql

Wyświetl plik

@ -82,6 +82,7 @@ SELECT (ST_Dump(ST_LineMerge(ST_Collect(geometry)))).geom AS geometry,
is_bridge,
is_tunnel,
is_ford,
expressway,
min(z_order) as z_order,
bicycle,
foot,
@ -95,7 +96,7 @@ SELECT (ST_Dump(ST_LineMerge(ST_Collect(geometry)))).geom AS geometry,
layer
FROM osm_highway_linestring_gen_z11
-- 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 */;
CREATE INDEX IF NOT EXISTS osm_transportation_merge_linestring_gen_z11_geometry_idx
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_tunnel,
is_ford,
expressway,
z_order,
bicycle,
foot,
@ -138,6 +140,7 @@ SELECT ST_Simplify(geometry, ZRes(11)) AS geometry,
is_bridge,
is_tunnel,
is_ford,
expressway,
z_order,
bicycle,
foot,
@ -164,13 +167,14 @@ SELECT ST_Simplify(ST_LineMerge(ST_Collect(geometry)), ZRes(10)) AS geometry,
is_bridge,
is_tunnel,
is_ford,
expressway,
min(z_order) as z_order
FROM osm_transportation_merge_linestring_gen_z9
WHERE (highway IN ('motorway', 'trunk', 'primary') OR
construction IN ('motorway', 'trunk', 'primary'))
AND ST_IsValid(geometry)
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 */;
CREATE INDEX IF NOT EXISTS osm_transportation_merge_linestring_gen_z8_geometry_idx
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_tunnel,
is_ford,
expressway,
z_order
FROM osm_transportation_merge_linestring_gen_z8
-- Current view: motorway/trunk/primary

Wyświetl plik

@ -37,6 +37,7 @@
<nd ref="500011" />
<nd ref="500012" />
<tag k="highway" v="trunk"/>
<tag k="expressway" v="yes"/>
<tag k="name" v="OpenMapTiles Trunk"/>
</way>
<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);
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
SELECT COUNT(*) INTO cnt FROM osm_transportation_name_linestring WHERE tags->'name' = 'OpenMapTiles Secondary 3';
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);
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
SELECT COUNT(*) INTO cnt FROM osm_transportation_merge_linestring_gen_z9
WHERE is_tunnel = TRUE

Wyświetl plik

@ -5,6 +5,13 @@
Change tags
-->
<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 -->
<way id="5003" version="2" timestamp="2020-01-02T00:00:00Z" visible="true">
<nd ref="500031" />