Compare commits
3 Commits
de76b9ec38
...
0ea1f6bdc9
Author | SHA1 | Date | |
---|---|---|---|
0ea1f6bdc9 | |||
2ff5a68998 | |||
c102c2b1ff |
@ -10,10 +10,11 @@ import mappingConfigIRVEFromOsmose from './mappings/converters/configIRVE_osmose
|
|||||||
import mappingConfigIRVE_simple from './mappings/converters/mappingConfigIRVE_simple'
|
import mappingConfigIRVE_simple from './mappings/converters/mappingConfigIRVE_simple'
|
||||||
import mappingTest from './mappings/converters/configTest'
|
import mappingTest from './mappings/converters/configTest'
|
||||||
import mapping_engine from './mappings/engine'
|
import mapping_engine from './mappings/engine'
|
||||||
import {BoundingBoxCoordinatesType, FeatureCollection} from "./mappings/mapping-config.type";
|
import MappingConfigType, {BoundingBoxCoordinatesType, FeatureCollection} from "./mappings/mapping-config.type";
|
||||||
import utils from './mappings/utils'
|
import utils from './mappings/utils'
|
||||||
|
import mappingRouenParkingVelos from "./mappings/converters/configRouen_OpenData_velo_parkings";
|
||||||
|
|
||||||
const allowed_configs = ['mappingIssy2Roues', 'mappingConfigIRVE', 'mappingConfigIRVEFromOsmose', 'mappingConfigIRVE_simple', 'mappingTest', 'ConfigIRVE'];
|
const allowed_configs = ['mappingIssy2Roues', 'mappingConfigIRVE', 'mappingConfigIRVEFromOsmose', 'mappingConfigIRVE_simple', 'mappingTest', 'ConfigIRVE','mappingRouenParkingVelos'];
|
||||||
|
|
||||||
const minimist = require('minimist')
|
const minimist = require('minimist')
|
||||||
|
|
||||||
@ -145,7 +146,7 @@ function writeFile(fileName: string, fileContent: any) {
|
|||||||
* @param pointCounterMax
|
* @param pointCounterMax
|
||||||
* @param boundingBoxCoordinates
|
* @param boundingBoxCoordinates
|
||||||
*/
|
*/
|
||||||
function convertDataFromSource(sourceFilePath: string, mapping: any, pointCounterMax: number, boundingBoxCoordinates: any) {
|
function convertDataFromSource(sourceFilePath: string, mapping: MappingConfigType, pointCounterMax: number, boundingBoxCoordinates: any) {
|
||||||
debugLog('convert data: source file from :', sourceFilePath)
|
debugLog('convert data: source file from :', sourceFilePath)
|
||||||
|
|
||||||
fs.readFile(sourceFilePath, 'utf8', function (err, data) {
|
fs.readFile(sourceFilePath, 'utf8', function (err, data) {
|
||||||
@ -161,7 +162,7 @@ function convertDataFromSource(sourceFilePath: string, mapping: any, pointCounte
|
|||||||
|
|
||||||
if (data_transformed.features) {
|
if (data_transformed.features) {
|
||||||
|
|
||||||
console.log('data found in source, features:', data_transformed.features.length)
|
console.log('------ data found in source, features:', data_transformed.features.length)
|
||||||
|
|
||||||
// find interesting list of points to use
|
// find interesting list of points to use
|
||||||
let list_of_points: any = data_transformed.features
|
let list_of_points: any = data_transformed.features
|
||||||
@ -175,6 +176,18 @@ function convertDataFromSource(sourceFilePath: string, mapping: any, pointCounte
|
|||||||
list_of_points.forEach((feature_point: any) => {
|
list_of_points.forEach((feature_point: any) => {
|
||||||
|
|
||||||
let regex_filter_test_result = true
|
let regex_filter_test_result = true
|
||||||
|
let remove_original_key = false;
|
||||||
|
feature_point.properties.tags?.forEach((tagKey:string, tagValue:string)=>{
|
||||||
|
if (mapping.filters && mapping.filters.exclude_point_if_tag_not_empty?.indexOf(tagKey) !== -1
|
||||||
|
&& tagValue.length
|
||||||
|
&& tagValue !== 'null') {
|
||||||
|
remove_original_key = true;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if(remove_original_key){
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (enable_filter_on_department) {
|
if (enable_filter_on_department) {
|
||||||
debugLog('filtre sur les départements activé')
|
debugLog('filtre sur les départements activé')
|
||||||
@ -344,6 +357,8 @@ function setMappingConfigFromName(engine_conf_choice: string) {
|
|||||||
Mapping_engine.setConfig(mappingTest)
|
Mapping_engine.setConfig(mappingTest)
|
||||||
} else if (engine_conf_choice == 'ConfigIRVE') {
|
} else if (engine_conf_choice == 'ConfigIRVE') {
|
||||||
Mapping_engine.setConfig(ConfigIRVE)
|
Mapping_engine.setConfig(ConfigIRVE)
|
||||||
|
} else if (engine_conf_choice == 'mappingRouenParkingVelos') {
|
||||||
|
Mapping_engine.setConfig(mappingRouenParkingVelos)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Mapping_engine.setConfig(mappingConfigIRVE)
|
Mapping_engine.setConfig(mappingConfigIRVE)
|
||||||
|
@ -22,3 +22,7 @@ Conversion en fichier OSM avec le paquet python pip geojson2osm:
|
|||||||
```shell
|
```shell
|
||||||
geojsontoosm output/my_converted_data_set__mappingIssy2Roues.json > osm_output/issy_parkings_2r.osm
|
geojsontoosm output/my_converted_data_set__mappingIssy2Roues.json > osm_output/issy_parkings_2r.osm
|
||||||
```
|
```
|
||||||
|
## Parking cyclables de la métropole de Rouen
|
||||||
|
```bash
|
||||||
|
ts-node convert_to_osm_tags.ts --source=etalab_data/cyclabilité/rouen_parking_velos.json --output-file=rouen_parking_velos.json --engine-config=mappingRouenParkingVelos
|
||||||
|
```
|
||||||
|
39821
etalab_data/cyclabilité/rouen_parking_velos.json
Normal file
39821
etalab_data/cyclabilité/rouen_parking_velos.json
Normal file
File diff suppressed because it is too large
Load Diff
95
mappings/converters/configRouen_OpenData_velo_parkings.ts
Normal file
95
mappings/converters/configRouen_OpenData_velo_parkings.ts
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
/**
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
import MappingConfigType from "../mapping-config.type";
|
||||||
|
|
||||||
|
const mappingRouenParkingVelos: MappingConfigType = {
|
||||||
|
config_name: "mappingRouenParkingVelos",
|
||||||
|
config_author: "tykayn <contact@cipherbliss.com>",
|
||||||
|
default_properties_of_point: {
|
||||||
|
'amenity': 'bicycle_parking'
|
||||||
|
},
|
||||||
|
source: {
|
||||||
|
geojson_path: "cyclabilité/rouen_parking_velos.json",
|
||||||
|
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']
|
||||||
|
},
|
||||||
|
add_not_mapped_tags_too: false,
|
||||||
|
boolean_keys: [
|
||||||
|
"acces_reglement",
|
||||||
|
],
|
||||||
|
tags_to_ignore_if_value_is: ['Non renseigne'],
|
||||||
|
tags: {
|
||||||
|
// ******* nombres
|
||||||
|
capacite: 'capacity',
|
||||||
|
capacite_cargo: 'capacity:cargo_bike',
|
||||||
|
gestionnaire: {
|
||||||
|
key_converted: 'operator',
|
||||||
|
conditionnal_values: {
|
||||||
|
"Non renseigne": {
|
||||||
|
ignore_this_data: true, // ne pas ajouter de tag si la valeur est égale à
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
proprietaire: {
|
||||||
|
key_converted: 'owner',
|
||||||
|
conditionnal_values: {
|
||||||
|
"Non renseigne": {
|
||||||
|
ignore_this_data: true, // ne pas ajouter de tag si la valeur est égale à
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
date_maj: 'check_date',
|
||||||
|
// ******* textes
|
||||||
|
commentaire: 'note',
|
||||||
|
surveillance: {
|
||||||
|
key_converted: 'surveillance',
|
||||||
|
ignore_if_falsy: true,
|
||||||
|
convert_to_boolean_value: true,
|
||||||
|
},
|
||||||
|
mobilier: {
|
||||||
|
key_converted: 'mobilier',
|
||||||
|
remove_original_key: true,
|
||||||
|
conditional_values: {
|
||||||
|
"POTELET": {
|
||||||
|
"tags_to_add": [
|
||||||
|
{
|
||||||
|
"bicycle_parking": "bollard"
|
||||||
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"ARCEAU": {
|
||||||
|
"tags_to_add": [
|
||||||
|
{
|
||||||
|
"bicycle_parking": "stands"
|
||||||
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"RATELIER": {
|
||||||
|
"tags_to_add": [
|
||||||
|
{
|
||||||
|
"bicycle_parking": "rack"
|
||||||
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
// "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',
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default mappingRouenParkingVelos;
|
@ -13,7 +13,10 @@ const MappingTest: MappingConfigType = {
|
|||||||
nom_amenageur : 'name'
|
nom_amenageur : 'name'
|
||||||
},
|
},
|
||||||
add_not_mapped_tags_too: false,
|
add_not_mapped_tags_too: false,
|
||||||
source: {},
|
source: {
|
||||||
|
geojson_path: "",
|
||||||
|
url: ""
|
||||||
|
},
|
||||||
filters: {},
|
filters: {},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import custom_utils from './utils'
|
import custom_utils from './utils'
|
||||||
import MappingConfigType from "./mapping-config.type";
|
import MappingConfigType from "./mapping-config.type";
|
||||||
import {debuglog} from "util";
|
|
||||||
|
|
||||||
const {debugLog} = custom_utils
|
const {debugLog} = custom_utils
|
||||||
|
|
||||||
@ -139,8 +138,10 @@ export default class {
|
|||||||
|
|
||||||
debugLog('mapElementFromConf: convert', pointKeyName)
|
debugLog('mapElementFromConf: convert', pointKeyName)
|
||||||
debugLog('mapElementFromConf: mapping keys:', mappingKeys)
|
debugLog('mapElementFromConf: mapping keys:', mappingKeys)
|
||||||
|
|
||||||
this.convertProperty(pointKeyName, mappingKeys, featurePoint, newProperties)
|
this.convertProperty(pointKeyName, mappingKeys, featurePoint, newProperties)
|
||||||
|
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
basePoint.properties = newProperties
|
basePoint.properties = newProperties
|
||||||
@ -178,6 +179,12 @@ export default class {
|
|||||||
debugLog(' ------ convertProperty: pointKeyName', pointKeyName)
|
debugLog(' ------ convertProperty: pointKeyName', pointKeyName)
|
||||||
// debugLog('convertProperty: mappingKeys', mappingKeys)
|
// debugLog('convertProperty: mappingKeys', mappingKeys)
|
||||||
|
|
||||||
|
let remove_original_key = false;
|
||||||
|
if (this.mapping_config.tags_to_ignore_if_value_is.indexOf(originalValue) !== -1) {
|
||||||
|
remove_original_key = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (this.jardinage) {
|
if (this.jardinage) {
|
||||||
debugLog(' ------ on fait du jardinage')
|
debugLog(' ------ on fait du jardinage')
|
||||||
debugLog(' ------ mode mise en qualité activé')
|
debugLog(' ------ mode mise en qualité activé')
|
||||||
@ -240,12 +247,14 @@ export default class {
|
|||||||
debugLog('convertProperty: no string value')
|
debugLog('convertProperty: no string value')
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isConfigMappingObject) {
|
|
||||||
let configObject = mappingConfigOfTag
|
let configObject = mappingConfigOfTag
|
||||||
|
|
||||||
|
if (isConfigMappingObject) {
|
||||||
|
|
||||||
|
|
||||||
debugLog('convertProperty: is config object', configObject)
|
debugLog('convertProperty: is config object', configObject)
|
||||||
let newKey: any = '' + pointKeyName
|
let newKey: any = '' + pointKeyName
|
||||||
let remove_original_key = false;
|
|
||||||
|
|
||||||
if (configObject.key_converted) {
|
if (configObject.key_converted) {
|
||||||
newKey = configObject.key_converted
|
newKey = configObject.key_converted
|
||||||
|
@ -24,25 +24,45 @@ export interface BoundingBoxCoordinatesType{
|
|||||||
yMin: number,
|
yMin: number,
|
||||||
yMax: number,
|
yMax: number,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* configuration to choose what point to exclude or include from geographic or properties hints
|
||||||
|
*/
|
||||||
|
export interface filteringConfig {
|
||||||
|
enable_coordinates_filter?: boolean;
|
||||||
|
enable_properties_filter?: boolean;
|
||||||
|
properties?: object;
|
||||||
|
bounding_box?: object;
|
||||||
|
exclude_point_if_tag_not_empty?: Array<string>;
|
||||||
|
exclude_point_if_tag_truthy?: Array<string>;
|
||||||
|
exclude_point_if_tag_falsy?: Array<string>;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface sourceConfig {
|
||||||
|
geojson_path: string; // the relative path to the geojson source file to analyse, from the root of this repository
|
||||||
|
url: string; // URL from where the geojson comes online, on a data platform. This URL should be fetchable to get the most recent data of the concerned dataset to convert.
|
||||||
|
}
|
||||||
|
|
||||||
export default interface MappingConfigType {
|
export default interface MappingConfigType {
|
||||||
config_name: string,
|
config_name: string,
|
||||||
config_author: string,
|
config_author: string,
|
||||||
osmose?: boolean,
|
osmose?: boolean,
|
||||||
boolean_keys?: Array<string>,
|
boolean_keys?: Array<string>,
|
||||||
|
tags_to_ignore_if_value_is?: Array<string>,
|
||||||
add_not_mapped_tags_too: boolean,
|
add_not_mapped_tags_too: boolean,
|
||||||
default_properties_of_point: object,
|
default_properties_of_point?: object, // tag to add to every converted point by default
|
||||||
source: object,
|
source: sourceConfig,
|
||||||
filters: object,
|
filters?: filteringConfig,
|
||||||
tags: FeaturePropertyMappingConfigType
|
tags: FeaturePropertyMappingConfigType
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* configuration concernant toutes les valeurs
|
* configuration concernant toutes les valeurs
|
||||||
*/
|
*/
|
||||||
export interface FeaturePropertyMappingConfigType {
|
export interface FeaturePropertyMappingConfigType {
|
||||||
[key: string]: any,
|
[key: string]: any,
|
||||||
|
|
||||||
convert_to_boolean_value?: boolean,
|
convert_to_boolean_value?: boolean,
|
||||||
remove_original_key?: boolean,
|
remove_original_key?: boolean,
|
||||||
conditionnal_values?: ConditionnalValuesType,
|
conditionnal_values?: ConditionnalValuesType,
|
||||||
@ -65,6 +85,7 @@ export interface ConditionnalValuesConfigType{
|
|||||||
export interface ConditionnalValuesType {
|
export interface ConditionnalValuesType {
|
||||||
[key: string]: ConditionnalValuesConfigType,
|
[key: string]: ConditionnalValuesConfigType,
|
||||||
}
|
}
|
||||||
|
|
||||||
interface OneOSMTag {
|
interface OneOSMTag {
|
||||||
[key: string]: string,
|
[key: string]: string,
|
||||||
}
|
}
|
||||||
|
17828
output/my_converted_data_set__mappingRouenParkingVelos.json
Normal file
17828
output/my_converted_data_set__mappingRouenParkingVelos.json
Normal file
File diff suppressed because it is too large
Load Diff
@ -13,6 +13,7 @@
|
|||||||
wget https://www.data.gouv.fr/fr/datasets/r/7eee8f09-5d1b-4f48-a304-5e99e8da1e26 -O "latest.json"
|
wget https://www.data.gouv.fr/fr/datasets/r/7eee8f09-5d1b-4f48-a304-5e99e8da1e26 -O "latest.json"
|
||||||
|
|
||||||
wget "https://data.issy.com/api/explore/v2.1/catalog/datasets/parkings-2-roues/exports/geojson?lang=fr&timezone=Europe%2FBerlin" -O "issy_les_mx_cyclabilité.json"
|
wget "https://data.issy.com/api/explore/v2.1/catalog/datasets/parkings-2-roues/exports/geojson?lang=fr&timezone=Europe%2FBerlin" -O "issy_les_mx_cyclabilité.json"
|
||||||
|
wget "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" -O "rouen_parking_velos.json"
|
||||||
wget https://www.data.gouv.fr/fr/datasets/r/8d9398ae-3037-48b2-be19-412c24561fbb -O "latest.csv"
|
wget https://www.data.gouv.fr/fr/datasets/r/8d9398ae-3037-48b2-be19-412c24561fbb -O "latest.csv"
|
||||||
#wget https://github.com/BastienGauthier/clean_french_irve/blob/main/data/df_irve_etalab_cleaned.csv -O "clean_french_irve.csv"
|
#wget https://github.com/BastienGauthier/clean_french_irve/blob/main/data/df_irve_etalab_cleaned.csv -O "clean_french_irve.csv"
|
||||||
wget "https://osmose.openstreetmap.fr/api/0.3/issues.geojson?full=true&status=open&item=8410&limit=20000" -O "osmose-item-irve-8411-intégrables.json"
|
wget "https://osmose.openstreetmap.fr/api/0.3/issues.geojson?full=true&status=open&item=8410&limit=20000" -O "osmose-item-irve-8411-intégrables.json"
|
||||||
@ -20,6 +21,7 @@ wget "https://osmose.openstreetmap.fr/api/0.3/issues.geojson?full=true&status=op
|
|||||||
rm website-data.log
|
rm website-data.log
|
||||||
echo " - déplacement des datasets des IRVE dans le dossier etalab_data/irve_bornes_recharge"
|
echo " - déplacement des datasets des IRVE dans le dossier etalab_data/irve_bornes_recharge"
|
||||||
mv "geojson?lang=fr" ../etalab_data/cyclabilité/issy_les_mx_cyclabilité.json
|
mv "geojson?lang=fr" ../etalab_data/cyclabilité/issy_les_mx_cyclabilité.json
|
||||||
|
mv "rouen_parking_velos.json" ../etalab_data/cyclabilité/rouen_parking_velos.json
|
||||||
mv latest.json ../etalab_data/irve_bornes_recharge/
|
mv latest.json ../etalab_data/irve_bornes_recharge/
|
||||||
mv clean_french_irve.csv ../etalab_data/irve_bornes_recharge/
|
mv clean_french_irve.csv ../etalab_data/irve_bornes_recharge/
|
||||||
mv osmose-item-irve-8411-intégrables.json ../etalab_data/irve_bornes_recharge/
|
mv osmose-item-irve-8411-intégrables.json ../etalab_data/irve_bornes_recharge/
|
||||||
|
Loading…
Reference in New Issue
Block a user