testing colors

This commit is contained in:
Tykayn 2024-12-17 12:17:33 +01:00 committed by tykayn
parent be0ea5263c
commit bdd0aaaba2
3 changed files with 73 additions and 10 deletions

View file

@ -1,5 +1,4 @@
import utils from "./utils.js"
import utils from './utils.js'
let unknown_color = '#c0b1b1' // color for unknown power output of the station
const colors = [
@ -16,20 +15,34 @@ const error_color = '#ff1414'
const max_out_legit_power = 400
const colorUtils = {
colors,
/**
* trouver une couleur correspondant
*/
getColor : (feature) =>{
getColor: (feature) => {
let outputPower = utils.guessOutputPowerFromFeature(feature)
feature.properties.tags.has_output_of_irve_specified = outputPower
if (outputPower) {
if(outputPower> max_out_legit_power){
return error_color;
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
}
let index = Math.min(Math.floor(outputPower / 10), colors.length - 1)
return colors[index]
}
// autrement, sans puissance max trouvée, on met la couleur des indéfinis