Add attribute into osm_transportation_name_linestring

pull/185/head
jirik 2017-02-28 16:23:47 +01:00
rodzic 7aa5e27d83
commit fa34831a54
1 zmienionych plików z 17 dodań i 15 usunięć

Wyświetl plik

@ -23,27 +23,29 @@ CREATE MATERIALIZED VIEW osm_transportation_name_linestring AS (
name_en, name_en,
ref, ref,
highway, highway,
network,
z_order z_order
FROM ( FROM (
SELECT SELECT
ST_LineMerge(ST_Collect(geometry)) AS geometry, ST_LineMerge(ST_Collect(geometry)) AS geometry,
name, hl.name,
COALESCE(NULLIF(name_en, ''), name) AS name_en, COALESCE(NULLIF(hl.name_en, ''), hl.name) AS name_en,
ref, hl.ref,
highway, hl.highway,
min(z_order) AS z_order, min(rm.network) AS network, -- should be improved, may be part of more networks
array_agg(DISTINCT osm_id) AS member_osm_ids min(hl.z_order) AS z_order,
FROM osm_highway_linestring array_agg(DISTINCT hl.osm_id) AS member_osm_ids
-- We only care about highways (not railways) for labeling FROM osm_highway_linestring hl
WHERE (name <> '' OR ref <> '') AND NULLIF(highway, '') IS NOT NULL left join osm_route_member rm on (rm.member = hl.osm_id)
GROUP BY name, name_en, highway, ref WHERE (hl.name <> '' OR hl.ref <> '')
group by hl.name, name_en, hl.ref, hl.highway
) AS highway_union ) AS highway_union
); );
CREATE INDEX IF NOT EXISTS osm_transportation_name_linestring_geometry_idx ON osm_transportation_name_linestring USING gist(geometry); 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 -- etldoc: osm_transportation_name_linestring -> osm_transportation_name_linestring_gen1
CREATE MATERIALIZED VIEW osm_transportation_name_linestring_gen1 AS ( CREATE MATERIALIZED VIEW osm_transportation_name_linestring_gen1 AS (
SELECT ST_Simplify(geometry, 50) AS geometry, osm_id, member_osm_ids, name, name_en, ref, highway, z_order SELECT ST_Simplify(geometry, 50) AS geometry, osm_id, member_osm_ids, name, name_en, ref, highway, network, z_order
FROM osm_transportation_name_linestring FROM osm_transportation_name_linestring
WHERE highway IN ('motorway','trunk') AND ST_Length(geometry) > 8000 WHERE highway IN ('motorway','trunk') AND ST_Length(geometry) > 8000
); );
@ -51,7 +53,7 @@ CREATE INDEX IF NOT EXISTS osm_transportation_name_linestring_gen1_geometry_idx
-- etldoc: osm_transportation_name_linestring_gen1 -> osm_transportation_name_linestring_gen2 -- etldoc: osm_transportation_name_linestring_gen1 -> osm_transportation_name_linestring_gen2
CREATE MATERIALIZED VIEW osm_transportation_name_linestring_gen2 AS ( CREATE MATERIALIZED VIEW osm_transportation_name_linestring_gen2 AS (
SELECT ST_Simplify(geometry, 120) AS geometry, osm_id, member_osm_ids, name, name_en, ref, highway, z_order SELECT ST_Simplify(geometry, 120) AS geometry, osm_id, member_osm_ids, name, name_en, ref, highway, network, z_order
FROM osm_transportation_name_linestring_gen1 FROM osm_transportation_name_linestring_gen1
WHERE highway IN ('motorway','trunk') AND ST_Length(geometry) > 14000 WHERE highway IN ('motorway','trunk') AND ST_Length(geometry) > 14000
); );
@ -59,7 +61,7 @@ CREATE INDEX IF NOT EXISTS osm_transportation_name_linestring_gen2_geometry_idx
-- etldoc: osm_transportation_name_linestring_gen2 -> osm_transportation_name_linestring_gen3 -- etldoc: osm_transportation_name_linestring_gen2 -> osm_transportation_name_linestring_gen3
CREATE MATERIALIZED VIEW osm_transportation_name_linestring_gen3 AS ( CREATE MATERIALIZED VIEW osm_transportation_name_linestring_gen3 AS (
SELECT ST_Simplify(geometry, 120) AS geometry, osm_id, member_osm_ids, name, name_en, ref, highway, z_order SELECT ST_Simplify(geometry, 120) AS geometry, osm_id, member_osm_ids, name, name_en, ref, highway, network, z_order
FROM osm_transportation_name_linestring_gen2 FROM osm_transportation_name_linestring_gen2
WHERE highway = 'motorway' AND ST_Length(geometry) > 20000 WHERE highway = 'motorway' AND ST_Length(geometry) > 20000
); );