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.
This commit is contained in:
committed by
GitHub
parent
0cff3449b5
commit
ec74480414
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user