Skip to content

Commit

Permalink
Update addresses.sql
Browse files Browse the repository at this point in the history
Whitelisted (exempted from processing) operator:addr* tags, see discussion at https://osmlatvija.github.io/zulip-archive/stream/360959-adreses/topic/botam.20nepat.C4.ABk.20operator.3Aaddr.html.
  • Loading branch information
Davis-Klavins committed Jan 31, 2024
1 parent 56d2720 commit e2a6911
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions addresses.sql
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ CREATE TABLE nodes_old (
,geom geometry(Point, 4326)
);

---Insert all nodes in Latvia that have at least one tag containing "addr", except "addr:unit", "addr:door", "addr:flats" and "addr:floor".
---Insert all nodes in Latvia that have at least one tag containing "addr", except "addr:unit", "addr:door", "addr:flats", "addr:floor" and "operator:addr*".
INSERT INTO nodes_old (
id
,version
Expand All @@ -90,10 +90,11 @@ WHERE a.tags ?| (
AND tag NOT LIKE 'addr:door'
AND tag NOT LIKE 'addr:flats'
AND tag NOT LIKE 'addr:floor'
AND tag NOT LIKE 'operator:addr%'
)
ORDER BY id;

--Delete all tags in Latvia from nodes containing "addr", except "addr:unit", "addr:door", "addr:flats" and "addr:floor".
--Delete all tags in Latvia from nodes containing "addr", except "addr:unit", "addr:door", "addr:flats", "addr:floor" and "operator:addr*".
WITH s
AS (
SELECT a.id
Expand All @@ -105,6 +106,7 @@ AS (
AND tag NOT LIKE 'addr:door'
AND tag NOT LIKE 'addr:flats'
AND tag NOT LIKE 'addr:floor'
AND tag NOT LIKE 'operator:addr%'
) tags
FROM nodes a
INNER JOIN nodes_lv b ON a.id = b.id
Expand All @@ -116,6 +118,7 @@ AS (
AND tag NOT LIKE 'addr:door'
AND tag NOT LIKE 'addr:flats'
AND tag NOT LIKE 'addr:floor'
AND tag NOT LIKE 'operator:addr%'
)
)
UPDATE nodes
Expand Down Expand Up @@ -165,7 +168,7 @@ CREATE TABLE ways_old (
,nodes BIGINT []
);

---Insert all ways in Latvia that have at least one tag containing "addr", except "addr:unit".
---Insert all ways in Latvia that have at least one tag containing "addr", except "addr:unit" and "operator:addr*".
INSERT INTO ways_old (
id
,version
Expand All @@ -189,10 +192,11 @@ WHERE a.tags ?| (
FROM tags
WHERE tag LIKE '%addr%'
AND tag NOT LIKE 'addr:unit'
AND tag NOT LIKE 'operator:addr%'
)
ORDER BY id;

--Delete all tags in Latvia from ways containing "addr", except "addr:unit".
--Delete all tags in Latvia from ways containing "addr", except "addr:unit" and "operator:addr*".
WITH s
AS (
SELECT a.id
Expand All @@ -201,6 +205,7 @@ AS (
FROM tags
WHERE tag LIKE '%addr%'
AND tag NOT LIKE 'addr:unit'
AND tag NOT LIKE 'operator:addr%'
) tags
FROM ways a
INNER JOIN ways_lv b ON a.id = b.id
Expand All @@ -209,6 +214,7 @@ AS (
FROM tags
WHERE tag LIKE '%addr%'
AND tag NOT LIKE 'addr:unit'
AND tag NOT LIKE 'operator:addr%'
)
)
UPDATE ways
Expand Down Expand Up @@ -257,7 +263,7 @@ CREATE TABLE relations_old (
,tags hstore
);

---Insert all relations in Latvia that have at least one tag containing "addr", except "addr:region".
---Insert all relations in Latvia that have at least one tag containing "addr", except "addr:region" and "operator:addr*".
INSERT INTO relations_old (
id
,version
Expand All @@ -279,10 +285,11 @@ WHERE a.tags ?| (
FROM tags
WHERE tag LIKE '%addr%'
AND tag NOT LIKE 'addr:region'
AND tag NOT LIKE 'operator:addr%'
)
ORDER BY id;

--Delete all tags in Latvia from relations containing "addr", except "addr:region".
--Delete all tags in Latvia from relations containing "addr", except "addr:region" and "operator:addr*".
WITH s
AS (
SELECT a.id
Expand All @@ -291,6 +298,7 @@ AS (
FROM tags
WHERE tag LIKE '%addr%'
AND tag NOT LIKE 'addr:region'
AND tag NOT LIKE 'operator:addr%'
) tags
FROM relations a
INNER JOIN relations_lv b ON a.id = b.id
Expand All @@ -299,6 +307,7 @@ AS (
FROM tags
WHERE tag LIKE '%addr%'
AND tag NOT LIKE 'addr:region'
AND tag NOT LIKE 'operator:addr%'
)
)
UPDATE relations
Expand Down

0 comments on commit e2a6911

Please sign in to comment.