Compare commits

..

3 Commits

10 changed files with 57867 additions and 69 deletions

View File

@ -10,10 +10,11 @@ import mappingConfigIRVEFromOsmose from './mappings/converters/configIRVE_osmose
import mappingConfigIRVE_simple from './mappings/converters/mappingConfigIRVE_simple'
import mappingTest from './mappings/converters/configTest'
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 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')
@ -145,7 +146,7 @@ function writeFile(fileName: string, fileContent: any) {
* @param pointCounterMax
* @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)
fs.readFile(sourceFilePath, 'utf8', function (err, data) {
@ -161,7 +162,7 @@ function convertDataFromSource(sourceFilePath: string, mapping: any, pointCounte
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
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) => {
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) {
debugLog('filtre sur les départements activé')
@ -344,6 +357,8 @@ function setMappingConfigFromName(engine_conf_choice: string) {
Mapping_engine.setConfig(mappingTest)
} else if (engine_conf_choice == 'ConfigIRVE') {
Mapping_engine.setConfig(ConfigIRVE)
} else if (engine_conf_choice == 'mappingRouenParkingVelos') {
Mapping_engine.setConfig(mappingRouenParkingVelos)
}
} else {
Mapping_engine.setConfig(mappingConfigIRVE)

View File

@ -22,3 +22,7 @@ Conversion en fichier OSM avec le paquet python pip geojson2osm:
```shell
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
```

File diff suppressed because it is too large Load Diff

View File

@ -89,11 +89,11 @@ const MappingIRVE: MappingConfigType = {
// ******** champs booléens
cable_t2_attache: {
key_converted: 'socket:type2_cable',
// socket:type2_cable vaut 1 dans OSM si vrai
truthy_value: '1',
ignore_if_falsy: true,
}
key_converted: 'socket:type2_cable',
// socket:type2_cable vaut 1 dans OSM si vrai
truthy_value: '1',
ignore_if_falsy: true,
}
,
prise_type_ef: {
key_converted: 'socket:typee',
@ -123,28 +123,28 @@ const MappingIRVE: MappingConfigType = {
convert_to_boolean_value: true,
},
accessibilite_pmr: {
key_converted: "wheelchair",
conditional_values: {
"Accessibilité inconnue": {
ignore_this_data: true, // ne pas ajouter de tag si la valeur est égale à Accessibilité inconnue.
},
"Accessible mais non réservé PMR": {
value_converted: "yes"
},
"Réservé PMR": {
value_converted: "yes"
},
"Non accessible": {
value_converted: "no"
},
"Mo-Fr 08:30-12:00,Mo-Fr 14:00-19:00,Sat 09:00-18:30": {
value_converted: "Mo-Fr 08:30-12:00,Mo-Fr 14:00-19:00,Sat 09:00-18:30"
},
// On précise que l'on veut conserver cette valeur, par défaut tout ce qui n'est pas précisé en valeur conditionnelle n'est pas conservé
"24/7": {
value_converted: "24/7"
}
},
key_converted: "wheelchair",
conditional_values: {
"Accessibilité inconnue": {
ignore_this_data: true, // ne pas ajouter de tag si la valeur est égale à Accessibilité inconnue.
},
"Accessible mais non réservé PMR": {
value_converted: "yes"
},
"Réservé PMR": {
value_converted: "yes"
},
"Non accessible": {
value_converted: "no"
},
"Mo-Fr 08:30-12:00,Mo-Fr 14:00-19:00,Sat 09:00-18:30": {
value_converted: "Mo-Fr 08:30-12:00,Mo-Fr 14:00-19:00,Sat 09:00-18:30"
},
// On précise que l'on veut conserver cette valeur, par défaut tout ce qui n'est pas précisé en valeur conditionnelle n'est pas conservé
"24/7": {
value_converted: "24/7"
}
},
},
station_deux_roues: {
remove_original_key: true,

View 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;

View File

@ -13,7 +13,10 @@ const MappingTest: MappingConfigType = {
nom_amenageur : 'name'
},
add_not_mapped_tags_too: false,
source: {},
source: {
geojson_path: "",
url: ""
},
filters: {},
}

View File

@ -1,6 +1,5 @@
import custom_utils from './utils'
import MappingConfigType from "./mapping-config.type";
import {debuglog} from "util";
const {debugLog} = custom_utils
@ -139,7 +138,9 @@ export default class {
debugLog('mapElementFromConf: convert', pointKeyName)
debugLog('mapElementFromConf: mapping keys:', mappingKeys)
this.convertProperty(pointKeyName, mappingKeys, featurePoint, newProperties)
this.convertProperty(pointKeyName, mappingKeys, featurePoint, newProperties)
})
@ -178,6 +179,12 @@ export default class {
debugLog(' ------ convertProperty: pointKeyName', pointKeyName)
// 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) {
debugLog(' ------ on fait du jardinage')
debugLog(' ------ mode mise en qualité activé')
@ -240,12 +247,14 @@ export default class {
debugLog('convertProperty: no string value')
}
let configObject = mappingConfigOfTag
if (isConfigMappingObject) {
let configObject = mappingConfigOfTag
debugLog('convertProperty: is config object', configObject)
let newKey: any = '' + pointKeyName
let remove_original_key = false;
if (configObject.key_converted) {
newKey = configObject.key_converted

View File

@ -1,75 +1,96 @@
interface GeoJsonGeometry {
type:string,
coordinates:Array<number>,
type: string,
coordinates: Array<number>,
}
interface GeoJsonProperties {
[key:string]: any,
[key: string]: any,
}
interface GeoJsonFeature {
type:string,
geometry:GeoJsonGeometry,
properties:GeoJsonProperties,
type: string,
geometry: GeoJsonGeometry,
properties: GeoJsonProperties,
}
export interface FeatureCollection{
type:string,
features:Array<GeoJsonFeature>,
export interface FeatureCollection {
type: string,
features: Array<GeoJsonFeature>,
}
export interface BoundingBoxCoordinatesType{
export interface BoundingBoxCoordinatesType {
xMin: number,
xMax: number,
yMin: number,
yMax: number,
}
export default interface MappingConfigType{
/**
* 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 {
config_name: string,
config_author: string,
osmose?: boolean,
boolean_keys?: Array<string>,
tags_to_ignore_if_value_is?: Array<string>,
add_not_mapped_tags_too: boolean,
default_properties_of_point: object,
source: object,
filters: object,
default_properties_of_point?: object, // tag to add to every converted point by default
source: sourceConfig,
filters?: filteringConfig,
tags: FeaturePropertyMappingConfigType
}
/**
* configuration concernant toutes les valeurs
*/
export interface FeaturePropertyMappingConfigType{
[key:string]: any,
convert_to_boolean_value?:boolean,
remove_original_key?:boolean,
conditionnal_values?:ConditionnalValuesType,
transform_function?:Function,
export interface FeaturePropertyMappingConfigType {
[key: string]: any,
convert_to_boolean_value?: boolean,
remove_original_key?: boolean,
conditionnal_values?: ConditionnalValuesType,
transform_function?: Function,
}
/**
* choix de conversion de la valeur originale selon des critères donnés
*/
export interface ConditionnalValuesConfigType{
key_converted?:string,
value_converted?:string,
truthy_value?:any,
falsy_value?:any, // si la valeur originale est falsy, la convertir en la valeur donnée ici
ignore_this_data?:boolean,
tags_to_add?:TagsToAddConfig,
transform_function?:Function,
export interface ConditionnalValuesConfigType {
key_converted?: string,
value_converted?: string,
truthy_value?: any,
falsy_value?: any, // si la valeur originale est falsy, la convertir en la valeur donnée ici
ignore_this_data?: boolean,
tags_to_add?: TagsToAddConfig,
transform_function?: Function,
}
export interface ConditionnalValuesType{
[key:string]: ConditionnalValuesConfigType,
export interface ConditionnalValuesType {
[key: string]: ConditionnalValuesConfigType,
}
interface OneOSMTag {
[key:string]: string,
[key: string]: string,
}
export interface TagsToAddConfig{
export interface TagsToAddConfig {
tags_to_add: Array<OneOSMTag>
}

File diff suppressed because it is too large Load Diff

View File

@ -13,6 +13,7 @@
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.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://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"
@ -20,6 +21,7 @@ wget "https://osmose.openstreetmap.fr/api/0.3/issues.geojson?full=true&status=op
rm website-data.log
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 "rouen_parking_velos.json" ../etalab_data/cyclabilité/rouen_parking_velos.json
mv latest.json ../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/