@@ -15,6 +15,7 @@ import {
15
15
16
16
import type { TypedArray } from '@openmeteo/file-reader' ;
17
17
import type { Domain } from './types' ;
18
+ import type { v8 } from 'maplibre-gl' ;
18
19
19
20
const TILE_SIZE = Number ( import . meta. env . VITE_TILE_SIZE ) * 2 ;
20
21
const OPACITY = Number ( import . meta. env . VITE_TILE_OPACITY ) ;
@@ -37,8 +38,8 @@ const drawArrow = (
37
38
domain : Domain ,
38
39
projectionGrid : ProjectionGrid ,
39
40
directions : TypedArray ,
40
- boxSize = TILE_SIZE / 16 ,
41
- arrowTipLength = 6
41
+ boxSize = TILE_SIZE / 8 ,
42
+ arrowTipLength = 7
42
43
) : void => {
43
44
const arrowCoords = [ ] ;
44
45
@@ -53,8 +54,8 @@ const drawArrow = (
53
54
const arrowCoordsRotated = [ ] ;
54
55
const arrowIndices = [ ] ;
55
56
56
- let iCenter = iBase + boxSize / 2 ;
57
- let jCenter = jBase + boxSize / 2 ;
57
+ let iCenter = iBase + Math . floor ( boxSize / 2 ) ;
58
+ let jCenter = jBase + Math . floor ( boxSize / 2 ) ;
58
59
59
60
const lat = tile2lat ( y + iCenter / TILE_SIZE , z ) ;
60
61
const lon = tile2lon ( x + jCenter / TILE_SIZE , z ) ;
@@ -135,6 +136,16 @@ self.onmessage = async (message) => {
135
136
} ) ;
136
137
} else if ( variable . value == 'relative_humidity_2m' ) {
137
138
colors = colorScale ( {
139
+ colorScheme : '' ,
140
+ customColors : [
141
+ '#009392' ,
142
+ '#39b185' ,
143
+ '#9ccb86' ,
144
+ '#e9e29c' ,
145
+ '#eeb479' ,
146
+ '#e88471' ,
147
+ '#cf597e'
148
+ ] . reverse ( ) ,
138
149
min : 0 ,
139
150
max : 100
140
151
} ) ;
@@ -143,6 +154,11 @@ self.onmessage = async (message) => {
143
154
min : 0 ,
144
155
max : 1000
145
156
} ) ;
157
+ } else if ( variable . value == 'cape' ) {
158
+ colors = colorScale ( {
159
+ min : 0 ,
160
+ max : 4000
161
+ } ) ;
146
162
} else {
147
163
colors = colorScale ( {
148
164
min : - 5 ,
@@ -204,32 +220,6 @@ self.onmessage = async (message) => {
204
220
}
205
221
}
206
222
207
- // if (
208
- // import.meta.env.DEV &&
209
- // (i === 0 ||
210
- // i === TILE_SIZE ||
211
- // j === 0 ||
212
- // j === TILE_SIZE ||
213
- // i % (TILE_SIZE / 16) === 0 ||
214
- // j % (TILE_SIZE / 16) === 0)
215
- // ) {
216
- // if (
217
- // i === 0 ||
218
- // i === TILE_SIZE ||
219
- // j === 0 ||
220
- // j === TILE_SIZE
221
- // ) {
222
- // rgba[4 * ind] = 255;
223
- // rgba[4 * ind + 1] = 0;
224
- // rgba[4 * ind + 2] = 255;
225
- // rgba[4 * ind + 3] = 255;
226
- // } else {
227
- // rgba[4 * ind] = 0;
228
- // rgba[4 * ind + 1] = 0;
229
- // rgba[4 * ind + 2] = 255;
230
- // rgba[4 * ind + 3] = 255;
231
- // }
232
- // } else {
233
223
if ( isNaN ( px ) || px === Infinity ) {
234
224
rgba [ 4 * ind ] = 0 ;
235
225
rgba [ 4 * ind + 1 ] = 0 ;
@@ -254,16 +244,16 @@ self.onmessage = async (message) => {
254
244
}
255
245
}
256
246
}
257
- //}
258
247
}
259
248
}
260
249
261
250
if ( requestMultiple . includes ( variable . value ) ) {
262
251
let reg = new RegExp ( / w i n d _ ( \d + ) m / ) ;
263
252
const matches = variable . value . match ( reg ) ;
253
+ const boxSize = Math . floor ( TILE_SIZE / 16 ) ;
264
254
if ( matches [ 0 ] ) {
265
- for ( let i = 0 ; i < TILE_SIZE ; i += TILE_SIZE / 16 ) {
266
- for ( let j = 0 ; j < TILE_SIZE ; j += TILE_SIZE / 16 ) {
255
+ for ( let i = 0 ; i < TILE_SIZE ; i += boxSize ) {
256
+ for ( let j = 0 ; j < TILE_SIZE ; j += boxSize ) {
267
257
drawArrow (
268
258
rgba ,
269
259
i ,
@@ -274,7 +264,8 @@ self.onmessage = async (message) => {
274
264
nx ,
275
265
domain ,
276
266
projectionGrid ,
277
- direction
267
+ direction ,
268
+ boxSize
278
269
) ;
279
270
}
280
271
}
0 commit comments