-
Notifications
You must be signed in to change notification settings - Fork 6
/
stores.ts
79 lines (73 loc) · 1.53 KB
/
stores.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import { ColorConfig } from "./libs/colors";
import { MAP_STYLES, SAVED_QUERY } from "./constants";
import { createStore, createMutable } from "solid-js/store";
const config = createMutable({
/**
* selected from saved query
*/
query: undefined as number | undefined,
/**
* maps tooltip
*/
tooltip: true as boolean,
/**
* map style config
*/
styles: MAP_STYLES[0],
});
/**
* we save worker to store so we can use it anywhere
*/
const [worker] = createStore({
grid: new Worker(new URL("./services/worker-grid.ts", import.meta.url), {
type: "module",
}),
point: new Worker(new URL("./services/worker-point.ts", import.meta.url), {
type: "module",
}),
});
export type LegendLayer = Map<
string | number | undefined,
{
total: number;
/**
* [r, g, b, alpha]
*/
color: [number, number, number, number];
}
>;
export interface LayerStore {
query: string;
color?: ColorConfig;
legend?: LegendLayer;
tooltip?: {
position: {
x: number;
y: number;
};
data?: Record<string, unknown>;
};
}
const layer = createMutable<{ point: LayerStore; grid: LayerStore }>({
grid: {
query: SAVED_QUERY[3].layer.grid.query,
legend: new Map(),
color: {
code: "Turbo",
alpha: 255,
length: 32,
reverse: false,
},
},
point: {
query: SAVED_QUERY[3].layer.point.query,
legend: new Map(),
color: {
code: "Viridis",
alpha: 255,
length: 8,
reverse: false,
},
},
});
export { worker, layer, config };