mirror of
https://forge.chapril.org/tykayn/wololo
synced 2025-10-09 17:02:46 +02:00
up plaques mapping
This commit is contained in:
parent
c9ecd31302
commit
e33aecb565
3 changed files with 74 additions and 25 deletions
|
@ -25,17 +25,36 @@ const MappingPlaquesCommémorativesParis: MappingConfigType = {
|
||||||
add_not_mapped_tags_too: false,
|
add_not_mapped_tags_too: false,
|
||||||
boolean_keys: [],
|
boolean_keys: [],
|
||||||
tags_to_ignore_if_value_is: ['Non renseigne', 'null'],
|
tags_to_ignore_if_value_is: ['Non renseigne', 'null'],
|
||||||
|
// allow_unspecified_conditional_values: false,
|
||||||
tags: {
|
tags: {
|
||||||
|
|
||||||
"index_plaque": "ref:FR:Paris:plaques",
|
"index_plaque": "ref:FR:Paris:plaques",
|
||||||
// "retranscription": "inscription",
|
"retranscription": "inscription",
|
||||||
"materiau": {
|
"materiau": {
|
||||||
key_converted: "material",
|
key_converted: "material",
|
||||||
// remove_original_key: true,
|
// remove_original_key: true,
|
||||||
conditional_values: {
|
conditional_values: {
|
||||||
|
"comblanchien": {
|
||||||
|
value_converted: "stone",
|
||||||
|
tags_to_add: [{ "color": "white" }]
|
||||||
|
},
|
||||||
|
"bronze": {
|
||||||
|
value_converted: "metal",
|
||||||
|
// tags_to_add: [{ "color": "orange" }]
|
||||||
|
},
|
||||||
|
"Méthacrylate": {
|
||||||
|
value_converted: "plastic"
|
||||||
|
},
|
||||||
|
|
||||||
|
"granit": {
|
||||||
|
value_converted: "stone"
|
||||||
|
},
|
||||||
"pierre": {
|
"pierre": {
|
||||||
value_converted: "stone"
|
value_converted: "stone"
|
||||||
},
|
},
|
||||||
|
"Pierre": {
|
||||||
|
value_converted: "stone"
|
||||||
|
},
|
||||||
"pierre blanche": {
|
"pierre blanche": {
|
||||||
value_converted: "stone"
|
value_converted: "stone"
|
||||||
},
|
},
|
||||||
|
@ -48,8 +67,18 @@ const MappingPlaquesCommémorativesParis: MappingConfigType = {
|
||||||
"marbre fonc\u00e9": {
|
"marbre fonc\u00e9": {
|
||||||
value_converted: "marbre"
|
value_converted: "marbre"
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"marbre gris": {
|
||||||
|
value_converted: "marbre",
|
||||||
|
tags_to_add: [{ "color": "grey" }]
|
||||||
|
},
|
||||||
"marbre clair": {
|
"marbre clair": {
|
||||||
value_converted: "marbre"
|
value_converted: "marbre",
|
||||||
|
tags_to_add: [{ "color": "white" }]
|
||||||
|
},
|
||||||
|
"marbre rose": {
|
||||||
|
value_converted: "marbre",
|
||||||
|
tags_to_add: [{ "color": "pink" }]
|
||||||
},
|
},
|
||||||
"cuivre": {
|
"cuivre": {
|
||||||
value_converted: "copper"
|
value_converted: "copper"
|
||||||
|
@ -57,6 +86,9 @@ const MappingPlaquesCommémorativesParis: MappingConfigType = {
|
||||||
"métal": {
|
"métal": {
|
||||||
value_converted: "metal"
|
value_converted: "metal"
|
||||||
},
|
},
|
||||||
|
"fonte": {
|
||||||
|
value_converted: "metal"
|
||||||
|
},
|
||||||
"plexiglas transparent": {
|
"plexiglas transparent": {
|
||||||
value_converted: "glass"
|
value_converted: "glass"
|
||||||
},
|
},
|
||||||
|
@ -72,10 +104,20 @@ const MappingPlaquesCommémorativesParis: MappingConfigType = {
|
||||||
"céramique": {
|
"céramique": {
|
||||||
value_converted: "ceramic"
|
value_converted: "ceramic"
|
||||||
},
|
},
|
||||||
|
"résine": {
|
||||||
|
value_converted: "resin"
|
||||||
|
},
|
||||||
|
"acier": {
|
||||||
|
value_converted: "steel"
|
||||||
|
},
|
||||||
|
"Marbre": {
|
||||||
|
value_converted: "marbre"
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// "titre": "name",
|
"titre": "name",
|
||||||
// "personnalite": "subject",
|
// "personnalite": "subject",
|
||||||
// -----------------------------------------
|
// -----------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -423,57 +423,63 @@ export default class MappingEngine {
|
||||||
debugLog('truncate_enums_to_limit => ', convertedValue)
|
debugLog('truncate_enums_to_limit => ', convertedValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
let conditionnalConfig: any = ''
|
let conditionalConfig: any = ''
|
||||||
/**
|
/**
|
||||||
* config pour une clé
|
* config pour une clé
|
||||||
* nous pouvons renseigner une string ou un objet décrivant les transformations à réaliser
|
* nous pouvons renseigner une string ou un objet décrivant les transformations à réaliser
|
||||||
*/
|
*/
|
||||||
if (configObject.conditional_values) {
|
if (configObject.conditional_values) {
|
||||||
// console.log('configObject.conditional_values', configObject.conditional_values)
|
|
||||||
|
|
||||||
|
|
||||||
// convert numbers from json to string to compare them correctly
|
// convert numbers from json to string to compare them correctly
|
||||||
originalValue = '' + originalValue
|
originalValue = '' + originalValue
|
||||||
|
|
||||||
let keysConditionnalValues: any = Object.keys(configObject.conditional_values)
|
let keysConditionnalValues: any = Object.keys(configObject.conditional_values)
|
||||||
let isFoundValue = keysConditionnalValues.indexOf(originalValue)
|
let foundValue = keysConditionnalValues.indexOf(originalValue)
|
||||||
conditionnalConfig = configObject.conditional_values[keysConditionnalValues[isFoundValue]]
|
conditionalConfig = configObject.conditional_values[keysConditionnalValues[foundValue]]
|
||||||
|
|
||||||
|
// par défaut on retire les valeurs qui ne sont pas dans la liste des valeurs conditionnelles
|
||||||
|
// sauf si on a activé l'option allow_unspecified_conditional_values dans la MappingConfigType
|
||||||
|
if (!this.mapping_config.allow_unspecified_conditional_values && foundValue === -1) {
|
||||||
|
|
||||||
|
// console.log('(x) => ignore', originalValue, ' in ', pointKeyName)
|
||||||
|
remove_original_key = true
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!remove_original_key) {
|
if (!remove_original_key) {
|
||||||
|
|
||||||
|
|
||||||
if (isFoundValue !== -1) {
|
if (foundValue !== -1) {
|
||||||
debugLog('found condition', isFoundValue)
|
debugLog('found condition', foundValue)
|
||||||
|
|
||||||
/** ----------------------
|
/** ----------------------
|
||||||
* gestion des valeurs conditionnelles
|
* gestion des valeurs conditionnelles
|
||||||
* ---------------------- */
|
* ---------------------- */
|
||||||
debugLog('conditionnalConfig', conditionnalConfig)
|
debugLog('conditionnalConfig', conditionalConfig)
|
||||||
|
|
||||||
|
|
||||||
if (conditionnalConfig.ignore_this_data) {
|
if (conditionalConfig.ignore_this_data) {
|
||||||
debugLog(`on ignore cette clé car sa valeur "${originalValue}" est à exclure: `, pointKeyName, '=>', newKey)
|
debugLog(`on ignore cette clé car sa valeur "${originalValue}" est à exclure: `, pointKeyName, '=>', newKey)
|
||||||
remove_original_key = true;
|
remove_original_key = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (conditionnalConfig.truthy_value) {
|
if (conditionalConfig.truthy_value) {
|
||||||
// convertir la valeur, si elle est truthy, la transformer en ce que donne la propriété truthy_value
|
// convertir la valeur, si elle est truthy, la transformer en ce que donne la propriété truthy_value
|
||||||
// exemple: le jeu de données dit que la colonne cable_t2_attache vaut "True", mais on veut le convertir en "1".
|
// exemple: le jeu de données dit que la colonne cable_t2_attache vaut "True", mais on veut le convertir en "1".
|
||||||
// on met donc truthy_value: '1'
|
// on met donc truthy_value: '1'
|
||||||
if (custom_utils.truthyValues.indexOf(originalValue) !== -1) {
|
if (custom_utils.truthyValues.indexOf(originalValue) !== -1) {
|
||||||
convertedValue = conditionnalConfig.truthy_value
|
convertedValue = conditionalConfig.truthy_value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (conditionnalConfig.falsy_value) {
|
if (conditionalConfig.falsy_value) {
|
||||||
if (custom_utils.falsyValues.indexOf(originalValue) !== -1) {
|
if (custom_utils.falsyValues.indexOf(originalValue) !== -1) {
|
||||||
convertedValue = conditionnalConfig.falsy_value
|
convertedValue = conditionalConfig.falsy_value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// use the value converted
|
// use the value converted
|
||||||
else if (conditionnalConfig.value_converted) {
|
else if (conditionalConfig.value_converted) {
|
||||||
convertedValue = conditionnalConfig.value_converted
|
convertedValue = conditionalConfig.value_converted
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -482,15 +488,15 @@ export default class MappingEngine {
|
||||||
|
|
||||||
}
|
}
|
||||||
// console.log('convertedValue =>', convertedValue)
|
// console.log('convertedValue =>', convertedValue)
|
||||||
if (conditionnalConfig?.tags_to_add) {
|
if (conditionalConfig?.tags_to_add) {
|
||||||
debugLog('on ajoute des tags', conditionnalConfig.tags_to_add)
|
debugLog('on ajoute des tags', conditionalConfig.tags_to_add)
|
||||||
// on peut définir un ensemble de tags à rajouter
|
// on peut définir un ensemble de tags à rajouter
|
||||||
let tagKeys = Object.keys(conditionnalConfig.tags_to_add)
|
let tagKeys = Object.keys(conditionalConfig.tags_to_add)
|
||||||
debugLog('conditionnalConfig.tags_to_add', conditionnalConfig.tags_to_add)
|
debugLog('conditionnalConfig.tags_to_add', conditionalConfig.tags_to_add)
|
||||||
tagKeys.forEach((index: any) => {
|
tagKeys.forEach((index: any) => {
|
||||||
debugLog('key', index)
|
debugLog('key', index)
|
||||||
debugLog('value', conditionnalConfig.tags_to_add[index])
|
debugLog('value', conditionalConfig.tags_to_add[index])
|
||||||
newProperties[index] = conditionnalConfig.tags_to_add[index]
|
newProperties[index] = conditionalConfig.tags_to_add[index]
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,7 @@ export default interface MappingConfigType {
|
||||||
default_properties_of_point?: object, // tag to add to every converted point by default
|
default_properties_of_point?: object, // tag to add to every converted point by default
|
||||||
source: sourceConfig,
|
source: sourceConfig,
|
||||||
filters?: filteringConfig,
|
filters?: filteringConfig,
|
||||||
|
allow_unspecified_conditional_values?: boolean, // by default, we do not add tags from properties that we do not specify in conditional_values, set this to true to change it
|
||||||
tags: FeaturePropertyMappingConfigType
|
tags: FeaturePropertyMappingConfigType
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +78,7 @@ export interface FeaturePropertyMappingConfigType {
|
||||||
truncate_enums_to_limit?: number,
|
truncate_enums_to_limit?: number,
|
||||||
conditional_values?: ConditionnalValuesConfigType,
|
conditional_values?: ConditionnalValuesConfigType,
|
||||||
transform_function?: Function,
|
transform_function?: Function,
|
||||||
keep_only_max_in_enum?:boolean,
|
keep_only_max_in_enum?: boolean,
|
||||||
|
|
||||||
[key: string]: any,
|
[key: string]: any,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue