kopia lustrzana https://github.com/openmaptiles/openmaptiles
Coalesce duplicate route concurrencies (#1361)
# Problem description #1128 introduced route relation concurrency information in OpenMapTiles via the `route_X` attributes. The original implementation assumed that there would be a single route relation for each `network` and `ref` pair. However, it is increasingly common practice to tag a separate route relation for each direction of a route in order to provide awareness to routers and other data consumers of the directionality of a route. This standard and growing practice is described on the [OSM wiki page on route directions](https://wiki.openstreetmap.org/wiki/Route_directions). Thus, the naïve implementation of #1128 caused duplicate entries to be added as `route_X` attributes in the case where separate route relations were used for directional routes. # Solution description This PR adds grouping when computing route concurrency information, such that duplicate entries are coalesced in a predictable way. Since this grouping is done only within a route membership join of a single member way, the computational complexity should be trivial.pull/1480/head^2
rodzic
efa6b27fba
commit
bc9bbd2e67
|
@ -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");
|
||||
|
||||
|
|
|
@ -147,4 +147,22 @@
|
|||
<tag k="route" v="hiking"/>
|
||||
<tag k="network" v="nwn"/>
|
||||
</relation>
|
||||
|
||||
<!-- Route Concurrency de-duplication -->
|
||||
<relation id="515" visible="true" timestamp="2019-01-01T00:00:00Z" version="1" changeset="1" user="u" uid="1">
|
||||
<member type="way" ref="5000" role=""/>
|
||||
<tag k="type" v="route"/>
|
||||
<tag k="route" v="road"/>
|
||||
<tag k="network" v="US:I"/>
|
||||
<tag k="ref" v="95"/>
|
||||
<tag k="description" v="I-95 Northbound"/>
|
||||
</relation>
|
||||
<relation id="516" visible="true" timestamp="2019-01-01T00:00:00Z" version="1" changeset="1" user="u" uid="1">
|
||||
<member type="way" ref="5000" role=""/>
|
||||
<tag k="type" v="route"/>
|
||||
<tag k="route" v="road"/>
|
||||
<tag k="network" v="US:I"/>
|
||||
<tag k="ref" v="95"/>
|
||||
<tag k="description" v="I-95 Southbound"/>
|
||||
</relation>
|
||||
</osm>
|
||||
|
|
|
@ -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
|
||||
|
|
Ładowanie…
Reference in New Issue