add toulouse ask angela, fix output name

This commit is contained in:
Tykayn 2024-10-17 10:47:43 +02:00 committed by tykayn
parent a41fd19c35
commit 2348d4f3e6
5 changed files with 6433 additions and 4375 deletions

View File

@ -18,7 +18,6 @@ import MappingArbresIssy from "./mappings/converters/configArbresIssy";
import MappingArbres92 from "./mappings/converters/configArbresHautsDeSeine"; import MappingArbres92 from "./mappings/converters/configArbresHautsDeSeine";
import MappingMuseums from "./mappings/converters/configMuseums"; import MappingMuseums from "./mappings/converters/configMuseums";
import MappingRouenPAV from "./mappings/converters/configRouen_PAV"; import MappingRouenPAV from "./mappings/converters/configRouen_PAV";
import MappingAskAngela from "mappings/converters/configAskAngela";
const limitWarningPercentageChangeInPoints = 5; // show a warning when more than N percent of the number of points changed const limitWarningPercentageChangeInPoints = 5; // show a warning when more than N percent of the number of points changed
const allowed_configs = [ const allowed_configs = [
@ -29,6 +28,7 @@ const allowed_configs = [
]; ];
import minimist = require('minimist'); import minimist = require('minimist');
import MappingAskAngela from "./mappings/converters/configAskAngela";
const debugLog = utils.debugLog; const debugLog = utils.debugLog;
@ -77,6 +77,9 @@ if (mini_arguments['engine-config']) {
let Mapping_engine: any; let Mapping_engine: any;
let outname = 'converted_' let outname = 'converted_'
if (mini_arguments['output-file']) {
outname = mini_arguments['output-file'];
}
if (mini_arguments['outname']) { if (mini_arguments['outname']) {
outname = mini_arguments['outname']; outname = mini_arguments['outname'];
} }
@ -125,8 +128,11 @@ let output_folder = 'output';
* @param fileContent * @param fileContent
*/ */
function writeFile(fileName: string, fileContent: any) { function writeFile(fileName: string, fileContent: any) {
if(outname){
fileName = ''+outname;
}
let write_path = `./${output_folder}/${fileName}` let write_path = `./${output_folder}/${fileName}`
debugLog("write file \n", outname + fileName, write_path) debugLog("write file \n", fileName, write_path)
console.log("-------- write file \n", fileName, "\n", write_path) console.log("-------- write file \n", fileName, "\n", write_path)
@ -198,7 +204,36 @@ function convertDataFromSource(sourceFilePath: string, mapping: MappingConfigTyp
let regex_filter_test_result = true let regex_filter_test_result = true
let remove_original_key = false; let remove_original_key = false;
feature_point.properties.tags?.forEach((tagKey: string, tagValue: string) => {
// fix des jeux de données qui ne sont pas des geojson
let properties_list:any = Object.keys(feature_point)
if(feature_point.geo_point_2d){
feature_point["type"] = "Feature"
feature_point["geometry"]={
"coordinates": feature_point.geo_point_2d[0],
"type": "Point"
}
}
if(feature_point['properties']){
properties_list = feature_point.properties
if(feature_point.properties['tags']){
properties_list = feature_point.properties.tags
}
}
if(!feature_point["properties"]){
let properties_list_to_move:any = Object.keys(feature_point)
feature_point["properties"] = {}
properties_list_to_move.forEach((tagKey: string, tagValue: any)=> {
feature_point["properties"][tagKey] = feature_point[tagKey]
})
}
properties_list?.forEach((tagKey: string, tagValue: string) => {
if (mapping.filters && mapping.filters.exclude_point_if_tag_not_empty?.indexOf(tagKey) !== -1 if (mapping.filters && mapping.filters.exclude_point_if_tag_not_empty?.indexOf(tagKey) !== -1
&& tagValue.length && tagValue.length
&& tagValue !== 'null') { && tagValue !== 'null') {

View File

@ -4,7 +4,7 @@ Les commerces et autres lieux adhérant au dispositif
# Conversion # Conversion
## Conversion des données de Toulouse ## Conversion des données de Toulouse
```bash ```bash
ts-node convert_to_osm_tags.ts --source=etalab_data/ask_angela/toulouse_askangela.json --output-file=toulouse_askangela.json --engine-config=MappingAskAngela ts-node convert_to_osm_tags.ts --source=etalab_data/askangela/toulouse_askangela.json --output-file=toulouse_askangela.json --engine-config=MappingAskAngela
``` ```
## Conversion des données de Bordeaux ## Conversion des données de Bordeaux

View File

@ -1,4 +1,6 @@
[ {
"type": "FeatureCollection",
"features": [
{ {
"geo_point_2d": { "geo_point_2d": {
"lon": 1.4179391144498137, "lon": 1.4179391144498137,
@ -4368,3 +4370,4 @@
"structure": "H\u00f4tel" "structure": "H\u00f4tel"
} }
] ]
}

View File

@ -16,7 +16,7 @@ const MappingAskAngela: MappingConfigType = {
}, },
filters: { filters: {
// exclude_point_if_tag_not_empty: ['id_osm'], // on peut exclure des données converties celles qui sont déjà avec un identifiant openstreetmap afin de favoriser l'intégration san avoir à gérer les doublons // exclude_point_if_tag_not_empty: ['id_osm'], // on peut exclure des données converties celles qui sont déjà avec un identifiant openstreetmap afin de favoriser l'intégration san avoir à gérer les doublons
// offset: 50 // offset: 1
}, },
add_not_mapped_tags_too: false, add_not_mapped_tags_too: false,
boolean_keys: [], boolean_keys: [],

File diff suppressed because it is too large Load Diff