mirror of
https://forge.chapril.org/tykayn/libre-charge-map
synced 2025-06-20 01:34:43 +02:00
refacto naming exports js librechargemap with lcm_ prefix
This commit is contained in:
parent
7100bc1d52
commit
c194a858b1
8 changed files with 110 additions and 95 deletions
53
js/lcm_color_utils.js
Normal file
53
js/lcm_color_utils.js
Normal file
|
@ -0,0 +1,53 @@
|
|||
import lcm_utils from './lcm_utils.js'
|
||||
|
||||
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 lcm_color_utils = {
|
||||
colors,
|
||||
/**
|
||||
* trouver une couleur correspondant
|
||||
*/
|
||||
getColor: (feature) => {
|
||||
|
||||
let outputPower = lcm_utils.guessOutputPowerFromFeature(feature)
|
||||
feature.properties.tags.has_output_of_irve_specified = outputPower
|
||||
if (outputPower) {
|
||||
|
||||
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
|
||||
}
|
||||
return colors[index]
|
||||
}
|
||||
// autrement, sans puissance max trouvée, on met la couleur des indéfinis
|
||||
return unknown_color
|
||||
},
|
||||
}
|
||||
|
||||
export default lcm_color_utils
|
Loading…
Add table
Add a link
Reference in a new issue