detect enum of power

This commit is contained in:
Tykayn 2024-12-22 18:57:06 +01:00 committed by tykayn
parent d1efdbd256
commit a004d47392

View File

@ -1,77 +1,89 @@
const utils = { const utils = {
/** /**
* fouiller dans les tags les valeurs explicites de puissance déclarée. * fouiller dans les tags les valeurs explicites de puissance déclarée.
* Deviner aussi les puissances non déclarées: * Deviner aussi les puissances non déclarées:
* - type 2 présent, max 43kW * - type 2 présent, max 43kW
* - type Chademo présent, max 63kW * - type Chademo présent, max 63kW
* https://forum.openstreetmap.fr/t/bornes-de-recharges-et-puissance-chargeurs-quel-est-votre-avis/27828 * https://forum.openstreetmap.fr/t/bornes-de-recharges-et-puissance-chargeurs-quel-est-votre-avis/27828
* *
* @param feature * @param feature
* @returns {number} * @returns {number}
*/ */
guessOutputPowerFromFeature: (feature) => { guessOutputPowerFromFeature: (feature) => {
let outputPower = 0 let outputPower = 0
let power = 0 let power = 0
if (feature.properties && feature.properties.tags) { if (feature.properties && feature.properties.tags) {
let found_type_2 = false let found_type_2 = false
let found_type_chademo = false let found_type_chademo = false
// deviner les puissances max selon les capacités de prises // deviner les puissances max selon les capacités de prises
for (var tag in feature.properties.tags) { for (var tag in feature.properties.tags) {
if (tag.indexOf('type2') !== -1) { if (tag.indexOf('type2') !== -1) {
found_type_2 = true found_type_2 = true
power = 43 power = 43
} }
if (tag.indexOf('chademo') !== -1) { if (tag.indexOf('chademo') !== -1) {
found_type_chademo = true found_type_chademo = true
power = 63 power = 63
} }
let value = feature.properties.tags[tag] let value = feature.properties.tags[tag]
if (value && tag.toLowerCase().indexOf('output') !== -1) { if (value && tag.toLowerCase().indexOf('output') !== -1) {
value = '' + value value = '' + value
if (value.replace) { if (value.indexOf(';') !== -1) {
value = value.replace(' ') console.log('value output multiple', value)
value = value.replace('kW', '') let explode = value.split(';')
} explode.forEach(elem => {
let power = parseInt(value) if (value.replace) {
if (power > outputPower) { value = value.replace(' ')
outputPower = power value = value.replace('kW', '')
} }
} let power = parseInt(value)
} if (power > outputPower) {
} outputPower = power
feature.properties.outputPower = outputPower }
return outputPower })
}, } else {
if (value.replace) {
value = value.replace(' ')
value = value.replace('kW', '')
}
let power = parseInt(value)
if (power > outputPower) {
outputPower = power
}
}
}
}
}
feature.properties.outputPower = outputPower
return outputPower
},
/** /**
* villes les plus peuplées de France * villes les plus peuplées de France
*/ */
cities: [ cities: [
{ name: 'Paris', coords: [48.8566, 2.3522] }, {name: 'Paris', coords: [48.8566, 2.3522]},
{ name: 'Marseille', coords: [43.2965, 5.3698] }, {name: 'Marseille', coords: [43.2965, 5.3698]},
{ name: 'Lyon', coords: [45.7640, 4.8357] }, {name: 'Lyon', coords: [45.7640, 4.8357]},
{ name: 'Toulouse', coords: [43.6042, 1.4437] }, {name: 'Toulouse', coords: [43.6042, 1.4437]},
{ name: 'Nice', coords: [43.7101, 7.2620] }, {name: 'Nice', coords: [43.7101, 7.2620]},
{ name: 'Nantes', coords: [47.2184, -1.5536] }, {name: 'Nantes', coords: [47.2184, -1.5536]},
{ name: 'Strasbourg', coords: [48.5831, 7.7521] }, {name: 'Strasbourg', coords: [48.5831, 7.7521]},
{ name: 'Montpellier', coords: [43.6167, 3.8742] }, {name: 'Montpellier', coords: [43.6167, 3.8742]},
{ name: 'Bordeaux', coords: [44.8378, -0.5792] }, {name: 'Bordeaux', coords: [44.8378, -0.5792]},
{ name: 'Lille', coords: [50.6293, 3.1466] }, {name: 'Lille', coords: [50.6293, 3.1466]},
{ name: 'Rennes', coords: [48.1120, -1.6823] }, {name: 'Rennes', coords: [48.1120, -1.6823]},
{ name: 'Toulon', coords: [43.1230, 5.9291] }, {name: 'Toulon', coords: [43.1230, 5.9291]},
{ name: 'Le Havre', coords: [49.4943, 0.1079] }, {name: 'Le Havre', coords: [49.4943, 0.1079]},
{ name: 'Saint-Etienne', coords: [45.4380, 4.3841] }, {name: 'Saint-Etienne', coords: [45.4380, 4.3841]},
{ name: 'Grenoble', coords: [45.1667, 5.7295] }, {name: 'Grenoble', coords: [45.1667, 5.7295]},
{ name: 'Rouen', coords: [49.4431, 1.0820] }, {name: 'Rouen', coords: [49.4431, 1.0820]},
{ name: 'Dijon', coords: [47.3221, 5.0446] }, {name: 'Dijon', coords: [47.3221, 5.0446]},
{ name: 'Angers', coords: [47.4786, -0.5551] }, {name: 'Angers', coords: [47.4786, -0.5551]},
{ name: 'Nîmes', coords: [43.8366, 4.3623] }, {name: 'Nîmes', coords: [43.8366, 4.3623]},
{ name: 'Reims', coords: [49.2500, 4.0333] } {name: 'Reims', coords: [49.2500, 4.0333]}
] ]
} }
export default utils export default utils