Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Attempt to) stop jumping markers for duplicate wiki pages #1958

Merged
merged 3 commits into from
Jul 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 28 additions & 20 deletions analysers/analyser_osmosis_wikipedia.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,21 @@
from .Analyser_Osmosis import Analyser_Osmosis

sql10 = """
SELECT
(array_agg(tid))[1:10],
ST_AsText(any_locate((array_agg(type))[1], (array_agg(id))[1])),
w
FROM ((
WITH t AS ((
SELECT
tags->'wikipedia' AS w,
'N' || id AS tid,
'N' AS type,
id
'N' AS type,
id AS id
FROM
nodes
WHERE
tags != ''::hstore AND
tags?'wikipedia' AND
NOT tags->'wikipedia' LIKE '%#%' AND
NOT tags?| ARRAY['highway', 'railway', 'waterway', 'power', 'place', 'shop', 'network', 'operator']
ORDER BY
id
) UNION ALL (
) UNION ALL (
SELECT
tags->'wikipedia' AS w,
'W' || id AS tid,
'W' AS type,
id
FROM
Expand All @@ -56,12 +48,9 @@
tags?'wikipedia' AND
NOT tags->'wikipedia' LIKE '%#%' AND
NOT tags?| ARRAY['highway', 'railway', 'waterway', 'power', 'place', 'shop', 'network', 'operator']
ORDER BY
id
) UNION ALL (
) UNION ALL (
SELECT
tags->'wikipedia' AS w,
'R' || id AS tid,
'R' AS type,
id
FROM
Expand All @@ -72,11 +61,30 @@
NOT tags->'wikipedia' LIKE '%#%' AND
NOT tags->'type' IN ('route', 'boundary') AND
NOT tags?| ARRAY['highway', 'railway', 'waterway', 'power', 'place', 'shop', 'network', 'operator']
ORDER BY
id
)) AS t
GROUP BY
)),
b AS (
SELECT
w,
type,
id,
first_value(type) OVER (PARTITION BY w ORDER BY type, id) || first_value(id) OVER (PARTITION BY w ORDER BY type, id) AS tid
FROM
t
)
SELECT
(array_agg(type || id))[1:10],
ST_AsText(
any_locate(
substring(tid, 1, 1),
substring(tid, 2)::bigint
)
),
w
FROM
b
GROUP BY
w,
tid
HAVING
count(*) > 1
"""
Expand Down
Loading