Compare commits

..

3 Commits

Author SHA1 Message Date
c28741d751 up convert to name 2024-10-09 16:34:52 +02:00
e414600d45 update conditional config convert to name 2024-10-09 16:22:57 +02:00
1b8a0c590b mapping finess works 2024-10-09 15:56:30 +02:00
11 changed files with 493962 additions and 18918 deletions

View File

@ -13,8 +13,9 @@ import mapping_engine from './mappings/engine'
import MappingConfigType, {BoundingBoxCoordinatesType, FeatureCollection} from "./mappings/mapping-config.type";
import utils from './mappings/utils'
import mappingRouenParkingVelos from "./mappings/converters/configRouen_OpenData_velo_parkings";
import mappingFINESS from "./mappings/converters/configFINESS";
const allowed_configs = ['mappingIssy2Roues', 'mappingConfigIRVE', 'mappingConfigIRVEFromOsmose', 'mappingConfigIRVE_simple', 'mappingTest', 'ConfigIRVE', 'mappingRouenParkingVelos'];
const allowed_configs = ['mappingIssy2Roues', 'mappingConfigIRVE', 'mappingConfigIRVEFromOsmose', 'mappingConfigIRVE_simple', 'mappingTest', 'ConfigIRVE', 'mappingRouenParkingVelos','mappingFINESS'];
const minimist = require('minimist')
@ -376,6 +377,9 @@ function setMappingConfigFromName(engine_conf_choice: string) {
} else if (engine_conf_choice == 'mappingRouenParkingVelos') {
Mapping_engine.setConfig(mappingRouenParkingVelos)
}
else if (engine_conf_choice == 'mappingFINESS') {
Mapping_engine.setConfig(mappingFINESS)
}
} else {
Mapping_engine.setConfig(mappingConfigIRVE)
}

View File

@ -28,8 +28,8 @@ Le détail complet des configurations de MappingConfigType est à voir dans la p
Choisir le jeu de données en changeant la configuration dans `convert_to_osm_tags.ts`.
Importer son Mapper dans `convert_to_osm_tags.ts` et le faire charger dans l'[Engine](engine.md) dans la partie qui réalise le chargement d'un Mapper.
Ajouter le nom du mapper dans le tableau `allowed_configs`, puis remplir une condition pour
Ajouter le nom du mapper dans le tableau `allowed_configs`, puis remplir une condition pour que l'Engine prenne le bon modèle de mapping.
# Debug
activer les logs.
activer les logs dans le fichier des `utils.ts`.

8
docs/finess_santé.md Normal file
View File

