Commit 2308977d authored by Adrien Pavie's avatar Adrien Pavie
Browse files

Changed existing themes to use French schemas when possible

parent 2cdb487f
......@@ -148,7 +148,9 @@ WHERE <GEOMCOND> AND emergency = 'defibrillator'
```
Des balises optionnelles peuvent également être prévues :
* `<ADM8>` : ajouter les métadonnées de la commune (code INSEE, nom)
* `<ADM8NAME>` : nom de la commune
* `<ADM8REF>` : code INSEE de la commune
* `<GEOMEMBED>` : la géométrie initiale (EPSG:3857), pour utilisation dans des fonctions type `ST_X / ST_Y` ou `ST_Transform`
## Base de données
......
......@@ -168,13 +168,15 @@ function getThemeData(theme, boundary, options) {
// Create SQL request
const boundaryId = "'" + boundary.id.toString().replace(/'/g, "") + "'";
const dist = options.radius > 0 ? options.radius * 1000 : null;
const hasAdm8 = theme.sql.includes("<ADM8>");
const hasAdm8 = theme.sql.includes("<ADM8");
const geomCond = `b.osm_id = ${boundaryId} AND ${dist ? `ST_DWithin(t.way, b.center, ${dist})` : "t.way && b.way AND ST_Intersects(t.way, b.way)"} ${hasAdm8 ? " AND b2.type = 'admin_8' AND ST_Contains(b2.way, ST_Centroid(t.way))" : ""}`;
let request = theme.geomtypes.map(g => (
theme.sql
.replace(/<TABLE>/g, `boundary b, planet_osm_${g} t${hasAdm8 ? ", boundary b2" : ""}`)
.replace(/<GEOM>/g, options.aspoint ? "ST_Centroid(t.way) AS geom" : "t.way AS geom")
.replace(/<ADM8>/g, "b2.name AS adm8_name, b2.ref AS adm8_ref")
.replace(/<GEOMEMBED>/g, "t.way")
.replace(/<ADM8NAME>/g, "b2.name")
.replace(/<ADM8REF>/g, "b2.ref")
)).join(" UNION ");
// Generate metadata file content
......
......@@ -112,3 +112,4 @@ node,way cycleway:left text linear
node,way cycleway:right text linear
node,way addr:housenumber text polygon
node,way internet_access text polygon
node,way carpool text polygon
--METADATA={ "name:fr": "Défibrillateur", "name:en": "Automated external defibrillator", "theme:fr": "Santé", "keywords:fr": [ "défibrilateur", "aed", "dae" ], "description:fr": "Défibrillateurs extraits d'OpenStreetMap (emergency=defibrillator)" }
--METADATA={ "name:fr": "Défibrillateur", "name:en": "Automated external defibrillator", "theme:fr": "Santé", "keywords:fr": [ "défibrilateur", "aed", "dae" ], "description:fr": "Défibrillateurs extraits d'OpenStreetMap (emergency=defibrillator) au format de la base de données nationale des DAE" }
--GEOMETRY=point
SELECT
t.osm_id, t.tags->'name' AS name, t.access, t.tags->'operator' AS operator,
t.tags->'opening_hours' AS opening_hours,
t.tags->'defibrillator:location' AS location, <GEOM>
t.tags->'name' AS nom,
ST_Y(ST_Transform(<GEOMEMBED>, 2154)) AS lat_coor1,
ST_X(ST_Transform(<GEOMEMBED>, 2154)) AS long_coor1,
CASE WHEN t.tags->'indoor' = 'yes' THEN 'intérieur' ELSE 'extérieur' END AS acc,
CASE
WHEN t.tags->'access' = 'yes' THEN 'OUI'
WHEN t.tags->'access' IS NOT NULL THEN 'NON'
ELSE ''
END AS acc_lib,
t.tags->'opening_hours' AS disp_j,
t.tags->'phone' AS tel1,
t.tags->'operator' AS expt_rais,
t.tags->'addr:housenumber' AS adr_num,
t.tags->'addr:street' AS adr_voie,
t.tags->'level' AS acc_etg,
t.tags->'defibrillator:location' AS acc_complt,
CASE
WHEN t.tags->'image' IS NOT NULL THEN t.tags->'image'
WHEN t.tags->'mapillary' IS NOT NULL THEN concat('https://images.mapillary.com/', t.tags->'mapillary', '/thumb-2048.jpg')
END AS photo1,
t.tags->'start_date' AS date_instal,
concat('node/', t.osm_id) AS gid,
ST_X(ST_Transform(<GEOMEMBED>, 4326)) AS x_coor2,
ST_Y(ST_Transform(<GEOMEMBED>, 4326)) AS y_coor2,
7 AS xy_precis,
<ADM8REF> AS com_insee,
<ADM8NAME> AS com_nom,
t.tags->'osm_timestamp' AS maj_don
FROM <TABLE>
WHERE <GEOMCOND> AND t.emergency = 'defibrillator'
--METADATA={ "name:fr": "Lieu de covoiturage", "name:en": "Carpool station", "theme:fr": "Transports", "keywords:fr": [ "covoiturage" ], "description:fr": "Lieux de covoiturage issus d'OpenStreetMap (amenity=parking + carpool=yes|designated ou amenity=car_pooling) au format Schéma Lieux covoiturage" }
--GEOMETRY=point,polygon
SELECT
t.tags->'ref:FR:BNCLC' AS id_lieu,
t.tags->'name' AS nom_lieu,
CASE WHEN t.tags->'addr:housenumber' IS NOT NULL AND t.tags->'addr:street' IS NOT NULL THEN concat(t.tags->'addr:housenumber', ' ', t.tags->'addr:street') END AS ad_lieu,
<ADM8NAME> AS com_lieu,
<ADM8REF> AS insee,
CASE
WHEN t.amenity = 'parking' AND t.tags->'park_ride' IN ('bus', 'yes') THEN 'Parking relais'
WHEN (t.amenity = 'parking' AND t.tags->'carpool' = 'designated') OR t.amenity = 'car_pooling' THEN 'Aire de covoiturage'
ELSE 'Parking'
END AS type,
split_part(t.tags->'osm_timestamp', 'T', 1) AS date_maj,
CASE WHEN t.access IS NULL or t.access != 'no' THEN true ELSE false END AS ouvert,
'OpenStreetMap' AS source,
ST_X(ST_Transform(ST_Centroid(<GEOMEMBED>), 4326)) AS "Xlong",
ST_Y(ST_Transform(ST_Centroid(<GEOMEMBED>), 4326)) AS "Ylat",
t.tags->'capacity' AS nbre_pl,
t.tags->'capacity:disabled' AS nbre_pmr,
t.tags->'maxstay' AS duree,
t.tags->'opening_hours' AS horaires,
t.tags->'operator' AS proprio,
CASE
WHEN t.tags->'lit' = 'yes' THEN true
WHEN t.tags->'lit' = 'no' THEN false
END AS lumiere,
COALESCE(t.tags->'description', t.tags->'note') AS comm
FROM <TABLE>
WHERE <GEOMCOND> AND ((t.amenity = 'parking' AND t.carpool IN ('yes', 'designated')) OR t.amenity = 'car_pooling')
......@@ -4,6 +4,6 @@
SELECT
t.osm_id, t.tags->'name' AS name, t.tags->'religion' AS religion, t.tags->'denomination' AS religion_denomination,
t.tags->'operator' AS operator, t.wheelchair, t.tags->'opening_hours' AS opening_hours,
<ADM8>, <GEOM>
<ADM8NAME> AS commune_name, <ADM8REF> AS code_insee, <GEOM>
FROM <TABLE>
WHERE <GEOMCOND> AND t.landuse = 'cemetery'
--METADATA={ "name:fr": "Borne de recharge de véhicule électrique (IRVE)", "name:en": "Vehicle charging station", "theme:fr": "Transports", "keywords:fr": [ "irve", "borne de recharge électrique" ], "description:fr": "Bornes de recharge de véhicule électrique issues d'OpenStreetMap (amenity=charging_station) au format Schéma IRVE" }
--GEOMETRY=point,polygon
SELECT
t.tags->'owner' AS n_amenageur,
t.tags->'operator' AS n_operateur,
COALESCE(t.tags->'network', t.tags->'brand') AS n_enseigne,
t.tags->'ref' AS id_station,
t.tags->'name' AS n_station,
CASE
WHEN t.tags->'addr:housenumber' IS NOT NULL AND t.tags->'addr:street' IS NOT NULL THEN concat(t.tags->'addr:housenumber', ' ', t.tags->'addr:street', ', ', <ADM8NAME>)
END AS ad_station,
<ADM8REF> AS code_insee,
ST_X(ST_Transform(ST_Centroid(<GEOMEMBED>), 4326)) AS "Xlongitude",
ST_Y(ST_Transform(ST_Centroid(<GEOMEMBED>), 4326)) AS "Ylatitude",
t.tags->'capacity' AS nbre_pdc,
'' AS id_pdc,
CASE WHEN t.tags->'charging_station:output' IS NOT NULL THEN replace(t.tags->'charging_station:output', ' kW', '') END AS puiss_max,
array_to_string(array_remove(ARRAY[
CASE WHEN t.tags->'socket:type2_combo' IS NOT NULL AND t.tags->'socket:type2_combo' != 'no' THEN 'type2_combo' ELSE '' END,
CASE WHEN t.tags->'socket:type2' IS NOT NULL AND t.tags->'socket:type2' != 'no' THEN 'type2' ELSE '' END,
CASE WHEN t.tags->'socket:chademo' IS NOT NULL AND t.tags->'socket:chademo' != 'no' THEN 'chademo' ELSE '' END,
CASE WHEN t.tags->'socket:typee' IS NOT NULL AND t.tags->'socket:typee' != 'no' THEN 'typee' ELSE '' END
], ''), ',') AS type_prise,
CASE
WHEN t.tags->'fee' = 'yes' THEN 'Payant'
WHEN t.tags->'fee' = 'no' THEN 'Gratuit'
END AS acces_recharge,
t.tags->'opening_hours' AS "accessibilité",
t.tags->'description' AS observations,
replace(split_part(t.tags->'osm_timestamp', 'T', 1), '-', '/') AS date_maj
FROM <TABLE>
WHERE <GEOMCOND> AND t.amenity = 'charging_station'
......@@ -4,6 +4,6 @@
SELECT
t.osm_id, t.tags->'name' AS name, t.tags->'amenity' AS type, t.tags->'school:FR' AS type_fr,
t.tags->'operator:type' AS statut, t.tags->'ref:UAI' AS ref_uai, t.tags->'wikidata' AS wikidata,
<ADM8>, <GEOM>
<ADM8NAME> AS commune_name, <ADM8REF> AS code_insee, <GEOM>
FROM <TABLE>
WHERE <GEOMCOND> AND t.amenity IN ('school', 'kindergarten', 'college', 'university')
......@@ -4,6 +4,6 @@
SELECT
t.osm_id, t.amenity AS type, t.tags->'name' AS name, t.tags->'ref:isil' AS ref_isil,
t.tags->'operator' AS operator, t.wheelchair, t.tags->'opening_hours' AS opening_hours,
<ADM8>, <GEOM>
<ADM8NAME> AS commune_name, <ADM8REF> AS code_insee, <GEOM>
FROM <TABLE>
WHERE <GEOMCOND> AND t.amenity IN ('library', 'public_bookcase')
--METADATA={ "name:fr": "Parking", "name:en": "Parking", "theme:fr": "Transports", "keywords:fr": [ "parking" ], "description:fr": "Parkings pour automobiles issus d'OpenStreetMap (amenity=parking|parking_space)" }
--METADATA={ "name:fr": "Lieu de stationnement", "name:en": "Parking", "theme:fr": "Transports", "keywords:fr": [ "parking" ], "description:fr": "Lieux de stationnement (vélo, voiture, deux roues) issus d'OpenStreetMap (amenity=parking|parking_space|bicycle_parking|motorcycle_parking|car_sharing) selon le schéma Stationnement de transport.data.gouv.fr" }
--GEOMETRY=point,polygon
SELECT
t.osm_id, t.amenity AS type, t.tags->'name' AS name, t.tags->'operator' AS operator,
t.tags->'brand' AS brand, t.tags->'opening_hours' AS opening_hours, t.access,
t.wheelchair, t.tags->'ref' AS ref, t.tags->'parking' AS subtype, t.tags->'capacity' AS capacity,
t.tags->'capacity:disabled' AS capacity_disabled, t.tags->'maxstay' AS maxstay,
t.tags->'fee' AS fee, t.tags->'park_ride' AS park_ride, t.tags->'carpool' AS covoiturage,
<GEOM>
t.osm_id AS id,
t.tags->'name' AS nom,
<ADM8REF> AS insee,
CASE WHEN t.tags->'addr:housenumber' IS NOT NULL AND t.tags->'addr:street' IS NOT NULL THEN concat(t.tags->'addr:housenumber', ' ', t.tags->'addr:street', ',', <ADM8NAME>) END AS adresse,
COALESCE(t.tags->'website', t.tags->'contact:website') AS url,
'tous' AS type_usagers,
CASE
WHEN t.tags->'fee' = 'no' OR t.tags->'fee' IS NULL THEN true
ELSE false
END AS gratuit,
CASE WHEN t.amenity = 'parking' THEN t.tags->'capacity' END AS nb_places,
'' AS nb_pr,
CASE WHEN t.amenity = 'parking_space' AND t.wheelchair = 'yes' THEN t.tags->'capacity' ELSE t.tags->'capacity:disabled' END AS nb_pmr,
t.tags->'capacity:charging' AS nb_voitures_electriques,
CASE WHEN t.amenity = 'bicycle_parking' THEN t.tags->'capacity' END AS nb_velo,
'' AS nb_2r_el,
CASE WHEN t.amenity = 'car_sharing' THEN t.tags->'capacity' END AS nb_autopartage,
CASE WHEN t.amenity = 'motorcycle_parking' THEN t.tags->'capacity' END AS nb_2_rm,
CASE WHEN t.carpool = 'designated' THEN t.tags->'capacity' ELSE t.tags->'capacity:carpool' END AS nb_covoit,
t.tags->'maxheight' AS hauteur_max,
t.tags->'operator:ref:FR:SIRET' AS num_siret,
ST_X(ST_Transform(ST_Centroid(<GEOMEMBED>), 4326)) AS "Xlong",
ST_Y(ST_Transform(ST_Centroid(<GEOMEMBED>), 4326)) AS "Ylat",
'' AS tarif_pmr,
'' AS tarif_1h,
'' AS tarif_2h,
'' AS tarif_3h,
'' AS tarif_4h,
'' AS tarif_24h,
'' AS abo_resident,
'' AS abo_non_resident,
t.tags->'parking' AS type_ouvrage,
COALESCE(t.tags->'description', t.tags->'note') AS info
FROM <TABLE>
WHERE <GEOMCOND> AND t.amenity IN ('parking', 'parking_space')
WHERE <GEOMCOND> AND t.amenity IN ('parking', 'parking_space', 'bicycle_parking', 'car_sharing', 'motorcycle_parking') AND (t.access IS NULL OR t.access NOT IN ('no', 'private'))
......@@ -4,6 +4,6 @@
SELECT
t.osm_id, COALESCE(t.amenity, t.office) AS type, t.tags->'name' AS name, t.tags->'operator' AS operator,
t.wheelchair, t.tags->'opening_hours' AS opening_hours,
<ADM8>, <GEOM>
<ADM8NAME> AS commune_name, <ADM8REF> AS code_insee, <GEOM>
FROM <TABLE>
WHERE <GEOMCOND> AND (t.amenity IN ('embassy', 'public_building', 'townhall') OR t.office IN ('diplomatic', 'government'))
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment