Add toll tagging (#1177)

Fixes #366

This PR sets `toll=1` in the `transportation` layer when a road is tagged as a toll road in OSM (with the tag `toll=yes`).  If a road is tagged with any other value of `tag=*`, the value is suppressed in the tile, since non-toll roads can be presumed as the default and therefore this PR should have only negligible impact in the tiles.

Support for toll road tagging is of interest in the American mapping community, because toll roads have historically been styled differently on American-style maps, for example:
![image](https://user-images.githubusercontent.com/3254090/129505967-5916eace-596a-4c89-ac5d-0aab3e641ed7.png)


Screen shot of a toll road being generated in the `transportation` layer tiles:
![image](https://user-images.githubusercontent.com/3254090/129505683-eb315643-95ff-455b-a606-f379f776f92d.png)
This commit is contained in:
Brian Sperlongano 2021-08-19 01:12:10 -04:00 committed by GitHub
parent e37076c133
commit 7ca751ec7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 41 additions and 5 deletions

View File

@ -96,6 +96,10 @@ access_field: &access
key: access key: access
name: access name: access
type: string type: string
toll_field: &toll
key: toll
name: toll
type: bool
usage_field: &usage usage_field: &usage
key: usage key: usage
name: usage name: usage
@ -188,6 +192,7 @@ tables:
- *area - *area
- *service - *service
- *access - *access
- *toll
- *usage - *usage
- *public_transport - *public_transport
- *man_made - *man_made

View File

@ -21,6 +21,7 @@ CREATE OR REPLACE FUNCTION layer_transportation(bbox geometry, zoom_level int)
brunnel text, brunnel text,
service text, service text,
access text, access text,
toll int,
layer int, layer int,
level int, level int,
indoor int, indoor int,
@ -59,6 +60,7 @@ SELECT osm_id,
brunnel(is_bridge, is_tunnel, is_ford) AS brunnel, brunnel(is_bridge, is_tunnel, is_ford) AS brunnel,
NULLIF(service, '') AS service, NULLIF(service, '') AS service,
access, access,
CASE WHEN toll = TRUE THEN 1 END AS toll,
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,
@ -80,6 +82,7 @@ FROM (
NULL AS public_transport, NULL AS public_transport,
NULL AS service, NULL AS service,
NULL AS access, NULL AS access,
NULL::boolean AS toll,
is_bridge, is_bridge,
is_tunnel, is_tunnel,
is_ford, is_ford,
@ -111,6 +114,7 @@ FROM (
NULL AS public_transport, NULL AS public_transport,
NULL AS service, NULL AS service,
NULL AS access, NULL AS access,
NULL::boolean AS toll,
is_bridge, is_bridge,
is_tunnel, is_tunnel,
is_ford, is_ford,
@ -142,6 +146,7 @@ FROM (
NULL AS public_transport, NULL AS public_transport,
NULL AS service, NULL AS service,
NULL AS access, NULL AS access,
NULL::boolean AS toll,
is_bridge, is_bridge,
is_tunnel, is_tunnel,
is_ford, is_ford,
@ -173,6 +178,7 @@ FROM (
NULL AS public_transport, NULL AS public_transport,
NULL AS service, NULL AS service,
NULL AS access, NULL AS access,
NULL::boolean AS toll,
is_bridge, is_bridge,
is_tunnel, is_tunnel,
is_ford, is_ford,
@ -204,6 +210,7 @@ FROM (
NULL AS public_transport, NULL AS public_transport,
NULL AS service, NULL AS service,
NULL AS access, NULL AS access,
NULL::boolean AS toll,
is_bridge, is_bridge,
is_tunnel, is_tunnel,
is_ford, is_ford,
@ -235,6 +242,7 @@ FROM (
NULL AS public_transport, NULL AS public_transport,
NULL AS service, NULL AS service,
access, access,
toll,
is_bridge, is_bridge,
is_tunnel, is_tunnel,
is_ford, is_ford,
@ -266,6 +274,7 @@ FROM (
NULL AS public_transport, NULL AS public_transport,
NULL AS service, NULL AS service,
access, access,
toll,
is_bridge, is_bridge,
is_tunnel, is_tunnel,
is_ford, is_ford,
@ -297,6 +306,7 @@ FROM (
NULL AS public_transport, NULL AS public_transport,
NULL AS service, NULL AS service,
access, access,
toll,
is_bridge, is_bridge,
is_tunnel, is_tunnel,
is_ford, is_ford,
@ -330,6 +340,7 @@ FROM (
public_transport, public_transport,
service_value(service) AS service, service_value(service) AS service,
CASE WHEN access IN ('private', 'no') THEN 'no' END AS access, CASE WHEN access IN ('private', 'no') THEN 'no' END AS access,
CASE WHEN toll='yes' THEN true ELSE NULL::boolean END AS toll,
is_bridge, is_bridge,
is_tunnel, is_tunnel,
is_ford, is_ford,
@ -380,6 +391,7 @@ FROM (
NULL AS public_transport, NULL AS public_transport,
service_value(service) AS service, service_value(service) AS service,
NULL::text AS access, NULL::text AS access,
NULL::boolean AS toll,
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,
@ -414,6 +426,7 @@ FROM (
NULL AS public_transport, NULL AS public_transport,
service_value(service) AS service, service_value(service) AS service,
NULL::text AS access, NULL::text AS access,
NULL::boolean AS toll,
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,
@ -448,6 +461,7 @@ FROM (
NULL AS public_transport, NULL AS public_transport,
service_value(service) AS service, service_value(service) AS service,
NULL::text AS access, NULL::text AS access,
NULL::boolean AS toll,
is_bridge, is_bridge,
is_tunnel, is_tunnel,
is_ford, is_ford,
@ -481,6 +495,7 @@ FROM (
NULL AS public_transport, NULL AS public_transport,
service_value(service) AS service, service_value(service) AS service,
NULL::text AS access, NULL::text AS access,
NULL::boolean AS toll,
is_bridge, is_bridge,
is_tunnel, is_tunnel,
is_ford, is_ford,
@ -514,6 +529,7 @@ FROM (
NULL AS public_transport, NULL AS public_transport,
service_value(service) AS service, service_value(service) AS service,
NULL::text AS access, NULL::text AS access,
NULL::boolean AS toll,
is_bridge, is_bridge,
is_tunnel, is_tunnel,
is_ford, is_ford,
@ -548,6 +564,7 @@ FROM (
NULL AS public_transport, NULL AS public_transport,
service_value(service) AS service, service_value(service) AS service,
NULL::text AS access, NULL::text AS access,
NULL::boolean AS toll,
is_bridge, is_bridge,
is_tunnel, is_tunnel,
is_ford, is_ford,
@ -582,6 +599,7 @@ FROM (
NULL AS public_transport, NULL AS public_transport,
service_value(service) AS service, service_value(service) AS service,
NULL::text AS access, NULL::text AS access,
NULL::boolean AS toll,
is_bridge, is_bridge,
is_tunnel, is_tunnel,
is_ford, is_ford,
@ -614,6 +632,7 @@ FROM (
NULL AS public_transport, NULL AS public_transport,
service_value(service) AS service, service_value(service) AS service,
NULL::text AS access, NULL::text AS access,
NULL::boolean AS toll,
is_bridge, is_bridge,
is_tunnel, is_tunnel,
is_ford, is_ford,
@ -645,6 +664,7 @@ FROM (
NULL AS public_transport, NULL AS public_transport,
service_value(service) AS service, service_value(service) AS service,
NULL::text AS access, NULL::text AS access,
NULL::boolean AS toll,
is_bridge, is_bridge,
is_tunnel, is_tunnel,
is_ford, is_ford,
@ -676,6 +696,7 @@ FROM (
NULL AS public_transport, NULL AS public_transport,
service_value(service) AS service, service_value(service) AS service,
NULL::text AS access, NULL::text AS access,
NULL::boolean AS toll,
is_bridge, is_bridge,
is_tunnel, is_tunnel,
is_ford, is_ford,
@ -708,6 +729,7 @@ FROM (
NULL AS public_transport, NULL AS public_transport,
service_value(service) AS service, service_value(service) AS service,
NULL::text AS access, NULL::text AS access,
NULL::boolean AS toll,
is_bridge, is_bridge,
is_tunnel, is_tunnel,
is_ford, is_ford,
@ -744,6 +766,7 @@ FROM (
public_transport, public_transport,
NULL AS service, NULL AS service,
NULL::text AS access, NULL::text AS access,
NULL::boolean AS toll,
CASE CASE
WHEN man_made IN ('bridge') THEN TRUE WHEN man_made IN ('bridge') THEN TRUE
ELSE FALSE ELSE FALSE

View File

@ -153,6 +153,10 @@ layer:
which resolve to `no`. which resolve to `no`.
values: values:
- no - no
toll:
description: |
Whether this is a toll road, based on the [`toll`](http://wiki.openstreetmap.org/wiki/Key:toll) tag.
values: [0, 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.
@ -187,7 +191,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, 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, 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

View File

@ -30,13 +30,15 @@ SELECT (ST_Dump(ST_LineMerge(ST_Collect(geometry)))).geom AS geometry,
horse, horse,
mtb_scale, mtb_scale,
CASE CASE
WHEN access IN ('private', 'no') WHEN access IN ('private', 'no') THEN 'no'
THEN 'no' ELSE NULL::text END AS access,
ELSE NULL::text END AS access, CASE
WHEN toll = 'yes' THEN true
ELSE false END AS toll,
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, access, layer GROUP BY highway, network, construction, is_bridge, is_tunnel, is_ford, bicycle, foot, horse, mtb_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);
@ -58,6 +60,7 @@ SELECT ST_Simplify(geometry, ZRes(12)) AS geometry,
horse, horse,
mtb_scale, mtb_scale,
access, access,
toll,
layer layer
FROM osm_transportation_merge_linestring_gen_z11 FROM osm_transportation_merge_linestring_gen_z11
WHERE highway NOT IN ('tertiary', 'tertiary_link') WHERE highway NOT IN ('tertiary', 'tertiary_link')
@ -83,6 +86,7 @@ SELECT ST_Simplify(geometry, ZRes(11)) AS geometry,
horse, horse,
mtb_scale, mtb_scale,
access, access,
toll,
layer layer
FROM osm_transportation_merge_linestring_gen_z10 FROM osm_transportation_merge_linestring_gen_z10
-- Current view: motorway/primary/secondary, with _link variants and construction -- Current view: motorway/primary/secondary, with _link variants and construction