@ -0,0 +1,8 @@
# fichier FINESS
Le fichier répertoriant les établissements de santé, hôpitaux, maisons médicales, pharmacies, laboratoires d'analyse...
# conversion
Commande de conversion:
```bash
ts-node convert_to_osm_tags.ts --source=etalab_data/finess/finess_idf.json --output-file=finess_idf.json --engine-config=mappingFINESS
```

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,99 @@
{"type":"FeatureCollection"
,"features":[
{"type":"Feature"
,"geometry":
{"type":"Point"
,"coordinates":[2.411054732630236,48.762205707875424]},
"properties":
{
"nofinesset":"940008006",
"nofinessej":"940007990",
"rs":"PHARMACIE DU PORT",
"rslongue":"PHARMACIE DU PORT",
"complrs":null
,"compldistrib":null
numvoie":41
,"typvoie":"AV"
,"voie":"ANATOLE FRANCE"
,"compvoie":null
,"lieuditbp":null,
"commune":"022"
,"com_code":"94022"
,"dep_code":"94"
,"dep_name":"VAL DE MARNE"
,"ligneacheminement":"94600 CHOISY LE ROI"
,"telephone":"0148847477",
"telecopie":null
,"categetab":620
,"libcategetab":"Pharmacie d'Officine"
,"categagretab":"3201"
,"libcategagretab":"Commerce de Biens \u00e0 Usage M\u00e9dicaux"
,"siret":"33909485600020"
,"codeape":null
,"codemft":"01"
,"libmft":"Etablissement Tarif Libre",
"codesph":null
,"libsph":null
,"dateouv":"2021-07-12"
,"dateautor":"2011-02-25"
,"datemaj_structure":"2022-10-26"
,"numuai":null
,"coordxet":656709.0,
"coordyet":6851506.0
,"sourcecoordet":"2,ATLASANTE,100,IGN,BD_ADRESSE,V2.2,LAMBERT_93"
,"datemaj_geo":"2024-07-01"
,"com_name":"Choisy-le-Roi",
"reg_code":"11"
,"reg_name":"\u00cele-de-France"
,"epci_code":"200054781"
,"epci_name":"M\u00e9tropole du Grand Paris"
,"address":"41 AV ANATOLE FRANCE"}
}
,{"type":"Feature"
,"geometry":{"type":"Point"
,"coordinates":[2.5384355598256487,48.83001017590122]},
"properties":{"nofinesset":"940008998"
,"nofinessej":"940721400"
,"rs":"CMP INFANTO JUVENILE VILLIERS"
,"rslongue":"CMP INFANTO JUVENILE VILLIERS"
,"complrs":null
,"compldistrib":null
,"numvoie":10
,"typvoie":"RTE"
,"voie":"DE BRY"
,"compvoie":null
,"lieuditbp":null
,"commune":"079"
,"com_code":"94079"
,"dep_code":"94"
,"dep_name":"VAL DE MARNE"
,"ligneacheminement":"94350 VILLIERS SUR MARNE"
,"telephone":"0145937171"
,"telecopie":"0145762003"
,"categetab":156
,"libcategetab":"Centre M\u00e9dico-Psychologique (C.M.P.)"
,"categagretab":"1111"
,"libcategagretab":"Autres Etablissements de Lutte contre les Maladies Mentales"
,"siret":null
,"codeape":"8610Z"
,"codemft":"15"
,"libmft":"ARS priv\u00e9 hors PSPH sous dotation globale"
,"codesph":7
,"libsph":"Etab de sant\u00e9 priv\u00e9 non lucratif, non d\u00e9clar int\u00e9r\u00eat collect"
,"dateouv":"1973-04-01"
,"dateautor":"1973-04-01"
,"datemaj_structure":"2019-03-14"
,"numuai":null
,"coordxet":666116.2
,"coordyet":6858982.7
,"sourcecoordet":"1,ATLASANTE,100,IGN,BD_ADRESSE,V2.2,LAMBERT_93"
,"datemaj_geo":"2024-07-01"
,"com_name":"Villiers-sur-Marne"
,"reg_code":"11"
,"reg_name":"\u00cele-de-France"
,"epci_code":"200054781"
,"epci_name":"M\u00e9tropole du Grand Paris"
,"address":"10 RTE DE BRY"}},
]}

View File

