mirror of
https://forge.chapril.org/tykayn/wololo
synced 2025-06-20 01:34:42 +02:00
add filter by date, and RNB conversion
This commit is contained in:
parent
97f818a29e
commit
11c272c582
8 changed files with 100 additions and 3 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -8,4 +8,6 @@ etalab_data/**/*.json
|
|||
etalab_data/**/*.geojson
|
||||
etalab_data/**/*.csv
|
||||
.idea
|
||||
output/*.geojson
|
||||
output/*json
|
||||
osm_output/*json
|
||||
wip/*json
|
|
@ -104,3 +104,5 @@ Données possible d'intégrer en plus avec le même jeu de données:
|
|||
### Bus
|
||||
|
||||
## projets à venir
|
||||
### Référentiel national des bâtiments RNB
|
||||
https://rnb.beta.gouv.fr
|
||||
|
|
|
@ -1,6 +1,36 @@
|
|||
/**
|
||||
* convertisseur de données de bornes de recharge électrique à partir de données Chargemap et open data Etalab
|
||||
* -----------------------------------------------
|
||||
* Arguments possibles en ligne de commande:
|
||||
*
|
||||
* --department=XX : Filtre les données sur le département XX
|
||||
* --osmose : Active le format Osmose pour la conversion
|
||||
* --source=chemin/vers/fichier.json : Spécifie le fichier source à convertir
|
||||
* --engine=true|false : Active/désactive le moteur de mapping
|
||||
* --engine-config=NomConfig : Utilise une configuration spécifique parmi:
|
||||
* - MappingRnb
|
||||
* - mappingIssy2Roues
|
||||
* - mappingConfigIRVE
|
||||
* - mappingConfigIRVEFromOsmose
|
||||
* - mappingConfigIRVE_simple
|
||||
* - mappingTest
|
||||
* - ConfigIRVE
|
||||
* - mappingRouenParkingVelos
|
||||
* - mappingFINESS
|
||||
* - MappingArbresIssy
|
||||
* - MappingArbresEchirolles
|
||||
* - MappingArbres92
|
||||
* - MappingMuseums
|
||||
* - MappingRouenPAV
|
||||
* - MappingAskAngela
|
||||
* - MappingPlanningFamlial
|
||||
* - MappingSurveillanceRouen
|
||||
* --output-file=nom_fichier : Spécifie le nom du fichier de sortie
|
||||
* --outname=nom_fichier : Alias pour --output-file
|
||||
* --testingConfig : Active le mode test avec la configuration mappingTest
|
||||
*/
|
||||
|
||||
|
||||
import * as fs from 'fs'
|
||||
|
||||
import mappingConfigIRVE from './mappings/converters/configIRVE'
|
||||
|
@ -22,10 +52,11 @@ import MappingRouenPAV from "./mappings/converters/configRouen_PAV";
|
|||
import MappingAskAngela from "./mappings/converters/configAskAngela";
|
||||
import MappingPlanningFamlial from "./mappings/converters/configPlanningFamilial";
|
||||
import MappingSurveillanceRouen from "./mappings/converters/configSurveillance";
|
||||
|
||||
import MappingRnb from "./mappings/converters/configRnb";
|
||||
const limitWarningPercentageChangeInPoints = 5; // show a warning when more than N percent of the number of points changed
|
||||
|
||||
const allowed_configs: any = {
|
||||
MappingRnb,
|
||||
mappingIssy2Roues,
|
||||
mappingConfigIRVE,
|
||||
mappingConfigIRVEFromOsmose,
|
||||
|
@ -70,6 +101,8 @@ let enable_filter_on_department = true
|
|||
enable_filter_on_department = false
|
||||
|
||||
let filterDepartment = 91
|
||||
|
||||
|
||||
if (mini_arguments['department']) {
|
||||
filterDepartment = mini_arguments['department']
|
||||
enable_filter_on_department = true
|
||||
|
@ -221,6 +254,11 @@ function convertDataFromSource(sourceFilePath: string, mapping: MappingConfigTyp
|
|||
console.log('------ filter: filter_points_lesser_than_NkW', mapping.filters.filter_points_lesser_than_NkW)
|
||||
list_of_points = Mapping_engine.filterListOfPointsByExcludingIfMaxPowerIsLesserThan(mapping.filters.filter_points_lesser_than_NkW, list_of_points)
|
||||
}
|
||||
if (mapping.filters.filter_points_older_than_year && mapping.filters.filter_points_by_year_property ) {
|
||||
console.log('------ filter: filter_points_older_than_year', mapping.filters.filter_points_older_than_year)
|
||||
list_of_points = Mapping_engine.filterListOfPointsByExcludingIfColumnBeforeSomeYear(mapping.filters.filter_points_older_than_year, mapping.filters.filter_points_by_year_property, list_of_points)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// for each point from the data source, filter if we take it or not
|
||||
|
|
|
@ -21,6 +21,8 @@ const MappingIRVE: MappingConfigType = {
|
|||
filters: {
|
||||
enable_coordinates_filter: false,
|
||||
enable_properties_filter: true,
|
||||
// filter_points_older_than_year: 2024,
|
||||
// filter_points_by_year_property: 'date_mise_en_service',
|
||||
filter_points_lesser_than_NkW: 50 // ne pas sortir les points qui ont moins de ce nombre de puissance nominale
|
||||
// add only geojson points who are found having this regex in the zipcode properties
|
||||
// properties: {
|
||||
|
|
33
mappings/converters/configRnb.ts
Normal file
33
mappings/converters/configRnb.ts
Normal file
|
@ -0,0 +1,33 @@
|
|||
/**
|
||||
* points d'apport volontaire de Rouen
|
||||
*/
|
||||
import MappingConfigType from "../mapping-config.type";
|
||||
|
||||
// référentiel national des bâtiments
|
||||
const MappingRnb: MappingConfigType = {
|
||||
config_name: "MappingRnb de référentiel national des bâtiments",
|
||||
config_author: "tykayn <contact@cipherbliss.com>",
|
||||
default_properties_of_point: {},
|
||||
source: {
|
||||
geojson_path: 'https://data.metropole-rouen-normandie.fr/api/explore/v2.1/catalog/datasets/donmetdec_pav/exports/geojson?lang=fr&timezone=Europe%2FBerlin',
|
||||
url: 'https://data.metropole-rouen-normandie.fr/explore/dataset/donmetdec_pav/information/'
|
||||
},
|
||||
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
|
||||
// offset: 50
|
||||
},
|
||||
add_not_mapped_tags_too: false,
|
||||
boolean_keys: [
|
||||
// "acces_reglement",
|
||||
],
|
||||
// tags_to_ignore_if_value_is: ['Non renseigne'],
|
||||
tags: {
|
||||
// ******* nombres
|
||||
rnb_id: 'ref:FR:RNB',
|
||||
// ******* textes
|
||||
status: 'ref:FR:RNB:status',
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
export default MappingRnb;
|
|
@ -130,6 +130,24 @@ export default class {
|
|||
return newList;
|
||||
}
|
||||
|
||||
filterListOfPointsByExcludingIfColumnBeforeSomeYear(year: number, column:string, list_of_points: any[]): any[] {
|
||||
let newList: any[] = []
|
||||
list_of_points.forEach((geojsonPoint: any) => {
|
||||
let pointProperties = Object.keys(geojsonPoint.properties)
|
||||
// trouver la valeur
|
||||
|
||||
// on inclut les points dont la date de création est de l'année demandée ou supérieure
|
||||
if (pointProperties.includes(column) &&
|
||||
(geojsonPoint.properties[column].substring(0,4) * 1) >= year
|
||||
) {
|
||||
newList.push(geojsonPoint)
|
||||
}
|
||||
})
|
||||
|
||||
return newList;
|
||||
|
||||
}
|
||||
|
||||
filterListOfPointsByExcludingIfMaxPowerIsLesserThan(minValue: number, list_of_points: any[]): any[] {
|
||||
let newList: any[] = []
|
||||
list_of_points.forEach((geojsonPoint: any) => {
|
||||
|
|
|
@ -35,6 +35,8 @@ export interface filteringConfig {
|
|||
bounding_box?: object;
|
||||
offset?: number;
|
||||
filter_points_lesser_than_NkW?: number; // filtrer les points qui ont moins de N kW dans la clé de puissance max
|
||||
filter_points_older_than_year?: number; // filtrer les points ayant une date avant une certaine année
|
||||
filter_points_by_year_property?: string; // choix de colonne à examiner pour filter_points_older_than_year
|
||||
exclude_point_if_tag_not_empty?: Array<string>;
|
||||
exclude_point_if_tag_truthy?: Array<string>;
|
||||
exclude_point_if_tag_falsy?: Array<string>;
|
||||
|
|
|
@ -5,7 +5,7 @@ import plotly.graph_objects as go
|
|||
import io
|
||||
|
||||
# Chargement du fichier JSON
|
||||
with open('/home/poule/encrypted/stockage-syncable/www/development/html/mapping-geojson-osm/etalab_data/irve_bornes_recharge/latest.csv', 'r') as file:
|
||||
with open('/home/poule/encrypted/stockage-syncable/www/development/html/wololo/etalab_data/irve_bornes_recharge/latest.csv', 'r') as file:
|
||||
data = pd.read_csv(file)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue