From fbfe0356ee7cb46a9d46a30ded5dafe25b4540a4 Mon Sep 17 00:00:00 2001 From: Tykayn Date: Sat, 5 Aug 2023 10:07:57 +0200 Subject: [PATCH] add types --- .../data_other/testing/mappings_to_test.ts | 34 +++++++++++++++++++ .../converters/mappingConfigIRVE_simple.ts | 10 +++--- .../mappings/mapping-config.type.ts | 19 +++++++++++ .../tests/main.test.js | 21 ++---------- 4 files changed, 62 insertions(+), 22 deletions(-) create mode 100644 mapping_geojson_to_osm_tags/data_other/testing/mappings_to_test.ts diff --git a/mapping_geojson_to_osm_tags/data_other/testing/mappings_to_test.ts b/mapping_geojson_to_osm_tags/data_other/testing/mappings_to_test.ts new file mode 100644 index 00000000..b3a13b9d --- /dev/null +++ b/mapping_geojson_to_osm_tags/data_other/testing/mappings_to_test.ts @@ -0,0 +1,34 @@ +import MappingConfigType from "../../mappings/mapping-config.type"; + +/** + * configurations de mapping pour les cas de tests + */ +export const mappingRemoveAll: MappingConfigType = { + config_name: 'testing config', + config_author: 'tykayn ', + default_properties_of_point: { + 'amenity': 'charging_station' + }, + tags: { + nom_amenageur: { + key_converted: 'autre_nom_amenageur', + conditional_values: { + 'Accessibilité inconnue': { + ignore_this_data: true, // ne pas ajouter de tag si la valeur est égale à Accessibilité inconnue. + }, + } + } + } +} +export const mappingIgnore: MappingConfigType = { + config_name: 'testing config', + config_author: 'tykayn ', + default_properties_of_point: { + 'amenity': 'charging_station' + }, + tags: { + nom_amenageur: { + ignore_this_data: true, + } + } +} \ No newline at end of file diff --git a/mapping_geojson_to_osm_tags/mappings/converters/mappingConfigIRVE_simple.ts b/mapping_geojson_to_osm_tags/mappings/converters/mappingConfigIRVE_simple.ts index f45c79f2..653b8360 100644 --- a/mapping_geojson_to_osm_tags/mappings/converters/mappingConfigIRVE_simple.ts +++ b/mapping_geojson_to_osm_tags/mappings/converters/mappingConfigIRVE_simple.ts @@ -4,18 +4,18 @@ * https://wiki.openstreetmap.org/wiki/France/data.gouv.fr/Bornes_de_Recharge_pour_V%C3%A9hicules_%C3%89lectriques */ -export default { + const mappingIRVE:any = { // ******* nombres nbre_pdc: 'capacity', - // ******* textes amenity: 'amenity', // conserver le tag de base capacity: 'capacity', // conserver le tag de base nom_amenageur: 'operator', siren_amenageur: 'owner:ref:FR:SIREN', nom_operateur: 'operator', telephone_operateur: 'phone', - contact_operateur: 'email', // ici, on souhaite convertir la clé contact_operateur=bidule en email=bidule + // 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', @@ -40,4 +40,6 @@ export default { // ******** champs plus complexes horaires: 'opening_hours', // déjà au bon format -} \ No newline at end of file +} + +export default mappingIRVE; \ No newline at end of file diff --git a/mapping_geojson_to_osm_tags/mappings/mapping-config.type.ts b/mapping_geojson_to_osm_tags/mappings/mapping-config.type.ts index 558642f9..906cf20b 100644 --- a/mapping_geojson_to_osm_tags/mappings/mapping-config.type.ts +++ b/mapping_geojson_to_osm_tags/mappings/mapping-config.type.ts @@ -1,3 +1,22 @@ +interface GeoJsonGeometry { + type:string, + coordinates:Array, +} + +interface GeoJsonProperties { + [key:string]: any, +} + +interface GeoJsonFeature { + type:string, + geometry:GeoJsonGeometry, + properties:GeoJsonProperties, +} + +export interface FeatureCollection{ + type:string, + features:Array, +} export interface FeaturePropertyMappingConfigType{ [key:string]: any, key_converted?:string, diff --git a/mapping_geojson_to_osm_tags/tests/main.test.js b/mapping_geojson_to_osm_tags/tests/main.test.js index f6372b85..d48fb3fd 100644 --- a/mapping_geojson_to_osm_tags/tests/main.test.js +++ b/mapping_geojson_to_osm_tags/tests/main.test.js @@ -1,4 +1,5 @@ -import mapping_engine from '../mappings/engine' +import mapping_engine from '../mappings/engine.ts' +import { mappingRemoveAll } from '../data_other/testing/mappings_to_test' describe('mapping properties with rich mapping engine', () => { @@ -7,23 +8,7 @@ describe('mapping properties with rich mapping engine', () => { }) test('remove all properties when mapping says so', () => { - let mappingRemoveAll = { - config_name: 'testing config', - config_author: 'tykayn ', - default_properties_of_point: { - 'amenity': 'charging_station' - }, - tags: { - nom_amenageur: { - key_converted: 'wheelchair', - conditional_values: { - 'Accessibilité inconnue': { - ignore_this_data: true, // ne pas ajouter de tag si la valeur est égale à Accessibilité inconnue. - }, - } - } - } - } + let Mapping_engine = new mapping_engine(mappingRemoveAll) let mapped_point = {}