diff --git a/mapping_geojson_to_osm_tags/convert_to_osm_tags.js b/mapping_geojson_to_osm_tags/convert_to_osm_tags.js deleted file mode 100644 index c4f1c520..00000000 --- a/mapping_geojson_to_osm_tags/convert_to_osm_tags.js +++ /dev/null @@ -1,184 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -/** - * convertisseur de données de bornes de recharge électrique à partir de données Chargemap et open data Etalab - */ -var fs = require("fs"); -var minimist = require("minimist"); -var configIRVE_1 = require("./mappings/converters/configIRVE"); -var mappingConfigIRVE_simple_1 = require("./mappings/converters/mappingConfigIRVE_simple"); -var engine_1 = require("./mappings/engine"); -var utils_ts_1 = require("./mappings/utils.ts"); -var debugLog = utils_ts_1.default.debugLog; -var use_mappping_engine = false; -use_mappping_engine = true; -var Mapping_engine = new engine_1.default(configIRVE_1.default); -var mini_arguments = minimist(process.argv.slice(2)); -var sourceFilePathGeoJson = './etalab_data/small.json'; -// wip filter -var filterOnBoundingBox = true; -filterOnBoundingBox = false; -var boundingBoxCoordinates = { - xMin: 1.91, - xMax: 2.38, - yMin: 48.7, - yMax: 48.4, -}; -var filterCoordinates = true; -var enable_filter_on_department = true; -enable_filter_on_department = false; -var filterDepartment = 91; -if (mini_arguments['department']) { - filterDepartment = mini_arguments['department']; - enable_filter_on_department = true; -} -if (mini_arguments['source']) { - sourceFilePathGeoJson = mini_arguments['source']; -} -if (mini_arguments['engine']) { - use_mappping_engine = mini_arguments['engine']; -} -var filterZipCode = new RegExp("^".concat(filterDepartment)); -var filterZipCodeAdresse = new RegExp(" ".concat(filterDepartment)); -var filteredName = ''; -if (enable_filter_on_department) { - filteredName = '_filtered_zipcode_' + filterDepartment; -} -else if (filterOnBoundingBox) { - filteredName = '_filtered_bbox_' + boundingBoxCoordinates.xMin + '-' + boundingBoxCoordinates.xMax + '_' + boundingBoxCoordinates.yMin + '-' + boundingBoxCoordinates.yMax; -} -var pointCounterMax = 1000000; -var limitConversionToFirstPoint = false; -// limitConversionToFirstPoint = true -if (limitConversionToFirstPoint) { - pointCounterMax = 1; -} -var defaultPropertiesOfPoint = { - 'amenity': 'charging_station' -}; -var converted_geo_json = { - type: 'FeatureCollection', - features: [] -}; -/** - * - * @param sourceFilePath - * @param mapping - * @param pointCounterMax - * @param boundingBoxCoordinates - */ -function convertDataForIRVE(sourceFilePath, mapping, pointCounterMax, boundingBoxCoordinates) { - debugLog('convertDataFromChargemap from ', sourceFilePath); - fs.readFile(sourceFilePath, 'utf8', function (err, data) { - var point_counter = 0; - if (err) { - return debugLog(err); - } - var data_transformed = JSON.parse(data); - // debug('data keys ', Object.keys(dataTransformed)) - debugLog('debug: properties of point 0', data_transformed.features[0]); - if (data_transformed.features) { - debugLog('data found, features:', data_transformed.features.length); - // find interesting list of points to use - var list_of_points = data_transformed.features; - // for each point from the data source, convert with the mapping - console.log('listOfPoints.length', list_of_points.length); - list_of_points.forEach(function (feature_point) { - var regex_filter_test_result = true; - if (enable_filter_on_department) { - debugLog('filtre sur les départements activé'); - regex_filter_test_result = (filterZipCode.test(feature_point.properties.consolidated_code_postal) - || - filterZipCodeAdresse.test(feature_point.properties.adresse_station)); - } - else if (filterOnBoundingBox) { - debugLog('filtre sur les coordonnées activé'); - var x = feature_point.properties.coordonneesXY[0]; - var xMin = boundingBoxCoordinates.xMin; - var xMax = boundingBoxCoordinates.xMax; - var yMin = boundingBoxCoordinates.yMin; - var yMax = boundingBoxCoordinates.yMax; - var y = feature_point.properties.coordonneesXY[1]; - regex_filter_test_result = ((x >= xMin && x <= xMax) - && - (y >= yMin && y <= yMax)); - } - // filter points depending on zipcode - if (filterCoordinates && regex_filter_test_result) { - debugLog('featurePoint.properties.consolidated_code_postal', feature_point.properties.consolidated_code_postal); - // limit results number of points - // if (pointcounter < pointCounterMax) { - debugLog('add point'); - debugLog('featurePoint', feature_point); - var mapped_point = {}; - if (use_mappping_engine) { - mapped_point = Mapping_engine.mapElementFromConf(feature_point); - } - else { - mapped_point = mapElementFromConfSimple(feature_point, mapping); - } - debugLog('map one point', feature_point, mapped_point); - if (mapped_point) { - converted_geo_json.features.push(mapped_point); - } - } - // } - point_counter++; - }); - // output new geojson - console.log('convertedGeoJson.features.length', converted_geo_json.features.length); - // write file on disk - var fileNameToWrite = 'my_converted_data_set' + filteredName + '.json'; - console.log('write file ', fileNameToWrite); - utils_ts_1.default.writeFile(fileNameToWrite, JSON.stringify(converted_geo_json, null, 2)); - debugLog('mapped output:', converted_geo_json.features); - return converted_geo_json; - } - }); -} -/** - * retuns the converted element from mapping config if present, null otherwise - */ -function mapElementFromConfSimple(featurePoint, mappingConfig) { - var mappingKeys = Object.keys(mappingConfig); - var featurePointPropertiesKeys = Object.keys(featurePoint.properties); - debugLog('keys', mappingKeys, featurePointPropertiesKeys); - var newProperties = defaultPropertiesOfPoint; - // reinit properties of current point - var basePoint = Object.create(featurePoint); - basePoint.type = featurePoint.type; - basePoint.geometry = featurePoint.geometry; - basePoint.properties = newProperties; - // apply new properties if found in mapping config - featurePointPropertiesKeys.forEach(function (pointKeyName) { - if (mappingKeys.indexOf(pointKeyName) !== -1) { - debugLog('found element', pointKeyName, '=>', mappingConfig[pointKeyName], 'value : ', featurePoint.properties[pointKeyName]); - var convertedValue = ''; - if (utils_ts_1.default.isBooleanKey(pointKeyName)) { - var copyOfValue = '' + featurePoint.properties[pointKeyName]; - if (typeof copyOfValue === typeof Object && copyOfValue.key_converted) { - copyOfValue = copyOfValue.key_converted; - } - convertedValue = copyOfValue.toLowerCase() == 'true' ? 'yes' : 'no'; - } - else { - convertedValue = featurePoint.properties[pointKeyName]; - } - if (convertedValue) { - newProperties[mappingConfig[pointKeyName]] = convertedValue; - } - } - }); - debugLog('basePoint', basePoint); - return basePoint; -} -if (use_mappping_engine) { - console.log(' - using mapping engine'); - console.log(' - pointCounterMax', pointCounterMax); - Mapping_engine.setConfig(configIRVE_1.default); - convertDataForIRVE(sourceFilePathGeoJson, configIRVE_1.default, pointCounterMax, boundingBoxCoordinates); -} -else { - configIRVE_1.default = mappingConfigIRVE_simple_1.default; - convertDataForIRVE(sourceFilePathGeoJson, configIRVE_1.default, pointCounterMax, boundingBoxCoordinates); -} diff --git a/mapping_geojson_to_osm_tags/convert_to_osm_tags.ts b/mapping_geojson_to_osm_tags/convert_to_osm_tags.ts index a79c5e89..7e4292a1 100644 --- a/mapping_geojson_to_osm_tags/convert_to_osm_tags.ts +++ b/mapping_geojson_to_osm_tags/convert_to_osm_tags.ts @@ -188,12 +188,13 @@ function convertDataForIRVE(sourceFilePath: string, mapping: any, pointCounterMa /** * conversion */ - debugLog(' after filtering, number of points: ', feature_points_after_filter.length) + debugLog(' after filtering, feature_points_after_filter number of points: ', feature_points_after_filter.length) feature_points_after_filter.forEach((feature_point: any) => { // debugLog('featurePoint.properties.consolidated_code_postal', feature_point.properties.consolidated_code_postal) debugLog('convert : work on 1 point') - debugLog('featurePoint', feature_point) + debugLog('convert :featurePoint', feature_point) + console.log('convert :feature_point', feature_point) let mapped_point: any = {} if (use_mappping_engine) { diff --git a/mapping_geojson_to_osm_tags/mappings/converters/configIRVE.js b/mapping_geojson_to_osm_tags/mappings/converters/configIRVE.js deleted file mode 100644 index 3a72d400..00000000 --- a/mapping_geojson_to_osm_tags/mappings/converters/configIRVE.js +++ /dev/null @@ -1,96 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var MappingIRVE = { - config_name: "IRVE config", - config_author: "tykayn ", - default_properties_of_point: { - 'amenity': 'charging_station' - }, - tags: { - // ******* nombres - nbre_pdc: 'capacity', - // ******* textes - amenity: 'amenity', - capacity: 'capacity', - nom_amenageur: 'operator', - siren_amenageur: 'owner:ref:FR:SIREN', - nom_operateur: 'operator', - telephone_operateur: 'phone', - contact_operateur: 'email', - 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: { - key_converted: 'socket:type2_cable', - // cable_t2_attache - truthy_value: '1' - }, - prise_type_ef: 'socket:typee', - prise_type_2: 'socket:type2', - prise_type_combo_ccs: 'socket:type2_combo', - prise_type_chademo: 'socket:chademo', - // ******** champs plus complexes - horaires: 'opening_hours', - // accessibilite_pmr: 'wheelchair', - // paiement_cb: 'payment:credit_cards', - accessibilite_pmr: { - key_converted: "wheelchair", - conditional_values: { - "Accessibilité inconnue": { - // value_converted: "", - ignore_this_data: true, // ne pas ajouter de tag si la valeur est égale à Accessibilité inconnue. - // transform_function : (original_value) => original_value.toLowerCase(), - }, - "Accessible mais non réservé PMR": { - value_converted: "yes" - }, - "Réservé PMR": { - value_converted: "yes" - }, - "Non accessible": { - value_converted: "no" - }, - // "Mo-Fr 08:30-12:00,Mo-Fr 14:00-19:00,Sat 09:00-18:30": { - // value_converted: "Mo-Fr 08:30-12:00,Mo-Fr 14:00-19:00,Sat 09:00-18:30" - // }, - // "24/7": { - // value_converted: "" - // } - // choix: - // Sa:09:00-19:00 - // 24/7 - // Mo-Fr 08:00-12:00,Mo-Fr 14:00-19:00,Sat 09:00-18:00 - // Mo-Fr 08:00-19:00,Sat 09:00-18:00 - // Sa:08:00-19:00 - // 24/7 - // Mo-Fr 08:30-12:00,Mo-Fr 14:00-19:00,Sat 09:00-18:30 - // Mo-Fr 09:00-16:00 - // Mo-Fr 08:00-12:00,Mo-Fr 14:00-18:00,Th 08:00-18:00 - } - }, - station_deux_roues: { - key_converted: null, - conditional_values: { - // ajout de trois tags si la valeur est yes - "yes": { - tags_to_add: [ - { bicycle: "yes" }, - { scooter: "yes" }, - { motorcar: "no" }, - ] - } - } - } - }, -}; -exports.default = MappingIRVE; diff --git a/mapping_geojson_to_osm_tags/mappings/converters/mappingConfigIRVE_simple.js b/mapping_geojson_to_osm_tags/mappings/converters/mappingConfigIRVE_simple.js deleted file mode 100644 index ef040352..00000000 --- a/mapping_geojson_to_osm_tags/mappings/converters/mappingConfigIRVE_simple.js +++ /dev/null @@ -1,38 +0,0 @@ -"use strict"; -/** - * 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 - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var mappingIRVE = { - // ******* nombres - nbre_pdc: 'capacity', - amenity: 'amenity', - capacity: 'capacity', - nom_amenageur: 'operator', - siren_amenageur: 'owner:ref:FR:SIREN', - nom_operateur: 'operator', - telephone_operateur: 'phone', - // ici, on souhaite convertir la clé contact_operateur=bidule en email=bidule - contact_operateur: 'email', - 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', - // ******** champs booléens - prise_type_ef: 'socket:typee', - prise_type_2: 'socket:type2', - prise_type_combo_ccs: 'socket:type2_combo', - prise_type_chademo: 'socket:chademo', - // ******** champs plus complexes - horaires: 'opening_hours', // déjà au bon format -}; -exports.default = mappingIRVE; diff --git a/mapping_geojson_to_osm_tags/mappings/engine.js b/mapping_geojson_to_osm_tags/mappings/engine.js deleted file mode 100644 index bcee8340..00000000 --- a/mapping_geojson_to_osm_tags/mappings/engine.js +++ /dev/null @@ -1,183 +0,0 @@ -"use strict"; -var __assign = (this && this.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; - }; - return __assign.apply(this, arguments); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var utils_1 = require("./utils"); -var debugLog = utils_1.default.debugLog; -var listOfBooleanKeys = [ - "prise_type_ef", - "prise_type_2", - "prise_type_combo_ccs", - "prise_type_chademo", - "gratuit", - "paiement_acte", - "paiement_cb", - "cable_t2_attache" -]; -var default_1 = /** @class */ (function () { - function default_1(mappingConfig) { - this.mapping_config = {}; - this.truthyValues = ['true', 'True', 'TRUE', '1', 1]; - this.falsyValues = ['false', 'False', 'FALSE', '0', 0]; - this.setConfig(mappingConfig); - } - default_1.prototype.setConfig = function (mappingConfig) { - this.mapping_config = mappingConfig; - }; - default_1.prototype.mapFeaturePoint = function (featurePointGeoJson) { - var geoJSONConvertedPoint = {}; - geoJSONConvertedPoint.properties = __assign({}, this.mapping_config.default_properties_of_point); - geoJSONConvertedPoint.type = featurePointGeoJson.type; - geoJSONConvertedPoint.geometry = featurePointGeoJson.geometry; - var props = featurePointGeoJson.properties; - props.forEach(function (key, value) { - }); - return geoJSONConvertedPoint; - }; - /** - * TODO convert to mapping config property to transform_truthy - * @param pointKeyName - * @returns {boolean} - */ - default_1.prototype.isBooleanKey = function (pointKeyName) { - return listOfBooleanKeys.indexOf(pointKeyName) !== -1; - }; - /** - * reduce number of features - * @param offsetCount - * @param listOfFeatures - */ - default_1.prototype.filterFeaturesByOffset = function (offsetCount, listOfFeatures) { - var filteredList = listOfFeatures; - // TODO - return filteredList; - }; - // filterFeaturesByPropertyRegex(bboxConfig, listOfFeatures) { - // console.log('bboxConfig', bboxConfig) - // let filteredList = listOfFeatures - // // TODO - // return filteredList - // } - default_1.prototype.filterFeaturesByPropertyRegex = function (propertyName, criteriaRegex, listOfFeatures) { - var filteredList = listOfFeatures.filter(function (feature) { - return criteriaRegex.test(feature === null || feature === void 0 ? void 0 : feature.properties[propertyName]); - }); - return filteredList; - }; - /** - * retuns the converted element from mapping config if present, null otherwise - */ - default_1.prototype.mapElementFromConf = function (featurePoint) { - var _this = this; - if (!this.mapping_config) { - throw new Error('no config was loaded in the mapping engine. use setConfig(my_mapping_config) on this instance of mapping engine before using this.'); - } - console.log('mapping_config tags', this.mapping_config.tags); - debugLog('config_name', this.mapping_config.config_name); - var mappingKeys = Object.keys(this.mapping_config.tags); - // let mappingKeys = (this.mapping_config.tags) - var featurePointPropertiesKeys = Object.keys(featurePoint.properties); - debugLog('============= keys mappingKeys:', this.mapping_config.tags.length, mappingKeys.length); - debugLog('============= keys featurePointPropertiesKeys :', featurePoint.properties.length, featurePointPropertiesKeys.length); - var newProperties = Object.create(this.mapping_config.default_properties_of_point); - return; - // reinit properties of current point - var basePoint = Object.create(featurePoint); - basePoint.type = featurePoint.type; - basePoint.geometry = featurePoint.geometry; - // apply new properties if found in mapping config - featurePointPropertiesKeys.forEach(function (pointKeyName) { - _this.convertProperty(pointKeyName, mappingKeys, featurePoint, newProperties); - }); - basePoint.properties = newProperties; - debugLog('basePoint', basePoint); - return basePoint; - }; - default_1.prototype.convertProperty = function (pointKeyName, mappingKeys, featurePoint, newProperties) { - console.log('pointKeyName', pointKeyName); - if (!mappingKeys.indexOf(pointKeyName) !== -1) { - debugLog('found element', pointKeyName, '=>', this.mapping_config[pointKeyName], 'value : ', featurePoint.properties[pointKeyName]); - var convertedValue = ''; - var valueConvertedFromMapping = featurePoint.properties[pointKeyName]; - var typeofValue = typeof valueConvertedFromMapping; - var isStringValue = typeofValue === 'string'; - debugLog('- pointKeyName', pointKeyName); - debugLog('- valueConvertedFromMapping', valueConvertedFromMapping); - // debugLog('typeof featurePoint.properties[pointKeyName] === \'string\'', typeofValue) - var isConfigMappingObject = typeofValue === 'string'; - if (isStringValue) { - debugLog('-- string value'); - if (this.isBooleanKey(pointKeyName)) { - var lowerValue = (valueConvertedFromMapping + '').toLowerCase(); - debugLog('isBooleanKey: lowerValue', lowerValue); - convertedValue = this.truthyValues.indexOf(lowerValue) ? 'yes' : 'no'; - } - else { - convertedValue = valueConvertedFromMapping; - } - debugLog('-- convertedValue', convertedValue); - if (convertedValue) { - newProperties[this.mapping_config[pointKeyName]] = convertedValue; - } - } - else if (isConfigMappingObject) { - var newKey = ''; - var configObject = valueConvertedFromMapping; - if (configObject.key_converted) { - newKey = configObject.key_converted; - } - /** - * gestion des valeurs conditionnelles - * nous pouvons renseigner une string ou un objet décrivant les transformations à réaliser - */ - if (configObject.conditional_values) { - var keysConditionnalValues = Object.keys(configObject.conditional_values); - var isFoundValue = keysConditionnalValues.indexOf(valueConvertedFromMapping); - if (isFoundValue !== -1) { - var conditionnalConfig = keysConditionnalValues[isFoundValue]; - if (conditionnalConfig.tags_to_add) { - // on peut définir un ensemble de tags à rajouter - newProperties.push.apply(newProperties, conditionnalConfig.tags_to_add); - } - if (conditionnalConfig.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". - // on met donc truthy_value: '1' - if (this.truthyValues.indexOf(valueConvertedFromMapping) !== -1) { - convertedValue = conditionnalConfig.truthy_value; - } - } - if (conditionnalConfig.falsy_value) { - if (this.falsyValues.indexOf(valueConvertedFromMapping) !== -1) { - convertedValue = conditionnalConfig.falsy_value; - } - } - if (conditionnalConfig.transform_function) { - // une transformation de la valeur - // apply transformation to value - convertedValue = conditionnalConfig.transform_function(valueConvertedFromMapping); - } - // use the value converted - else if (conditionnalConfig.value_converted) { - convertedValue = conditionnalConfig.value_converted; - } - } - } - if (newKey && !configObject.ignore_this_data) { - newProperties[newKey] = convertedValue; - } - } - } - }; - return default_1; -}()); -exports.default = default_1; diff --git a/mapping_geojson_to_osm_tags/mappings/engine.ts b/mapping_geojson_to_osm_tags/mappings/engine.ts index 3ffe570b..3c5da5c9 100644 --- a/mapping_geojson_to_osm_tags/mappings/engine.ts +++ b/mapping_geojson_to_osm_tags/mappings/engine.ts @@ -1,4 +1,5 @@ import custom_utils from './utils' +import MappingConfigType from "./mapping-config.type"; const {debugLog} = custom_utils @@ -16,15 +17,15 @@ let listOfBooleanKeys = [ export default class { mapping_config: any = {} - constructor(mappingConfig) { + constructor(mappingConfig: MappingConfigType) { this.setConfig(mappingConfig) } - setConfig(mappingConfig) { + setConfig(mappingConfig: MappingConfigType) { this.mapping_config = mappingConfig } - mapFeaturePoint(featurePointGeoJson) { + mapFeaturePoint(featurePointGeoJson: any) { let geoJSONConvertedPoint: any = {} geoJSONConvertedPoint.properties = {...this.mapping_config.default_properties_of_point} @@ -45,7 +46,7 @@ export default class { * @param pointKeyName * @returns {boolean} */ - isBooleanKey(pointKeyName): boolean { + isBooleanKey(pointKeyName: string): boolean { return listOfBooleanKeys.indexOf(pointKeyName) !== -1 } @@ -58,21 +59,21 @@ export default class { * @param offsetCount * @param listOfFeatures */ - filterFeaturesByOffset(offsetCount: number, listOfFeatures): Array { + filterFeaturesByOffset(offsetCount: number, listOfFeatures: any): Array { let filteredList = listOfFeatures // TODO return filteredList } - // filterFeaturesByPropertyRegex(bboxConfig, listOfFeatures) { + // filterFeaturesByPropertyRegex(bboxConfig:any, listOfFeatures:any) { // debugLog('bboxConfig', bboxConfig) // let filteredList = listOfFeatures // // TODO // return filteredList // } - filterFeaturesByPropertyRegex(propertyName, criteriaRegex, listOfFeatures) { - let filteredList = listOfFeatures.filter(feature => { + filterFeaturesByPropertyRegex(propertyName: string, criteriaRegex: any, listOfFeatures: any) { + let filteredList = listOfFeatures.filter((feature:any) => { return criteriaRegex.test(feature?.properties[propertyName]) }) return filteredList @@ -81,8 +82,8 @@ export default class { /** * retuns the converted element from mapping config if present, null otherwise */ - mapElementFromConf(featurePoint: any):any { - debugLog('mapElementFromConf: mapElementFromConf',featurePoint) + mapElementFromConf(featurePoint: any): any { + debugLog('mapElementFromConf: mapElementFromConf', featurePoint) if (!this.mapping_config) { throw new Error('no config was loaded in the mapping engine. use setConfig(my_mapping_config) on this instance of mapping engine before using this.') } @@ -123,10 +124,10 @@ export default class { * @param featurePoint * @param newProperties */ - convertProperty(pointKeyName, mappingKeys, featurePoint, newProperties) { + convertProperty(pointKeyName: string, mappingKeys: any, featurePoint: any, newProperties: any) { debugLog('convertProperty: pointKeyName', pointKeyName) debugLog('convertProperty: mappingKeys', mappingKeys) - if (!mappingKeys.indexOf(pointKeyName) !== -1) { + if (mappingKeys.indexOf(pointKeyName) !== -1) { debugLog('convertProperty: found element', pointKeyName, '=>', this.mapping_config[pointKeyName], 'value : ', featurePoint.properties[pointKeyName]) let convertedValue = '' @@ -155,12 +156,9 @@ export default class { if (convertedValue) { newProperties[this.mapping_config[pointKeyName]] = convertedValue } - } - - else if(isConfigMappingObject){ + } else if (isConfigMappingObject) { debugLog('convertProperty: is config object') - } - else{ + } else { debugLog('convertProperty: no string value') } // TODO handle config object for complex mapping diff --git a/mapping_geojson_to_osm_tags/mappings/mapping-config.type.js b/mapping_geojson_to_osm_tags/mappings/mapping-config.type.js deleted file mode 100644 index c8ad2e54..00000000 --- a/mapping_geojson_to_osm_tags/mappings/mapping-config.type.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/mapping_geojson_to_osm_tags/mappings/utils.js b/mapping_geojson_to_osm_tags/mappings/utils.js deleted file mode 100644 index 022eefd2..00000000 --- a/mapping_geojson_to_osm_tags/mappings/utils.js +++ /dev/null @@ -1,68 +0,0 @@ -"use strict"; -var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { - if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { - if (ar || !(i in from)) { - if (!ar) ar = Array.prototype.slice.call(from, 0, i); - ar[i] = from[i]; - } - } - return to.concat(ar || Array.prototype.slice.call(from)); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var fs_1 = require("fs"); -var show_debug = 0; -show_debug = 1; -var output_folder = 'output'; -/** - * wrapper de log qui se montre uniquemnt si show_debug a été activé - * @param args - */ -function debugLog() { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i] = arguments[_i]; - } - if (!show_debug) { - return; - } - console.log.apply(console, __spreadArray(['debug: '], args, false)); -} -var listOfBooleanKeys = [ - "prise_type_ef", - "prise_type_2", - "prise_type_combo_ccs", - "prise_type_chademo", - "gratuit", - "paiement_acte", - "paiement_cb", - "cable_t2_attache" -]; -/** - * - * @param pointKeyName - * @returns {boolean} - */ -function isBooleanKey(pointKeyName) { - return listOfBooleanKeys.indexOf(pointKeyName) !== -1; -} -/** - * crée un fichier dans le dossier par défaut, output - * @param fileName - * @param fileContent - */ -function writeFile(fileName, fileContent) { - debugLog('write file ', fileName); - return fs_1.default.writeFile("./".concat(output_folder, "/").concat(fileName), fileContent, 'utf8', function (err) { - if (err) { - debugLog("Error writing file: ".concat(err)); - } - else { - debugLog("File ".concat(fileName, " is written successfully!")); - } - }); -} -exports.default = { - debugLog: debugLog, - isBooleanKey: isBooleanKey, - writeFile: writeFile -}; diff --git a/mapping_geojson_to_osm_tags/mappings/utils.ts b/mapping_geojson_to_osm_tags/mappings/utils.ts index 91e79664..ab92e29a 100644 --- a/mapping_geojson_to_osm_tags/mappings/utils.ts +++ b/mapping_geojson_to_osm_tags/mappings/utils.ts @@ -1,18 +1,19 @@ import fs from 'fs' let show_debug = 0 -show_debug = 1 +// show_debug = 1 let output_folder = 'output'; +console.log('----------------------show_debug', show_debug) + /** * wrapper de log qui se montre uniquemnt si show_debug a été activé * @param args */ function debugLog(...args: any[]) { - if (!show_debug) { - return + 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 8bc6dafe..3cc3a6de 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 @@ -1,4 +1,18 @@ { "type": "FeatureCollection", - "features": [] + "features": [ + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 4.822159, + 45.635079 + ] + }, + "properties": { + "undefined": "891624884" + } + } + ] } \ No newline at end of file