diff --git a/layers/transportation/update_route_member.sql b/layers/transportation/update_route_member.sql index fd128139..83361abc 100644 --- a/layers/transportation/update_route_member.sql +++ b/layers/transportation/update_route_member.sql @@ -149,6 +149,17 @@ CREATE INDEX IF NOT EXISTS osm_route_member_ref_idx ON osm_route_member ("ref"); CREATE INDEX IF NOT EXISTS osm_route_member_network_type_idx ON osm_route_member ("network_type"); +/** +* Discard duplicate routes +*/ +DELETE FROM osm_route_member WHERE id IN + (SELECT id + FROM (SELECT id, + ROW_NUMBER() OVER (partition BY member, network, ref ORDER BY id) AS rnum + FROM osm_route_member) t + WHERE t.rnum > 1); +CREATE UNIQUE INDEX IF NOT EXISTS osm_route_member_network_ref_idx ON osm_route_member ("member", "network", "ref"); + CREATE INDEX IF NOT EXISTS osm_highway_linestring_osm_id_idx ON osm_highway_linestring ("osm_id"); CREATE UNIQUE INDEX IF NOT EXISTS osm_highway_linestring_gen_z11_osm_id_idx ON osm_highway_linestring_gen_z11 ("osm_id"); diff --git a/tests/import/500_import-highway.osm b/tests/import/500_import-highway.osm index 7fcbec92..8b745512 100644 --- a/tests/import/500_import-highway.osm +++ b/tests/import/500_import-highway.osm @@ -147,4 +147,22 @@ + + + + + + + + + + + + + + + + + + diff --git a/tests/test-post-import.sql b/tests/test-post-import.sql index f874a25a..b1af312c 100644 --- a/tests/test-post-import.sql +++ b/tests/test-post-import.sql @@ -160,6 +160,13 @@ BEGIN INSERT INTO omt_test_failures VALUES(500, 'import', 'osm_transportation_name_linestring z12 route_rank expected 1, got ' || cnt); END IF; + -- Duplicate route concurrencies collapsed + SELECT COUNT(*) INTO cnt FROM osm_route_member + WHERE network='US:I' AND ref='95'; + IF cnt <> 1 THEN + INSERT INTO omt_test_failures VALUES(500, 'import', 'osm_route_member 1 route membership expected, got ' || cnt); + END IF; + -- Test 600 -- verify that atms are imported with correct name which can come from tags like operator or network