Skip to content

Commit

Permalink
Use old_name and alt_name fields
Browse files Browse the repository at this point in the history
  • Loading branch information
frodrigo committed Feb 22, 2024
1 parent 03a7d87 commit b0c82d7
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 15 deletions.
2 changes: 2 additions & 0 deletions bano.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ tables:
- {name: 'member_index', type: member_index}
- {key: 'ref:FR:FANTOIR', name: 'ref:FR:FANTOIR', type: string}
- {key: 'name', name: 'name', type: string}
- {key: 'alt_name', name: 'alt_name', type: string}
- {key: 'old_name', name: 'old_name', type: string}
- {key: 'type', name: 'type', type: string}
planet_osm_postal_code:
type: polygon
Expand Down
8 changes: 4 additions & 4 deletions bano/sql/charge_noms_voies_lieux-dits_OSM.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ SELECT DISTINCT provenance,
nature
FROM (SELECT 1::integer AS provenance,
pt.way,
UNNEST(ARRAY[pt.name,pt.tags->'alt_name',pt.tags->'old_name']) as name,
UNNEST(ARRAY[pt.name,pt.alt_name,pt.old_name]) as name,
tags,
CASE
WHEN pt.place='' THEN 'voie'::text
Expand All @@ -20,7 +20,7 @@ FROM (SELECT 1::integer AS provenance,
UNION ALL
SELECT 2,
l.way,
UNNEST(ARRAY[l.name,l.tags->'alt_name',l.tags->'old_name']) as name,
UNNEST(ARRAY[l.name,l.alt_name,l.old_name]) as name,
tags,
'voie'
FROM (SELECT way FROM planet_osm_polygon WHERE "ref:INSEE" = '__code_insee__') p
Expand All @@ -29,7 +29,7 @@ FROM (SELECT 1::integer AS provenance,
UNION ALL
SELECT 3,
pl.way,
UNNEST(ARRAY[pl.name,pl.tags->'alt_name',pl.tags->'old_name']) as name,
UNNEST(ARRAY[pl.name,pl.alt_name,pl.old_name]) as name,
tags,
'voie'
FROM (SELECT way FROM planet_osm_polygon WHERE "ref:INSEE" = '__code_insee__') p
Expand All @@ -40,4 +40,4 @@ LEFT OUTER JOIN suffixe h
ON ST_Intersects(l.way, h.geometrie)
LEFT OUTER JOIN (SELECT * FROM polygones_insee_a9 where insee_a8 = '__code_insee__') a9
ON ST_Contains(a9.geometrie,way)
WHERE l.name IS NOT NULL;
WHERE l.name IS NOT NULL;
10 changes: 5 additions & 5 deletions bano/sql/charge_noms_voies_relation_OSM.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,26 @@ SELECT DISTINCT provenance,
a9.nom,
'voie'::text
FROM (SELECT 4::integer AS provenance,
UNNEST(ARRAY[l.name,l.tags->'alt_name',l.tags->'old_name']) as name,
UNNEST(ARRAY[l.name,l.alt_name,l.old_name]) as name,
l.way,
r.tags
FROM (SELECT way FROM planet_osm_polygon WHERE "ref:INSEE" = '__code_insee__') p
JOIN (SELECT name,tags,osm_id,way FROM planet_osm_line WHERE highway != '' AND name != '') l
JOIN (SELECT name,alt_name,old_name,tags,osm_id,way FROM planet_osm_line WHERE highway != '' AND name != '') l
ON p.way && l.way AND ST_Contains(p.way, l.way)
JOIN planet_osm_rels r
ON r.osm_id = l.osm_id
UNION ALL
SELECT 5,
UNNEST(ARRAY[l.name,l.tags->'alt_name',l.tags->'old_name']) as name,
UNNEST(ARRAY[l.name,l.alt_name,l.old_name]) as name,
l.way,
r.tags
FROM (SELECT way FROM planet_osm_polygon WHERE "ref:INSEE" = '__code_insee__') p
JOIN (SELECT name,tags,osm_id,way FROM planet_osm_polygon WHERE highway != '' AND name != '') l
JOIN (SELECT name,alt_name,old_name,tags,osm_id,way FROM planet_osm_polygon WHERE highway != '' AND name != '') l
ON p.way && l.way AND ST_Contains(p.way, l.way)
JOIN planet_osm_rels r
ON r.osm_id = l.osm_id) l
LEFT OUTER JOIN (SELECT * FROM suffixe WHERE code_insee = '__code_insee__') h
ON ST_Intersects(way, h.geometrie)
LEFT OUTER JOIN (SELECT * FROM polygones_insee_a9 where insee_a8 = '__code_insee__') a9
ON ST_Contains(a9.geometrie,way)
WHERE l.name IS NOT NULL;
WHERE l.name IS NOT NULL;
8 changes: 4 additions & 4 deletions bano/sql/charge_points_nommes_centroides_OSM.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ WITH
lignes_brutes
AS
(SELECT l.way,
unnest(array[l.name,l.tags->'alt_name',l.tags->'old_name']) AS name,
unnest(array[l.name,l.alt_name,l.old_name]) AS name,
COALESCE(a9.code_insee,'xxxxx') as insee_jointure,
a9.code_insee insee_ac,
unnest(array["ref:FR:FANTOIR","ref:FR:FANTOIR:left","ref:FR:FANTOIR:right"]) AS fantoir,
Expand All @@ -19,7 +19,7 @@ WHERE (l.highway != '' OR
l.name != ''
UNION ALL
SELECT ST_PointOnSurface(l.way),
unnest(array[l.name,l.tags->'alt_name',l.tags->'old_name']) AS name,
unnest(array[l.name,l.alt_name,l.old_name]) AS name,
COALESCE(a9.code_insee,'xxxxx') as insee_jointure,
a9.code_insee insee_ac,
"ref:FR:FANTOIR" AS fantoir,
Expand All @@ -35,7 +35,7 @@ WHERE (l.highway||"ref:FR:FANTOIR" != '' OR l.landuse = 'residential' OR l.ame
l.name != ''
UNION ALL
SELECT l.way,
unnest(array[l.name,l.tags->'alt_name',l.tags->'old_name']) AS name,
unnest(array[l.name,l.alt_name,l.old_name]) AS name,
COALESCE(a9.code_insee,'xxxxx') as insee_jointure,
a9.code_insee insee_ac,
"ref:FR:FANTOIR" AS fantoir,
Expand All @@ -50,7 +50,7 @@ WHERE l.member_role = 'street' AND
l.name != ''),
lignes_noms
AS
(SELECT CASE
(SELECT CASE
WHEN GeometryType(way) = 'POINT' THEN ST_MakeLine(ST_Translate(way,-0.000001,-0.000001),ST_Translate(way,0.000001,0.000001))
WHEN GeometryType(way) LIKE '%POLYGON' THEN ST_ExteriorRing(way)
ELSE way
Expand Down
4 changes: 2 additions & 2 deletions bano/sql/charge_points_nommes_places_OSM.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ WITH
pts
AS
(SELECT pt.way,
UNNEST(ARRAY[pt.name,pt.tags->'alt_name',pt.tags->'old_name']) as name,
UNNEST(ARRAY[pt.name,pt.alt_name,pt.old_name]) as name,
tags,
place,
a9.code_insee AS insee_ac,
"ref:FR:FANTOIR" AS fantoir,
a9.nom AS nom_ac
a9.nom AS nom_ac
FROM (SELECT way FROM planet_osm_polygon WHERE "ref:INSEE" = '__code_insee__') p
JOIN (SELECT * FROM planet_osm_point WHERE place != '' AND name != '') pt
ON pt.way && p.way AND
Expand Down

0 comments on commit b0c82d7

Please sign in to comment.