Move highway and railway into transportation
This commit is contained in:
parent
c769577c56
commit
35b6951c81
12
Makefile
12
Makefile
@ -1,7 +1,7 @@
|
||||
all: build/openmaptiles.tm2source/data.yml build/mapping.yaml build/tileset.sql
|
||||
|
||||
.PHONY: docs
|
||||
docs: layers/railway/README.md layers/boundary/README.md layers/water/README.md layers/building/README.md layers/highway/README.md layers/highway_name/README.md layers/poi/README.md layers/place/README.md layers/waterway/README.md layers/water_name/README.md layers/landcover/README.md layers/landuse/README.md layers/housenumber/README.md
|
||||
docs: layers/railway/README.md layers/boundary/README.md layers/water/README.md layers/building/README.md layers/transportation/README.md layers/transportation_name/README.md layers/poi/README.md layers/place/README.md layers/waterway/README.md layers/water_name/README.md layers/landcover/README.md layers/landuse/README.md layers/housenumber/README.md
|
||||
|
||||
build/openmaptiles.tm2source/data.yml:
|
||||
mkdir -p build/openmaptiles.tm2source && generate-tm2source openmaptiles.yaml --host="postgres" --port=5432 --database="openmaptiles" --user="openmaptiles" --password="openmaptiles" > build/openmaptiles.tm2source/data.yml
|
||||
@ -15,11 +15,11 @@ build/tileset.sql:
|
||||
layers/poi/README.md:
|
||||
generate-doc layers/poi/poi.yaml --diagram layers/poi/mapping > layers/poi/README.md
|
||||
|
||||
layers/highway/README.md:
|
||||
generate-doc layers/highway/highway.yaml --diagram layers/highway/mapping > layers/highway/README.md
|
||||
layers/transportation/README.md:
|
||||
generate-doc layers/transportation/transportation.yaml --diagram layers/transportation/mapping > layers/transportation/README.md
|
||||
|
||||
layers/highway_name/README.md:
|
||||
generate-doc layers/highway_name/highway_name.yaml > layers/highway_name/README.md
|
||||
layers/transportation_name/README.md:
|
||||
generate-doc layers/transportation_name/transportation_name.yaml > layers/transportation_name/README.md
|
||||
|
||||
layers/railway/README.md:
|
||||
generate-doc layers/railway/railway.yaml --diagram layers/railway/mapping > layers/railway/README.md
|
||||
@ -52,4 +52,4 @@ layers/housenumber/README.md:
|
||||
generate-doc layers/housenumber/housenumber.yaml > layers/housenumber/README.md
|
||||
|
||||
clean:
|
||||
rm -f build/openmaptiles.tm2source/data.yml && rm -f build/mapping.yaml && rm -f build/tileset.sql && rm -f layers/**/README.md&& rm -f layers/**/*.png
|
||||
rm -f build/openmaptiles.tm2source/data.yml && rm -f build/mapping.yaml && rm -f build/tileset.sql
|
||||
|
||||
@ -1,50 +0,0 @@
|
||||
|
||||
-- etldoc: layer_highway_name[shape=record fillcolor=lightpink, style="rounded,filled",
|
||||
-- etldoc: label="layer_highway_name | <z8> z8 |<z9> z9 |<z10> z10 |<z11> z11 |<z12> z12|<z13> z13|<z14_> z14_" ] ;
|
||||
|
||||
CREATE OR REPLACE FUNCTION layer_highway_name(bbox geometry, zoom_level integer)
|
||||
RETURNS TABLE(osm_id bigint, geometry geometry, name text, ref text, ref_length int, class highway_class, subclass text) AS $$
|
||||
SELECT osm_id, geometry, name,
|
||||
NULLIF(ref, ''), NULLIF(LENGTH(ref), 0) AS ref_length,
|
||||
to_highway_class(highway) AS class, highway AS subclass
|
||||
FROM (
|
||||
|
||||
-- etldoc: osm_highway_name_linestring_gen3 -> layer_highway_name:z8
|
||||
SELECT * FROM osm_highway_name_linestring_gen3
|
||||
WHERE zoom_level = 8
|
||||
UNION ALL
|
||||
|
||||
-- etldoc: osm_highway_name_linestring_gen2 -> layer_highway_name:z9
|
||||
SELECT * FROM osm_highway_name_linestring_gen2
|
||||
WHERE zoom_level = 9
|
||||
UNION ALL
|
||||
|
||||
-- etldoc: osm_highway_name_linestring_gen1 -> layer_highway_name:z10
|
||||
-- etldoc: osm_highway_name_linestring_gen1 -> layer_highway_name:z11
|
||||
SELECT * FROM osm_highway_name_linestring_gen1
|
||||
WHERE zoom_level BETWEEN 10 AND 11
|
||||
UNION ALL
|
||||
|
||||
-- etldoc: osm_highway_name_linestring -> layer_highway_name:z12
|
||||
SELECT * FROM osm_highway_name_linestring
|
||||
WHERE zoom_level = 12
|
||||
AND LineLabel(zoom_level, COALESCE(NULLIF(name, ''), ref), geometry)
|
||||
AND to_highway_class(highway) < 'minor_road'::highway_class
|
||||
AND NOT highway_is_link(highway)
|
||||
UNION ALL
|
||||
|
||||
-- etldoc: osm_highway_name_linestring -> layer_highway_name:z13
|
||||
SELECT * FROM osm_highway_name_linestring
|
||||
WHERE zoom_level = 13
|
||||
AND LineLabel(zoom_level, COALESCE(NULLIF(name, ''), ref), geometry)
|
||||
AND to_highway_class(highway) < 'path'::highway_class
|
||||
UNION ALL
|
||||
|
||||
-- etldoc: osm_highway_name_linestring -> layer_highway_name:z14_
|
||||
SELECT * FROM osm_highway_name_linestring
|
||||
WHERE zoom_level >= 14
|
||||
|
||||
) AS zoom_levels
|
||||
WHERE geometry && bbox
|
||||
ORDER BY z_order ASC;
|
||||
$$ LANGUAGE SQL IMMUTABLE;
|
||||
@ -1,57 +0,0 @@
|
||||
-- Instead of using relations to find out the road names we
|
||||
-- stitch together the touching ways with the same name
|
||||
-- to allow for nice label rendering
|
||||
-- Because this works well for roads that do not have relations as well
|
||||
|
||||
-- etldoc: osm_highway_linestring -> osm_highway_name_linestring
|
||||
CREATE TABLE IF NOT EXISTS osm_highway_name_linestring AS (
|
||||
SELECT
|
||||
(ST_Dump(geometry)).geom AS geometry,
|
||||
-- NOTE: The osm_id is no longer the original one which can make it difficult
|
||||
-- to lookup road names by OSM ID
|
||||
member_osm_ids[0] AS osm_id,
|
||||
member_osm_ids,
|
||||
name,
|
||||
ref,
|
||||
highway,
|
||||
z_order
|
||||
FROM (
|
||||
SELECT
|
||||
ST_LineMerge(ST_Union(geometry)) AS geometry,
|
||||
name,
|
||||
ref,
|
||||
highway,
|
||||
min(z_order) AS z_order,
|
||||
array_agg(DISTINCT osm_id) AS member_osm_ids
|
||||
FROM osm_highway_linestring
|
||||
-- We only care about roads for labelling
|
||||
WHERE name <> '' OR ref <> ''
|
||||
GROUP BY name, highway, ref
|
||||
) AS highway_union
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS osm_highway_name_linestring_geometry_idx ON osm_highway_name_linestring USING gist(geometry);
|
||||
|
||||
-- etldoc: osm_highway_name_linestring -> osm_highway_name_linestring_gen1
|
||||
CREATE TABLE IF NOT EXISTS osm_highway_name_linestring_gen1 AS (
|
||||
SELECT ST_Simplify(geometry, 50) AS geometry, osm_id, member_osm_ids, name, ref, highway, z_order
|
||||
FROM osm_highway_name_linestring
|
||||
WHERE highway IN ('motorway','trunk') AND ST_Length(geometry) > 8000
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS osm_highway_name_linestring_gen1_geometry_idx ON osm_highway_name_linestring_gen1 USING gist(geometry);
|
||||
|
||||
-- etldoc: osm_highway_name_linestring_gen1 -> osm_highway_name_linestring_gen2
|
||||
CREATE TABLE IF NOT EXISTS osm_highway_name_linestring_gen2 AS (
|
||||
SELECT ST_Simplify(geometry, 120) AS geometry, osm_id, member_osm_ids, name, ref, highway, z_order
|
||||
FROM osm_highway_name_linestring_gen1
|
||||
WHERE highway IN ('motorway','trunk') AND ST_Length(geometry) > 14000
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS osm_highway_name_linestring_gen2_geometry_idx ON osm_highway_name_linestring_gen2 USING gist(geometry);
|
||||
|
||||
-- etldoc: osm_highway_name_linestring_gen2 -> osm_highway_name_linestring_gen3
|
||||
CREATE TABLE IF NOT EXISTS osm_highway_name_linestring_gen3 AS (
|
||||
SELECT ST_Simplify(geometry, 120) AS geometry, osm_id, member_osm_ids, name, ref, highway, z_order
|
||||
FROM osm_highway_name_linestring_gen2
|
||||
WHERE highway = 'motorway' AND ST_Length(geometry) > 20000
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS osm_highway_name_linestring_gen3_geometry_idx ON osm_highway_name_linestring_gen3 USING gist(geometry);
|
||||
@ -1,19 +0,0 @@
|
||||
# railway
|
||||
|
||||
The `railway` layer contains linestrings marking tracks from [OSM Railways](http://wiki.openstreetmap.org/wiki/Railways).
|
||||
It contains tracks for [passenger and freight trains]() and smaller tracks for [Trams](http://wiki.openstreetmap.org/wiki/Tag:railway%3Dtram) or [similar](http://wiki.openstreetmap.org/wiki/Tag:railway%3Dlight_rail) vehicles. But also tracks for [subways](http://wiki.openstreetmap.org/wiki/Tag:railway%3Dsubway), [narrow-gauge trains](http://wiki.openstreetmap.org/wiki/Tag:railway%3Dnarrow_gauge) or [historic trains](http://wiki.openstreetmap.org/wiki/Tag:railway%3Dpreserved).
|
||||
Non mainline tracks (marked with class `minor_rail`) used for [storage of trains](http://wiki.openstreetmap.org/wiki/Tag:service%3Dyard) and [maintenance](http://wiki.openstreetmap.org/wiki/Tag:service%3Dsiding) are contained in the highest zoom levels and should be styled more subtle than the mainline tracks with class `rail`.
|
||||
|
||||
## Fields
|
||||
|
||||
- **class**: Divides the track into mainline tracks (class `rail`) and less important tracks
|
||||
used for maintenance (class `minor_rail`).
|
||||
- **subclass**: Original value of the [`railway`](http://wiki.openstreetmap.org/wiki/Key:railway) can be one of
|
||||
`rail`, `light_rail`, `subway`, `narrow_gauge`, `preserved`, `tram`.
|
||||
- **properties**: Additional properties describing the nature of tracks. Can be either `bridge` or `tunnel`.
|
||||
|
||||
## Mapping
|
||||
|
||||

|
||||
|
||||
|
||||
@ -1,14 +0,0 @@
|
||||
digraph "Imposm Mapping" {
|
||||
graph [rankdir=LR ranksep=3]
|
||||
subgraph railway_linestring {
|
||||
node [fixed_size=shape "width:"=20]
|
||||
railway_linestring [shape=box]
|
||||
key_railway [label=railway shape=box]
|
||||
key_railway -> railway_linestring [label="rail
|
||||
light_rail
|
||||
subway
|
||||
narrow_gauge
|
||||
preserved
|
||||
tram"]
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 13 KiB |
@ -1,34 +0,0 @@
|
||||
tables:
|
||||
# etldoc: imposm3 -> osm_railway_linestring
|
||||
railway_linestring:
|
||||
type: linestring
|
||||
fields:
|
||||
- name: osm_id
|
||||
type: id
|
||||
- name: geometry
|
||||
type: geometry
|
||||
- key: railway
|
||||
name: railway
|
||||
type: string
|
||||
- name: z_order
|
||||
type: wayzorder
|
||||
- key: tunnel
|
||||
name: is_tunnel
|
||||
type: bool
|
||||
- key: bridge
|
||||
name: is_bridge
|
||||
type: bool
|
||||
- key: service
|
||||
name: service
|
||||
type: string
|
||||
- key: usage
|
||||
name: usage
|
||||
type: string
|
||||
mapping:
|
||||
railway:
|
||||
- rail
|
||||
- light_rail
|
||||
- subway
|
||||
- narrow_gauge
|
||||
- preserved
|
||||
- tram
|
||||
@ -1,35 +0,0 @@
|
||||
CREATE OR REPLACE FUNCTION railway_class(railway text, service text) RETURNS TEXT AS $$
|
||||
SELECT CASE
|
||||
WHEN railway='rail' AND service='' THEN 'rail'
|
||||
ELSE 'minor_rail'
|
||||
END;
|
||||
$$ LANGUAGE SQL IMMUTABLE;
|
||||
|
||||
CREATE OR REPLACE FUNCTION railway_brunnel(is_bridge boolean, is_tunnel boolean) RETURNS TEXT AS $$
|
||||
SELECT CASE
|
||||
WHEN is_bridge THEN 'bridge'
|
||||
WHEN is_tunnel THEN 'tunnel'
|
||||
ELSE NULL
|
||||
END;
|
||||
$$ LANGUAGE SQL IMMUTABLE;
|
||||
|
||||
-- etldoc: layer_railway[shape=record fillcolor=lightpink, style="rounded,filled",
|
||||
-- etldoc: label="layer_railway | <z13> z13 | <z14_> z14_" ] ;
|
||||
|
||||
CREATE OR REPLACE FUNCTION layer_railway(bbox geometry, zoom_level int)
|
||||
RETURNS TABLE(osm_id bigint, geometry geometry, class text, subclass text, properties railway_properties) AS $$
|
||||
SELECT osm_id, geometry,
|
||||
railway_class(railway, service) AS class,
|
||||
railway AS subclass,
|
||||
to_railway_properties(is_bridge, is_tunnel) AS properties
|
||||
FROM (
|
||||
-- etldoc: osm_railway_linestring -> layer_railway :z13
|
||||
SELECT * FROM osm_railway_linestring
|
||||
WHERE zoom_level = 13 AND railway = 'rail' AND service=''
|
||||
UNION ALL
|
||||
-- etldoc: osm_railway_linestring -> layer_railway :z14_
|
||||
SELECT * FROM osm_railway_linestring WHERE zoom_level >= 14
|
||||
) AS zoom_levels
|
||||
WHERE geometry && bbox
|
||||
ORDER BY z_order ASC;
|
||||
$$ LANGUAGE SQL IMMUTABLE;
|
||||
@ -1,25 +0,0 @@
|
||||
layer:
|
||||
id: "railway"
|
||||
description: |
|
||||
The `railway` layer contains linestrings marking tracks from [OSM Railways](http://wiki.openstreetmap.org/wiki/Railways).
|
||||
It contains tracks for [passenger and freight trains]() and smaller tracks for [Trams](http://wiki.openstreetmap.org/wiki/Tag:railway%3Dtram) or [similar](http://wiki.openstreetmap.org/wiki/Tag:railway%3Dlight_rail) vehicles. But also tracks for [subways](http://wiki.openstreetmap.org/wiki/Tag:railway%3Dsubway), [narrow-gauge trains](http://wiki.openstreetmap.org/wiki/Tag:railway%3Dnarrow_gauge) or [historic trains](http://wiki.openstreetmap.org/wiki/Tag:railway%3Dpreserved).
|
||||
Non mainline tracks (marked with class `minor_rail`) used for [storage of trains](http://wiki.openstreetmap.org/wiki/Tag:service%3Dyard) and [maintenance](http://wiki.openstreetmap.org/wiki/Tag:service%3Dsiding) are contained in the highest zoom levels and should be styled more subtle than the mainline tracks with class `rail`.
|
||||
fields:
|
||||
class: |
|
||||
Divides the track into mainline tracks (class `rail`) and less important tracks
|
||||
used for maintenance (class `minor_rail`).
|
||||
subclass: |
|
||||
Original value of the [`railway`](http://wiki.openstreetmap.org/wiki/Key:railway) can be one of
|
||||
`rail`, `light_rail`, `subway`, `narrow_gauge`, `preserved`, `tram`.
|
||||
properties: |
|
||||
Additional properties describing the nature of tracks. Can be either `bridge` or `tunnel`.
|
||||
buffer_size: 4
|
||||
datasource:
|
||||
geometry_field: geometry
|
||||
query: (SELECT geometry, class, subclass, properties::text FROM layer_railway(!bbox!, z(!scale_denominator!))) AS t
|
||||
schema:
|
||||
- ./types.sql
|
||||
- ./railway.sql
|
||||
datasources:
|
||||
- type: imposm3
|
||||
mapping_file: ./mapping.yaml
|
||||
@ -1,15 +0,0 @@
|
||||
DO $$
|
||||
BEGIN
|
||||
IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'railway_properties') THEN
|
||||
CREATE TYPE railway_properties AS ENUM ('bridge', 'tunnel');
|
||||
END IF;
|
||||
END
|
||||
$$;
|
||||
|
||||
CREATE OR REPLACE FUNCTION to_railway_properties(is_bridge boolean, is_tunnel boolean) RETURNS railway_properties AS $$
|
||||
SELECT CASE
|
||||
WHEN is_bridge THEN 'bridge'::railway_properties
|
||||
WHEN is_tunnel THEN 'tunnel'::railway_properties
|
||||
ELSE NULL
|
||||
END;
|
||||
$$ LANGUAGE SQL IMMUTABLE;
|
||||
@ -1,13 +1,11 @@
|
||||
|
||||
|
||||
CREATE OR REPLACE FUNCTION highway_is_link(highway TEXT) RETURNS BOOLEAN AS $$
|
||||
SELECT highway LIKE '%_link';
|
||||
$$ LANGUAGE SQL IMMUTABLE STRICT;
|
||||
|
||||
|
||||
-- etldoc: layer_highway[shape=record fillcolor=lightpink, style="rounded,filled",
|
||||
-- etldoc: label="<sql> layer_highway |<z4z7> z4-z7 |<z8> z8 |<z9> z9 |<z10> z10 |<z11> z11 |<z12> z12|<z13> z13|<z14_> z14_" ] ;
|
||||
CREATE OR REPLACE FUNCTION layer_highway(bbox geometry, zoom_level int)
|
||||
-- etldoc: layer_transportation[shape=record fillcolor=lightpink, style="rounded,filled",
|
||||
-- etldoc: label="<sql> layer_transportation |<z4z7> z4-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 highway_class, subclass text, properties highway_properties) AS $$
|
||||
SELECT
|
||||
osm_id, geometry,
|
||||
@ -15,8 +13,8 @@ RETURNS TABLE(osm_id bigint, geometry geometry, class highway_class, subclass te
|
||||
to_highway_properties(is_bridge, is_tunnel, is_ford, is_ramp, is_oneway) AS properties
|
||||
FROM (
|
||||
|
||||
-- etldoc: ne_10m_global_roads -> layer_highway:z4z7
|
||||
SELECT
|
||||
-- etldoc: ne_10m_global_roads -> layer_transportation:z4z7
|
||||
SELECT
|
||||
NULL::bigint AS osm_id, geometry, highway,
|
||||
FALSE AS is_bridge, FALSE AS is_tunnel, FALSE AS is_ford, FALSE AS is_ramp, FALSE AS is_oneway,
|
||||
0 AS z_order
|
||||
@ -24,59 +22,59 @@ RETURNS TABLE(osm_id bigint, geometry geometry, class highway_class, subclass te
|
||||
WHERE zoom_level BETWEEN 4 AND 7 AND scalerank <= 1 + zoom_level
|
||||
UNION ALL
|
||||
|
||||
-- etldoc: osm_highway_linestring_gen4 -> layer_highway:z8
|
||||
-- etldoc: osm_transportation_linestring_gen4 -> layer_transportation:z8
|
||||
SELECT osm_id, geometry, highway, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order
|
||||
FROM osm_highway_linestring_gen4
|
||||
FROM osm_transportation_linestring_gen4
|
||||
WHERE zoom_level = 8
|
||||
UNION ALL
|
||||
|
||||
-- etldoc: osm_highway_linestring_gen3 -> layer_highway:z9
|
||||
-- etldoc: osm_transportation_linestring_gen3 -> layer_transportation:z9
|
||||
SELECT osm_id, geometry, highway, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order
|
||||
FROM osm_highway_linestring_gen3
|
||||
FROM osm_transportation_linestring_gen3
|
||||
WHERE zoom_level = 9
|
||||
UNION ALL
|
||||
|
||||
-- etldoc: osm_highway_linestring_gen2 -> layer_highway:z10
|
||||
-- etldoc: osm_transportation_linestring_gen2 -> layer_transportation:z10
|
||||
SELECT osm_id, geometry, highway, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order
|
||||
FROM osm_highway_linestring_gen2
|
||||
FROM osm_transportation_linestring_gen2
|
||||
WHERE zoom_level = 10
|
||||
UNION ALL
|
||||
|
||||
-- etldoc: osm_highway_linestring_gen1 -> layer_highway:z11
|
||||
-- etldoc: osm_transportation_linestring_gen1 -> layer_transportation:z11
|
||||
SELECT osm_id, geometry, highway, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order
|
||||
FROM osm_highway_linestring_gen1
|
||||
FROM osm_transportation_linestring_gen1
|
||||
WHERE zoom_level = 11
|
||||
UNION ALL
|
||||
|
||||
-- etldoc: osm_highway_linestring -> layer_highway:z12
|
||||
-- etldoc: osm_transportation_linestring -> layer_transportation:z12
|
||||
SELECT osm_id, geometry, highway, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order
|
||||
FROM osm_highway_linestring
|
||||
FROM osm_transportation_linestring
|
||||
WHERE zoom_level = 12
|
||||
AND (to_highway_class(highway) < 'minor_road'::highway_class OR highway IN ('unclassified', 'residential'))
|
||||
AND NOT highway_is_link(highway)
|
||||
AND NOT is_area
|
||||
UNION ALL
|
||||
|
||||
-- etldoc: osm_highway_linestring -> layer_highway:z13
|
||||
-- etldoc: osm_transportation_linestring -> layer_transportation:z13
|
||||
SELECT osm_id, geometry, highway, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order
|
||||
FROM osm_highway_linestring
|
||||
FROM osm_transportation_linestring
|
||||
WHERE zoom_level = 13
|
||||
AND to_highway_class(highway) < 'path'::highway_class
|
||||
AND NOT is_area
|
||||
UNION ALL
|
||||
|
||||
-- etldoc: osm_highway_linestring -> layer_highway:z14_
|
||||
-- etldoc: osm_transportation_linestring -> layer_transportation:z14_
|
||||
SELECT osm_id, geometry, highway, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order
|
||||
FROM osm_highway_linestring
|
||||
FROM osm_transportation_linestring
|
||||
WHERE zoom_level >= 14 AND NOT is_area
|
||||
UNION ALL
|
||||
|
||||
-- NOTE: We limit the selection of polys because we need to be careful to net get false positives here because
|
||||
-- it is possible that closed linestrings appear both as highway linestrings and as polygon
|
||||
-- etldoc: osm_highway_polygon -> layer_highway:z13
|
||||
-- etldoc: osm_highway_polygon -> layer_highway:z14_
|
||||
-- etldoc: osm_transportation__polygon -> layer_transportation:z13
|
||||
-- etldoc: osm_transportation__polygon -> layer_transportation:z14_
|
||||
SELECT osm_id, geometry, highway, FALSE AS is_bridge, FALSE AS is_tunnel, FALSE AS is_ford, FALSE AS is_ramp, FALSE AS is_oneway, z_order
|
||||
FROM osm_highway_polygon
|
||||
FROM osm_transportation_polygon
|
||||
-- We do not want underground pedestrian areas for now
|
||||
WHERE zoom_level >= 13 AND is_area AND COALESCE(layer, 0) >= 0
|
||||
) AS zoom_levels
|
||||
39
layers/transportation/mapping
Normal file
39
layers/transportation/mapping
Normal file
@ -0,0 +1,39 @@
|
||||
digraph "Imposm Mapping" {
|
||||
graph [rankdir=LR ranksep=3]
|
||||
subgraph highway_polygon {
|
||||
node [fixed_size=shape "width:"=20]
|
||||
highway_polygon [shape=box]
|
||||
key_highway [label=highway shape=box]
|
||||
key_highway -> highway_polygon [label=pedestrian]
|
||||
}
|
||||
subgraph highway_linestring {
|
||||
node [fixed_size=shape "width:"=20]
|
||||
highway_linestring [shape=box]
|
||||
key_highway [label=highway shape=box]
|
||||
key_highway -> highway_linestring [label="motorway
|
||||
motorway_link
|
||||
trunk
|
||||
trunk_link
|
||||
primary
|
||||
primary_link
|
||||
secondary
|
||||
secondary_link
|
||||
tertiary
|
||||
tertiary_link
|
||||
unclassified
|
||||
residential
|
||||
road
|
||||
living_street
|
||||
raceway
|
||||
construction
|
||||
track
|
||||
service
|
||||
path
|
||||
cycleway
|
||||
bridleway
|
||||
footway
|
||||
corridor
|
||||
crossing
|
||||
pedestrian"]
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 61 KiB After Width: | Height: | Size: 61 KiB |
@ -1,33 +1,33 @@
|
||||
|
||||
generalized_tables:
|
||||
|
||||
# etldoc: imposm3 -> osm_highway_linestring_gen4
|
||||
highway_linestring_gen4:
|
||||
source: highway_linestring_gen3
|
||||
# etldoc: imposm3 -> osm_transportation_linestring_gen4
|
||||
transportation_linestring_gen4:
|
||||
source: transportation_linestring_gen3
|
||||
sql_filter: highway IN ('motorway','trunk') AND NOT is_area
|
||||
tolerance: 200.0
|
||||
|
||||
# etldoc: imposm3 -> osm_highway_linestring_gen3
|
||||
highway_linestring_gen3:
|
||||
source: highway_linestring_gen2
|
||||
# etldoc: imposm3 -> osm_transportation_linestring_gen3
|
||||
transportation_linestring_gen3:
|
||||
source: transportation_linestring_gen2
|
||||
sql_filter: highway IN ('motorway','trunk', 'primary') AND NOT is_area
|
||||
tolerance: 120.0
|
||||
|
||||
# etldoc: imposm3 -> osm_highway_linestring_gen2
|
||||
highway_linestring_gen2:
|
||||
source: highway_linestring_gen1
|
||||
# etldoc: imposm3 -> osm_transportation_linestring_gen2
|
||||
transportation_linestring_gen2:
|
||||
source: transportation_linestring_gen1
|
||||
sql_filter: highway IN ('motorway','trunk', 'primary', 'secondary') AND NOT is_area
|
||||
tolerance: 50.0
|
||||
|
||||
# etldoc: imposm3 -> osm_highway_linestring_gen1
|
||||
highway_linestring_gen1:
|
||||
source: highway_linestring
|
||||
# etldoc: imposm3 -> osm_transportation_linestring_gen1
|
||||
transportation_linestring_gen1:
|
||||
source: transportation_linestring
|
||||
sql_filter: highway IN ('motorway','trunk', 'primary', 'secondary', 'tertiary') AND NOT is_area
|
||||
tolerance: 20.0
|
||||
|
||||
tables:
|
||||
# etldoc: imposm3 -> osm_highway_linestring
|
||||
highway_linestring:
|
||||
# etldoc: imposm3 -> osm_transportation_linestring
|
||||
transportation_linestring:
|
||||
type: linestring
|
||||
fields:
|
||||
- name: osm_id
|
||||
@ -37,6 +37,9 @@ tables:
|
||||
- name: highway
|
||||
key: highway
|
||||
type: string
|
||||
- key: railway
|
||||
name: railway
|
||||
type: string
|
||||
- key: ref
|
||||
name: ref
|
||||
type: string
|
||||
@ -63,12 +66,21 @@ tables:
|
||||
- key: name
|
||||
name: name
|
||||
type: string
|
||||
- key: short_name
|
||||
name: short_name
|
||||
type: string
|
||||
- name: name_en
|
||||
key: name:en
|
||||
type: string
|
||||
- name: is_area
|
||||
key: area
|
||||
type: bool
|
||||
- key: service
|
||||
name: service
|
||||
type: string
|
||||
- key: usage
|
||||
name: usage
|
||||
type: string
|
||||
mapping:
|
||||
highway:
|
||||
- motorway
|
||||
@ -96,9 +108,16 @@ tables:
|
||||
- corridor
|
||||
- crossing
|
||||
- pedestrian
|
||||
railway:
|
||||
- rail
|
||||
- light_rail
|
||||
- subway
|
||||
- narrow_gauge
|
||||
- preserved
|
||||
- tram
|
||||
|
||||
# etldoc: imposm3 -> osm_highway_polygon
|
||||
highway_polygon:
|
||||
# etldoc: imposm3 -> osm_transportation_polygon
|
||||
transportation_polygon:
|
||||
type: polygon
|
||||
fields:
|
||||
- name: osm_id
|
||||
@ -1,5 +1,5 @@
|
||||
layer:
|
||||
id: "highway"
|
||||
id: "transportation"
|
||||
description: |
|
||||
Roads or [`highway`](http://wiki.openstreetmap.org/wiki/Key:highway) in OpenStreetMap lingo.
|
||||
This layer is directly derived from the OSM road hierarchy which is why it is called `highway`. Only
|
||||
@ -29,7 +29,7 @@ layer:
|
||||
datasource:
|
||||
geometry_field: geometry
|
||||
srid: 900913
|
||||
query: (SELECT geometry, class::text, subclass, properties::text FROM layer_highway(!bbox!, z(!scale_denominator!))) AS t
|
||||
query: (SELECT geometry, class::text, subclass, properties::text FROM layer_transportation(!bbox!, z(!scale_denominator!))) AS t
|
||||
schema:
|
||||
- ./types.sql
|
||||
- ./ne_global_roads.sql
|
||||
50
layers/transportation_name/layer.sql
Normal file
50
layers/transportation_name/layer.sql
Normal file
@ -0,0 +1,50 @@
|
||||
|
||||
-- etldoc: layer_transportation_name[shape=record fillcolor=lightpink, style="rounded,filled",
|
||||
-- etldoc: label="layer_transportation_name | <z8> z8 |<z9> z9 |<z10> z10 |<z11> z11 |<z12> z12|<z13> z13|<z14_> z14_" ] ;
|
||||
|
||||
CREATE OR REPLACE FUNCTION layer_transportation_name(bbox geometry, zoom_level integer)
|
||||
RETURNS TABLE(osm_id bigint, geometry geometry, name text, ref text, ref_length int, class highway_class, subclass text) AS $$
|
||||
SELECT osm_id, geometry, name,
|
||||
NULLIF(ref, ''), NULLIF(LENGTH(ref), 0) AS ref_length,
|
||||
to_highway_class(highway) AS class, highway AS subclass
|
||||
FROM (
|
||||
|
||||
-- etldoc: osm_transportation_name_linestring_gen3 -> layer_transportation_name:z8
|
||||
SELECT * FROM osm_transportation_name_linestring_gen3
|
||||
WHERE zoom_level = 8
|
||||
UNION ALL
|
||||
|
||||
-- etldoc: osm_transportation_name_linestring_gen2 -> layer_transportation_name:z9
|
||||
SELECT * FROM osm_transportation_name_linestring_gen2
|
||||
WHERE zoom_level = 9
|
||||
UNION ALL
|
||||
|
||||
-- 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
|
||||
WHERE zoom_level BETWEEN 10 AND 11
|
||||
UNION ALL
|
||||
|
||||
-- etldoc: osm_transportation_name_linestring -> layer_transportation_name:z12
|
||||
SELECT * FROM osm_transportation_name_linestring
|
||||
WHERE zoom_level = 12
|
||||
AND LineLabel(zoom_level, COALESCE(NULLIF(name, ''), ref), geometry)
|
||||
AND to_highway_class(highway) < 'minor_road'::highway_class
|
||||
AND NOT highway_is_link(highway)
|
||||
UNION ALL
|
||||
|
||||
-- etldoc: osm_transportation_name_linestring -> layer_transportation_name:z13
|
||||
SELECT * FROM osm_transportation_name_linestring
|
||||
WHERE zoom_level = 13
|
||||
AND LineLabel(zoom_level, COALESCE(NULLIF(name, ''), ref), geometry)
|
||||
AND to_highway_class(highway) < 'path'::highway_class
|
||||
UNION ALL
|
||||
|
||||
-- etldoc: osm_transportation_name_linestring -> layer_transportation_name:z14_
|
||||
SELECT * FROM osm_transportation_name_linestring
|
||||
WHERE zoom_level >= 14
|
||||
|
||||
) AS zoom_levels
|
||||
WHERE geometry && bbox
|
||||
ORDER BY z_order ASC;
|
||||
$$ LANGUAGE SQL IMMUTABLE;
|
||||
57
layers/transportation_name/merge_highways.sql
Normal file
57
layers/transportation_name/merge_highways.sql
Normal file
@ -0,0 +1,57 @@
|
||||
-- Instead of using relations to find out the road names we
|
||||
-- stitch together the touching ways with the same name
|
||||
-- to allow for nice label rendering
|
||||
-- Because this works well for roads that do not have relations as well
|
||||
|
||||
-- etldoc: osm_transportation_linestring -> osm_transportation_name_linestring
|
||||
CREATE TABLE IF NOT EXISTS osm_transportation_name_linestring AS (
|
||||
SELECT
|
||||
(ST_Dump(geometry)).geom AS geometry,
|
||||
-- NOTE: The osm_id is no longer the original one which can make it difficult
|
||||
-- to lookup road names by OSM ID
|
||||
member_osm_ids[0] AS osm_id,
|
||||
member_osm_ids,
|
||||
name,
|
||||
ref,
|
||||
highway,
|
||||
z_order
|
||||
FROM (
|
||||
SELECT
|
||||
ST_LineMerge(ST_Union(geometry)) AS geometry,
|
||||
name,
|
||||
ref,
|
||||
highway,
|
||||
min(z_order) AS z_order,
|
||||
array_agg(DISTINCT osm_id) AS member_osm_ids
|
||||
FROM osm_transportation_linestring
|
||||
-- We only care about highways (not railways) for labeling
|
||||
WHERE (name <> '' OR ref <> '') AND NULLIF(highway, '') IS NOT NULL
|
||||
GROUP BY name, highway, ref
|
||||
) AS highway_union
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS osm_transportation_name_linestring_geometry_idx ON osm_transportation_name_linestring USING gist(geometry);
|
||||
|
||||
-- etldoc: osm_transportation_name_linestring -> osm_transportation_name_linestring_gen1
|
||||
CREATE TABLE IF NOT EXISTS osm_transportation_name_linestring_gen1 AS (
|
||||
SELECT ST_Simplify(geometry, 50) AS geometry, osm_id, member_osm_ids, name, ref, highway, z_order
|
||||
FROM osm_transportation_name_linestring
|
||||
WHERE highway IN ('motorway','trunk') AND ST_Length(geometry) > 8000
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS osm_transportation_name_linestring_gen1_geometry_idx ON osm_transportation_name_linestring_gen1 USING gist(geometry);
|
||||
|
||||
-- etldoc: osm_transportation_name_linestring_gen1 -> osm_transportation_name_linestring_gen2
|
||||
CREATE TABLE IF NOT EXISTS osm_transportation_name_linestring_gen2 AS (
|
||||
SELECT ST_Simplify(geometry, 120) AS geometry, osm_id, member_osm_ids, name, ref, highway, z_order
|
||||
FROM osm_transportation_name_linestring_gen1
|
||||
WHERE highway IN ('motorway','trunk') AND ST_Length(geometry) > 14000
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS osm_transportation_name_linestring_gen2_geometry_idx ON osm_transportation_name_linestring_gen2 USING gist(geometry);
|
||||
|
||||
-- etldoc: osm_transportation_name_linestring_gen2 -> osm_transportation_name_linestring_gen3
|
||||
CREATE TABLE IF NOT EXISTS osm_transportation_name_linestring_gen3 AS (
|
||||
SELECT ST_Simplify(geometry, 120) AS geometry, osm_id, member_osm_ids, name, ref, highway, z_order
|
||||
FROM osm_transportation_name_linestring_gen2
|
||||
WHERE highway = 'motorway' AND ST_Length(geometry) > 20000
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS osm_transportation_name_linestring_gen3_geometry_idx ON osm_transportation_name_linestring_gen3 USING gist(geometry);
|
||||
@ -1,5 +1,5 @@
|
||||
layer:
|
||||
id: "highway_name"
|
||||
id: "transportation_name"
|
||||
description: |
|
||||
This is the layer for labelling the highways. Only highways that are named `name=*` and are long enough
|
||||
to place text upon appear. The OSM roads are stitched together if they contain the same name
|
||||
@ -20,10 +20,10 @@ layer:
|
||||
datasource:
|
||||
geometry_field: geometry
|
||||
srid: 900913
|
||||
query: (SELECT geometry, name, ref, ref_length, class::text, subclass FROM layer_highway_name(!bbox!, z(!scale_denominator!))) AS t
|
||||
query: (SELECT geometry, name, ref, ref_length, class::text, subclass FROM layer_transportation_name(!bbox!, z(!scale_denominator!))) AS t
|
||||
schema:
|
||||
- ./merge_highways.sql
|
||||
- ./layer.sql
|
||||
datasources:
|
||||
- type: imposm3
|
||||
mapping_file: ../highway/mapping.yaml
|
||||
mapping_file: ../transportation/mapping.yaml
|
||||
@ -1,13 +1,12 @@
|
||||
tileset:
|
||||
layers:
|
||||
- layers/boundary/boundary.yaml
|
||||
- layers/highway/highway.yaml
|
||||
- layers/highway_name/highway_name.yaml
|
||||
- layers/transportation/transportation.yaml
|
||||
- layers/transportation_name/transportation_name.yaml
|
||||
- layers/building/building.yaml
|
||||
- layers/housenumber/housenumber.yaml
|
||||
- layers/place/place.yaml
|
||||
- layers/poi/poi.yaml
|
||||
- layers/railway/railway.yaml
|
||||
- layers/water_name/water_name.yaml
|
||||
- layers/water/water.yaml
|
||||
- layers/waterway/waterway.yaml
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user