Commit 4f7999f6 authored by Adrien Pavie's avatar Adrien Pavie
Browse files

Fix missing geometry in SCDL themes

parent 11671559
......@@ -126,6 +126,7 @@ Les propriétés à renseigner sont :
* `theme:fr` : thématique du jeu de données, sur la base de la nomenclature Eurovoc ou de la [nomenclature OpenDataFrance](https://docs.google.com/document/d/1oDJsHw3bmABfto6HPgCPG1ztrV3CihuHjcfU8tQpvPc/edit#heading=h.5aw35qsix45f)
* `keywords:fr` : liste de mots clés, sous la forme d'un tableau
* `description:fr` : un bref résumé du jeu de données, ainsi que des clés OSM utilisées pour l'extraction
* `skipGeomCSV` : mettre à `true` pour ne pas ajouter la géométrie lors d'un export CSV (si des colonnes lat/long sont déjà prévues)
### 2e ligne du fichier
......
......@@ -169,14 +169,19 @@ function getThemeData(theme, boundary, options) {
const boundaryId = "'" + boundary.id.toString().replace(/'/g, "") + "'";
const dist = options.radius > 0 ? options.radius * 1000 : null;
const hasAdm8 = theme.sql.includes("<ADM8");
const geom = format === "csv" && theme.skipGeomCSV ? "" : (options.aspoint ? "ST_Centroid(t.way) AS geom" : "t.way AS geom");
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(/<GEOM>/g, geom)
.replace(/<GEOMEMBED>/g, "t.way")
.replace(/<ADM8NAME>/g, "b2.name")
.replace(/<ADM8REF>/g, "b2.ref")
.replace(/SELECT\s+,/g, "SELECT ")
.replace(/,\s+FROM/g, " FROM")
)).join(" UNION ");
// Generate metadata file content
......
--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" }
--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", "skipGeomCSV": true }
--GEOMETRY=point
SELECT
......@@ -29,6 +29,7 @@ SELECT
7 AS xy_precis,
<ADM8REF> AS com_insee,
<ADM8NAME> AS com_nom,
t.tags->'osm_timestamp' AS maj_don
t.tags->'osm_timestamp' AS maj_don,
<GEOM>
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" }
--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", "skipGeomCSV": true }
--GEOMETRY=point,polygon
SELECT
......@@ -26,6 +26,7 @@ SELECT
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
COALESCE(t.tags->'description', t.tags->'note') AS comm,
<GEOM>
FROM <TABLE>
WHERE <GEOMCOND> AND ((t.amenity = 'parking' AND t.carpool IN ('yes', 'designated')) OR t.amenity = 'car_pooling')
--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" }
--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", "skipGeomCSV": true }
--GEOMETRY=point,polygon
SELECT
......@@ -28,6 +28,7 @@ SELECT
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
replace(split_part(t.tags->'osm_timestamp', 'T', 1), '-', '/') AS date_maj,
<GEOM>
FROM <TABLE>
WHERE <GEOMCOND> AND t.amenity = 'charging_station'
--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" }
--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", "skipGeomCSV": true }
--GEOMETRY=point,polygon
SELECT
......@@ -34,6 +34,7 @@ SELECT
'' AS abo_resident,
'' AS abo_non_resident,
t.tags->'parking' AS type_ouvrage,
COALESCE(t.tags->'description', t.tags->'note') AS info
COALESCE(t.tags->'description', t.tags->'note') AS info,
<GEOM>
FROM <TABLE>
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'))
Markdown is supported
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