convert to yes no values boolean fields
This commit is contained in:
parent
bfb59df09c
commit
9eaef4dbf9
|
@ -17,16 +17,15 @@ let boundingBoxCoordinates = {
|
|||
}
|
||||
|
||||
let filterCoordinates = true
|
||||
let enableFilterOnDepartment = false
|
||||
let filterDepartment = 91
|
||||
let enableFilterOnDepartment = true
|
||||
let filterDepartment = 974
|
||||
let filterZipCode = new RegExp(`^${filterDepartment}`)
|
||||
let filterZipCodeAdresse = new RegExp(` ${filterDepartment}`)
|
||||
let filteredName = ''
|
||||
|
||||
if (enableFilterOnDepartment) {
|
||||
filteredName = '_filtered_zipcode_' + filterDepartment
|
||||
}
|
||||
if (filterOnBoundingBox) {
|
||||
} else if (filterOnBoundingBox) {
|
||||
filteredName = '_filtered_bbox_' + boundingBoxCoordinates.xMin + '-' + boundingBoxCoordinates.xMax + '_' + boundingBoxCoordinates.yMin + '-' + boundingBoxCoordinates.yMax
|
||||
}
|
||||
let pointCounterMax = 1000000
|
||||
|
@ -39,12 +38,18 @@ if (limitConversionToFirstPoint) {
|
|||
|
||||
// let sourceFileChargemapJson = './chargemap_data/hurepoix.json'
|
||||
let sourceFileIRVEGeoJson = './etalab_data/latest.json'
|
||||
let defaultPropertiesOfPoint = {
|
||||
'amenity': 'charging_station'
|
||||
}
|
||||
/**
|
||||
* plan de conversion des clés du jeu de données vers les tags OSM
|
||||
* détail dans le tableau
|
||||
* https://wiki.openstreetmap.org/wiki/France/data.gouv.fr/Bornes_de_Recharge_pour_V%C3%A9hicules_%C3%89lectriques
|
||||
*/
|
||||
let mappingConfigIRVE = {
|
||||
// ******* nombres
|
||||
nbre_pdc: 'capacity',
|
||||
// ******* textes
|
||||
amenity: 'amenity', // conserver le tag de base
|
||||
capacity: 'capacity', // conserver le tag de base
|
||||
nom_amenageur: 'operator',
|
||||
|
@ -52,26 +57,36 @@ let mappingConfigIRVE = {
|
|||
nom_operateur: 'operator',
|
||||
telephone_operateur: 'phone',
|
||||
contact_operateur: 'email', // ici, on souhaite convertir la clé contact_operateur=bidule en email=bidule
|
||||
nbre_pdc: 'capacity',
|
||||
|
||||
id_station_itinerance: 'ref:EU:EVSE',
|
||||
id_station_local: 'ref',
|
||||
|
||||
gratuit: 'fee',
|
||||
paiement_acte: 'authentication:none',
|
||||
|
||||
reservation: 'reservation',
|
||||
observations: 'note',
|
||||
nom_station: 'name',
|
||||
nom_enseigne: 'network',
|
||||
|
||||
// ******* dates
|
||||
date_mise_en_service: 'start_date',
|
||||
date_maj: 'source:date',
|
||||
|
||||
// TODO gestion des types dont on doit convertir la valeur
|
||||
// ******** champs booléens
|
||||
cable_t2_attache: 'socket:type2_cable',
|
||||
prise_type_ef: 'socket:typee',
|
||||
prise_type_2: 'socket:type2',
|
||||
prise_type_combo_ccs: 'socket:type2_combo',
|
||||
prise_type_chademo: 'socket:chademo',
|
||||
gratuit: 'fee',
|
||||
paiement_acte: 'authentication:none',
|
||||
paiement_cb: 'payment:credit_cards',
|
||||
reservation: 'reservation',
|
||||
accessibilite_pmr: 'wheelchair',
|
||||
date_mise_en_service: 'start_date',
|
||||
observations: 'note',
|
||||
date_maj: 'source:date',
|
||||
nom_station: 'name',
|
||||
nom_enseigne: 'network',
|
||||
cable_t2_attache: 'socket:type2_cable',
|
||||
|
||||
// TODO gestion des types dont on doit convertir la valeur
|
||||
// ******** champs plus complexes
|
||||
horaires: 'opening_hours', // déjà au bon format
|
||||
|
||||
// accessibilite_pmr: 'wheelchair',
|
||||
// paiement_cb: 'payment:credit_cards',
|
||||
|
||||
// station_deux_roues =>
|
||||
// ajout de trois tags:
|
||||
// bicycle=yes
|
||||
|
@ -80,6 +95,16 @@ let mappingConfigIRVE = {
|
|||
|
||||
// consolidated_code_postal: "zipcode",
|
||||
}
|
||||
let listOfBooleanKeys = Object.keys({
|
||||
prise_type_ef: 'socket:typee',
|
||||
prise_type_2: 'socket:type2',
|
||||
prise_type_combo_ccs: 'socket:type2_combo',
|
||||
prise_type_chademo: 'socket:chademo',
|
||||
gratuit: 'fee',
|
||||
paiement_acte: 'authentication:none',
|
||||
paiement_cb: 'payment:credit_cards',
|
||||
cable_t2_attache: 'socket:type2_cable',
|
||||
})
|
||||
|
||||
function debugLog (message) {
|
||||
if (!show_debug) {
|
||||
|
@ -179,6 +204,11 @@ function convertDataForIRVE (sourceFilePath, mapping, pointCounterMax, boundingB
|
|||
})
|
||||
}
|
||||
|
||||
function isBooleanKey (pointKeyName) {
|
||||
|
||||
return listOfBooleanKeys.indexOf(pointKeyName) !== -1
|
||||
}
|
||||
|
||||
/**
|
||||
* retuns the converted element from mapping config if present, null otherwise
|
||||
*/
|
||||
|
@ -189,7 +219,7 @@ function mapElementFromConf (featurePoint, mappingConfig) {
|
|||
|
||||
debugLog('keys', mappingKeys, featurePointPropertiesKeys)
|
||||
|
||||
let newProperties = {}
|
||||
let newProperties = defaultPropertiesOfPoint
|
||||
|
||||
// reinit properties of current point
|
||||
let basePoint = Object.create(featurePoint)
|
||||
|
@ -202,7 +232,17 @@ function mapElementFromConf (featurePoint, mappingConfig) {
|
|||
|
||||
if (mappingKeys.indexOf(pointKeyName) !== -1) {
|
||||
debugLog('found element', pointKeyName, '=>', mappingConfig[pointKeyName], 'value : ', featurePoint.properties[pointKeyName])
|
||||
newProperties[mappingConfig[pointKeyName]] = featurePoint.properties[pointKeyName]
|
||||
let convertedValue = ''
|
||||
if (isBooleanKey(pointKeyName)) {
|
||||
|
||||
convertedValue = featurePoint.properties[pointKeyName].toLowerCase() == 'true' ? 'yes' : 'no'
|
||||
} else {
|
||||
convertedValue = featurePoint.properties[pointKeyName]
|
||||
}
|
||||
|
||||
if (convertedValue) {
|
||||
newProperties[mappingConfig[pointKeyName]] = convertedValue
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue