up change percentage message
This commit is contained in:
parent
04c3bd8d53
commit
01482e1411
@ -150,8 +150,6 @@ function convertDataFromSource(sourceFilePath: string, mapping: MappingConfigTyp
|
||||
return debugLog(err)
|
||||
}
|
||||
let data_transformed: FeatureCollection = JSON.parse(data)
|
||||
// debug('data keys ', Object.keys(dataTransformed))
|
||||
// debugLog('properties of point 0', data_transformed.features[0])
|
||||
|
||||
if (data_transformed.features) {
|
||||
|
||||
@ -171,6 +169,7 @@ function convertDataFromSource(sourceFilePath: string, mapping: MappingConfigTyp
|
||||
debugLog('filter offset enabled', mapping.filters.offset)
|
||||
list_of_points = list_of_points.splice(0,mapping.filters.offset)
|
||||
}
|
||||
|
||||
console.log('list_of_points.length', list_of_points.length)
|
||||
|
||||
|
||||
@ -179,6 +178,10 @@ function convertDataFromSource(sourceFilePath: string, mapping: MappingConfigTyp
|
||||
* run filters before mapping OSM tags
|
||||
* TODO: do it in the engine
|
||||
*/
|
||||
if(mapping.filters && mapping.filters.exclude_point_if_tag_not_empty){
|
||||
list_of_points = Mapping_engine.filterListOfPointsByExcludingIfKeyFilled(list_of_points, mapping.filters.exclude_point_if_tag_not_empty)
|
||||
}
|
||||
|
||||
// for each point from the data source, filter if we take it or not
|
||||
list_of_points.forEach((feature_point: any) => {
|
||||
|
||||
@ -236,6 +239,8 @@ function convertDataFromSource(sourceFilePath: string, mapping: MappingConfigTyp
|
||||
point_counter++
|
||||
}
|
||||
|
||||
|
||||
|
||||
})
|
||||
|
||||
/**
|
||||
@ -274,6 +279,11 @@ function convertDataFromSource(sourceFilePath: string, mapping: MappingConfigTyp
|
||||
let fileNameToWrite = '_' + filteredName + output_supplement + '.json'
|
||||
console.log('converted features:', converted_geo_json.features.length)
|
||||
console.log('diff: ', data_transformed.features.length - converted_geo_json.features.length)
|
||||
let percentChange = 100-((1-(data_transformed.features.length / converted_geo_json.features.length))*-1)
|
||||
console.log('Changement de features', percentChange,'%')
|
||||
if(percentChange>5){
|
||||
console.log(' /!\\ pas mal de points en moins, plus de '+percentChange+'%')
|
||||
}
|
||||
debugLog('convert : write file ', fileNameToWrite)
|
||||
|
||||
// console.log('mapping_engine.stats', Mapping_engine.stats)
|
||||
|
@ -16,8 +16,8 @@ const mappingRouenParkingVelos: MappingConfigType = {
|
||||
url: 'https://data.metropole-rouen-normandie.fr/api/explore/v2.1/catalog/datasets/liste-des-stationnements-cyclables-metropole-rouen-normandie/exports/geojson?lang=fr&timezone=Europe%2FBerlin'
|
||||
},
|
||||
filters: {
|
||||
exclude_point_if_tag_not_empty: ['osm_id'],
|
||||
// offset: 1
|
||||
exclude_point_if_tag_not_empty: ['id_osm'],
|
||||
// offset: 100
|
||||
},
|
||||
add_not_mapped_tags_too: false,
|
||||
boolean_keys: [
|
||||
@ -77,16 +77,8 @@ const mappingRouenParkingVelos: MappingConfigType = {
|
||||
},
|
||||
]
|
||||
},
|
||||
// "Anneaux": {
|
||||
// "tags_to_add": [
|
||||
// {
|
||||
// "bicycle_parking": "stands"
|
||||
// },
|
||||
// ]
|
||||
// },
|
||||
}
|
||||
},
|
||||
// type_aire: 'nb_pl_moto', // Poteaux => bicycle_parking=bollard, Arceaux, Anneaux => bicycle_parking=stands, Marquage, null, Non renseigné, Range-vélos, Sans, Trottoir
|
||||
id_local: 'ref:FR:rouen_veloparking_id',
|
||||
// acces_reglement: 'access',
|
||||
|
||||
|
@ -25,12 +25,14 @@ export default class {
|
||||
private jardinage = false;
|
||||
public stats: any;
|
||||
private current_converted_geojson_point: any;
|
||||
private current_geojson_point: any;
|
||||
private current_geojson_point: any; // currently converting point
|
||||
private list_of_points: any; // list of geojson points
|
||||
|
||||
constructor(mappingConfig: MappingConfigType) {
|
||||
|
||||
this.setConfig(mappingConfig)
|
||||
this.stats = {
|
||||
filtered_by_excluded_tags: 0,
|
||||
phones_updated: 0,
|
||||
power_output: 0,
|
||||
phones_updated_list: [],
|
||||
@ -86,13 +88,13 @@ export default class {
|
||||
return filteredList
|
||||
}
|
||||
|
||||
// filterFeaturesByPropertyRegex(bboxConfig:any, listOfFeatures:any) {
|
||||
// debugLog('bboxConfig', bboxConfig)
|
||||
// let filteredList = listOfFeatures
|
||||
// // TODO
|
||||
// return filteredList
|
||||
// }
|
||||
|
||||
/**
|
||||
* filterFeaturesByPropertyRegex
|
||||
* TODO
|
||||
* @param propertyName
|
||||
* @param criteriaRegex
|
||||
* @param listOfFeatures
|
||||
*/
|
||||
filterFeaturesByPropertyRegex(propertyName: string, criteriaRegex: any, listOfFeatures: any) {
|
||||
let filteredList = listOfFeatures.filter((feature: any) => {
|
||||
return criteriaRegex.test(feature?.properties[propertyName])
|
||||
@ -100,6 +102,35 @@ export default class {
|
||||
return filteredList
|
||||
}
|
||||
|
||||
/**
|
||||
* filter a list of geojson points if one of the given exludedKeys is present in their properties.
|
||||
* Example, we do not want to convert already present OSM point which have an osm_id value in their properties.
|
||||
* @param list
|
||||
* @param excludedKeys
|
||||
*/
|
||||
filterListOfPointsByExcludingIfKeyFilled(list: any, excludedKeys: Array<string>):any[] {
|
||||
let newList: Array<any> = []
|
||||
list.forEach((geojsonPoint: any) => {
|
||||
let pointProperties = Object.keys(geojsonPoint.properties)
|
||||
let addPoint = true;
|
||||
excludedKeys.forEach((key: any) => {
|
||||
debugLog(key, 'pointProperties[key]', pointProperties[key])
|
||||
let foundProperty:string = pointProperties[key]
|
||||
if ( foundProperty && foundProperty !== 'null') {
|
||||
addPoint = false
|
||||
}
|
||||
})
|
||||
if (addPoint) {
|
||||
// only add points that pass the not null filter
|
||||
newList.push(geojsonPoint)
|
||||
} else {
|
||||
this.stats.filtered_by_excluded_tags++
|
||||
}
|
||||
})
|
||||
|
||||
return newList;
|
||||
}
|
||||
|
||||
/**
|
||||
* retuns the converted element from mapping config if present, null otherwise
|
||||
*/
|
||||
|
18899
output/___mappingRouenParkingVelos.geojson
Normal file
18899
output/___mappingRouenParkingVelos.geojson
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user