Add layer, level, and indoor tags for footways and steps

pull/354/head
jirik 2017-11-09 09:36:09 +01:00 zatwierdzone przez Jiri Kozel
rodzic 0b94704436
commit e95f2d476b
6 zmienionych plików z 191 dodań i 28 usunięć

Wyświetl plik

@ -7,7 +7,8 @@ $$ LANGUAGE SQL IMMUTABLE STRICT;
-- etldoc: label="<sql> layer_transportation |<z4> z4 |<z5> z5 |<z6> z6 |<z7> z7 |<z8> z8 |<z9> z9 |<z10> z10 |<z11> z11 |<z12> z12|<z13> z13|<z14_> z14+" ] ;
CREATE OR REPLACE FUNCTION layer_transportation(bbox geometry, zoom_level int)
RETURNS TABLE(osm_id bigint, geometry geometry, class text, subclass text,
ramp int, oneway int, brunnel TEXT, service TEXT) AS $$
ramp int, oneway int, brunnel TEXT, service TEXT, layer INT, level INT,
indoor INT) AS $$
SELECT
osm_id, geometry,
CASE
@ -28,7 +29,10 @@ ramp int, oneway int, brunnel TEXT, service TEXT) AS $$
THEN 1 ELSE is_ramp::int END AS ramp,
is_oneway::int AS oneway,
brunnel(is_bridge, is_tunnel, is_ford) AS brunnel,
NULLIF(service, '') AS service
NULLIF(service, '') AS service,
NULLIF(layer, 0) AS layer,
"level",
CASE WHEN indoor=TRUE THEN 1 ELSE NULL END as indoor
FROM (
-- etldoc: osm_transportation_merge_linestring_gen7 -> layer_transportation:z4
SELECT
@ -38,6 +42,7 @@ ramp int, oneway int, brunnel TEXT, service TEXT) AS $$
NULL::boolean AS is_bridge, NULL::boolean AS is_tunnel,
NULL::boolean AS is_ford,
NULL::boolean AS is_ramp, NULL::boolean AS is_oneway,
NULL::int AS layer, NULL::int AS level, NULL::boolean AS indoor,
z_order
FROM osm_transportation_merge_linestring_gen7
WHERE zoom_level = 4
@ -51,6 +56,7 @@ ramp int, oneway int, brunnel TEXT, service TEXT) AS $$
NULL::boolean AS is_bridge, NULL::boolean AS is_tunnel,
NULL::boolean AS is_ford,
NULL::boolean AS is_ramp, NULL::boolean AS is_oneway,
NULL::int AS layer, NULL::int AS level, NULL::boolean AS indoor,
z_order
FROM osm_transportation_merge_linestring_gen6
WHERE zoom_level = 5
@ -64,6 +70,7 @@ ramp int, oneway int, brunnel TEXT, service TEXT) AS $$
NULL::boolean AS is_bridge, NULL::boolean AS is_tunnel,
NULL::boolean AS is_ford,
NULL::boolean AS is_ramp, NULL::boolean AS is_oneway,
NULL::int AS layer, NULL::int AS level, NULL::boolean AS indoor,
z_order
FROM osm_transportation_merge_linestring_gen5
WHERE zoom_level = 6
@ -77,6 +84,7 @@ ramp int, oneway int, brunnel TEXT, service TEXT) AS $$
NULL::boolean AS is_bridge, NULL::boolean AS is_tunnel,
NULL::boolean AS is_ford,
NULL::boolean AS is_ramp, NULL::boolean AS is_oneway,
NULL::int AS layer, NULL::int AS level, NULL::boolean AS indoor,
z_order
FROM osm_transportation_merge_linestring_gen4
WHERE zoom_level = 7
@ -90,6 +98,7 @@ ramp int, oneway int, brunnel TEXT, service TEXT) AS $$
NULL::boolean AS is_bridge, NULL::boolean AS is_tunnel,
NULL::boolean AS is_ford,
NULL::boolean AS is_ramp, NULL::boolean AS is_oneway,
NULL::int AS layer, NULL::int AS level, NULL::boolean AS indoor,
z_order
FROM osm_transportation_merge_linestring_gen3
WHERE zoom_level = 8
@ -104,6 +113,7 @@ ramp int, oneway int, brunnel TEXT, service TEXT) AS $$
NULL::boolean AS is_bridge, NULL::boolean AS is_tunnel,
NULL::boolean AS is_ford,
NULL::boolean AS is_ramp, NULL::boolean AS is_oneway,
NULL::int AS layer, NULL::int AS level, NULL::boolean AS indoor,
z_order
FROM osm_highway_linestring_gen2
WHERE zoom_level BETWEEN 9 AND 10
@ -118,6 +128,7 @@ ramp int, oneway int, brunnel TEXT, service TEXT) AS $$
NULL::boolean AS is_bridge, NULL::boolean AS is_tunnel,
NULL::boolean AS is_ford,
NULL::boolean AS is_ramp, NULL::boolean AS is_oneway,
NULL::int AS layer, NULL::int AS level, NULL::boolean AS indoor,
z_order
FROM osm_highway_linestring_gen1
WHERE zoom_level = 11
@ -131,7 +142,17 @@ ramp int, oneway int, brunnel TEXT, service TEXT) AS $$
osm_id, geometry,
highway, NULL AS railway, NULL AS aerialway, NULL AS shipway,
public_transport, service_value(service) AS service,
is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order
is_bridge, is_tunnel, is_ford, is_ramp, is_oneway,
CASE WHEN highway IN ('footway', 'steps') THEN layer
ELSE NULL::int
END AS layer,
CASE WHEN highway IN ('footway', 'steps') THEN "level"
ELSE NULL::int
END AS "level",
CASE WHEN highway IN ('footway', 'steps') THEN indoor
ELSE NULL::boolean
END AS indoor,
z_order
FROM osm_highway_linestring
WHERE NOT is_area AND (
zoom_level = 12 AND (
@ -152,6 +173,7 @@ ramp int, oneway int, brunnel TEXT, service TEXT) AS $$
NULL::boolean AS is_bridge, NULL::boolean AS is_tunnel,
NULL::boolean AS is_ford,
NULL::boolean AS is_ramp, NULL::boolean AS is_oneway,
NULL::int AS layer, NULL::int AS level, NULL::boolean AS indoor,
z_order
FROM osm_railway_linestring_gen5
WHERE zoom_level = 8
@ -166,6 +188,7 @@ ramp int, oneway int, brunnel TEXT, service TEXT) AS $$
NULL::boolean AS is_bridge, NULL::boolean AS is_tunnel,
NULL::boolean AS is_ford,
NULL::boolean AS is_ramp, NULL::boolean AS is_oneway,
NULL::int AS layer, NULL::int AS level, NULL::boolean AS indoor,
z_order
FROM osm_railway_linestring_gen4
WHERE zoom_level = 9
@ -177,7 +200,9 @@ ramp int, oneway int, brunnel TEXT, service TEXT) AS $$
osm_id, geometry,
NULL AS highway, railway, NULL AS aerialway, NULL AS shipway,
NULL AS public_transport, service_value(service) AS service,
is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order
is_bridge, is_tunnel, is_ford, is_ramp, is_oneway,
NULL::int AS layer, NULL::int AS level, NULL::boolean AS indoor,
z_order
FROM osm_railway_linestring_gen3
WHERE zoom_level = 10
AND railway IN ('rail', 'narrow_gauge') AND service = ''
@ -188,7 +213,9 @@ ramp int, oneway int, brunnel TEXT, service TEXT) AS $$
osm_id, geometry,
NULL AS highway, railway, NULL AS aerialway, NULL AS shipway,
NULL AS public_transport, service_value(service) AS service,
is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order
is_bridge, is_tunnel, is_ford, is_ramp, is_oneway,
NULL::int AS layer, NULL::int AS level, NULL::boolean AS indoor,
z_order
FROM osm_railway_linestring_gen2
WHERE zoom_level = 11
AND railway IN ('rail', 'narrow_gauge', 'light_rail') AND service = ''
@ -199,7 +226,9 @@ ramp int, oneway int, brunnel TEXT, service TEXT) AS $$
osm_id, geometry,
NULL AS highway, railway, NULL AS aerialway, NULL AS shipway,
NULL AS public_transport, service_value(service) AS service,
is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order
is_bridge, is_tunnel, is_ford, is_ramp, is_oneway,
NULL::int AS layer, NULL::int AS level, NULL::boolean AS indoor,
z_order
FROM osm_railway_linestring_gen1
WHERE zoom_level = 12
AND railway IN ('rail', 'narrow_gauge', 'light_rail') AND service = ''
@ -211,7 +240,9 @@ ramp int, oneway int, brunnel TEXT, service TEXT) AS $$
osm_id, geometry,
NULL AS highway, railway, NULL AS aerialway, NULL AS shipway,
NULL AS public_transport, service_value(service) AS service,
is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order
is_bridge, is_tunnel, is_ford, is_ramp, is_oneway,
NULL::int AS layer, NULL::int AS level, NULL::boolean AS indoor,
z_order
FROM osm_railway_linestring
WHERE zoom_level = 13
AND railway IN ('rail', 'narrow_gauge', 'light_rail') AND service = ''
@ -223,7 +254,9 @@ ramp int, oneway int, brunnel TEXT, service TEXT) AS $$
osm_id, geometry,
NULL AS highway, NULL as railway, aerialway, NULL AS shipway,
NULL AS public_transport, service_value(service) AS service,
is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order
is_bridge, is_tunnel, is_ford, is_ramp, is_oneway,
NULL::int AS layer, NULL::int AS level, NULL::boolean AS indoor,
z_order
FROM osm_aerialway_linestring_gen1
WHERE zoom_level = 12
UNION ALL
@ -234,7 +267,9 @@ ramp int, oneway int, brunnel TEXT, service TEXT) AS $$
osm_id, geometry,
NULL AS highway, NULL as railway, aerialway, NULL AS shipway,
NULL AS public_transport, service_value(service) AS service,
is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order
is_bridge, is_tunnel, is_ford, is_ramp, is_oneway,
NULL::int AS layer, NULL::int AS level, NULL::boolean AS indoor,
z_order
FROM osm_aerialway_linestring
WHERE zoom_level >= 13
UNION ALL
@ -244,7 +279,9 @@ ramp int, oneway int, brunnel TEXT, service TEXT) AS $$
osm_id, geometry,
NULL AS highway, NULL AS railway, NULL AS aerialway, shipway,
NULL AS public_transport, service_value(service) AS service,
is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order
is_bridge, is_tunnel, is_ford, is_ramp, is_oneway,
NULL::int AS layer, NULL::int AS level, NULL::boolean AS indoor,
z_order
FROM osm_shipway_linestring_gen2
WHERE zoom_level = 11
UNION ALL
@ -254,7 +291,9 @@ ramp int, oneway int, brunnel TEXT, service TEXT) AS $$
osm_id, geometry,
NULL AS highway, NULL AS railway, NULL AS aerialway, shipway,
NULL AS public_transport, service_value(service) AS service,
is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order
is_bridge, is_tunnel, is_ford, is_ramp, is_oneway,
NULL::int AS layer, NULL::int AS level, NULL::boolean AS indoor,
z_order
FROM osm_shipway_linestring_gen1
WHERE zoom_level = 12
UNION ALL
@ -265,7 +304,9 @@ ramp int, oneway int, brunnel TEXT, service TEXT) AS $$
osm_id, geometry,
NULL AS highway, NULL AS railway, NULL AS aerialway, shipway,
NULL AS public_transport, service_value(service) AS service,
is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order
is_bridge, is_tunnel, is_ford, is_ramp, is_oneway,
NULL::int AS layer, NULL::int AS level, NULL::boolean AS indoor,
z_order
FROM osm_shipway_linestring
WHERE zoom_level >= 13
UNION ALL
@ -281,7 +322,9 @@ ramp int, oneway int, brunnel TEXT, service TEXT) AS $$
highway, NULL AS railway, NULL AS aerialway, NULL AS shipway,
public_transport, NULL AS service,
FALSE AS is_bridge, FALSE AS is_tunnel, FALSE AS is_ford,
FALSE AS is_ramp, FALSE AS is_oneway, z_order
FALSE AS is_ramp, FALSE AS is_oneway,
NULL::int AS layer, NULL::int AS level, NULL::boolean AS indoor,
z_order
FROM osm_highway_polygon
-- We do not want underground pedestrian areas for now
WHERE zoom_level >= 13 AND is_area AND COALESCE(layer, 0) >= 0

