From 092798f4b122cee8757bcdcf137fba26a5fc7e3b Mon Sep 17 00:00:00 2001 From: Tykayn Date: Sat, 5 Aug 2023 12:05:52 +0200 Subject: [PATCH] convert from engine simple values --- mapping_geojson_to_osm_tags/mappings/engine.ts | 16 +++++++++------- mapping_geojson_to_osm_tags/mappings/utils.ts | 4 ++-- .../output/my_converted_data_set.json | 3 ++- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/mapping_geojson_to_osm_tags/mappings/engine.ts b/mapping_geojson_to_osm_tags/mappings/engine.ts index 3c5da5c9..e47989a8 100644 --- a/mapping_geojson_to_osm_tags/mappings/engine.ts +++ b/mapping_geojson_to_osm_tags/mappings/engine.ts @@ -73,7 +73,7 @@ export default class { // } filterFeaturesByPropertyRegex(propertyName: string, criteriaRegex: any, listOfFeatures: any) { - let filteredList = listOfFeatures.filter((feature:any) => { + let filteredList = listOfFeatures.filter((feature: any) => { return criteriaRegex.test(feature?.properties[propertyName]) }) return filteredList @@ -126,18 +126,20 @@ export default class { */ convertProperty(pointKeyName: string, mappingKeys: any, featurePoint: any, newProperties: any) { debugLog('convertProperty: pointKeyName', pointKeyName) - debugLog('convertProperty: mappingKeys', mappingKeys) - if (mappingKeys.indexOf(pointKeyName) !== -1) { - debugLog('convertProperty: found element', pointKeyName, '=>', this.mapping_config[pointKeyName], 'value : ', featurePoint.properties[pointKeyName]) + // debugLog('convertProperty: mappingKeys', mappingKeys) + if (mappingKeys.indexOf(pointKeyName) > 0) { + let valueConvertedFromMapping = featurePoint.properties[pointKeyName] + let keyConvertedFromMapping = mappingKeys[mappingKeys.indexOf(pointKeyName)] + + debugLog('convertProperty: found element', pointKeyName, '=>', keyConvertedFromMapping, 'value : ', valueConvertedFromMapping) let convertedValue = '' - let valueConvertedFromMapping = featurePoint.properties[pointKeyName] let typeofValue = typeof valueConvertedFromMapping let isStringValue = typeofValue === 'string' debugLog('convertProperty: - typeofValue', typeofValue) debugLog('convertProperty: - pointKeyName', pointKeyName) debugLog('convertProperty: - valueConvertedFromMapping', valueConvertedFromMapping) - // debugLog('typeof featurePoint.properties[pointKeyName] === \'string\'', typeofValue) + debugLog('typeof valueConvertedFromMapping === \'string\'', typeofValue) let isConfigMappingObject = typeofValue === 'string' @@ -154,7 +156,7 @@ export default class { } debugLog('convertProperty: -- convertedValue', convertedValue) if (convertedValue) { - newProperties[this.mapping_config[pointKeyName]] = convertedValue + newProperties[keyConvertedFromMapping] = convertedValue } } else if (isConfigMappingObject) { debugLog('convertProperty: is config object') diff --git a/mapping_geojson_to_osm_tags/mappings/utils.ts b/mapping_geojson_to_osm_tags/mappings/utils.ts index ab92e29a..42752810 100644 --- a/mapping_geojson_to_osm_tags/mappings/utils.ts +++ b/mapping_geojson_to_osm_tags/mappings/utils.ts @@ -1,7 +1,7 @@ import fs from 'fs' let show_debug = 0 -// show_debug = 1 +show_debug = 1 let output_folder = 'output'; console.log('----------------------show_debug', show_debug) @@ -12,7 +12,7 @@ console.log('----------------------show_debug', show_debug) */ function debugLog(...args: any[]) { if (show_debug) { - // console.log('### debug: ', ...args) + console.log('### debug: ', ...args) } } diff --git a/mapping_geojson_to_osm_tags/output/my_converted_data_set.json b/mapping_geojson_to_osm_tags/output/my_converted_data_set.json index 3cc3a6de..930265bb 100644 --- a/mapping_geojson_to_osm_tags/output/my_converted_data_set.json +++ b/mapping_geojson_to_osm_tags/output/my_converted_data_set.json @@ -11,7 +11,8 @@ ] }, "properties": { - "undefined": "891624884" + "nom_amenageur": "ELECTRA", + "siren_amenageur": "891624884" } } ]