improve finding keys

This commit is contained in:
Tykayn 2023-08-18 11:39:40 +02:00 committed by tykayn
parent 2cb019ff5c
commit d136015f5e
5 changed files with 13 additions and 6 deletions

View File

@ -125,7 +125,7 @@ function writeFile(fileName: string, fileContent: any) {
* @param boundingBoxCoordinates * @param boundingBoxCoordinates
*/ */
function convertDataForIRVE(sourceFilePath: string, mapping: any, pointCounterMax: number, boundingBoxCoordinates: any) { function convertDataForIRVE(sourceFilePath: string, mapping: any, pointCounterMax: number, boundingBoxCoordinates: any) {
debugLog('convertDataForIRVE from ', sourceFilePath) debugLog('convert data: source file from :', sourceFilePath)
fs.readFile(sourceFilePath, 'utf8', function (err, data) { fs.readFile(sourceFilePath, 'utf8', function (err, data) {
let point_counter = 0 let point_counter = 0

View File

@ -6,7 +6,7 @@
import MappingConfigType from "../mapping-config.type"; import MappingConfigType from "../mapping-config.type";
const MappingTest: MappingConfigType = { const MappingTest: MappingConfigType = {
config_name: 'testing config mappingSame', config_name: 'testing config MappingTest',
config_author: 'tykayn <contact@cipherbliss.com>', config_author: 'tykayn <contact@cipherbliss.com>',
default_properties_of_point: {}, default_properties_of_point: {},
tags: { tags: {

View File

@ -114,6 +114,7 @@ export default class {
featurePointPropertiesKeys.forEach(pointKeyName => { featurePointPropertiesKeys.forEach(pointKeyName => {
debugLog('mapElementFromConf: convert', pointKeyName) debugLog('mapElementFromConf: convert', pointKeyName)
debugLog('mapElementFromConf: mapping keys:', mappingKeys)
this.convertProperty(pointKeyName, mappingKeys, featurePoint, newProperties) this.convertProperty(pointKeyName, mappingKeys, featurePoint, newProperties)
}) })
@ -135,7 +136,7 @@ export default class {
let originalValue = featurePoint.properties[pointKeyName] let originalValue = featurePoint.properties[pointKeyName]
let mappingValueObject: any = ''; let mappingValueObject: any = '';
if (mappingKeys.indexOf(pointKeyName) > 0) { if (mappingKeys.indexOf(pointKeyName) !== -1) {
mappingValueObject = this.mapping_config.tags[pointKeyName] mappingValueObject = this.mapping_config.tags[pointKeyName]
debugLog('convertProperty: mappingValueObject ', mappingValueObject) debugLog('convertProperty: mappingValueObject ', mappingValueObject)
} }
@ -147,13 +148,14 @@ export default class {
/** /**
* add all unmapped tags is enabled * add all unmapped tags is enabled
*/ */
debugLog(' ------ add all unmapped tags is enabled')
newProperties[pointKeyName] = originalValue; newProperties[pointKeyName] = originalValue;
} else { } else {
/** /**
* only use existing keys * only use existing keys
*/ */
if (mappingKeys.indexOf(pointKeyName) > 0) { if (mappingKeys.indexOf(pointKeyName) !== -1) {
let valueConvertedFromMapping = featurePoint.properties[pointKeyName] let valueConvertedFromMapping = featurePoint.properties[pointKeyName]
let keyConvertedFromMapping = mappingKeys[mappingKeys.indexOf(pointKeyName)] let keyConvertedFromMapping = mappingKeys[mappingKeys.indexOf(pointKeyName)]
let mappingConfigOfTag = this.mapping_config.tags[pointKeyName] let mappingConfigOfTag = this.mapping_config.tags[pointKeyName]
@ -329,6 +331,8 @@ export default class {
newProperties[newKey] = convertedValue.trim() newProperties[newKey] = convertedValue.trim()
} }
} }
}else{
debugLog('!!!!!! property not found in mappingKeys: ', pointKeyName)
} }
} }

View File

@ -12,7 +12,8 @@ let output_folder = 'output';
*/ */
function debugLog(...args: any[]) { function debugLog(...args: any[]) {
if (show_debug) { if (show_debug) {
console.log('### debug: ', ...args) console.log('### debug: ',)
args.map((elem: any) => console.log(' ',elem))
} }
} }

View File

@ -10,7 +10,9 @@
45.635079 45.635079
] ]
}, },
"properties": {} "properties": {
"name": "Bob"
}
} }
] ]
} }