|
|
|
@ -4,6 +4,46 @@ import { useGridSize } from "../stores/useGridSize";
|
|
|
|
import { useLayersVisibility } from "../stores/useLayersVisibility";
|
|
|
|
import { useLayersVisibility } from "../stores/useLayersVisibility";
|
|
|
|
import { useMemo } from "react";
|
|
|
|
import { useMemo } from "react";
|
|
|
|
import { useRateExpression } from "./useRateExpression";
|
|
|
|
import { useRateExpression } from "./useRateExpression";
|
|
|
|
|
|
|
|
import { useModel } from "../stores/useModel";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const useGridColorScale = () => {
|
|
|
|
|
|
|
|
const rate = useRateExpression();
|
|
|
|
|
|
|
|
const { model } = useModel();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (model === "ml") {
|
|
|
|
|
|
|
|
return [
|
|
|
|
|
|
|
|
"interpolate",
|
|
|
|
|
|
|
|
["linear"],
|
|
|
|
|
|
|
|
rate,
|
|
|
|
|
|
|
|
0,
|
|
|
|
|
|
|
|
"rgba(255,0,0,0.78)",
|
|
|
|
|
|
|
|
10,
|
|
|
|
|
|
|
|
"rgb(255,137,52)",
|
|
|
|
|
|
|
|
20,
|
|
|
|
|
|
|
|
"rgb(255,197,52)",
|
|
|
|
|
|
|
|
30,
|
|
|
|
|
|
|
|
"rgb(233,250,0)",
|
|
|
|
|
|
|
|
40,
|
|
|
|
|
|
|
|
"rgb(92,164,3)",
|
|
|
|
|
|
|
|
80,
|
|
|
|
|
|
|
|
"rgb(7,112,3)",
|
|
|
|
|
|
|
|
100,
|
|
|
|
|
|
|
|
"rgb(2,72,1)",
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return [
|
|
|
|
|
|
|
|
"interpolate",
|
|
|
|
|
|
|
|
["linear"],
|
|
|
|
|
|
|
|
rate,
|
|
|
|
|
|
|
|
0,
|
|
|
|
|
|
|
|
"rgb(204,34,34)",
|
|
|
|
|
|
|
|
10,
|
|
|
|
|
|
|
|
"rgb(255,221,52)",
|
|
|
|
|
|
|
|
20,
|
|
|
|
|
|
|
|
"rgb(30,131,42)",
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
export const Grid = ({ rate: rateRange }) => {
|
|
|
|
export const Grid = ({ rate: rateRange }) => {
|
|
|
|
const { gridSize } = useGridSize();
|
|
|
|
const { gridSize } = useGridSize();
|
|
|
|
@ -12,6 +52,7 @@ export const Grid = ({ rate: rateRange }) => {
|
|
|
|
} = useLayersVisibility();
|
|
|
|
} = useLayersVisibility();
|
|
|
|
|
|
|
|
|
|
|
|
const rate = useRateExpression();
|
|
|
|
const rate = useRateExpression();
|
|
|
|
|
|
|
|
const colorScale = useGridColorScale();
|
|
|
|
|
|
|
|
|
|
|
|
const filter = useMemo(() => {
|
|
|
|
const filter = useMemo(() => {
|
|
|
|
return ["all", [">=", rate, rateRange[0]], ["<=", rate, rateRange[1]]];
|
|
|
|
return ["all", [">=", rate, rateRange[0]], ["<=", rate, rateRange[1]]];
|
|
|
|
@ -19,17 +60,7 @@ export const Grid = ({ rate: rateRange }) => {
|
|
|
|
|
|
|
|
|
|
|
|
const paintConfig = {
|
|
|
|
const paintConfig = {
|
|
|
|
...gridLayer.paint,
|
|
|
|
...gridLayer.paint,
|
|
|
|
"fill-color": [
|
|
|
|
"fill-color": colorScale,
|
|
|
|
"interpolate",
|
|
|
|
|
|
|
|
["linear"],
|
|
|
|
|
|
|
|
rate,
|
|
|
|
|
|
|
|
0,
|
|
|
|
|
|
|
|
"rgb(204,34,34)",
|
|
|
|
|
|
|
|
10,
|
|
|
|
|
|
|
|
"rgb(255,221,52)",
|
|
|
|
|
|
|
|
20,
|
|
|
|
|
|
|
|
"rgb(30,131,42)",
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
|