BUGFIX: Route concurrency data is wiped after route member updates (#1239)

This PR is a bugfix for the `transportation_name` layer.  Currently, the updates process does not work, as noted by @zstadler in #1230.  The issue is that the computed `concurrency_index` column in `osm_route_member` is never updated after the initial updates.  Therefore, whenever route member ways are updated, they will lose their route concurrency index, and hence route concurrencies will be lost in the `transportation_name` tiles.  This PR adds the missing concurrency index update code to the transportation/network update triggers.

This PR as written also incorporates the fixes in #1230 and #1233.

The following SQL is a unit test to demonstrate that these triggers work correctly:

```
select count(*) from osm_route_member where concurrency_index > 5;
select count(*) from osm_transportation_name_network where route_6 is not null;

update osm_route_member set concurrency_index=NULL where concurrency_index > 5;

select count(*) from osm_route_member where concurrency_index > 5;
select count(*) from osm_transportation_name_network where route_6 is not null;
```

If working correctly, both pairs of `count(*)` values should return the same pair of numbers.
master-tools^2
Brian Sperlongano 2021-09-21 06:56:25 -04:00 zatwierdzone przez GitHub
rodzic 6f0ab57547
commit 88389f2a2c
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
2 zmienionych plików z 50 dodań i 20 usunięć

Wyświetl plik

@ -60,13 +60,16 @@ BEGIN
JOIN transportation_name.network_changes AS c ON JOIN transportation_name.network_changes AS c ON
r.osm_id = c.osm_id; r.osm_id = c.osm_id;
UPDATE INSERT INTO osm_route_member (id, network_type, concurrency_index)
osm_route_member AS r SELECT
SET network_type = osm_route_member_network_type(network) id,
FROM transportation_name.network_changes AS c osm_route_member_network_type(network) AS network_type,
WHERE network != '' DENSE_RANK() over (PARTITION BY member ORDER BY network_type, network, LENGTH(ref), ref) AS concurrency_index
AND network_type IS DISTINCT FROM osm_route_member_network_type(network) FROM osm_route_member rm
AND r.member = c.osm_id; WHERE rm.member IN
(SELECT DISTINCT osm_id FROM transportation_name.network_changes)
ON CONFLICT (id) DO UPDATE SET concurrency_index = EXCLUDED.concurrency_index;
END; END;
$$ LANGUAGE plpgsql; $$ LANGUAGE plpgsql;
@ -82,6 +85,7 @@ CREATE INDEX IF NOT EXISTS osm_highway_linestring_gen_z11_osm_id_idx ON osm_high
ALTER TABLE osm_route_member ADD COLUMN IF NOT EXISTS concurrency_index int; ALTER TABLE osm_route_member ADD COLUMN IF NOT EXISTS concurrency_index int;
-- One-time load of concurrency indexes; updates occur via trigger
INSERT INTO osm_route_member (id, concurrency_index) INSERT INTO osm_route_member (id, concurrency_index)
SELECT SELECT
id, id,

Wyświetl plik

@ -312,6 +312,22 @@ BEGIN
transportation_name.network_changes AS c transportation_name.network_changes AS c
WHERE n.osm_id = c.osm_id; WHERE n.osm_id = c.osm_id;
UPDATE osm_highway_linestring hl
SET network = rm.network_type
FROM transportation_name.network_changes c,
osm_route_member rm
WHERE hl.osm_id=c.osm_id
AND hl.osm_id=rm.member
AND rm.concurrency_index=1;
UPDATE osm_highway_linestring_gen_z11 hl
SET network = rm.network_type
FROM transportation_name.network_changes c,
osm_route_member rm
WHERE hl.osm_id=c.osm_id
AND hl.osm_id=rm.member
AND rm.concurrency_index=1;
INSERT INTO osm_transportation_name_network INSERT INTO osm_transportation_name_network
SELECT SELECT
geometry, geometry,
@ -337,7 +353,7 @@ BEGIN
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_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, 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, slice_language_tags(hl.tags) AS tags,
rm.network_type, rm1.network_type,
CASE CASE
WHEN rm1.network_type IS NOT NULL AND rm1.ref::text <> '' WHEN rm1.network_type IS NOT NULL AND rm1.ref::text <> ''
THEN rm1.ref::text THEN rm1.ref::text
@ -349,13 +365,23 @@ BEGIN
CASE WHEN highway IN ('footway', 'steps') THEN layer END AS layer, CASE WHEN highway IN ('footway', 'steps') THEN layer END AS layer,
CASE WHEN highway IN ('footway', 'steps') THEN level END AS level, CASE WHEN highway IN ('footway', 'steps') THEN level END AS level,
CASE WHEN highway IN ('footway', 'steps') THEN indoor END AS indoor, CASE WHEN highway IN ('footway', 'steps') THEN indoor END AS indoor,
route_1, route_2, route_3, route_4, route_5, route_6, NULLIF(rm1.network, '') || '=' || COALESCE(rm1.ref, '') AS route_1,
NULLIF(rm2.network, '') || '=' || COALESCE(rm2.ref, '') AS route_2,
NULLIF(rm3.network, '') || '=' || COALESCE(rm3.ref, '') AS route_3,
NULLIF(rm4.network, '') || '=' || COALESCE(rm4.ref, '') AS route_4,
NULLIF(rm5.network, '') || '=' || COALESCE(rm5.ref, '') AS route_5,
NULLIF(rm6.network, '') || '=' || COALESCE(rm6.ref, '') AS route_6,
hl.z_order hl.z_order
FROM osm_highway_linestring hl FROM osm_highway_linestring hl
JOIN transportation_name.network_changes AS c ON JOIN transportation_name.network_changes AS c ON
hl.osm_id = c.osm_id hl.osm_id = c.osm_id
LEFT OUTER JOIN osm_route_member rm ON rm.member = hl.osm_id AND rm.concurrency_index=1 LEFT OUTER JOIN osm_route_member rm1 ON rm1.member = hl.osm_id AND rm1.concurrency_index=1
WHERE (hl.name <> '' OR hl.ref <> '') LEFT OUTER JOIN osm_route_member rm2 ON rm2.member = hl.osm_id AND rm2.concurrency_index=2
LEFT OUTER JOIN osm_route_member rm3 ON rm3.member = hl.osm_id AND rm3.concurrency_index=3
LEFT OUTER JOIN osm_route_member rm4 ON rm4.member = hl.osm_id AND rm4.concurrency_index=4
LEFT OUTER JOIN osm_route_member rm5 ON rm5.member = hl.osm_id AND rm5.concurrency_index=5
LEFT OUTER JOIN osm_route_member rm6 ON rm6.member = hl.osm_id AND rm6.concurrency_index=6
WHERE (hl.name <> '' OR hl.ref <> '' OR rm1.ref <> '' OR rm1.network <> '')
AND hl.highway <> '' AND hl.highway <> ''
) AS t; ) AS t;
@ -515,7 +541,7 @@ BEGIN
AND n.level IS NOT DISTINCT FROM c.level AND n.level IS NOT DISTINCT FROM c.level
AND n.layer IS NOT DISTINCT FROM c.layer AND n.layer IS NOT DISTINCT FROM c.layer
AND n.indoor IS NOT DISTINCT FROM c.indoor AND n.indoor IS NOT DISTINCT FROM c.indoor
AND n.network_type IS NOT DISTINCT FROM c.network_type AND n.network IS NOT DISTINCT FROM c.network_type
AND n.route_1 IS NOT DISTINCT FROM c.route_1 AND n.route_1 IS NOT DISTINCT FROM c.route_1
AND n.route_2 IS NOT DISTINCT FROM c.route_2 AND n.route_2 IS NOT DISTINCT FROM c.route_2
AND n.route_3 IS NOT DISTINCT FROM c.route_3 AND n.route_3 IS NOT DISTINCT FROM c.route_3
@ -592,7 +618,7 @@ BEGIN
AND n.highway IS NOT DISTINCT FROM c.highway AND n.highway IS NOT DISTINCT FROM c.highway
AND n.subclass IS NOT DISTINCT FROM c.subclass AND n.subclass IS NOT DISTINCT FROM c.subclass
AND n.brunnel IS NOT DISTINCT FROM c.brunnel AND n.brunnel IS NOT DISTINCT FROM c.brunnel
AND n.network_type IS NOT DISTINCT FROM c.network_type AND n.network IS NOT DISTINCT FROM c.network_type
AND n.route_1 IS NOT DISTINCT FROM c.route_1 AND n.route_1 IS NOT DISTINCT FROM c.route_1
AND n.route_2 IS NOT DISTINCT FROM c.route_2 AND n.route_2 IS NOT DISTINCT FROM c.route_2
AND n.route_3 IS NOT DISTINCT FROM c.route_3 AND n.route_3 IS NOT DISTINCT FROM c.route_3
@ -612,7 +638,7 @@ BEGIN
AND n.highway IS NOT DISTINCT FROM c.highway AND n.highway IS NOT DISTINCT FROM c.highway
AND n.subclass IS NOT DISTINCT FROM c.subclass AND n.subclass IS NOT DISTINCT FROM c.subclass
AND n.brunnel IS NOT DISTINCT FROM c.brunnel AND n.brunnel IS NOT DISTINCT FROM c.brunnel
AND n.network_type IS NOT DISTINCT FROM c.network_type AND n.network IS NOT DISTINCT FROM c.network_type
AND n.route_1 IS NOT DISTINCT FROM c.route_1 AND n.route_1 IS NOT DISTINCT FROM c.route_1
AND n.route_2 IS NOT DISTINCT FROM c.route_2 AND n.route_2 IS NOT DISTINCT FROM c.route_2
AND n.route_3 IS NOT DISTINCT FROM c.route_3 AND n.route_3 IS NOT DISTINCT FROM c.route_3
@ -632,7 +658,7 @@ BEGIN
AND n.highway IS NOT DISTINCT FROM c.highway AND n.highway IS NOT DISTINCT FROM c.highway
AND n.subclass IS NOT DISTINCT FROM c.subclass AND n.subclass IS NOT DISTINCT FROM c.subclass
AND n.brunnel IS NOT DISTINCT FROM c.brunnel AND n.brunnel IS NOT DISTINCT FROM c.brunnel
AND n.network_type IS NOT DISTINCT FROM c.network_type AND n.network IS NOT DISTINCT FROM c.network_type
AND n.route_1 IS NOT DISTINCT FROM c.route_1 AND n.route_1 IS NOT DISTINCT FROM c.route_1
AND n.route_2 IS NOT DISTINCT FROM c.route_2 AND n.route_2 IS NOT DISTINCT FROM c.route_2
AND n.route_3 IS NOT DISTINCT FROM c.route_3 AND n.route_3 IS NOT DISTINCT FROM c.route_3
@ -652,7 +678,7 @@ BEGIN
AND n.highway IS NOT DISTINCT FROM c.highway AND n.highway IS NOT DISTINCT FROM c.highway
AND n.subclass IS NOT DISTINCT FROM c.subclass AND n.subclass IS NOT DISTINCT FROM c.subclass
AND n.brunnel IS NOT DISTINCT FROM c.brunnel AND n.brunnel IS NOT DISTINCT FROM c.brunnel
AND n.network_type IS NOT DISTINCT FROM c.network_type AND n.network IS NOT DISTINCT FROM c.network_type
AND n.route_1 IS NOT DISTINCT FROM c.route_1 AND n.route_1 IS NOT DISTINCT FROM c.route_1
AND n.route_2 IS NOT DISTINCT FROM c.route_2 AND n.route_2 IS NOT DISTINCT FROM c.route_2
AND n.route_3 IS NOT DISTINCT FROM c.route_3 AND n.route_3 IS NOT DISTINCT FROM c.route_3
@ -672,7 +698,7 @@ BEGIN
AND n.highway IS NOT DISTINCT FROM c.highway AND n.highway IS NOT DISTINCT FROM c.highway
AND n.subclass IS NOT DISTINCT FROM c.subclass AND n.subclass IS NOT DISTINCT FROM c.subclass
AND n.brunnel IS NOT DISTINCT FROM c.brunnel AND n.brunnel IS NOT DISTINCT FROM c.brunnel
AND n.network_type IS NOT DISTINCT FROM c.network_type AND n.network IS NOT DISTINCT FROM c.network_type
AND n.route_1 IS NOT DISTINCT FROM c.route_1 AND n.route_1 IS NOT DISTINCT FROM c.route_1
AND n.route_2 IS NOT DISTINCT FROM c.route_2 AND n.route_2 IS NOT DISTINCT FROM c.route_2
AND n.route_3 IS NOT DISTINCT FROM c.route_3 AND n.route_3 IS NOT DISTINCT FROM c.route_3
@ -692,7 +718,7 @@ BEGIN
AND n.highway IS NOT DISTINCT FROM c.highway AND n.highway IS NOT DISTINCT FROM c.highway
AND n.subclass IS NOT DISTINCT FROM c.subclass AND n.subclass IS NOT DISTINCT FROM c.subclass
AND n.brunnel IS NOT DISTINCT FROM c.brunnel AND n.brunnel IS NOT DISTINCT FROM c.brunnel
AND n.network_type IS NOT DISTINCT FROM c.network_type AND n.network IS NOT DISTINCT FROM c.network_type
AND n.route_1 IS NOT DISTINCT FROM c.route_1 AND n.route_1 IS NOT DISTINCT FROM c.route_1
AND n.route_2 IS NOT DISTINCT FROM c.route_2 AND n.route_2 IS NOT DISTINCT FROM c.route_2
AND n.route_3 IS NOT DISTINCT FROM c.route_3 AND n.route_3 IS NOT DISTINCT FROM c.route_3
@ -712,7 +738,7 @@ BEGIN
AND n.highway IS NOT DISTINCT FROM c.highway AND n.highway IS NOT DISTINCT FROM c.highway
AND n.subclass IS NOT DISTINCT FROM c.subclass AND n.subclass IS NOT DISTINCT FROM c.subclass
AND n.brunnel IS NOT DISTINCT FROM c.brunnel AND n.brunnel IS NOT DISTINCT FROM c.brunnel
AND n.network_type IS NOT DISTINCT FROM c.network_type AND n.network IS NOT DISTINCT FROM c.network_type
AND n.route_1 IS NOT DISTINCT FROM c.route_1 AND n.route_1 IS NOT DISTINCT FROM c.route_1
AND n.route_2 IS NOT DISTINCT FROM c.route_2 AND n.route_2 IS NOT DISTINCT FROM c.route_2
AND n.route_3 IS NOT DISTINCT FROM c.route_3 AND n.route_3 IS NOT DISTINCT FROM c.route_3
@ -732,7 +758,7 @@ BEGIN
AND n.highway IS NOT DISTINCT FROM c.highway AND n.highway IS NOT DISTINCT FROM c.highway
AND n.subclass IS NOT DISTINCT FROM c.subclass AND n.subclass IS NOT DISTINCT FROM c.subclass
AND n.brunnel IS NOT DISTINCT FROM c.brunnel AND n.brunnel IS NOT DISTINCT FROM c.brunnel
AND n.network_type IS NOT DISTINCT FROM c.network_type AND n.network IS NOT DISTINCT FROM c.network_type
AND n.route_1 IS NOT DISTINCT FROM c.route_1 AND n.route_1 IS NOT DISTINCT FROM c.route_1
AND n.route_2 IS NOT DISTINCT FROM c.route_2 AND n.route_2 IS NOT DISTINCT FROM c.route_2
AND n.route_3 IS NOT DISTINCT FROM c.route_3 AND n.route_3 IS NOT DISTINCT FROM c.route_3