add query to check single municipalities

This commit is contained in:
Hugoren Martinako 2022-01-23 20:13:37 +01:00
parent 64dcd1ef5f
commit 570d7cb98d
1 changed files with 36 additions and 0 deletions

View File

@ -0,0 +1,36 @@
WITH municipios AS (
SELECT
name
, way
, COALESCE("ine:municipio", osm_id::TEXT) AS id
FROM
planet_osm_polygon pop
WHERE
admin_level = '8'
AND boundary = 'administrative'
AND lower(name) ~* lower(:MUNICIPIO)
)
, streets AS (
SELECT
*
FROM
planet_osm_line
WHERE
highway IN (
'residential', 'living_street', 'pedestrian'
)
)
SELECT
municipios.id AS id
, municipios.name
, streets.osm_id
, streets.way
FROM
streets
RIGHT JOIN municipios ON
st_within(
streets.way
, municipios.way
)
WHERE
streets.name IS NULL AND streets.noname IS NULL