kopia lustrzana https://github.com/openmaptiles/openmaptiles
BUGFIX: Fix name-based way fragmentation in transportation_name (#1295)
I discovered this bug while investigating issues with the updates process related to #1190 #1292, and #814. The `transportation_name` layer produces slightly different `tags` hstore values in the `osm_transportation_name_linestring` table during the initial import versus when running an update. As currently written, the import code produces null-value keys in the `tags` column, while the update code suppresses them. This PR removes that difference and makes the import code use same method that is currently used in the update code. With a test case I've written, the import code produces a tags hstore that looks like this: `"name"=>"OpenMapTiles Secondary 2", "name:de"=>NULL, "name:en"=>NULL, "name_int"=>"OpenMapTiles Secondary 2", "name:latin"=>"OpenMapTiles Secondary 2"` ...while the update code produces a tags hstore that looks like this: `"name"=>"OpenMapTiles Secondary 2", "name_int"=>"OpenMapTiles Secondary 2", "name:latin"=>"OpenMapTiles Secondary 2"` Note the missing NULL values. This bug causes a small amount of space wastage after an update is run, because the update matching code detects the `tags` value as different, resulting in a duplicate copy of the tags value if that row is updated. This causes duplicate objects and breaks GROUP BY clauses that expect to group same-tagged features together. I've tested this by inspection of a generated mbtiles, database spot checks, and the unit test code included in this PR.pull/1309/head
rodzic
0cff3449b5
commit
ec74480414
|
@ -0,0 +1,15 @@
|
|||
CREATE OR REPLACE FUNCTION transportation_name_tags(geometry geometry, tags hstore, name text, name_en text, name_de text) RETURNS hstore AS
|
||||
$$
|
||||
SELECT hstore(string_agg(nullif(slice_language_tags(tags ||
|
||||
hstore(ARRAY [
|
||||
'name', CASE WHEN length(name) > 15 THEN osml10n_street_abbrev_all(name) ELSE NULLIF(name, '') END,
|
||||
'name:en', CASE WHEN length(name_en) > 15 THEN osml10n_street_abbrev_en(name_en) ELSE NULLIF(name_en, '') END,
|
||||
'name:de', CASE WHEN length(name_de) > 15 THEN osml10n_street_abbrev_de(name_de) ELSE NULLIF(name_de, '') END
|
||||
]))::text,
|
||||
''), ','))
|
||||
|| get_basic_names(tags, geometry);
|
||||
$$ LANGUAGE SQL IMMUTABLE
|
||||
STRICT
|
||||
PARALLEL SAFE;
|
||||
|
||||
|
|
@ -200,6 +200,7 @@ layer:
|
|||
schema:
|
||||
- ./network_type.sql
|
||||
- ./class.sql
|
||||
- ./highway_name.sql
|
||||
- ./update_route_member.sql
|
||||
- ./update_transportation_merge.sql
|
||||
- ./transportation.sql
|
||||
|
|
|
@ -12,9 +12,6 @@ CREATE TABLE IF NOT EXISTS osm_transportation_name_network AS
|
|||
SELECT
|
||||
geometry,
|
||||
osm_id,
|
||||
name,
|
||||
name_en,
|
||||
name_de,
|
||||
tags,
|
||||
ref,
|
||||
highway,
|
||||
|
@ -32,10 +29,7 @@ FROM (
|
|||
SELECT DISTINCT ON (hl.osm_id)
|
||||
hl.geometry,
|
||||
hl.osm_id,
|
||||
CASE WHEN length(hl.name) > 15 THEN osml10n_street_abbrev_all(hl.name) ELSE NULLIF(hl.name, '') END AS "name",
|
||||
CASE WHEN length(hl.name_en) > 15 THEN osml10n_street_abbrev_en(hl.name_en) ELSE NULLIF(hl.name_en, '') END AS "name_en",
|
||||
CASE WHEN length(hl.name_de) > 15 THEN osml10n_street_abbrev_de(hl.name_de) ELSE NULLIF(hl.name_de, '') END AS "name_de",
|
||||
slice_language_tags(hl.tags) AS tags,
|
||||
transportation_name_tags(hl.geometry, hl.tags, hl.name, hl.name_en, hl.name_de) AS tags,
|
||||
rm1.network_type,
|
||||
CASE
|
||||
WHEN rm1.network_type IS NOT NULL AND rm1.ref::text <> ''
|
||||
|
@ -68,7 +62,7 @@ FROM (
|
|||
AND hl.highway <> ''
|
||||
) AS t;
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS osm_transportation_name_network_osm_id_idx ON osm_transportation_name_network (osm_id);
|
||||
CREATE INDEX IF NOT EXISTS osm_transportation_name_network_name_ref_idx ON osm_transportation_name_network (coalesce(name, ''), coalesce(ref, ''));
|
||||
CREATE INDEX IF NOT EXISTS osm_transportation_name_network_name_ref_idx ON osm_transportation_name_network (coalesce(tags->'name', ''), coalesce(ref, ''));
|
||||
CREATE INDEX IF NOT EXISTS osm_transportation_name_network_geometry_idx ON osm_transportation_name_network USING gist (geometry);
|
||||
|
||||
-- Improve performance of the sql in transportation/update_route_member.sql
|
||||
|
|
|
@ -28,9 +28,9 @@ CREATE OR REPLACE FUNCTION layer_transportation_name(bbox geometry, zoom_level i
|
|||
AS
|
||||
$$
|
||||
SELECT geometry,
|
||||
name,
|
||||
COALESCE(name_en, name) AS name_en,
|
||||
COALESCE(name_de, name, name_en) AS name_de,
|
||||
tags->'name' AS name,
|
||||
COALESCE(tags->'name:en', tags->'name') AS name_en,
|
||||
COALESCE(tags->'name:de', tags->'name', tags->'name:en') AS name_de,
|
||||
tags,
|
||||
ref,
|
||||
NULLIF(LENGTH(ref), 0) AS ref_length,
|
||||
|
@ -93,9 +93,6 @@ FROM (
|
|||
|
||||
-- etldoc: osm_transportation_name_linestring -> layer_transportation_name:z12
|
||||
SELECT geometry,
|
||||
name,
|
||||
name_en,
|
||||
name_de,
|
||||
"tags",
|
||||
ref,
|
||||
highway,
|
||||
|
@ -109,7 +106,7 @@ FROM (
|
|||
indoor
|
||||
FROM osm_transportation_name_linestring
|
||||
WHERE zoom_level = 12
|
||||
AND LineLabel(zoom_level, COALESCE(name, ref), geometry)
|
||||
AND LineLabel(zoom_level, COALESCE(tags->'name', ref), geometry)
|
||||
AND NOT highway_is_link(highway)
|
||||
AND
|
||||
CASE WHEN highway_class(highway, NULL::text, NULL::text) NOT IN ('path', 'minor') THEN TRUE
|
||||
|
@ -120,9 +117,6 @@ FROM (
|
|||
|
||||
-- etldoc: osm_transportation_name_linestring -> layer_transportation_name:z13
|
||||
SELECT geometry,
|
||||
name,
|
||||
name_en,
|
||||
name_de,
|
||||
"tags",
|
||||
ref,
|
||||
highway,
|
||||
|
@ -136,11 +130,11 @@ FROM (
|
|||
indoor
|
||||
FROM osm_transportation_name_linestring
|
||||
WHERE zoom_level = 13
|
||||
AND LineLabel(zoom_level, COALESCE(name, ref), geometry)
|
||||
AND LineLabel(zoom_level, COALESCE(tags->'name', ref), geometry)
|
||||
AND
|
||||
CASE WHEN highway <> 'path' THEN TRUE
|
||||
WHEN highway = 'path' AND (
|
||||
name <> ''
|
||||
tags->'name' <> ''
|
||||
OR network IS NOT NULL
|
||||
OR sac_scale <> ''
|
||||
OR route_rank <= 2
|
||||
|
@ -151,9 +145,6 @@ FROM (
|
|||
|
||||
-- etldoc: osm_transportation_name_linestring -> layer_transportation_name:z14_
|
||||
SELECT geometry,
|
||||
name,
|
||||
name_en,
|
||||
name_de,
|
||||
"tags",
|
||||
ref,
|
||||
highway,
|
||||
|
@ -172,11 +163,8 @@ FROM (
|
|||
-- etldoc: osm_highway_point -> layer_transportation_name:z10
|
||||
SELECT
|
||||
p.geometry,
|
||||
p.name,
|
||||
p.name_en,
|
||||
p.name_de,
|
||||
p.tags,
|
||||
p.tags->'ref',
|
||||
p.ref,
|
||||
(
|
||||
SELECT highest_highway(l.tags->'highway')
|
||||
FROM osm_highway_linestring l
|
||||
|
|
|
@ -7,10 +7,7 @@
|
|||
-- etldoc: osm_shipway_linestring -> osm_transportation_name_linestring
|
||||
CREATE TABLE IF NOT EXISTS osm_transportation_name_linestring AS
|
||||
SELECT (ST_Dump(geometry)).geom AS geometry,
|
||||
name,
|
||||
name_en,
|
||||
name_de,
|
||||
tags || get_basic_names(tags, geometry) AS "tags",
|
||||
tags,
|
||||
ref,
|
||||
highway,
|
||||
subclass,
|
||||
|
@ -25,11 +22,7 @@ SELECT (ST_Dump(geometry)).geom AS geometry,
|
|||
route_rank
|
||||
FROM (
|
||||
SELECT ST_LineMerge(ST_Collect(geometry)) AS geometry,
|
||||
name,
|
||||
name_en,
|
||||
name_de,
|
||||
tags || hstore( -- store results of osml10n_street_abbrev_* above
|
||||
ARRAY ['name', name, 'name:en', name_en, 'name:de', name_de]) AS tags,
|
||||
tags,
|
||||
ref,
|
||||
highway,
|
||||
subclass,
|
||||
|
@ -45,16 +38,13 @@ FROM (
|
|||
min(z_order) AS z_order,
|
||||
min(route_rank) AS route_rank
|
||||
FROM osm_transportation_name_network
|
||||
WHERE name <> '' OR ref <> ''
|
||||
GROUP BY name, name_en, name_de, tags, ref, highway, subclass, sac_scale, "level", layer, indoor, network_type,
|
||||
WHERE tags->'name' <> '' OR ref <> ''
|
||||
GROUP BY tags, ref, highway, subclass, "level", layer, sac_scale, indoor, network_type,
|
||||
route_1, route_2, route_3, route_4, route_5, route_6
|
||||
UNION ALL
|
||||
|
||||
SELECT ST_LineMerge(ST_Collect(geometry)) AS geometry,
|
||||
CASE WHEN length(name) > 15 THEN osml10n_street_abbrev_all(name) ELSE NULLIF(name, '') END AS "name",
|
||||
CASE WHEN length(name_en) > 15 THEN osml10n_street_abbrev_en(name_en) ELSE NULLIF(name_en, '') END AS "name_en",
|
||||
CASE WHEN length(name_de) > 15 THEN osml10n_street_abbrev_de(name_de) ELSE NULLIF(name_de, '') END AS "name_de",
|
||||
slice_language_tags(tags) || hstore(ARRAY ['name', name, 'name:en', name_en, 'name:de', name_de]) AS tags,
|
||||
transportation_name_tags(NULL::geometry, tags, name, name_en, name_de) AS tags,
|
||||
NULL AS ref,
|
||||
'shipway' AS highway,
|
||||
shipway AS subclass,
|
||||
|
@ -77,7 +67,7 @@ FROM (
|
|||
GROUP BY name, name_en, name_de, tags, subclass, "level", layer
|
||||
) AS highway_union
|
||||
;
|
||||
CREATE INDEX IF NOT EXISTS osm_transportation_name_linestring_name_ref_idx ON osm_transportation_name_linestring (coalesce(name, ''), coalesce(ref, ''));
|
||||
CREATE INDEX IF NOT EXISTS osm_transportation_name_linestring_name_ref_idx ON osm_transportation_name_linestring (coalesce(tags->'name', ''), coalesce(ref, ''));
|
||||
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_highway_partial_idx
|
||||
|
@ -87,9 +77,6 @@ CREATE INDEX IF NOT EXISTS osm_transportation_name_linestring_highway_partial_id
|
|||
-- etldoc: osm_transportation_name_linestring -> osm_transportation_name_linestring_gen1
|
||||
CREATE OR REPLACE VIEW osm_transportation_name_linestring_gen1_view AS
|
||||
SELECT ST_Simplify(geometry, 50) AS geometry,
|
||||
name,
|
||||
name_en,
|
||||
name_de,
|
||||
tags,
|
||||
ref,
|
||||
highway,
|
||||
|
@ -105,7 +92,7 @@ WHERE (highway IN ('motorway', 'trunk') OR highway = 'construction' AND subclass
|
|||
CREATE TABLE IF NOT EXISTS osm_transportation_name_linestring_gen1 AS
|
||||
SELECT *
|
||||
FROM osm_transportation_name_linestring_gen1_view;
|
||||
CREATE INDEX IF NOT EXISTS osm_transportation_name_linestring_gen1_name_ref_idx ON osm_transportation_name_linestring_gen1((coalesce(name, ref)));
|
||||
CREATE INDEX IF NOT EXISTS osm_transportation_name_linestring_gen1_name_ref_idx ON osm_transportation_name_linestring_gen1((coalesce(tags->'name', ref)));
|
||||
CREATE INDEX IF NOT EXISTS osm_transportation_name_linestring_gen1_geometry_idx ON osm_transportation_name_linestring_gen1 USING gist (geometry);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS osm_transportation_name_linestring_gen1_highway_partial_idx
|
||||
|
@ -115,9 +102,6 @@ CREATE INDEX IF NOT EXISTS osm_transportation_name_linestring_gen1_highway_parti
|
|||
-- etldoc: osm_transportation_name_linestring_gen1 -> osm_transportation_name_linestring_gen2
|
||||
CREATE OR REPLACE VIEW osm_transportation_name_linestring_gen2_view AS
|
||||
SELECT ST_Simplify(geometry, 120) AS geometry,
|
||||
name,
|
||||
name_en,
|
||||
name_de,
|
||||
tags,
|
||||
ref,
|
||||
highway,
|
||||
|
@ -133,7 +117,7 @@ WHERE (highway IN ('motorway', 'trunk') OR highway = 'construction' AND subclass
|
|||
CREATE TABLE IF NOT EXISTS osm_transportation_name_linestring_gen2 AS
|
||||
SELECT *
|
||||
FROM osm_transportation_name_linestring_gen2_view;
|
||||
CREATE INDEX IF NOT EXISTS osm_transportation_name_linestring_gen2_name_ref_idx ON osm_transportation_name_linestring_gen2((coalesce(name, ref)));
|
||||
CREATE INDEX IF NOT EXISTS osm_transportation_name_linestring_gen2_name_ref_idx ON osm_transportation_name_linestring_gen2((coalesce(tags->'name', ref)));
|
||||
CREATE INDEX IF NOT EXISTS osm_transportation_name_linestring_gen2_geometry_idx ON osm_transportation_name_linestring_gen2 USING gist (geometry);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS osm_transportation_name_linestring_gen2_highway_partial_idx
|
||||
|
@ -143,9 +127,6 @@ CREATE INDEX IF NOT EXISTS osm_transportation_name_linestring_gen2_highway_parti
|
|||
-- etldoc: osm_transportation_name_linestring_gen2 -> osm_transportation_name_linestring_gen3
|
||||
CREATE OR REPLACE VIEW osm_transportation_name_linestring_gen3_view AS
|
||||
SELECT ST_Simplify(geometry, 200) AS geometry,
|
||||
name,
|
||||
name_en,
|
||||
name_de,
|
||||
tags,
|
||||
ref,
|
||||
highway,
|
||||
|
@ -161,7 +142,7 @@ WHERE (highway = 'motorway' OR highway = 'construction' AND subclass = 'motorway
|
|||
CREATE TABLE IF NOT EXISTS osm_transportation_name_linestring_gen3 AS
|
||||
SELECT *
|
||||
FROM osm_transportation_name_linestring_gen3_view;
|
||||
CREATE INDEX IF NOT EXISTS osm_transportation_name_linestring_gen3_name_ref_idx ON osm_transportation_name_linestring_gen3((coalesce(name, ref)));
|
||||
CREATE INDEX IF NOT EXISTS osm_transportation_name_linestring_gen3_name_ref_idx ON osm_transportation_name_linestring_gen3((coalesce(tags->'name', ref)));
|
||||
CREATE INDEX IF NOT EXISTS osm_transportation_name_linestring_gen3_geometry_idx ON osm_transportation_name_linestring_gen3 USING gist (geometry);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS osm_transportation_name_linestring_gen3_highway_partial_idx
|
||||
|
@ -171,9 +152,6 @@ CREATE INDEX IF NOT EXISTS osm_transportation_name_linestring_gen3_highway_parti
|
|||
-- etldoc: osm_transportation_name_linestring_gen3 -> osm_transportation_name_linestring_gen4
|
||||
CREATE OR REPLACE VIEW osm_transportation_name_linestring_gen4_view AS
|
||||
SELECT ST_Simplify(geometry, 500) AS geometry,
|
||||
name,
|
||||
name_en,
|
||||
name_de,
|
||||
tags,
|
||||
ref,
|
||||
highway,
|
||||
|
@ -189,7 +167,7 @@ WHERE (highway = 'motorway' OR highway = 'construction' AND subclass = 'motorway
|
|||
CREATE TABLE IF NOT EXISTS osm_transportation_name_linestring_gen4 AS
|
||||
SELECT *
|
||||
FROM osm_transportation_name_linestring_gen4_view;
|
||||
CREATE INDEX IF NOT EXISTS osm_transportation_name_linestring_gen4_name_ref_idx ON osm_transportation_name_linestring_gen4((coalesce(name, ref)));
|
||||
CREATE INDEX IF NOT EXISTS osm_transportation_name_linestring_gen4_name_ref_idx ON osm_transportation_name_linestring_gen4((coalesce(tags->'name', ref)));
|
||||
CREATE INDEX IF NOT EXISTS osm_transportation_name_linestring_gen4_geometry_idx ON osm_transportation_name_linestring_gen4 USING gist (geometry);
|
||||
|
||||
-- Handle updates
|
||||
|
@ -275,9 +253,6 @@ BEGIN
|
|||
SELECT
|
||||
geometry,
|
||||
osm_id,
|
||||
name,
|
||||
name_en,
|
||||
name_de,
|
||||
tags,
|
||||
ref,
|
||||
highway,
|
||||
|
@ -294,10 +269,7 @@ BEGIN
|
|||
FROM (
|
||||
SELECT hl.geometry,
|
||||
hl.osm_id,
|
||||
CASE WHEN length(hl.name) > 15 THEN osml10n_street_abbrev_all(hl.name) ELSE NULLIF(hl.name, '') END AS name,
|
||||
CASE WHEN length(hl.name_en) > 15 THEN osml10n_street_abbrev_en(hl.name_en) ELSE NULLIF(hl.name_en, '') END AS name_en,
|
||||
CASE WHEN length(hl.name_de) > 15 THEN osml10n_street_abbrev_de(hl.name_de) ELSE NULLIF(hl.name_de, '') END AS name_de,
|
||||
slice_language_tags(hl.tags) AS tags,
|
||||
transportation_name_tags(hl.geometry, hl.tags, hl.name, hl.name_en, hl.name_de) AS tags,
|
||||
rm1.network_type,
|
||||
CASE
|
||||
WHEN rm1.network_type IS NOT NULL AND rm1.ref::text <> ''
|
||||
|
@ -376,9 +348,6 @@ CREATE TABLE IF NOT EXISTS transportation_name.name_changes
|
|||
id serial PRIMARY KEY,
|
||||
is_old boolean,
|
||||
osm_id bigint,
|
||||
name character varying,
|
||||
name_en character varying,
|
||||
name_de character varying,
|
||||
tags hstore,
|
||||
ref character varying,
|
||||
highway character varying,
|
||||
|
@ -402,20 +371,20 @@ $$
|
|||
BEGIN
|
||||
IF (tg_op IN ('DELETE', 'UPDATE'))
|
||||
THEN
|
||||
INSERT INTO transportation_name.name_changes(is_old, osm_id, name, name_en, name_de, tags, ref, highway, subclass,
|
||||
brunnel, level, layer, indoor, network_type,
|
||||
INSERT INTO transportation_name.name_changes(is_old, osm_id, tags, ref, highway, subclass,
|
||||
brunnel, sac_scale, level, layer, indoor, network_type,
|
||||
route_1, route_2, route_3, route_4, route_5, route_6)
|
||||
VALUES (TRUE, old.osm_id, old.name, old.name_en, old.name_de, old.tags, old.ref, old.highway, old.subclass,
|
||||
old.brunnel, old.level, old.layer, old.indoor, old.network_type,
|
||||
VALUES (TRUE, old.osm_id, old.tags, old.ref, old.highway, old.subclass,
|
||||
old.brunnel, old.sac_scale, old.level, old.layer, old.indoor, old.network_type,
|
||||
old.route_1, old.route_2, old.route_3, old.route_4, old.route_5, old.route_6);
|
||||
END IF;
|
||||
IF (tg_op IN ('UPDATE', 'INSERT'))
|
||||
THEN
|
||||
INSERT INTO transportation_name.name_changes(is_old, osm_id, name, name_en, name_de, tags, ref, highway, subclass,
|
||||
brunnel, level, layer, indoor, network_type,
|
||||
INSERT INTO transportation_name.name_changes(is_old, osm_id, tags, ref, highway, subclass,
|
||||
brunnel, sac_scale, level, layer, indoor, network_type,
|
||||
route_1, route_2, route_3, route_4, route_5, route_6)
|
||||
VALUES (FALSE, new.osm_id, new.name, new.name_en, new.name_de, new.tags, new.ref, new.highway, new.subclass,
|
||||
new.brunnel, new.level, new.layer, new.indoor, new.network_type,
|
||||
VALUES (FALSE, new.osm_id, new.tags, new.ref, new.highway, new.subclass,
|
||||
new.brunnel, new.sac_scale, new.level, new.layer, new.indoor, new.network_type,
|
||||
new.route_1, new.route_2, new.route_3, new.route_4, new.route_5, new.route_6);
|
||||
END IF;
|
||||
RETURN NULL;
|
||||
|
@ -447,11 +416,8 @@ BEGIN
|
|||
|
||||
-- Compact the change history to keep only the first and last version, and then uniq version of row
|
||||
CREATE TEMP TABLE name_changes_compact AS
|
||||
SELECT DISTINCT ON (name, name_en, name_de, tags, ref, highway, subclass, brunnel, sac_scale, level, layer, indoor, network_type,
|
||||
SELECT DISTINCT ON (tags, ref, highway, subclass, brunnel, sac_scale, level, layer, indoor, network_type,
|
||||
route_1, route_2, route_3, route_4, route_5, route_6)
|
||||
name,
|
||||
name_en,
|
||||
name_de,
|
||||
tags,
|
||||
ref,
|
||||
highway,
|
||||
|
@ -463,7 +429,7 @@ BEGIN
|
|||
indoor,
|
||||
network_type,
|
||||
route_1, route_2, route_3, route_4, route_5, route_6,
|
||||
coalesce(name, ref) AS name_ref
|
||||
coalesce(tags->'name', ref) AS name_ref
|
||||
FROM ((
|
||||
SELECT DISTINCT ON (osm_id) *
|
||||
FROM transportation_name.name_changes
|
||||
|
@ -483,10 +449,7 @@ BEGIN
|
|||
DELETE
|
||||
FROM osm_transportation_name_linestring AS n
|
||||
USING name_changes_compact AS c
|
||||
WHERE coalesce(n.name, '') = coalesce(c.name, '')
|
||||
AND coalesce(n.ref, '') = coalesce(c.ref, '')
|
||||
AND n.name_en IS NOT DISTINCT FROM c.name_en
|
||||
AND n.name_de IS NOT DISTINCT FROM c.name_de
|
||||
WHERE coalesce(n.ref, '') = coalesce(c.ref, '')
|
||||
AND n.tags IS NOT DISTINCT FROM c.tags
|
||||
AND n.highway IS NOT DISTINCT FROM c.highway
|
||||
AND n.subclass IS NOT DISTINCT FROM c.subclass
|
||||
|
@ -505,10 +468,7 @@ BEGIN
|
|||
|
||||
INSERT INTO osm_transportation_name_linestring
|
||||
SELECT (ST_Dump(geometry)).geom AS geometry,
|
||||
name,
|
||||
name_en,
|
||||
name_de,
|
||||
tags || get_basic_names(tags, geometry) AS tags,
|
||||
tags,
|
||||
ref,
|
||||
highway,
|
||||
subclass,
|
||||
|
@ -522,12 +482,7 @@ BEGIN
|
|||
z_order
|
||||
FROM (
|
||||
SELECT ST_LineMerge(ST_Collect(n.geometry)) AS geometry,
|
||||
n.name,
|
||||
n.name_en,
|
||||
n.name_de,
|
||||
hstore(string_agg(nullif(slice_language_tags(n.tags ||
|
||||
hstore(ARRAY ['name', n.name, 'name:en', n.name_en, 'name:de', n.name_de]))::text,
|
||||
''), ',')) AS tags,
|
||||
n.tags,
|
||||
n.ref,
|
||||
n.highway,
|
||||
n.subclass,
|
||||
|
@ -541,10 +496,7 @@ BEGIN
|
|||
min(n.z_order) AS z_order
|
||||
FROM osm_transportation_name_network AS n
|
||||
JOIN name_changes_compact AS c ON
|
||||
coalesce(n.name, '') = coalesce(c.name, '')
|
||||
AND coalesce(n.ref, '') = coalesce(c.ref, '')
|
||||
AND n.name_en IS NOT DISTINCT FROM c.name_en
|
||||
AND n.name_de IS NOT DISTINCT FROM c.name_de
|
||||
coalesce(n.ref, '') = coalesce(c.ref, '')
|
||||
AND n.tags IS NOT DISTINCT FROM c.tags
|
||||
AND n.highway IS NOT DISTINCT FROM c.highway
|
||||
AND n.subclass IS NOT DISTINCT FROM c.subclass
|
||||
|
@ -560,7 +512,7 @@ BEGIN
|
|||
AND n.route_4 IS NOT DISTINCT FROM c.route_4
|
||||
AND n.route_5 IS NOT DISTINCT FROM c.route_5
|
||||
AND n.route_6 IS NOT DISTINCT FROM c.route_6
|
||||
GROUP BY n.name, n.name_en, n.name_de, n.tags, n.ref, n.highway, n.subclass, n.brunnel, n.sac_scale, n.level, n.layer, n.indoor, n.network_type,
|
||||
GROUP BY n.tags, n.ref, n.highway, n.subclass, n.brunnel, n.sac_scale, n.level, n.layer, n.indoor, n.network_type,
|
||||
n.route_1, n.route_2, n.route_3, n.route_4, n.route_5, n.route_6
|
||||
) AS highway_union;
|
||||
|
||||
|
@ -568,10 +520,7 @@ BEGIN
|
|||
DELETE FROM osm_transportation_name_linestring_gen1 AS n
|
||||
USING name_changes_compact AS c
|
||||
WHERE
|
||||
coalesce(n.name, n.ref) = c.name_ref
|
||||
AND n.name IS NOT DISTINCT FROM c.name
|
||||
AND n.name_en IS NOT DISTINCT FROM c.name_en
|
||||
AND n.name_de IS NOT DISTINCT FROM c.name_de
|
||||
coalesce(n.tags->'name', n.ref) = c.name_ref
|
||||
AND n.tags IS NOT DISTINCT FROM c.tags
|
||||
AND n.ref IS NOT DISTINCT FROM c.ref
|
||||
AND n.highway IS NOT DISTINCT FROM c.highway
|
||||
|
@ -589,10 +538,7 @@ BEGIN
|
|||
SELECT n.*
|
||||
FROM osm_transportation_name_linestring_gen1_view AS n
|
||||
JOIN name_changes_compact AS c ON
|
||||
coalesce(n.name, n.ref) = c.name_ref
|
||||
AND n.name IS NOT DISTINCT FROM c.name
|
||||
AND n.name_en IS NOT DISTINCT FROM c.name_en
|
||||
AND n.name_de IS NOT DISTINCT FROM c.name_de
|
||||
coalesce(n.tags->'name', n.ref) = c.name_ref
|
||||
AND n.tags IS NOT DISTINCT FROM c.tags
|
||||
AND n.ref IS NOT DISTINCT FROM c.ref
|
||||
AND n.highway IS NOT DISTINCT FROM c.highway
|
||||
|
@ -610,10 +556,7 @@ BEGIN
|
|||
DELETE FROM osm_transportation_name_linestring_gen2 AS n
|
||||
USING name_changes_compact AS c
|
||||
WHERE
|
||||
coalesce(n.name, n.ref) = c.name_ref
|
||||
AND n.name IS NOT DISTINCT FROM c.name
|
||||
AND n.name_en IS NOT DISTINCT FROM c.name_en
|
||||
AND n.name_de IS NOT DISTINCT FROM c.name_de
|
||||
coalesce(n.tags->'name', n.ref) = c.name_ref
|
||||
AND n.tags IS NOT DISTINCT FROM c.tags
|
||||
AND n.ref IS NOT DISTINCT FROM c.ref
|
||||
AND n.highway IS NOT DISTINCT FROM c.highway
|
||||
|
@ -631,10 +574,7 @@ BEGIN
|
|||
SELECT n.*
|
||||
FROM osm_transportation_name_linestring_gen2_view AS n
|
||||
JOIN name_changes_compact AS c ON
|
||||
coalesce(n.name, n.ref) = c.name_ref
|
||||
AND n.name IS NOT DISTINCT FROM c.name
|
||||
AND n.name_en IS NOT DISTINCT FROM c.name_en
|
||||
AND n.name_de IS NOT DISTINCT FROM c.name_de
|
||||
coalesce(n.tags->'name', n.ref) = c.name_ref
|
||||
AND n.tags IS NOT DISTINCT FROM c.tags
|
||||
AND n.ref IS NOT DISTINCT FROM c.ref
|
||||
AND n.highway IS NOT DISTINCT FROM c.highway
|
||||
|
@ -652,10 +592,7 @@ BEGIN
|
|||
DELETE FROM osm_transportation_name_linestring_gen3 AS n
|
||||
USING name_changes_compact AS c
|
||||
WHERE
|
||||
coalesce(n.name, n.ref) = c.name_ref
|
||||
AND n.name IS NOT DISTINCT FROM c.name
|
||||
AND n.name_en IS NOT DISTINCT FROM c.name_en
|
||||
AND n.name_de IS NOT DISTINCT FROM c.name_de
|
||||
coalesce(n.tags->'name', n.ref) = c.name_ref
|
||||
AND n.tags IS NOT DISTINCT FROM c.tags
|
||||
AND n.ref IS NOT DISTINCT FROM c.ref
|
||||
AND n.highway IS NOT DISTINCT FROM c.highway
|
||||
|
@ -673,10 +610,7 @@ BEGIN
|
|||
SELECT n.*
|
||||
FROM osm_transportation_name_linestring_gen3_view AS n
|
||||
JOIN name_changes_compact AS c ON
|
||||
coalesce(n.name, n.ref) = c.name_ref
|
||||
AND n.name IS NOT DISTINCT FROM c.name
|
||||
AND n.name_en IS NOT DISTINCT FROM c.name_en
|
||||
AND n.name_de IS NOT DISTINCT FROM c.name_de
|
||||
coalesce(n.tags->'name', n.ref) = c.name_ref
|
||||
AND n.tags IS NOT DISTINCT FROM c.tags
|
||||
AND n.ref IS NOT DISTINCT FROM c.ref
|
||||
AND n.highway IS NOT DISTINCT FROM c.highway
|
||||
|
@ -694,10 +628,7 @@ BEGIN
|
|||
DELETE FROM osm_transportation_name_linestring_gen4 AS n
|
||||
USING name_changes_compact AS c
|
||||
WHERE
|
||||
coalesce(n.name, n.ref) = c.name_ref
|
||||
AND n.name IS NOT DISTINCT FROM c.name
|
||||
AND n.name_en IS NOT DISTINCT FROM c.name_en
|
||||
AND n.name_de IS NOT DISTINCT FROM c.name_de
|
||||
coalesce(n.tags->'name', n.ref) = c.name_ref
|
||||
AND n.tags IS NOT DISTINCT FROM c.tags
|
||||
AND n.ref IS NOT DISTINCT FROM c.ref
|
||||
AND n.highway IS NOT DISTINCT FROM c.highway
|
||||
|
@ -715,10 +646,7 @@ BEGIN
|
|||
SELECT n.*
|
||||
FROM osm_transportation_name_linestring_gen4_view AS n
|
||||
JOIN name_changes_compact AS c ON
|
||||
coalesce(n.name, n.ref) = c.name_ref
|
||||
AND n.name IS NOT DISTINCT FROM c.name
|
||||
AND n.name_en IS NOT DISTINCT FROM c.name_en
|
||||
AND n.name_de IS NOT DISTINCT FROM c.name_de
|
||||
coalesce(n.tags->'name', n.ref) = c.name_ref
|
||||
AND n.tags IS NOT DISTINCT FROM c.tags
|
||||
AND n.ref IS NOT DISTINCT FROM c.ref
|
||||
AND n.highway IS NOT DISTINCT FROM c.highway
|
||||
|
|
|
@ -16,8 +16,16 @@
|
|||
<node id="500062" visible="true" timestamp="2019-01-01T00:00:00Z" version="1" lat="33.5" lon="-90.06" />
|
||||
<node id="500071" visible="true" timestamp="2019-01-01T00:00:00Z" version="1" lat="33.0" lon="-90.07" />
|
||||
<node id="500072" visible="true" timestamp="2019-01-01T00:00:00Z" version="1" lat="33.5" lon="-90.07" />
|
||||
<node id="500081" visible="true" timestamp="2019-01-01T00:00:00Z" version="1" lat="33.0" lon="-90.07" />
|
||||
<node id="500082" visible="true" timestamp="2019-01-01T00:00:00Z" version="1" lat="33.5" lon="-90.07" />
|
||||
<node id="500081" visible="true" timestamp="2019-01-01T00:00:00Z" version="1" lat="34.0" lon="-90.07" />
|
||||
<node id="500091" visible="true" timestamp="2019-01-01T00:00:00Z" version="1" lat="34.5" lon="-90.07" />
|
||||
<node id="500101" visible="true" timestamp="2019-01-01T00:00:00Z" version="1" lat="33.0" lon="-90.08" />
|
||||
<node id="500102" visible="true" timestamp="2019-01-01T00:00:00Z" version="1" lat="33.5" lon="-90.08" />
|
||||
<node id="500111" visible="true" timestamp="2019-01-01T00:00:00Z" version="1" lat="34.0" lon="-90.08" />
|
||||
<node id="500121" visible="true" timestamp="2019-01-01T00:00:00Z" version="1" lat="34.5" lon="-90.08" />
|
||||
<node id="500131" visible="true" timestamp="2019-01-01T00:00:00Z" version="1" lat="33.0" lon="-90.09" />
|
||||
<node id="500132" visible="true" timestamp="2019-01-01T00:00:00Z" version="1" lat="33.5" lon="-90.09" />
|
||||
<node id="500141" visible="true" timestamp="2019-01-01T00:00:00Z" version="1" lat="33.0" lon="-90.10" />
|
||||
<node id="500142" visible="true" timestamp="2019-01-01T00:00:00Z" version="1" lat="33.5" lon="-90.10" />
|
||||
|
||||
<way id="5000" version="1" timestamp="2019-01-01T00:00:00Z" visible="true">
|
||||
<nd ref="500001" />
|
||||
|
@ -69,27 +77,71 @@
|
|||
<tag k="highway" v="track"/>
|
||||
<tag k="name" v="OpenMapTiles Track"/>
|
||||
</way>
|
||||
|
||||
<!-- Test way stitching -->
|
||||
<way id="5007" version="1" timestamp="2019-01-01T00:00:00Z" visible="true">
|
||||
<nd ref="500071" />
|
||||
<nd ref="500072" />
|
||||
<tag k="highway" v="secondary"/>
|
||||
<tag k="name" v="OpenMapTiles Secondary 2"/>
|
||||
</way>
|
||||
<way id="5008" version="1" timestamp="2019-01-01T00:00:00Z" visible="true">
|
||||
<nd ref="500072" />
|
||||
<nd ref="500081" />
|
||||
<tag k="highway" v="secondary"/>
|
||||
<tag k="name" v="OpenMapTiles Secondary 2"/>
|
||||
</way>
|
||||
<way id="5009" version="1" timestamp="2019-01-01T00:00:00Z" visible="true">
|
||||
<nd ref="500081" />
|
||||
<nd ref="500091" />
|
||||
<tag k="highway" v="secondary"/>
|
||||
<tag k="name" v="OpenMapTiles Secondary 2"/>
|
||||
</way>
|
||||
|
||||
<!-- Test disrupted way stitching -->
|
||||
<way id="5010" version="1" timestamp="2019-01-01T00:00:00Z" visible="true">
|
||||
<nd ref="500101" />
|
||||
<nd ref="500102" />
|
||||
<tag k="highway" v="secondary"/>
|
||||
<tag k="bicycle" v="yes"/>
|
||||
<tag k="name" v="OpenMapTiles Secondary 3"/>
|
||||
</way>
|
||||
<way id="5011" version="1" timestamp="2019-01-01T00:00:00Z" visible="true">
|
||||
<nd ref="500102" />
|
||||
<nd ref="500111" />
|
||||
<tag k="highway" v="secondary"/>
|
||||
<tag k="bridge" v="yes"/>
|
||||
<tag k="layer" v="1"/>
|
||||
<tag k="toll" v="yes"/>
|
||||
<tag k="name" v="OpenMapTiles Secondary 3 (Toll)"/>
|
||||
</way>
|
||||
<way id="5012" version="1" timestamp="2019-01-01T00:00:00Z" visible="true">
|
||||
<nd ref="500111" />
|
||||
<nd ref="500121" />
|
||||
<tag k="highway" v="secondary"/>
|
||||
<tag k="name" v="OpenMapTiles Secondary 3"/>
|
||||
</way>
|
||||
<way id="5013" version="1" timestamp="2019-01-01T00:00:00Z" visible="true">
|
||||
<nd ref="500131" />
|
||||
<nd ref="500132" />
|
||||
<tag k="highway" v="path"/>
|
||||
<tag k="name" v="OpenMapTiles Path z13"/>
|
||||
</way>
|
||||
<way id="5008" version="1" timestamp="2019-01-01T00:00:00Z" visible="true">
|
||||
<nd ref="500081" />
|
||||
<nd ref="500082" />
|
||||
<way id="5014" version="1" timestamp="2019-01-01T00:00:00Z" visible="true">
|
||||
<nd ref="500141" />
|
||||
<nd ref="500142" />
|
||||
<tag k="highway" v="path"/>
|
||||
<tag k="name" v="OpenMapTiles Track z12"/>
|
||||
</way>
|
||||
|
||||
<relation id="507" visible="true" timestamp="2019-01-01T00:00:00Z" version="1" changeset="1" user="u" uid="1">
|
||||
<member type="way" ref="5007" role=""/>
|
||||
<relation id="513" visible="true" timestamp="2019-01-01T00:00:00Z" version="1" changeset="1" user="u" uid="1">
|
||||
<member type="way" ref="5013" role=""/>
|
||||
<tag k="type" v="route"/>
|
||||
<tag k="route" v="hiking"/>
|
||||
<tag k="colour" v="red"/>
|
||||
</relation>
|
||||
<relation id="508" visible="true" timestamp="2019-01-01T00:00:00Z" version="1" changeset="1" user="u" uid="1">
|
||||
<member type="way" ref="5008" role=""/>
|
||||
<relation id="514" visible="true" timestamp="2019-01-01T00:00:00Z" version="1" changeset="1" user="u" uid="1">
|
||||
<member type="way" ref="5014" role=""/>
|
||||
<tag k="type" v="route"/>
|
||||
<tag k="route" v="hiking"/>
|
||||
<tag k="network" v="nwn"/>
|
||||
|
|
|
@ -73,8 +73,8 @@ BEGIN
|
|||
|
||||
-- Verify that road classifications show up at the right zoom level
|
||||
SELECT COUNT(*) INTO cnt FROM osm_transportation_merge_linestring_gen_z4 WHERE highway='motorway';
|
||||
IF cnt <> 1 THEN
|
||||
INSERT INTO omt_test_failures VALUES(500, 'import', 'osm_transportation_linestring z4 motorway count expected 1, got ' || cnt);
|
||||
IF cnt < 1 THEN
|
||||
INSERT INTO omt_test_failures VALUES(500, 'import', 'osm_transportation_linestring z4 motorway count expected >=1, got ' || cnt);
|
||||
END IF;
|
||||
|
||||
SELECT COUNT(*) INTO cnt FROM osm_transportation_merge_linestring_gen_z4 WHERE highway='trunk';
|
||||
|
@ -83,8 +83,8 @@ BEGIN
|
|||
END IF;
|
||||
|
||||
SELECT COUNT(*) INTO cnt FROM osm_transportation_merge_linestring_gen_z5 WHERE highway='trunk';
|
||||
IF cnt <> 1 THEN
|
||||
INSERT INTO omt_test_failures VALUES(500, 'import', 'osm_transportation_linestring z5 trunk count expected 1, got ' || cnt);
|
||||
IF cnt < 1 THEN
|
||||
INSERT INTO omt_test_failures VALUES(500, 'import', 'osm_transportation_linestring z5 trunk count expected >=1, got ' || cnt);
|
||||
END IF;
|
||||
|
||||
SELECT COUNT(*) INTO cnt FROM osm_transportation_merge_linestring_gen_z6 WHERE highway='primary';
|
||||
|
@ -93,8 +93,8 @@ BEGIN
|
|||
END IF;
|
||||
|
||||
SELECT COUNT(*) INTO cnt FROM osm_transportation_merge_linestring_gen_z7 WHERE highway='primary';
|
||||
IF cnt <> 1 THEN
|
||||
INSERT INTO omt_test_failures VALUES(500, 'import', 'osm_transportation_linestring z7 primary count expected 1, got ' || cnt);
|
||||
IF cnt < 1 THEN
|
||||
INSERT INTO omt_test_failures VALUES(500, 'import', 'osm_transportation_linestring z7 primary count expected >=1, got ' || cnt);
|
||||
END IF;
|
||||
|
||||
SELECT COUNT(*) INTO cnt FROM osm_transportation_merge_linestring_gen_z8 WHERE highway='secondary';
|
||||
|
@ -103,8 +103,8 @@ BEGIN
|
|||
END IF;
|
||||
|
||||
SELECT COUNT(*) INTO cnt FROM osm_transportation_merge_linestring_gen_z9 WHERE highway='secondary';
|
||||
IF cnt <> 1 THEN
|
||||
INSERT INTO omt_test_failures VALUES(500, 'import', 'osm_transportation_linestring z9 secondary count expected 1, got ' || cnt);
|
||||
IF cnt < 1 THEN
|
||||
INSERT INTO omt_test_failures VALUES(500, 'import', 'osm_transportation_linestring z9 secondary count expected >=1, got ' || cnt);
|
||||
END IF;
|
||||
|
||||
SELECT COUNT(*) INTO cnt FROM osm_transportation_merge_linestring_gen_z10 WHERE highway='tertiary';
|
||||
|
@ -113,8 +113,8 @@ BEGIN
|
|||
END IF;
|
||||
|
||||
SELECT COUNT(*) INTO cnt FROM osm_transportation_merge_linestring_gen_z11 WHERE highway='tertiary';
|
||||
IF cnt <> 1 THEN
|
||||
INSERT INTO omt_test_failures VALUES(500, 'import', 'osm_transportation_linestring z11 tertiary count expected 1, got ' || cnt);
|
||||
IF cnt < 1 THEN
|
||||
INSERT INTO omt_test_failures VALUES(500, 'import', 'osm_transportation_linestring z11 tertiary count expected >=1, got ' || cnt);
|
||||
END IF;
|
||||
|
||||
SELECT COUNT(*) INTO cnt FROM osm_transportation_merge_linestring_gen_z11 WHERE highway IN ('service', 'track');
|
||||
|
@ -133,6 +133,12 @@ BEGIN
|
|||
INSERT INTO omt_test_failures VALUES(500, 'import', 'osm_transportation_linestring z9 import tags expected 1, got ' || cnt);
|
||||
END IF;
|
||||
|
||||
-- Same-named road split into 3 parts, because the middle segment is tagged toll=yes
|
||||
SELECT COUNT(*) INTO cnt FROM osm_transportation_name_linestring WHERE tags->'name' = 'OpenMapTiles Secondary 3';
|
||||
IF cnt <> 2 THEN
|
||||
INSERT INTO omt_test_failures VALUES(500, 'import', 'osm_transportation_linestring split road count expected 2, got ' || cnt);
|
||||
END IF;
|
||||
|
||||
SELECT COUNT(*) INTO cnt FROM osm_transportation_name_linestring
|
||||
WHERE tags->'name' = 'OpenMapTiles Path z13'
|
||||
AND route_rank = 2;
|
||||
|
|
|
@ -48,7 +48,14 @@ BEGIN
|
|||
INSERT INTO omt_test_failures VALUES(400, 'update', 'osm_border_linestring city count expected 2, got ' || cnt);
|
||||
END IF;
|
||||
|
||||
-- Test 500: Verify tags changed
|
||||
-- Test 500: Highways
|
||||
-- Same-named road previous split into 3 parts, now merged because the middle segment had toll=yes removed
|
||||
SELECT COUNT(*) INTO cnt FROM osm_transportation_name_linestring WHERE tags->'name' = 'OpenMapTiles Secondary 3';
|
||||
IF cnt <> 1 THEN
|
||||
INSERT INTO omt_test_failures VALUES(500, 'update', 'osm_transportation_linestring unsplit road count expected 1, got ' || cnt);
|
||||
END IF;
|
||||
|
||||
-- Verify tags changed
|
||||
SELECT COUNT(*) INTO cnt FROM osm_transportation_merge_linestring_gen_z9
|
||||
WHERE is_tunnel = TRUE
|
||||
AND is_bridge = FALSE
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
-->
|
||||
<modify>
|
||||
<!-- Change tags -->
|
||||
<way id="5003" version="2" timestamp="2019-01-01T00:00:00Z" visible="true">
|
||||
<way id="5003" version="2" timestamp="2020-01-02T00:00:00Z" visible="true">
|
||||
<nd ref="500031" />
|
||||
<nd ref="500032" />
|
||||
<tag k="highway" v="secondary"/>
|
||||
|
@ -19,5 +19,19 @@
|
|||
<tag k="horse" v="yes"/>
|
||||
<tag k="foot" v="yes"/>
|
||||
</way>
|
||||
|
||||
<!-- Remove toll to make way match adjoining ways -->
|
||||
<way id="5010" version="2" timestamp="2019-01-01T00:00:00Z" visible="true">
|
||||
<nd ref="500101" />
|
||||
<nd ref="500102" />
|
||||
<tag k="highway" v="secondary"/>
|
||||
<tag k="name" v="OpenMapTiles Secondary 3"/>
|
||||
</way>
|
||||
<way id="5011" version="2" timestamp="2020-01-02T00:00:00Z" visible="true">
|
||||
<nd ref="500102" />
|
||||
<nd ref="500111" />
|
||||
<tag k="highway" v="secondary"/>
|
||||
<tag k="name" v="OpenMapTiles Secondary 3"/>
|
||||
</way>
|
||||
</modify>
|
||||
</osmChange>
|
||||
|
|
Ładowanie…
Reference in New Issue