Wyświetl plik

@ -116,6 +116,14 @@ layer_field: &layer
key: layer
name: layer
type: integer
level_field: &level
key: level
name: level
type: integer
indoor_field: &indoor
key: indoor
name: indoor
type: bool
z_order_field: &z_order
name: z_order
type: wayzorder
@ -136,6 +144,8 @@ tables:
- *network
- *z_order
- *layer
- *level
- *indoor
- *name
- *name_en
- *name_de
@ -193,6 +203,8 @@ tables:
- *network
- *z_order
- *layer
- *level
- *indoor
- *name
- *name_en
- *name_de
@ -287,9 +299,9 @@ tables:
type: string
- name: z_order
type: wayzorder
- name: layer
key: layer
type: integer
- *layer
- *level
- *indoor
- name: is_area
key: area
type: bool

Wyświetl plik

@ -88,10 +88,24 @@ layer:
- driveway
- alley
- parking_aisle
level:
description: |
Experimental feature! Filled only for steps and footways. Original
value of [`level`](http://wiki.openstreetmap.org/wiki/Key:level) tag.
layer:
description: |
Experimental feature! Filled only for steps and footways. Original
value of [`layer`](http://wiki.openstreetmap.org/wiki/Key:layer) tag.
indoor:
description: |
Experimental feature! Filled only for steps and footways. Original
value of [`indoor`](http://wiki.openstreetmap.org/wiki/Key:indoor) tag.
values:
- 1
datasource:
geometry_field: geometry
srid: 900913
query: (SELECT geometry, class, subclass, oneway, ramp, brunnel, service FROM layer_transportation(!bbox!, z(!scale_denominator!))) AS t
query: (SELECT geometry, class, subclass, oneway, ramp, brunnel, service, layer, level, indoor FROM layer_transportation(!bbox!, z(!scale_denominator!))) AS t
schema:
- ./class.sql
- ./update_transportation_merge.sql

Wyświetl plik

@ -5,7 +5,7 @@
CREATE OR REPLACE FUNCTION layer_transportation_name(bbox geometry, zoom_level integer)
RETURNS TABLE(osm_id bigint, geometry geometry, name text, name_en text,
name_de text, tags hstore, ref text, ref_length int, network text, class
text, subclass text) AS $$
text, subclass text, layer INT, level INT, indoor INT) AS $$
SELECT osm_id, geometry,
NULLIF(name, '') AS name,
COALESCE(NULLIF(name_en, ''), name) AS name_en,
@ -24,33 +24,64 @@ RETURNS TABLE(osm_id bigint, geometry geometry, name text, name_en text,
WHEN highway IS NOT NULL AND highway_class(highway, '') = 'path'
THEN highway
ELSE NULL
END AS subclass
END AS subclass,
NULLIF(layer, 0) AS layer,
"level",
CASE WHEN indoor=TRUE THEN 1 ELSE NULL END as indoor
FROM (
-- etldoc: osm_transportation_name_linestring_gen4 -> layer_transportation_name:z6
SELECT * FROM osm_transportation_name_linestring_gen4
SELECT *,
NULL::int AS layer, NULL::int AS level, NULL::boolean AS indoor
FROM osm_transportation_name_linestring_gen4
WHERE zoom_level = 6
UNION ALL
-- etldoc: osm_transportation_name_linestring_gen3 -> layer_transportation_name:z7
SELECT * FROM osm_transportation_name_linestring_gen3
SELECT *,
NULL::int AS layer, NULL::int AS level, NULL::boolean AS indoor
FROM osm_transportation_name_linestring_gen3
WHERE zoom_level = 7
UNION ALL
-- etldoc: osm_transportation_name_linestring_gen2 -> layer_transportation_name:z8
SELECT * FROM osm_transportation_name_linestring_gen2
SELECT *,
NULL::int AS layer, NULL::int AS level, NULL::boolean AS indoor
FROM osm_transportation_name_linestring_gen2
WHERE zoom_level = 8
UNION ALL
-- etldoc: osm_transportation_name_linestring_gen1 -> layer_transportation_name:z9
-- etldoc: osm_transportation_name_linestring_gen1 -> layer_transportation_name:z10
-- etldoc: osm_transportation_name_linestring_gen1 -> layer_transportation_name:z11
SELECT * FROM osm_transportation_name_linestring_gen1
SELECT *,
NULL::int AS layer, NULL::int AS level, NULL::boolean AS indoor
FROM osm_transportation_name_linestring_gen1
WHERE zoom_level BETWEEN 9 AND 11
UNION ALL
-- etldoc: osm_transportation_name_linestring -> layer_transportation_name:z12
SELECT * FROM osm_transportation_name_linestring
SELECT
geometry,
osm_id,
name,
name_en,
name_de,
"tags",
ref,
highway,
network,
z_order,
CASE WHEN highway IN ('footway', 'steps') THEN layer
ELSE NULL::int
END AS layer,
CASE WHEN highway IN ('footway', 'steps') THEN "level"
ELSE NULL::int
END AS "level",
CASE WHEN highway IN ('footway', 'steps') THEN indoor
ELSE NULL::boolean
END AS indoor
FROM osm_transportation_name_linestring
WHERE zoom_level = 12
AND LineLabel(zoom_level, COALESCE(NULLIF(name, ''), ref), geometry)
AND highway_class(highway, '') NOT IN ('minor', 'track', 'path')
@ -58,14 +89,54 @@ RETURNS TABLE(osm_id bigint, geometry geometry, name text, name_en text,
UNION ALL
-- etldoc: osm_transportation_name_linestring -> layer_transportation_name:z13
SELECT * FROM osm_transportation_name_linestring
SELECT
geometry,
osm_id,
name,
name_en,
name_de,
"tags",
ref,
highway,
network,
z_order,
CASE WHEN highway IN ('footway', 'steps') THEN layer
ELSE NULL::int
END AS layer,
CASE WHEN highway IN ('footway', 'steps') THEN "level"
ELSE NULL::int
END AS "level",
CASE WHEN highway IN ('footway', 'steps') THEN indoor
ELSE NULL::boolean
END AS indoor
FROM osm_transportation_name_linestring
WHERE zoom_level = 13
AND LineLabel(zoom_level, COALESCE(NULLIF(name, ''), ref), geometry)
AND highway_class(highway, '') NOT IN ('track', 'path')
UNION ALL
-- etldoc: osm_transportation_name_linestring -> layer_transportation_name:z14_
SELECT * FROM osm_transportation_name_linestring
SELECT
geometry,
osm_id,
name,
name_en,
name_de,
"tags",
ref,
highway,
network,
z_order,
CASE WHEN highway IN ('footway', 'steps') THEN layer
ELSE NULL::int
END AS layer,
CASE WHEN highway IN ('footway', 'steps') THEN "level"
ELSE NULL::int
END AS "level",
CASE WHEN highway IN ('footway', 'steps') THEN indoor
ELSE NULL::boolean
END AS indoor
FROM osm_transportation_name_linestring
WHERE zoom_level >= 14
) AS zoom_levels

Wyświetl plik

@ -57,10 +57,24 @@ layer:
- bridleway
- corridor
- platform
level:
description: |
Experimental feature! Filled only for steps and footways. Original
value of [`level`](http://wiki.openstreetmap.org/wiki/Key:level) tag.
layer:
description: |
Experimental feature! Filled only for steps and footways. Original
value of [`layer`](http://wiki.openstreetmap.org/wiki/Key:layer) tag.
indoor:
description: |
Experimental feature! Filled only for steps and footways. Original
value of [`indoor`](http://wiki.openstreetmap.org/wiki/Key:indoor) tag.
values:
- 1
datasource:
geometry_field: geometry
srid: 900913
query: (SELECT geometry, name, name_en, name_de, {name_languages}, ref, ref_length, network::text, class::text, subclass FROM layer_transportation_name(!bbox!, z(!scale_denominator!))) AS t
query: (SELECT geometry, name, name_en, name_de, {name_languages}, ref, ref_length, network::text, class::text, subclass, layer, level, indoor FROM layer_transportation_name(!bbox!, z(!scale_denominator!))) AS t
schema:
- ./network_type.sql
- ./update_route_member.sql

Wyświetl plik

@ -23,6 +23,9 @@ CREATE MATERIALIZED VIEW osm_transportation_name_network AS (
else hl.ref
end as ref,
hl.highway,
hl.level,
hl.layer,
hl.indoor,
ROW_NUMBER() OVER(PARTITION BY hl.osm_id
ORDER BY rm.network_type) AS "rank",
hl.z_order
@ -45,6 +48,9 @@ CREATE MATERIALIZED VIEW osm_transportation_name_linestring AS (
AS "tags",
ref,
highway,
"level",
layer,
indoor,
network_type AS network,
z_order
FROM (
@ -55,13 +61,16 @@ CREATE MATERIALIZED VIEW osm_transportation_name_linestring AS (
name_de,
ref,
highway,
"level",
layer,
indoor,
network_type,
min(z_order) AS z_order
FROM osm_transportation_name_network
WHERE ("rank"=1 OR "rank" is null)
AND (name <> '' OR ref <> '')
AND NULLIF(highway, '') IS NOT NULL
group by name, name_en, name_de, ref, highway, network_type
group by name, name_en, name_de, ref, highway, "level", layer, indoor, network_type
) AS highway_union
);
CREATE INDEX IF NOT EXISTS osm_transportation_name_linestring_geometry_idx ON osm_transportation_name_linestring USING gist(geometry);