add config plaques commémoratives

This commit is contained in:
Tykayn 2025-04-17 17:34:39 +02:00 committed by tykayn
parent 2956a3ffee
commit c9ecd31302
14 changed files with 536 additions and 166 deletions

View file

@ -24,7 +24,7 @@ const MappingIRVE: MappingConfigType = {
enable_properties_filter: true,
// filter_points_older_than_year: 2024,
// filter_points_by_year_property: 'date_mise_en_service',
// filter_points_lesser_than_NkW: 50 // ne pas sortir les points qui ont moins de ce nombre de puissance nominale
// filter_points_lesser_than_NkW: 50 // ne pas sortir les points qui ont moins de ce nombre de puissance nominale
// add only geojson points who are found having this regex in the zipcode properties
// properties: {
// consolidated_code_postal: '^[76|27]'
@ -36,7 +36,10 @@ const MappingIRVE: MappingConfigType = {
add_not_mapped_tags_too: false,
boolean_keys: [
"prise_type_ef",
"prise_type_e",
"prise_type2",
"prise_type_2",
"prise_type_3",
"prise_type_combo_ccs",
"prise_type_chademo",
"gratuit",

View file

@ -0,0 +1,86 @@
/**
* Plaques commémoratives de Paris
*
* npx ts-node convert_to_osm_tags.ts --engine-config=MappingPlaquesCommémorativesParis --source=./etalab_data/plaques_commémoratives/plaques_commemoratives.geojson
*/
import MappingConfigType from "../mapping-config.type";
const MappingPlaquesCommémorativesParis: MappingConfigType = {
config_name: "MappingPlaquesCommémorativesParis",
config_author: "tykayn",
default_properties_of_point: {
// Ajoutez ici les propriétés par défaut pour vos points
"memorial": "plaque",
"historic": "memorial",
},
source: {
geojson_path: '',
url: ''
},
filters: {
// exclude_point_if_tag_not_empty: ['id_osm'], // exclure les points ayant déjà un id_osm pour éviter les doublons
// offset: 10
},
add_not_mapped_tags_too: false,
boolean_keys: [],
tags_to_ignore_if_value_is: ['Non renseigne', 'null'],
tags: {
"index_plaque": "ref:FR:Paris:plaques",
// "retranscription": "inscription",
"materiau": {
key_converted: "material",
// remove_original_key: true,
conditional_values: {
"pierre": {
value_converted: "stone"
},
"pierre blanche": {
value_converted: "stone"
},
"pierre beige": {
value_converted: "stone"
},
"marbre": {
value_converted: "marbre"
},
"marbre fonc\u00e9": {
value_converted: "marbre"
},
"marbre clair": {
value_converted: "marbre"
},
"cuivre": {
value_converted: "copper"
},
"métal": {
value_converted: "metal"
},
"plexiglas transparent": {
value_converted: "glass"
},
"plexiglas opaque": {
value_converted: "glass"
},
"bois": {
value_converted: "wood"
},
"verre": {
value_converted: "glass"
},
"céramique": {
value_converted: "ceramic"
},
}
},
// "titre": "name",
// "personnalite": "subject",
// -----------------------------------------
}
}
export default MappingPlaquesCommémorativesParis;

View file

@ -175,8 +175,7 @@ export default class MappingEngine {
}
debugLog('mapElementFromConf: ============= keys mappingKeys:', this.mapping_config.tags.length, mappingKeys.length)
debugLog('mapElementFromConf: ============= keys featurePointPropertiesKeys :', featurePoint.properties.length, featurePointPropertiesKeys.length)
// console.log('mapElementFromConf: ============= keys mappingKeys:', featurePointPropertiesKeys.length, mappingKeys)
let newProperties = { ...this.mapping_config.default_properties_of_point }
@ -187,15 +186,16 @@ export default class MappingEngine {
basePoint.geometry = featurePoint.geometry
basePoint.properties = { ...this.mapping_config.default_properties_of_point }
// apply new properties if found in mapping config
featurePointPropertiesKeys.forEach(pointKeyName => {
debugLog('mapElementFromConf: convert', pointKeyName)
debugLog('mapElementFromConf: mapping keys:', mappingKeys)
// if (featurePointPropertiesKeys.indexOf(pointKeyName) !== -1) {
this.convertProperty({
pointKeyName, mappingKeys, featurePoint, newProperties
})
// }
})
@ -270,7 +270,7 @@ export default class MappingEngine {
/**
* only use existing keys
*/
debugLog("only use existing keys,", pointKeyName)
// console.log("only use existing keys,", pointKeyName)
if (mappingKeys.indexOf(pointKeyName) !== -1) {
let valueConvertedFromMapping = featurePoint.properties[pointKeyName]
let keyConvertedFromMapping = mappingKeys[mappingKeys.indexOf(pointKeyName)]
@ -282,6 +282,7 @@ export default class MappingEngine {
let convertedValue = originalValue
let typeOfConfigForKey = typeof mappingConfigOfTag
// console.log('typeOfConfigForKey', typeOfConfigForKey)
let isStringValue = typeOfConfigForKey === 'string'
let isConfigMappingObject = typeOfConfigForKey === 'object'
@ -321,7 +322,7 @@ export default class MappingEngine {
if (isConfigMappingObject) {
debugLog('convertProperty: is config object', configObject)
// console.log('convertProperty: is config object', configObject)
let newKey: any = '' + pointKeyName
@ -422,11 +423,13 @@ export default class MappingEngine {
debugLog('truncate_enums_to_limit => ', convertedValue)
}
let conditionnalConfig: any = ''
/**
* config pour une clé
* nous pouvons renseigner une string ou un objet décrivant les transformations à réaliser
*/
if (configObject.conditional_values) {
// console.log('configObject.conditional_values', configObject.conditional_values)
// convert numbers from json to string to compare them correctly
@ -434,15 +437,8 @@ export default class MappingEngine {
let keysConditionnalValues: any = Object.keys(configObject.conditional_values)
let isFoundValue = keysConditionnalValues.indexOf(originalValue)
let conditionnalConfig: any = configObject.conditional_values[keysConditionnalValues[isFoundValue]]
debugLog('convertProperty: conditional_values__________',
configObject.conditional_values)
conditionnalConfig = configObject.conditional_values[keysConditionnalValues[isFoundValue]]
debugLog('isFoundValue', isFoundValue, originalValue)
debugLog('keysConditionnalValues', keysConditionnalValues)
debugLog('-----++++++++ originalValue', originalValue)
debugLog('----------- isFoundValue', isFoundValue)
if (!remove_original_key) {
@ -481,9 +477,11 @@ export default class MappingEngine {
}
}
}
// console.log('convertedValue =>', convertedValue)
if (conditionnalConfig?.tags_to_add) {
debugLog('on ajoute des tags', conditionnalConfig.tags_to_add)
// on peut définir un ensemble de tags à rajouter
@ -496,7 +494,10 @@ export default class MappingEngine {
})
}
} else {
debugLog('no conditional values', configObject)
}
// console.log('conditionnalConfig', conditionnalConfig, convertedValue)
debugLog('convertProperty: convertedValue ==========> {', newKey, ':', convertedValue, '}')
@ -511,7 +512,12 @@ export default class MappingEngine {
}
debugLog('remove_original_key && newKey && convertedValue && hasKeyIgnoreThisData', remove_original_key, newKey, convertedValue, hasKeyIgnoreThisData)
if (!remove_original_key && newKey && convertedValue && !hasKeyIgnoreThisData
// console.log('newKey && convertedValue && !hasKeyIgnoreThisData', newKey && convertedValue && !hasKeyIgnoreThisData, newKey, convertedValue, !hasKeyIgnoreThisData)
if (remove_original_key) {
delete newProperties[pointKeyName];
}
if (newKey && convertedValue && !hasKeyIgnoreThisData
) {
debugLog('convertedValue', convertedValue)
@ -520,13 +526,16 @@ export default class MappingEngine {
}
}
else {
debugLog('!!!!!! not isConfigMappingObject: ', isConfigMappingObject)
}
} else {
debugLog('!!!!!! property not found in mappingKeys: ', pointKeyName)
}
}
debugLog('newProperties', newProperties)
// console.log('pointKeyName', pointKeyName)
return newProperties;
}

View file

@ -14,7 +14,7 @@ const prefix_phone_fr_only = true
function debugLog(...args: any[]) {
if (show_debug) {
console.log('### debug: ',)
args.map((elem: any) => console.log(' ', elem))
args.map((elem: any) => console.log(' - ', elem))
}
}