kopia lustrzana https://github.com/openmaptiles/openmaptiles
Merge pull request #138 from openmaptiles/add_name_en
Add name_en to waterway and transportation_namepull/147/head
commit
e651fd15ff
|
@ -3,8 +3,10 @@
|
||||||
-- etldoc: label="layer_transportation_name | <z8> z8 |<z9> z9 |<z10> z10 |<z11> z11 |<z12> z12|<z13> z13|<z14_> z14+" ] ;
|
-- 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)
|
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, network text, class text) AS $$
|
RETURNS TABLE(osm_id bigint, geometry geometry, name text, name_en text, ref text, ref_length int, network text, class text) AS $$
|
||||||
SELECT osm_id, geometry, name,
|
SELECT osm_id, geometry,
|
||||||
|
NULLIF(name, '') AS name,
|
||||||
|
COALESCE(NULLIF(name_en, ''), NULLIF(name, '')) AS name_en,
|
||||||
NULLIF(ref, ''), NULLIF(LENGTH(ref), 0) AS ref_length,
|
NULLIF(ref, ''), NULLIF(LENGTH(ref), 0) AS ref_length,
|
||||||
--TODO: The road network of the road is not yet implemented
|
--TODO: The road network of the road is not yet implemented
|
||||||
NULL::text AS network,
|
NULL::text AS network,
|
||||||
|
|
|
@ -20,6 +20,7 @@ CREATE MATERIALIZED VIEW osm_transportation_name_linestring AS (
|
||||||
member_osm_ids[0] AS osm_id,
|
member_osm_ids[0] AS osm_id,
|
||||||
member_osm_ids,
|
member_osm_ids,
|
||||||
name,
|
name,
|
||||||
|
name_en,
|
||||||
ref,
|
ref,
|
||||||
highway,
|
highway,
|
||||||
z_order
|
z_order
|
||||||
|
@ -27,6 +28,7 @@ CREATE MATERIALIZED VIEW osm_transportation_name_linestring AS (
|
||||||
SELECT
|
SELECT
|
||||||
ST_LineMerge(ST_Collect(geometry)) AS geometry,
|
ST_LineMerge(ST_Collect(geometry)) AS geometry,
|
||||||
name,
|
name,
|
||||||
|
COALESCE(NULLIF(name_en, ''), name) AS name_en,
|
||||||
ref,
|
ref,
|
||||||
highway,
|
highway,
|
||||||
min(z_order) AS z_order,
|
min(z_order) AS z_order,
|
||||||
|
@ -34,14 +36,14 @@ CREATE MATERIALIZED VIEW osm_transportation_name_linestring AS (
|
||||||
FROM osm_highway_linestring
|
FROM osm_highway_linestring
|
||||||
-- We only care about highways (not railways) for labeling
|
-- We only care about highways (not railways) for labeling
|
||||||
WHERE (name <> '' OR ref <> '') AND NULLIF(highway, '') IS NOT NULL
|
WHERE (name <> '' OR ref <> '') AND NULLIF(highway, '') IS NOT NULL
|
||||||
GROUP BY name, highway, ref
|
GROUP BY name, name_en, highway, ref
|
||||||
) 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, ref, highway, z_order
|
SELECT ST_Simplify(geometry, 50) AS geometry, osm_id, member_osm_ids, name, name_en, ref, highway, 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
|
||||||
);
|
);
|
||||||
|
@ -49,7 +51,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, ref, highway, z_order
|
SELECT ST_Simplify(geometry, 120) AS geometry, osm_id, member_osm_ids, name, name_en, ref, highway, 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
|
||||||
);
|
);
|
||||||
|
@ -57,7 +59,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, ref, highway, z_order
|
SELECT ST_Simplify(geometry, 120) AS geometry, osm_id, member_osm_ids, name, name_en, ref, highway, 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
|
||||||
);
|
);
|
||||||
|
|
|
@ -9,6 +9,7 @@ layer:
|
||||||
srs: +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over
|
srs: +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over
|
||||||
fields:
|
fields:
|
||||||
name: The OSM [`name`](http://wiki.openstreetmap.org/wiki/Highways#Names_and_references) value of the highway.
|
name: The OSM [`name`](http://wiki.openstreetmap.org/wiki/Highways#Names_and_references) value of the highway.
|
||||||
|
name_en: The english `name:en` value if available.
|
||||||
ref: The OSM [`ref`](http://wiki.openstreetmap.org/wiki/Key:ref) tag of the motorway or road.
|
ref: The OSM [`ref`](http://wiki.openstreetmap.org/wiki/Key:ref) tag of the motorway or road.
|
||||||
ref_length: Length of the `ref` field. Useful for having a shield icon as background for labeling motorways.
|
ref_length: Length of the `ref` field. Useful for having a shield icon as background for labeling motorways.
|
||||||
network: The OSM [`network`](http://wiki.openstreetmap.org/wiki/Key:network) tag of the road.
|
network: The OSM [`network`](http://wiki.openstreetmap.org/wiki/Key:network) tag of the road.
|
||||||
|
@ -31,7 +32,7 @@ layer:
|
||||||
datasource:
|
datasource:
|
||||||
geometry_field: geometry
|
geometry_field: geometry
|
||||||
srid: 900913
|
srid: 900913
|
||||||
query: (SELECT geometry, name, ref, ref_length, class::text FROM layer_transportation_name(!bbox!, z(!scale_denominator!))) AS t
|
query: (SELECT geometry, name, name_en, ref, ref_length, class::text FROM layer_transportation_name(!bbox!, z(!scale_denominator!))) AS t
|
||||||
schema:
|
schema:
|
||||||
- ./merge_highways.sql
|
- ./merge_highways.sql
|
||||||
- ./layer.sql
|
- ./layer.sql
|
||||||
|
|
|
@ -14,21 +14,21 @@ DROP MATERIALIZED VIEW IF EXISTS osm_important_waterway_linestring_gen3 CASCADE;
|
||||||
CREATE MATERIALIZED VIEW osm_important_waterway_linestring AS (
|
CREATE MATERIALIZED VIEW osm_important_waterway_linestring AS (
|
||||||
SELECT
|
SELECT
|
||||||
(ST_Dump(geometry)).geom AS geometry,
|
(ST_Dump(geometry)).geom AS geometry,
|
||||||
name
|
name, name_en
|
||||||
FROM (
|
FROM (
|
||||||
SELECT
|
SELECT
|
||||||
ST_LineMerge(ST_Union(geometry)) AS geometry,
|
ST_LineMerge(ST_Union(geometry)) AS geometry,
|
||||||
name
|
name, COALESCE(NULLIF(name_en, ''), name) AS name_en
|
||||||
FROM osm_waterway_linestring
|
FROM osm_waterway_linestring
|
||||||
WHERE name <> '' AND waterway = 'river'
|
WHERE name <> '' AND waterway = 'river'
|
||||||
GROUP BY name
|
GROUP BY name, name_en
|
||||||
) AS waterway_union
|
) AS waterway_union
|
||||||
);
|
);
|
||||||
CREATE INDEX IF NOT EXISTS osm_important_waterway_linestring_geometry_idx ON osm_important_waterway_linestring USING gist(geometry);
|
CREATE INDEX IF NOT EXISTS osm_important_waterway_linestring_geometry_idx ON osm_important_waterway_linestring USING gist(geometry);
|
||||||
|
|
||||||
-- etldoc: osm_important_waterway_linestring -> osm_important_waterway_linestring_gen1
|
-- etldoc: osm_important_waterway_linestring -> osm_important_waterway_linestring_gen1
|
||||||
CREATE MATERIALIZED VIEW osm_important_waterway_linestring_gen1 AS (
|
CREATE MATERIALIZED VIEW osm_important_waterway_linestring_gen1 AS (
|
||||||
SELECT ST_Simplify(geometry, 60) AS geometry, name
|
SELECT ST_Simplify(geometry, 60) AS geometry, name, name_en
|
||||||
FROM osm_important_waterway_linestring
|
FROM osm_important_waterway_linestring
|
||||||
WHERE ST_Length(geometry) > 1000
|
WHERE ST_Length(geometry) > 1000
|
||||||
);
|
);
|
||||||
|
@ -36,7 +36,7 @@ CREATE INDEX IF NOT EXISTS osm_important_waterway_linestring_gen1_geometry_idx O
|
||||||
|
|
||||||
-- etldoc: osm_important_waterway_linestring_gen1 -> osm_important_waterway_linestring_gen2
|
-- etldoc: osm_important_waterway_linestring_gen1 -> osm_important_waterway_linestring_gen2
|
||||||
CREATE MATERIALIZED VIEW osm_important_waterway_linestring_gen2 AS (
|
CREATE MATERIALIZED VIEW osm_important_waterway_linestring_gen2 AS (
|
||||||
SELECT ST_Simplify(geometry, 100) AS geometry, name
|
SELECT ST_Simplify(geometry, 100) AS geometry, name, name_en
|
||||||
FROM osm_important_waterway_linestring_gen1
|
FROM osm_important_waterway_linestring_gen1
|
||||||
WHERE ST_Length(geometry) > 4000
|
WHERE ST_Length(geometry) > 4000
|
||||||
);
|
);
|
||||||
|
@ -44,7 +44,7 @@ CREATE INDEX IF NOT EXISTS osm_important_waterway_linestring_gen2_geometry_idx O
|
||||||
|
|
||||||
-- etldoc: osm_important_waterway_linestring_gen2 -> osm_important_waterway_linestring_gen3
|
-- etldoc: osm_important_waterway_linestring_gen2 -> osm_important_waterway_linestring_gen3
|
||||||
CREATE MATERIALIZED VIEW osm_important_waterway_linestring_gen3 AS (
|
CREATE MATERIALIZED VIEW osm_important_waterway_linestring_gen3 AS (
|
||||||
SELECT ST_Simplify(geometry, 200) AS geometry, name
|
SELECT ST_Simplify(geometry, 200) AS geometry, name, name_en
|
||||||
FROM osm_important_waterway_linestring_gen2
|
FROM osm_important_waterway_linestring_gen2
|
||||||
WHERE ST_Length(geometry) > 8000
|
WHERE ST_Length(geometry) > 8000
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,60 +1,66 @@
|
||||||
|
|
||||||
-- etldoc: ne_110m_rivers_lake_centerlines -> waterway_z3
|
-- etldoc: ne_110m_rivers_lake_centerlines -> waterway_z3
|
||||||
CREATE OR REPLACE VIEW waterway_z3 AS (
|
CREATE OR REPLACE VIEW waterway_z3 AS (
|
||||||
SELECT geometry, 'river'::text AS class, NULL::text AS name FROM ne_110m_rivers_lake_centerlines
|
SELECT geometry, 'river'::text AS class, NULL::text AS name, NULL::text AS name_en
|
||||||
|
FROM ne_110m_rivers_lake_centerlines
|
||||||
WHERE featurecla = 'River'
|
WHERE featurecla = 'River'
|
||||||
);
|
);
|
||||||
|
|
||||||
-- etldoc: ne_50m_rivers_lake_centerlines -> waterway_z4
|
-- etldoc: ne_50m_rivers_lake_centerlines -> waterway_z4
|
||||||
CREATE OR REPLACE VIEW waterway_z4 AS (
|
CREATE OR REPLACE VIEW waterway_z4 AS (
|
||||||
SELECT geometry, 'river'::text AS class, NULL::text AS name FROM ne_50m_rivers_lake_centerlines
|
SELECT geometry, 'river'::text AS class, NULL::text AS name, NULL::text AS name_en
|
||||||
|
FROM ne_50m_rivers_lake_centerlines
|
||||||
WHERE featurecla = 'River'
|
WHERE featurecla = 'River'
|
||||||
);
|
);
|
||||||
|
|
||||||
-- etldoc: ne_10m_rivers_lake_centerlines -> waterway_z6
|
-- etldoc: ne_10m_rivers_lake_centerlines -> waterway_z6
|
||||||
CREATE OR REPLACE VIEW waterway_z6 AS (
|
CREATE OR REPLACE VIEW waterway_z6 AS (
|
||||||
SELECT geometry, 'river'::text AS class, NULL::text AS name FROM ne_10m_rivers_lake_centerlines
|
SELECT geometry, 'river'::text AS class, NULL::text AS name, NULL::text AS name_en
|
||||||
|
FROM ne_10m_rivers_lake_centerlines
|
||||||
WHERE featurecla = 'River'
|
WHERE featurecla = 'River'
|
||||||
);
|
);
|
||||||
|
|
||||||
-- etldoc: osm_important_waterway_linestring_gen3 -> waterway_z9
|
-- etldoc: osm_important_waterway_linestring_gen3 -> waterway_z9
|
||||||
CREATE OR REPLACE VIEW waterway_z9 AS (
|
CREATE OR REPLACE VIEW waterway_z9 AS (
|
||||||
SELECT geometry, 'river'::text AS class, name FROM osm_important_waterway_linestring_gen3
|
SELECT geometry, 'river'::text AS class, name, name_en FROM osm_important_waterway_linestring_gen3
|
||||||
);
|
);
|
||||||
|
|
||||||
-- etldoc: osm_important_waterway_linestring_gen2 -> waterway_z10
|
-- etldoc: osm_important_waterway_linestring_gen2 -> waterway_z10
|
||||||
CREATE OR REPLACE VIEW waterway_z10 AS (
|
CREATE OR REPLACE VIEW waterway_z10 AS (
|
||||||
SELECT geometry, 'river'::text AS class, name FROM osm_important_waterway_linestring_gen2
|
SELECT geometry, 'river'::text AS class, name, name_en FROM osm_important_waterway_linestring_gen2
|
||||||
);
|
);
|
||||||
|
|
||||||
-- etldoc:osm_important_waterway_linestring_gen1 -> waterway_z11
|
-- etldoc:osm_important_waterway_linestring_gen1 -> waterway_z11
|
||||||
CREATE OR REPLACE VIEW waterway_z11 AS (
|
CREATE OR REPLACE VIEW waterway_z11 AS (
|
||||||
SELECT geometry, 'river'::text AS class, name FROM osm_important_waterway_linestring_gen1
|
SELECT geometry, 'river'::text AS class, name, name_en FROM osm_important_waterway_linestring_gen1
|
||||||
);
|
);
|
||||||
|
|
||||||
-- etldoc: osm_waterway_linestring -> waterway_z12
|
-- etldoc: osm_waterway_linestring -> waterway_z12
|
||||||
CREATE OR REPLACE VIEW waterway_z12 AS (
|
CREATE OR REPLACE VIEW waterway_z12 AS (
|
||||||
SELECT geometry, waterway AS class, name FROM osm_waterway_linestring
|
SELECT geometry, waterway AS class, name, name_en FROM osm_waterway_linestring
|
||||||
WHERE waterway IN ('river', 'canal')
|
WHERE waterway IN ('river', 'canal')
|
||||||
);
|
);
|
||||||
|
|
||||||
-- etldoc: osm_waterway_linestring -> waterway_z13
|
-- etldoc: osm_waterway_linestring -> waterway_z13
|
||||||
CREATE OR REPLACE VIEW waterway_z13 AS (
|
CREATE OR REPLACE VIEW waterway_z13 AS (
|
||||||
SELECT geometry, waterway::text AS class, name FROM osm_waterway_linestring
|
SELECT geometry, waterway::text AS class, name, name_en FROM osm_waterway_linestring
|
||||||
WHERE waterway IN ('river', 'canal', 'stream', 'drain', 'ditch')
|
WHERE waterway IN ('river', 'canal', 'stream', 'drain', 'ditch')
|
||||||
);
|
);
|
||||||
|
|
||||||
-- etldoc: osm_waterway_linestring -> waterway_z14
|
-- etldoc: osm_waterway_linestring -> waterway_z14
|
||||||
CREATE OR REPLACE VIEW waterway_z14 AS (
|
CREATE OR REPLACE VIEW waterway_z14 AS (
|
||||||
SELECT geometry, waterway::text AS class, name FROM osm_waterway_linestring
|
SELECT geometry, waterway::text AS class, name, name_en FROM osm_waterway_linestring
|
||||||
);
|
);
|
||||||
|
|
||||||
-- etldoc: layer_waterway[shape=record fillcolor=lightpink, style="rounded,filled",
|
-- etldoc: layer_waterway[shape=record fillcolor=lightpink, style="rounded,filled",
|
||||||
-- etldoc: label="layer_waterway | <z3> z3 |<z4_5> z4-z5 |<z6_8> z6-8 | <z9> z9 |<z10> z10 |<z11> z11 |<z12> z12|<z13> z13|<z14> z14+" ];
|
-- etldoc: label="layer_waterway | <z3> z3 |<z4_5> z4-z5 |<z6_8> z6-8 | <z9> z9 |<z10> z10 |<z11> z11 |<z12> z12|<z13> z13|<z14> z14+" ];
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION layer_waterway(bbox geometry, zoom_level int)
|
CREATE OR REPLACE FUNCTION layer_waterway(bbox geometry, zoom_level int)
|
||||||
RETURNS TABLE(geometry geometry, class text, name text) AS $$
|
RETURNS TABLE(geometry geometry, class text, name text, name_en text) AS $$
|
||||||
SELECT geometry, class, NULLIF(name, '') AS name FROM (
|
SELECT geometry, class,
|
||||||
|
NULLIF(name, '') AS name,
|
||||||
|
COALESCE(NULLIF(name_en, ''), name) AS name_en
|
||||||
|
FROM (
|
||||||
-- etldoc: waterway_z3 -> layer_waterway:z3
|
-- etldoc: waterway_z3 -> layer_waterway:z3
|
||||||
SELECT * FROM waterway_z3 WHERE zoom_level = 3
|
SELECT * FROM waterway_z3 WHERE zoom_level = 3
|
||||||
UNION ALL
|
UNION ALL
|
||||||
|
|
|
@ -10,6 +10,7 @@ layer:
|
||||||
name: |
|
name: |
|
||||||
The OSM [`name`](http://wiki.openstreetmap.org/wiki/Key:name) value of the waterway.
|
The OSM [`name`](http://wiki.openstreetmap.org/wiki/Key:name) value of the waterway.
|
||||||
The `name` field may be empty for NaturalEarth data or at lower zoom levels.
|
The `name` field may be empty for NaturalEarth data or at lower zoom levels.
|
||||||
|
name_en: The english `name:en` value if available.
|
||||||
class:
|
class:
|
||||||
description: |
|
description: |
|
||||||
The original value of the [`waterway`](http://wiki.openstreetmap.org/wiki/Key:waterway) tag.
|
The original value of the [`waterway`](http://wiki.openstreetmap.org/wiki/Key:waterway) tag.
|
||||||
|
@ -21,7 +22,7 @@ layer:
|
||||||
- ditch
|
- ditch
|
||||||
datasource:
|
datasource:
|
||||||
geometry_field: geometry
|
geometry_field: geometry
|
||||||
query: (SELECT geometry, name, class FROM layer_waterway(!bbox!, z(!scale_denominator!))) AS t
|
query: (SELECT geometry, name, name_en, class FROM layer_waterway(!bbox!, z(!scale_denominator!))) AS t
|
||||||
schema:
|
schema:
|
||||||
- ./merge_waterway.sql
|
- ./merge_waterway.sql
|
||||||
- ./waterway.sql
|
- ./waterway.sql
|
||||||
|
|
Ładowanie…
Reference in New Issue