diff --git a/layers/waterway/merge_waterway.sql b/layers/waterway/merge_waterway.sql index 5cf6ab0c..51853554 100644 --- a/layers/waterway/merge_waterway.sql +++ b/layers/waterway/merge_waterway.sql @@ -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 ); @@ -59,7 +59,7 @@ CREATE OR REPLACE FUNCTION waterway.flag() RETURNS trigger AS $$ BEGIN INSERT INTO waterway.updates(t) VALUES ('y') ON CONFLICT(t) DO NOTHING; RETURN null; -END; +END; $$ language plpgsql; CREATE OR REPLACE FUNCTION waterway.refresh() RETURNS trigger AS diff --git a/layers/waterway/waterway.sql b/layers/waterway/waterway.sql index 36c48267..7ed137a0 100644 --- a/layers/waterway/waterway.sql +++ b/layers/waterway/waterway.sql @@ -56,7 +56,7 @@ CREATE OR REPLACE VIEW waterway_z14 AS ( -- etldoc: label="layer_waterway | z3 | z4-z5 | z6-8 | z9 | z10 | z11 | z12| z13| z14+" ]; 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, COALESCE(NULLIF(name_en, ''), name) AS name_en