Add support for work Opendata in Hauts-de-Seine
This commit is contained in:
parent
f6cb9a3bc0
commit
f2e6091402
@ -2,6 +2,7 @@
|
|||||||
"""
|
"""
|
||||||
Import French opendata about works on roads.
|
Import French opendata about works on roads.
|
||||||
"""
|
"""
|
||||||
|
import datetime
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
@ -35,6 +36,51 @@ logging.basicConfig(level=level)
|
|||||||
REPORT_DOWNVOTES_THRESHOLD = 1
|
REPORT_DOWNVOTES_THRESHOLD = 1
|
||||||
|
|
||||||
|
|
||||||
|
def preprocess_hauts_de_seine(data):
|
||||||
|
out = []
|
||||||
|
for item in data:
|
||||||
|
try:
|
||||||
|
fields = item['fields']
|
||||||
|
new_item = {
|
||||||
|
'fields': fields,
|
||||||
|
'geometry': {
|
||||||
|
'type': 'Point',
|
||||||
|
# Use lng, lat
|
||||||
|
'coordinates': fields['geo_point_2d'][::-1]
|
||||||
|
},
|
||||||
|
'recordid': item['recordid'],
|
||||||
|
'source': 'opendata-hauts-de-seine'
|
||||||
|
}
|
||||||
|
new_fields = new_item['fields']
|
||||||
|
# Guess start date / end date
|
||||||
|
# If the item is in the data, it should be valid for the current
|
||||||
|
# trimester.
|
||||||
|
now = datetime.datetime.now()
|
||||||
|
new_fields['date_debut'] = arrow.get(
|
||||||
|
datetime.datetime(
|
||||||
|
now.year,
|
||||||
|
(now.month // 3) * 3,
|
||||||
|
1
|
||||||
|
)
|
||||||
|
).isoformat()
|
||||||
|
new_fields['date_fin'] = arrow.get(
|
||||||
|
datetime.datetime(
|
||||||
|
now.year,
|
||||||
|
(now.month // 3 + 1) * 3,
|
||||||
|
1
|
||||||
|
)
|
||||||
|
).isoformat()
|
||||||
|
out.append(new_item)
|
||||||
|
except KeyError as exc:
|
||||||
|
logging.warning(
|
||||||
|
'Invalid item %s in Lille data: %s.',
|
||||||
|
item.get('recordid', '?'),
|
||||||
|
exc
|
||||||
|
)
|
||||||
|
continue
|
||||||
|
return out
|
||||||
|
|
||||||
|
|
||||||
def preprocess_lille(data):
|
def preprocess_lille(data):
|
||||||
out = []
|
out = []
|
||||||
for item in data:
|
for item in data:
|
||||||
@ -406,11 +452,17 @@ def preprocess_versailles(data):
|
|||||||
|
|
||||||
MIN_DISTANCE_REPORT_DETAILS = 40 # Distance in meters, same as in constants.js
|
MIN_DISTANCE_REPORT_DETAILS = 40 # Distance in meters, same as in constants.js
|
||||||
OPENDATA_URLS = {
|
OPENDATA_URLS = {
|
||||||
|
# Work in Hauts de Seine
|
||||||
|
# https://opendata.hauts-de-seine.fr/explore/dataset/travaux-sur-la-voirie-departementale-lignes/information/
|
||||||
|
# Licence Ouverte (Etalab) : https://www.etalab.gouv.fr/wp-content/uploads/2014/05/Licence_Ouverte.pdf
|
||||||
|
"hauts-de-seine": {
|
||||||
|
"preprocess": preprocess_hauts_de_seine,
|
||||||
|
"url": "https://opendata.hauts-de-seine.fr/explore/dataset/travaux-sur-la-voirie-departementale-lignes/download/?format=json&timezone=Europe/Berlin",
|
||||||
|
},
|
||||||
# Work in Lille
|
# Work in Lille
|
||||||
# https://opendata.lillemetropole.fr/explore/dataset/troncons-de-voirie-impactes-par-des-travaux-en-temps-reel/
|
# https://opendata.lillemetropole.fr/explore/dataset/troncons-de-voirie-impactes-par-des-travaux-en-temps-reel/
|
||||||
# Licence Ouverte (Etalab) : https://www.etalab.gouv.fr/wp-content/uploads/2014/05/Licence_Ouverte.pdf
|
# Licence Ouverte (Etalab) : https://www.etalab.gouv.fr/wp-content/uploads/2014/05/Licence_Ouverte.pdf
|
||||||
"lille": {
|
"lille": {
|
||||||
# https://opendata.lillemetropole.fr/explore/dataset/carrefours-de-voirie-impactes-par-des-travaux-temps-reel/information/
|
|
||||||
"preprocess": preprocess_lille,
|
"preprocess": preprocess_lille,
|
||||||
"url": "https://opendata.lillemetropole.fr/explore/dataset/troncons-de-voirie-impactes-par-des-travaux-en-temps-reel/download/?format=json&timezone=Europe/Berlin"
|
"url": "https://opendata.lillemetropole.fr/explore/dataset/troncons-de-voirie-impactes-par-des-travaux-en-temps-reel/download/?format=json&timezone=Europe/Berlin"
|
||||||
},
|
},
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
"availableReportsTitle": "The available reports so far are:",
|
"availableReportsTitle": "The available reports so far are:",
|
||||||
"lastReportAdded": "Last report added {fromNow}.",
|
"lastReportAdded": "Last report added {fromNow}.",
|
||||||
"license": "License",
|
"license": "License",
|
||||||
"licenseDescription": "It is released under an <a href=\"https://opensource.org/licenses/MIT\">MIT license</a> (<a href=\"https://framagit.org/phyks/cyclassist\">source code</a>). Icons are based on creations from Wikimedia, Vecteezy, Pixabay or Flaticon. Sounds are based on CC0 works from <a href=\"https://freesound.org/\">freesound.org</a>. The map background is using tiles from <a href=\"https://carto.com/location-data-services/basemaps/\">Carto.com</a> or <a href=\"http://thunderforest.com/\">Thunderforest</a>, thanks to <a href=\"https://www.openstreetmap.org/copyright\">OpenStreetMap contributors</a> and <a href=\"http://leafletjs.com/\">Leaflet</a>. Collected reports are available under <a href=\"https://opendatacommons.org/licenses/odbl/\">ODbL license</a>. Manual location picking uses the awesome API from <a href=\"https://adresse.data.gouv.fr\">adresse.data.gouv.fr</a>. Opendata about current roadworks are imported from Lille, Lyon, Nancy, the Département de Seine-Saint-Denis, Sicoval and Versailles (all available under Etalab Licence Ouverte) as well as from Montpellier, Paris, Rennes and Toulouse (all available under ODbL license) and from the Département du Loiret. All opendata sources are fetched daily. More info about the licenses can be found in <a href=\"https://framagit.org/phyks/cyclassist/blob/master/README.md#license\">the README</a>.",
|
"licenseDescription": "It is released under an <a href=\"https://opensource.org/licenses/MIT\">MIT license</a> (<a href=\"https://framagit.org/phyks/cyclassist\">source code</a>). Icons are based on creations from Wikimedia, Vecteezy, Pixabay or Flaticon. Sounds are based on CC0 works from <a href=\"https://freesound.org/\">freesound.org</a>. The map background is using tiles from <a href=\"https://carto.com/location-data-services/basemaps/\">Carto.com</a> or <a href=\"http://thunderforest.com/\">Thunderforest</a>, thanks to <a href=\"https://www.openstreetmap.org/copyright\">OpenStreetMap contributors</a> and <a href=\"http://leafletjs.com/\">Leaflet</a>. Collected reports are available under <a href=\"https://opendatacommons.org/licenses/odbl/\">ODbL license</a>. Manual location picking uses the awesome API from <a href=\"https://adresse.data.gouv.fr\">adresse.data.gouv.fr</a>. Opendata about current roadworks are imported from the Département des Hauts-de-Seine, Lille, Lyon, Nancy, the Département de Seine-Saint-Denis, Sicoval and Versailles (all available under Etalab Licence Ouverte) as well as from Montpellier, Paris, Rennes and Toulouse (all available under ODbL license) and from the Département du Loiret. All opendata sources are fetched daily. More info about the licenses can be found in <a href=\"https://framagit.org/phyks/cyclassist/blob/master/README.md#license\">the README</a>.",
|
||||||
"nbActiveReports": "No active report. |\u00a0One active report. | {nbActiveReports} active reports.",
|
"nbActiveReports": "No active report. |\u00a0One active report. | {nbActiveReports} active reports.",
|
||||||
"nbReports": "No report. | One report. | {nbReports} reports.",
|
"nbReports": "No report. | One report. | {nbReports} reports.",
|
||||||
"stats": "Stats",
|
"stats": "Stats",
|
||||||
|
Loading…
Reference in New Issue
Block a user