Add snow depth color thresholds
This commit is contained in:
@@ -27,6 +27,21 @@ export const PRECIPITATION: ColorEntry[] = [
|
||||
{ value: 0.1, color: [152, 233, 252, 0] },
|
||||
]
|
||||
|
||||
export const SNOW_DEPTH: ColorEntry[] = [
|
||||
{ value: 40, color: [126, 26, 99, 255] },
|
||||
{ value: 30, color: [120, 27, 131, 255] },
|
||||
{ value: 20, color: [84, 20, 130, 255] },
|
||||
{ value: 15, color: [49, 16, 129, 255] },
|
||||
{ value: 10, color: [9, 15, 129, 255] },
|
||||
{ value: 7, color: [0, 24, 150, 255] },
|
||||
{ value: 6, color: [0, 43, 186, 255] },
|
||||
{ value: 5, color: [10, 70, 220, 255] },
|
||||
{ value: 4, color: [40, 109, 246, 255] },
|
||||
{ value: 3, color: [80, 162, 248, 255] },
|
||||
{ value: 2, color: [118, 202, 249, 255] },
|
||||
{ value: 1, color: [152, 233, 252, 0] },
|
||||
]
|
||||
|
||||
// from ltv
|
||||
export const TEMPERATURES: ColorEntry[] = [
|
||||
{ value: 35, color: [155, 30, 30, 255] },
|
||||
|
||||
@@ -8,6 +8,7 @@ import { temperatureColors } from './temperature'
|
||||
import { isCalculatedWindDirection, windDirectionArrows, windDirectionColors, windSpeedColors } from './windDirection'
|
||||
|
||||
import latvia_border from '../../../assets/latvia_contour.webp'
|
||||
import { snowDepthColors } from './snowDepth'
|
||||
const latviaBoderImg = new Image()
|
||||
latviaBoderImg.onload = () => {}
|
||||
latviaBoderImg.src = latvia_border
|
||||
@@ -123,7 +124,7 @@ function fillImageData(
|
||||
color = precipitationColors(encodedValue, conversion, isInterpolated)
|
||||
}
|
||||
else if (isMeteoEqual(meteo, SNOW_DEPTH)) {
|
||||
color = precipitationColors(encodedValue, conversion, isInterpolated)
|
||||
color = snowDepthColors(encodedValue, conversion, isInterpolated)
|
||||
}
|
||||
else if (isMeteoEqual(meteo, TEMPERATURE)) {
|
||||
color = temperatureColors(encodedValue, conversion, isInterpolated)
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
import { valueToColorInterpolated, valueToColorThreshold } from '../../../helpers/interpolateColors'
|
||||
import { MeteoConversion } from '../interfaces'
|
||||
import { SNOW_DEPTH } from './constants'
|
||||
|
||||
export function snowDepthColors(
|
||||
encodedValue: number,
|
||||
{ reference, binaryScale, decimalScale}: MeteoConversion,
|
||||
isInterpolated = true,
|
||||
): [number, number, number, number] {
|
||||
const rainMM = (reference + encodedValue * Math.pow(2, binaryScale)) * Math.pow(10, -decimalScale)
|
||||
|
||||
return isInterpolated
|
||||
? valueToColorInterpolated(rainMM, SNOW_DEPTH)
|
||||
: valueToColorThreshold(rainMM, SNOW_DEPTH)
|
||||
}
|
||||
Reference in New Issue
Block a user