2024-12-17 12:17:33 +01:00
|
|
|
import utils from './utils.js'
|
2024-12-17 11:53:02 +01:00
|
|
|
|
|
|
|
let unknown_color = '#c0b1b1' // color for unknown power output of the station
|
|
|
|
const colors = [
|
|
|
|
'#36423d',
|
|
|
|
'#4e8a8d',
|
|
|
|
'#2999b3',
|
|
|
|
'#1782dd',
|
|
|
|
'#2900ff',
|
|
|
|
'#8000ff',
|
|
|
|
]
|
|
|
|
|
|
|
|
const error_color = '#ff1414'
|
|
|
|
// 2024-12-16: au delà d'une valeur de 400kW on peut dire qu'il existe une erreur de saisie, nous n'avons pas de chargeur de 1800kW en production.
|
|
|
|
const max_out_legit_power = 400
|
|
|
|
|
|
|
|
const colorUtils = {
|
2024-12-17 12:17:33 +01:00
|
|
|
colors,
|
2024-12-17 11:53:02 +01:00
|
|
|
/**
|
|
|
|
* trouver une couleur correspondant
|
|
|
|
*/
|
2024-12-17 12:17:33 +01:00
|
|
|
getColor: (feature) => {
|
2024-12-17 11:53:02 +01:00
|
|
|
|
|
|
|
let outputPower = utils.guessOutputPowerFromFeature(feature)
|
|
|
|
feature.properties.tags.has_output_of_irve_specified = outputPower
|
|
|
|
if (outputPower) {
|
|
|
|
|
2024-12-17 12:17:33 +01:00
|
|
|
if (outputPower > max_out_legit_power) {
|
|
|
|
return error_color
|
|
|
|
}
|
|
|
|
let index = 0
|
|
|
|
// index = Math.min(Math.floor(outputPower / 10), colors.length - 1)
|
|
|
|
if (outputPower >= 300) {
|
|
|
|
index = 5
|
|
|
|
} else if (outputPower >= 200) {
|
|
|
|
index = 4
|
|
|
|
} else if (outputPower >= 100) {
|
|
|
|
index = 3
|
|
|
|
} else if (outputPower >= 50) {
|
|
|
|
index = 2
|
|
|
|
} else if (outputPower >= 20) {
|
|
|
|
index = 1
|
|
|
|
} else if (outputPower >= 0) {
|
|
|
|
index = 0
|
2024-12-17 11:53:02 +01:00
|
|
|
}
|
|
|
|
return colors[index]
|
|
|
|
}
|
|
|
|
// autrement, sans puissance max trouvée, on met la couleur des indéfinis
|
|
|
|
return unknown_color
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
export default colorUtils
|