Merge pull request #138 from openmaptiles/add_name_en

Add name_en to waterway and transportation_name
pull/147/head
Lukas Martinelli 2017-01-18 17:06:26 +01:00 zatwierdzone przez GitHub
commit e651fd15ff
6 zmienionych plików z 58 dodań i 46 usunięć

Wyświetl plik

@ -3,8 +3,10 @@
-- 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, network text, class text) AS $$
SELECT osm_id, geometry, name,
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,
NULLIF(name, '') AS name,
COALESCE(NULLIF(name_en, ''), NULLIF(name, '')) AS name_en,
NULLIF(ref, ''), NULLIF(LENGTH(ref), 0) AS ref_length,
--TODO: The road network of the road is not yet implemented
NULL::text AS network,

Wyświetl plik

@ -20,6 +20,7 @@ CREATE MATERIALIZED VIEW osm_transportation_name_linestring AS (
member_osm_ids[0] AS osm_id,
member_osm_ids,
name,
name_en,
ref,
highway,
z_order
@ -27,6 +28,7 @@ CREATE MATERIALIZED VIEW osm_transportation_name_linestring AS (
SELECT
ST_LineMerge(ST_Collect(geometry)) AS geometry,
name,
COALESCE(NULLIF(name_en, ''), name) AS name_en,
ref,
highway,
min(z_order) AS z_order,
@ -34,14 +36,14 @@ CREATE MATERIALIZED VIEW osm_transportation_name_linestring AS (
FROM osm_highway_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
GROUP BY name, name_en, 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 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
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
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
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
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
WHERE highway = 'motorway' AND ST_Length(geometry) > 20000
);

Wyświetl plik

@ -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
fields:
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_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.
@ -31,7 +32,7 @@ layer:
datasource:
geometry_field: geometry
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:
- ./merge_highways.sql
- ./layer.sql

Wyświetl plik

@ -14,21 +14,21 @@ DROP MATERIALIZED VIEW IF EXISTS osm_important_waterway_linestring_gen3 CASCADE;
CREATE MATERIALIZED VIEW osm_important_waterway_linestring AS (
SELECT
(ST_Dump(geometry)).geom AS geometry,
name
name, name_en
FROM (
SELECT
ST_LineMerge(ST_Union(geometry)) AS geometry,
name
name, COALESCE(NULLIF(name_en, ''), name) AS name_en
FROM osm_waterway_linestring
WHERE name <> '' AND waterway = 'river'
GROUP BY name
GROUP BY name, name_en
) AS waterway_union
);
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
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
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
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
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
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
WHERE ST_Length(geometry) > 8000
);

Wyświetl plik

@ -1,60 +1,66 @@
-- etldoc: ne_110m_rivers_lake_centerlines -> waterway_z3
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'
);
-- etldoc: ne_50m_rivers_lake_centerlines -> waterway_z4
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'
);
-- etldoc: ne_10m_rivers_lake_centerlines -> waterway_z6
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'
);
-- etldoc: osm_important_waterway_linestring_gen3 -> waterway_z9
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
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
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
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')
);
-- etldoc: osm_waterway_linestring -> waterway_z13
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')
);
-- etldoc: osm_waterway_linestring -> waterway_z14
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: 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)
RETURNS TABLE(geometry geometry, class text, name text) AS $$
SELECT geometry, class, NULLIF(name, '') AS name FROM (
RETURNS TABLE(geometry geometry, class text, name text, name_en text) AS $$
SELECT geometry, class,
NULLIF(name, '') AS name,
COALESCE(NULLIF(name_en, ''), name) AS name_en
FROM (
-- etldoc: waterway_z3 -> layer_waterway:z3
SELECT * FROM waterway_z3 WHERE zoom_level = 3
UNION ALL

Wyświetl plik

@ -10,6 +10,7 @@ layer:
name: |
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.
name_en: The english `name:en` value if available.
class:
description: |
The original value of the [`waterway`](http://wiki.openstreetmap.org/wiki/Key:waterway) tag.
@ -21,7 +22,7 @@ layer:
- ditch
datasource:
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:
- ./merge_waterway.sql
- ./waterway.sql