@ -0,0 +1,84 @@
/**
* 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 mappingFINESS: MappingConfigType = {
config_name: "mappingFINESS",
config_author: "tykayn <contact@cipherbliss.com>",
default_properties_of_point: {},
source: {
geojson_path: "finess/finess_idf.json",
url: 'https://www.data.gouv.fr/fr/datasets/r/b9731c6f-c0d7-422e-9e1c-19edd51687ce'
},
filters: {
// exclude_point_if_tag_not_empty: ['id_osm'],
// offset: 1
},
add_not_mapped_tags_too: false,
boolean_keys: [],
tags_to_ignore_if_value_is: [],
tags: {
// ******* nombres
// capacite: 'capacity',
// ******* textes
siret: 'ref:FR:SIRET',
rslongue: {
key_converted: 'name',
convert_to_name: true,
},
nofinesset: 'ref:FR:FINESS:et',
nofinessej: 'ref:FR:FINESS:ej',
// categetab: 'ref:FR:categtab',
epci_code: 'ref:FR:code_EPCI',
epci_name: 'ref:FR:EPCI',
codeape: 'ref:FR:NAF', // https://wiki.openstreetmap.org/wiki/FR:Key:ref:FR:NAF
// categtab: 'type:FR:FINESS',
dateouv: 'start_date',
dateautor: 'authorisation_date',
telephone: {
key_converted: 'operator:phone',
convert_to_phone: true,
},
telecopie: {
key_converted: 'operator:fax',
convert_to_phone: true,
},
categetab: {
// remove_original_key: true,
key_converted: 'ref:FR:FINESS:category',
conditional_values: {
// "Laboratoires de Biologie Médicale": {
611: {
tags_to_add: {
"healthcare": "laboratory"
}
},
// "Centre Hospitalier (C.H.)": {
"412": {
tags_to_add: {
"amenity": "hospital",
"healthcare": "hospital"
}
},
// "Pharmacie d'Officine": {
620: {
tags_to_add: {
"healthcare": "pharmacy"
}
},
// "Maison de santé (L.6223-3)": {
"603": {
tags_to_add: {
"healthcare": "centre"
}
},
}
},
}
}
export default mappingFINESS;

View File

@ -212,7 +212,7 @@ export default class {
// debugLog('convertProperty: mappingKeys', mappingKeys)
let remove_original_key = false;
if (this.mapping_config.tags_to_ignore_if_value_is.indexOf(originalValue) !== -1) {
if (this.mapping_config.tags_to_ignore_if_value_is?.indexOf(originalValue) !== -1) {
debugLog('(x) => ignore', originalValue, ' in ', pointKeyName)
remove_original_key = true;
}
@ -437,6 +437,9 @@ export default class {
}
}
if (configObject.convert_to_name) {
convertedValue = Formatters.convertToName(originalValue)
}
if (configObject.remove_original_key) {
remove_original_key = true
}
@ -452,6 +455,9 @@ export default class {
*/
if (configObject.conditional_values) {
// convert numbers from json to string to compare them correctly
originalValue = ''+originalValue
let keysConditionnalValues: any = Object.keys(configObject.conditional_values)
let isFoundValue = keysConditionnalValues.indexOf(originalValue)
let conditionnalConfig: any = configObject.conditional_values[keysConditionnalValues[isFoundValue]]
@ -461,10 +467,13 @@ export default class {
debugLog('isFoundValue', isFoundValue, originalValue)
debugLog('keysConditionnalValues', keysConditionnalValues)
debugLog('-----++++++++ originalValue', originalValue)
debugLog('----------- isFoundValue', isFoundValue)
if (!remove_original_key) {
if (isFoundValue > -1) {
if (isFoundValue !== -1) {
debugLog('found condition',isFoundValue )
/** ----------------------
* gestion des valeurs conditionnelles
@ -505,16 +514,10 @@ export default class {
// on peut définir un ensemble de tags à rajouter
let tagKeys = Object.keys(conditionnalConfig.tags_to_add)
debugLog('conditionnalConfig.tags_to_add', conditionnalConfig.tags_to_add)
conditionnalConfig.tags_to_add.forEach((object: any, pair: any) => {
debugLog('object', object)
debugLog('pair', pair)
let key: any = Object.keys(object)
key = key[0]
let value = object[key]
debugLog('key', key)
debugLog('value', value)
newProperties[key] = value
tagKeys.forEach((index:any) => {
debugLog('key', index)
debugLog('value', conditionnalConfig.tags_to_add[index])
newProperties[index] = conditionnalConfig.tags_to_add[index]
})
}

View File

@ -69,4 +69,15 @@ export default class Formatters {
return "";
}
static convertToName(originalValue: string) {
if (originalValue && originalValue.length) {
let tab = originalValue.toLowerCase().split('')
tab[0] = originalValue[0].toUpperCase()
return tab.join('');
}
return ''
}
}

View File

@ -65,8 +65,13 @@ export interface FeaturePropertyMappingConfigType {
[key: string]: any,
convert_to_boolean_value?: boolean,
invert_boolean_value?: boolean,
remove_original_key?: boolean,
conditionnal_values?: ConditionnalValuesType,
convert_to_phone?: boolean,
convert_to_name?: boolean,
ignore_if_falsy?: boolean,
ignore_if_truthy?: boolean,
conditional_values?: ConditionnalValuesType,
transform_function?: Function,
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff