add functions to filter
This commit is contained in:
parent
740ec9d0f8
commit
6fc08cc6b3
@ -12,10 +12,8 @@ const { debugLog } = custom_utils
|
|||||||
const { isBooleanKey } = custom_utils
|
const { isBooleanKey } = custom_utils
|
||||||
const { writeFile } = custom_utils
|
const { writeFile } = custom_utils
|
||||||
|
|
||||||
// let debugLog = custom_utils.debugLog
|
|
||||||
|
|
||||||
let use_mappping_engine = false
|
let use_mappping_engine = false
|
||||||
use_mappping_engine = true
|
// use_mappping_engine = true
|
||||||
|
|
||||||
let Mapping_engine = new mapping_engine(mappingConfigIRVE)
|
let Mapping_engine = new mapping_engine(mappingConfigIRVE)
|
||||||
|
|
||||||
@ -38,9 +36,11 @@ let boundingBoxCoordinates = {
|
|||||||
let filterCoordinates = true
|
let filterCoordinates = true
|
||||||
let enable_filter_on_department = true
|
let enable_filter_on_department = true
|
||||||
enable_filter_on_department = false
|
enable_filter_on_department = false
|
||||||
|
|
||||||
let filterDepartment = 91
|
let filterDepartment = 91
|
||||||
if (mini_arguments['department']) {
|
if (mini_arguments['department']) {
|
||||||
filterDepartment = mini_arguments['department']
|
filterDepartment = mini_arguments['department']
|
||||||
|
enable_filter_on_department = true
|
||||||
}
|
}
|
||||||
if (mini_arguments['source']) {
|
if (mini_arguments['source']) {
|
||||||
sourceFilePathGeoJson = mini_arguments['source']
|
sourceFilePathGeoJson = mini_arguments['source']
|
||||||
@ -61,9 +61,9 @@ if (enable_filter_on_department) {
|
|||||||
let pointCounterMax = 1000000
|
let pointCounterMax = 1000000
|
||||||
|
|
||||||
let limitConversionToFirstPoint = false
|
let limitConversionToFirstPoint = false
|
||||||
limitConversionToFirstPoint = true
|
// limitConversionToFirstPoint = true
|
||||||
if (limitConversionToFirstPoint) {
|
if (limitConversionToFirstPoint) {
|
||||||
pointCounterMax = 2
|
pointCounterMax = 1
|
||||||
}
|
}
|
||||||
let defaultPropertiesOfPoint = {
|
let defaultPropertiesOfPoint = {
|
||||||
'amenity': 'charging_station'
|
'amenity': 'charging_station'
|
||||||
@ -146,8 +146,6 @@ function convertDataForIRVE (sourceFilePath, mapping, pointCounterMax, boundingB
|
|||||||
let mapped_point = {}
|
let mapped_point = {}
|
||||||
|
|
||||||
if (use_mappping_engine) {
|
if (use_mappping_engine) {
|
||||||
console.log('go mapping engine')
|
|
||||||
Mapping_engine.setConfig(mapping)
|
|
||||||
mapped_point = Mapping_engine.mapElementFromConf(feature_point)
|
mapped_point = Mapping_engine.mapElementFromConf(feature_point)
|
||||||
} else {
|
} else {
|
||||||
mapped_point = mapElementFromConfSimple(feature_point, mapping)
|
mapped_point = mapElementFromConfSimple(feature_point, mapping)
|
||||||
@ -220,8 +218,9 @@ function mapElementFromConfSimple (featurePoint, mappingConfig) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (use_mappping_engine) {
|
if (use_mappping_engine) {
|
||||||
console.log('using mapping engine')
|
console.log(' - using mapping engine')
|
||||||
console.log('pointCounterMax', pointCounterMax)
|
console.log(' - pointCounterMax', pointCounterMax)
|
||||||
|
Mapping_engine.setConfig(mappingConfigIRVE)
|
||||||
convertDataForIRVE(sourceFilePathGeoJson, mappingConfigIRVE, pointCounterMax, boundingBoxCoordinates)
|
convertDataForIRVE(sourceFilePathGeoJson, mappingConfigIRVE, pointCounterMax, boundingBoxCoordinates)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<coverage generated="1690835414332" clover="3.2.0">
|
<coverage generated="1690835538708" clover="3.2.0">
|
||||||
<project timestamp="1690835414332" name="All files">
|
<project timestamp="1690835538709" name="All files">
|
||||||
<metrics statements="0" coveredstatements="0" conditionals="0" coveredconditionals="0" methods="0" coveredmethods="0" elements="0" coveredelements="0" complexity="0" loc="0" ncloc="0" packages="0" files="0" classes="0"/>
|
<metrics statements="0" coveredstatements="0" conditionals="0" coveredconditionals="0" methods="0" coveredmethods="0" elements="0" coveredelements="0" complexity="0" loc="0" ncloc="0" packages="0" files="0" classes="0"/>
|
||||||
</project>
|
</project>
|
||||||
</coverage>
|
</coverage>
|
||||||
|
@ -86,7 +86,7 @@
|
|||||||
<div class='footer quiet pad2 space-top1 center small'>
|
<div class='footer quiet pad2 space-top1 center small'>
|
||||||
Code coverage generated by
|
Code coverage generated by
|
||||||
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
||||||
at 2023-07-31T20:30:14.330Z
|
at 2023-07-31T20:32:18.706Z
|
||||||
</div>
|
</div>
|
||||||
<script src="prettify.js"></script>
|
<script src="prettify.js"></script>
|
||||||
<script>
|
<script>
|
||||||
|
@ -1 +0,0 @@
|
|||||||
,tykayn,spaceship,29.07.2023 21:47,file:///home/tykayn/.config/libreoffice/4;
|
|
@ -62,6 +62,6 @@
|
|||||||
"consolidated_is_lon_lat_correct": true,
|
"consolidated_is_lon_lat_correct": true,
|
||||||
"consolidated_is_code_insee_verified": true
|
"consolidated_is_code_insee_verified": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
67
mapping_geojson_to_osm_tags/etalab_data/small.json
Normal file
67
mapping_geojson_to_osm_tags/etalab_data/small.json
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
{
|
||||||
|
"type": "FeatureCollection",
|
||||||
|
"features": [
|
||||||
|
{
|
||||||
|
"type": "Feature",
|
||||||
|
"geometry": {
|
||||||
|
"type": "Point",
|
||||||
|
"coordinates": [
|
||||||
|
4.822159,
|
||||||
|
45.635079
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"properties": {
|
||||||
|
"nom_amenageur": "ELECTRA",
|
||||||
|
"siren_amenageur": "891624884",
|
||||||
|
"contact_amenageur": "help@electra.com",
|
||||||
|
"nom_operateur": "ELECTRA",
|
||||||
|
"contact_operateur": "help@electra.com",
|
||||||
|
"telephone_operateur": "",
|
||||||
|
"nom_enseigne": "ELECTRA",
|
||||||
|
"id_station_itinerance": "FRELCPSDRPG",
|
||||||
|
"id_station_local": "",
|
||||||
|
"nom_station": "S\u00e9r\u00e9zin-du-Rh\u00f4ne - Peugeot",
|
||||||
|
"implantation_station": "Station d\u00e9di\u00e9e \u00e0 la recharge rapide",
|
||||||
|
"adresse_station": "12 chemin d\u00e9partemental 12, Peugeot 69360 S\u00e9r\u00e9zin-du-Rh\u00f4ne",
|
||||||
|
"code_insee_commune": "69294",
|
||||||
|
"coordonneesXY": "[4.82215900,45.63507900]",
|
||||||
|
"nbre_pdc": "8",
|
||||||
|
"id_pdc_itinerance": "FRELCECURS",
|
||||||
|
"id_pdc_local": "",
|
||||||
|
"puissance_nominale": "225",
|
||||||
|
"prise_type_ef": "false",
|
||||||
|
"prise_type_2": "false",
|
||||||
|
"prise_type_combo_ccs": "true",
|
||||||
|
"prise_type_chademo": "false",
|
||||||
|
"prise_type_autre": "false",
|
||||||
|
"gratuit": "false",
|
||||||
|
"paiement_acte": "true",
|
||||||
|
"paiement_cb": "true",
|
||||||
|
"paiement_autre": "true",
|
||||||
|
"tarification": "",
|
||||||
|
"condition_acces": "Acc\u00e8s libre",
|
||||||
|
"reservation": "true",
|
||||||
|
"horaires": "24/7",
|
||||||
|
"accessibilite_pmr": "Accessibilit\u00e9 inconnue",
|
||||||
|
"restriction_gabarit": "Inconnu",
|
||||||
|
"station_deux_roues": "false",
|
||||||
|
"raccordement": "Direct",
|
||||||
|
"num_pdl": "N/A",
|
||||||
|
"date_mise_en_service": "2022-10-27",
|
||||||
|
"observations": "T\u00e9l\u00e9charger l'application ELECTRA pour r\u00e9server et payer sur go-electra.com",
|
||||||
|
"date_maj": "2023-07-29",
|
||||||
|
"cable_t2_attache": "",
|
||||||
|
"last_modified": "2023-07-29T03:05:24.360000+00:00",
|
||||||
|
"datagouv_dataset_id": "623ca46c13130c3228abd018",
|
||||||
|
"datagouv_resource_id": "e9bb3424-77cd-40ba-8bbd-5a19362d0365",
|
||||||
|
"datagouv_organization_or_owner": "electra",
|
||||||
|
"consolidated_longitude": 4.822159,
|
||||||
|
"consolidated_latitude": 45.635079,
|
||||||
|
"consolidated_code_postal": "69360",
|
||||||
|
"consolidated_commune": "S\u00e9r\u00e9zin-du-Rh\u00f4ne",
|
||||||
|
"consolidated_is_lon_lat_correct": true,
|
||||||
|
"consolidated_is_code_insee_verified": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -1,7 +1,5 @@
|
|||||||
|
|
||||||
import custom_utils from './utils.mjs'
|
import custom_utils from './utils.mjs'
|
||||||
|
|
||||||
|
|
||||||
const { debugLog } = custom_utils
|
const { debugLog } = custom_utils
|
||||||
|
|
||||||
let listOfBooleanKeys = Object.keys({
|
let listOfBooleanKeys = Object.keys({
|
||||||
@ -15,12 +13,10 @@ let listOfBooleanKeys = Object.keys({
|
|||||||
cable_t2_attache: 'socket:type2_cable',
|
cable_t2_attache: 'socket:type2_cable',
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
export default class {
|
export default class {
|
||||||
mapping_config = {}
|
mapping_config = {}
|
||||||
|
|
||||||
constructor (mappingConfig) {
|
constructor (mappingConfig) {
|
||||||
|
|
||||||
this.setConfig(mappingConfig)
|
this.setConfig(mappingConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,6 +40,11 @@ export default class {
|
|||||||
return geoJSONConvertedPoint
|
return geoJSONConvertedPoint
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO convert to mapping config property to transform_truthy
|
||||||
|
* @param pointKeyName
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
isBooleanKey (pointKeyName) {
|
isBooleanKey (pointKeyName) {
|
||||||
|
|
||||||
return listOfBooleanKeys.indexOf(pointKeyName) !== -1
|
return listOfBooleanKeys.indexOf(pointKeyName) !== -1
|
||||||
@ -52,15 +53,40 @@ export default class {
|
|||||||
truthyValues = ['true', 'True', 'TRUE', '1', 1]
|
truthyValues = ['true', 'True', 'TRUE', '1', 1]
|
||||||
falsyValues = ['false', 'False', 'FALSE', '0', 0]
|
falsyValues = ['false', 'False', 'FALSE', '0', 0]
|
||||||
|
|
||||||
|
filterFeaturesByOffset (offsetCount, listOfFeatures) {
|
||||||
|
let filteredList = listOfFeatures
|
||||||
|
// TODO
|
||||||
|
return filteredList
|
||||||
|
}
|
||||||
|
|
||||||
|
filterFeaturesByPropertyRegex (bboxConfig, listOfFeatures) {
|
||||||
|
console.log('bboxConfig', bboxConfig)
|
||||||
|
let filteredList = listOfFeatures
|
||||||
|
// TODO
|
||||||
|
return filteredList
|
||||||
|
}
|
||||||
|
|
||||||
|
filterFeaturesByPropertyRegex (propertyName, criteriaRegex, listOfFeatures) {
|
||||||
|
let filteredList = listOfFeatures.filter(feature => {
|
||||||
|
return criteriaRegex.test(feature?.properties[propertyName])
|
||||||
|
})
|
||||||
|
return filteredList
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* retuns the converted element from mapping config if present, null otherwise
|
* retuns the converted element from mapping config if present, null otherwise
|
||||||
*/
|
*/
|
||||||
mapElementFromConf (featurePoint) {
|
mapElementFromConf(featurePoint) {
|
||||||
console.log('config_name', this.mapping_config.config_name)
|
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.')
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
debugLog('config_name', this.mapping_config.config_name)
|
||||||
let mappingKeys = Object.keys(this.mapping_config.tags)
|
let mappingKeys = Object.keys(this.mapping_config.tags)
|
||||||
let featurePointPropertiesKeys = Object.keys(featurePoint.properties)
|
let featurePointPropertiesKeys = Object.keys(featurePoint.properties)
|
||||||
|
|
||||||
console.log('keys', mappingKeys, featurePointPropertiesKeys)
|
debugLog('keys', mappingKeys, featurePointPropertiesKeys)
|
||||||
|
|
||||||
let newProperties = Object.create(this.mapping_config.default_properties_of_point)
|
let newProperties = Object.create(this.mapping_config.default_properties_of_point)
|
||||||
|
|
||||||
@ -68,7 +94,6 @@ export default class {
|
|||||||
let basePoint = Object.create(featurePoint)
|
let basePoint = Object.create(featurePoint)
|
||||||
basePoint.type = featurePoint.type
|
basePoint.type = featurePoint.type
|
||||||
basePoint.geometry = featurePoint.geometry
|
basePoint.geometry = featurePoint.geometry
|
||||||
basePoint.properties = newProperties
|
|
||||||
|
|
||||||
// apply new properties if found in mapping config
|
// apply new properties if found in mapping config
|
||||||
featurePointPropertiesKeys.forEach(pointKeyName => {
|
featurePointPropertiesKeys.forEach(pointKeyName => {
|
||||||
@ -80,12 +105,12 @@ export default class {
|
|||||||
let valueConvertedFromMapping = featurePoint.properties[pointKeyName]
|
let valueConvertedFromMapping = featurePoint.properties[pointKeyName]
|
||||||
let typeofValue = typeof valueConvertedFromMapping
|
let typeofValue = typeof valueConvertedFromMapping
|
||||||
let isStringValue = typeofValue === 'string'
|
let isStringValue = typeofValue === 'string'
|
||||||
console.log('typeof featurePoint.properties[pointKeyName] === \'string\'', typeofValue)
|
debugLog('typeof featurePoint.properties[pointKeyName] === \'string\'', typeofValue)
|
||||||
|
|
||||||
let isConfigMappingObject = typeofValue === 'string'
|
let isConfigMappingObject = typeofValue === 'string'
|
||||||
|
|
||||||
if (isStringValue) {
|
if (isStringValue) {
|
||||||
console.log('string value')
|
debugLog('string value')
|
||||||
if (this.isBooleanKey(pointKeyName)) {
|
if (this.isBooleanKey(pointKeyName)) {
|
||||||
let lowerValue = (valueConvertedFromMapping + '').toLowerCase()
|
let lowerValue = (valueConvertedFromMapping + '').toLowerCase()
|
||||||
convertedValue = this.truthyValues.indexOf(lowerValue) ? 'yes' : 'no'
|
convertedValue = this.truthyValues.indexOf(lowerValue) ? 'yes' : 'no'
|
||||||
@ -150,6 +175,8 @@ export default class {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
basePoint.properties = newProperties
|
||||||
|
|
||||||
debugLog('basePoint', basePoint)
|
debugLog('basePoint', basePoint)
|
||||||
return basePoint
|
return basePoint
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import fs from 'node-fs'
|
import fs from 'node-fs'
|
||||||
|
|
||||||
let show_debug = 1
|
let show_debug = 0
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* faire un log
|
* faire un log
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
<osm version="0.6" generator="geojsontoosm"/>
|
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"type": "FeatureCollection",
|
||||||
|
"features": []
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user