|
|
|
|
@ -1,11 +1,9 @@
|
|
|
|
|
import { Layer, Source } from "react-map-gl";
|
|
|
|
|
import { pointLayer } from "./layers-config";
|
|
|
|
|
import { useLayersVisibility } from "../stores/useLayersVisibility";
|
|
|
|
|
import { useActiveTypes } from "../stores/useActiveTypes";
|
|
|
|
|
import { useGridSize } from "../stores/useGridSize";
|
|
|
|
|
import { useMemo } from "react";
|
|
|
|
|
import { useRateExpression } from "./useRateExpression";
|
|
|
|
|
import { useModel } from "../stores/useModel";
|
|
|
|
|
import { BASE_URL } from "../api";
|
|
|
|
|
|
|
|
|
|
const usePointSizeScale = () => {
|
|
|
|
|
const rate = useRateExpression();
|
|
|
|
|
@ -37,35 +35,35 @@ const usePointSizeScale = () => {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const Points = ({ rate: rateRange }) => {
|
|
|
|
|
const { gridSize } = useGridSize();
|
|
|
|
|
// const { gridSize } = useGridSize();
|
|
|
|
|
const { isVisible } = useLayersVisibility();
|
|
|
|
|
const { activeTypes } = useActiveTypes();
|
|
|
|
|
|
|
|
|
|
const rate = useRateExpression();
|
|
|
|
|
const sizeScale = usePointSizeScale();
|
|
|
|
|
|
|
|
|
|
const filter = useMemo(() => {
|
|
|
|
|
let result = [
|
|
|
|
|
"all",
|
|
|
|
|
[">=", rate, rateRange[0]],
|
|
|
|
|
["<=", rate, rateRange[1]],
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
if (activeTypes.length) {
|
|
|
|
|
result = [
|
|
|
|
|
"all",
|
|
|
|
|
["in", ["get", "category"], ["literal", activeTypes]],
|
|
|
|
|
[">=", rate, rateRange[0]],
|
|
|
|
|
["<=", rate, rateRange[1]],
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}, [rate, rateRange, activeTypes]);
|
|
|
|
|
// const { activeTypes } = useActiveTypes();
|
|
|
|
|
//
|
|
|
|
|
// const rate = useRateExpression();
|
|
|
|
|
// const sizeScale = usePointSizeScale();
|
|
|
|
|
//
|
|
|
|
|
// const filter = useMemo(() => {
|
|
|
|
|
// let result = [
|
|
|
|
|
// "all",
|
|
|
|
|
// [">=", rate, rateRange[0]],
|
|
|
|
|
// ["<=", rate, rateRange[1]],
|
|
|
|
|
// ];
|
|
|
|
|
//
|
|
|
|
|
// if (activeTypes.length) {
|
|
|
|
|
// result = [
|
|
|
|
|
// "all",
|
|
|
|
|
// ["in", ["get", "category"], ["literal", activeTypes]],
|
|
|
|
|
// [">=", rate, rateRange[0]],
|
|
|
|
|
// ["<=", rate, rateRange[1]],
|
|
|
|
|
// ];
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// return result;
|
|
|
|
|
// }, [rate, rateRange, activeTypes]);
|
|
|
|
|
|
|
|
|
|
const paintConfig = {
|
|
|
|
|
...pointLayer.paint,
|
|
|
|
|
"circle-radius": sizeScale,
|
|
|
|
|
// "circle-radius": sizeScale,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
@ -74,62 +72,19 @@ export const Points = ({ rate: rateRange }) => {
|
|
|
|
|
id="point3"
|
|
|
|
|
type="vector"
|
|
|
|
|
tiles={[
|
|
|
|
|
"https://postamates.spatiality.website/martin/public.point3/{z}/{x}/{y}.pbf",
|
|
|
|
|
]}
|
|
|
|
|
>
|
|
|
|
|
<Layer
|
|
|
|
|
{...pointLayer}
|
|
|
|
|
id={"point3"}
|
|
|
|
|
source={"point3"}
|
|
|
|
|
source-layer={"public.point3"}
|
|
|
|
|
layout={{
|
|
|
|
|
...pointLayer.layout,
|
|
|
|
|
visibility:
|
|
|
|
|
isVisible.points && gridSize === "net_3" ? "visible" : "none",
|
|
|
|
|
}}
|
|
|
|
|
filter={filter}
|
|
|
|
|
paint={paintConfig}
|
|
|
|
|
/>
|
|
|
|
|
</Source>
|
|
|
|
|
<Source
|
|
|
|
|
id="point4"
|
|
|
|
|
type="vector"
|
|
|
|
|
tiles={[
|
|
|
|
|
"https://postamates.spatiality.website/martin/public.point4/{z}/{x}/{y}.pbf",
|
|
|
|
|
]}
|
|
|
|
|
>
|
|
|
|
|
<Layer
|
|
|
|
|
{...pointLayer}
|
|
|
|
|
id={"point4"}
|
|
|
|
|
source={"point4"}
|
|
|
|
|
source-layer={"public.point4"}
|
|
|
|
|
layout={{
|
|
|
|
|
...pointLayer.layout,
|
|
|
|
|
visibility:
|
|
|
|
|
isVisible.points && gridSize === "net_4" ? "visible" : "none",
|
|
|
|
|
}}
|
|
|
|
|
filter={filter}
|
|
|
|
|
paint={paintConfig}
|
|
|
|
|
/>
|
|
|
|
|
</Source>
|
|
|
|
|
<Source
|
|
|
|
|
id="point5"
|
|
|
|
|
type="vector"
|
|
|
|
|
tiles={[
|
|
|
|
|
"https://postamates.spatiality.website/martin/public.point5/{z}/{x}/{y}.pbf",
|
|
|
|
|
`${BASE_URL}/martin/public.service_placementpoint/{z}/{x}/{y}.pbf`,
|
|
|
|
|
]}
|
|
|
|
|
>
|
|
|
|
|
<Layer
|
|
|
|
|
{...pointLayer}
|
|
|
|
|
id={"point5"}
|
|
|
|
|
source={"point5"}
|
|
|
|
|
source-layer={"public.point5"}
|
|
|
|
|
id={"points"}
|
|
|
|
|
source={"points"}
|
|
|
|
|
source-layer={"public.service_placementpoint"}
|
|
|
|
|
layout={{
|
|
|
|
|
...pointLayer.layout,
|
|
|
|
|
visibility:
|
|
|
|
|
isVisible.points && gridSize === "net_5" ? "visible" : "none",
|
|
|
|
|
visibility: isVisible.points ? "visible" : "none",
|
|
|
|
|
}}
|
|
|
|
|
filter={filter}
|
|
|
|
|
// filter={filter}
|
|
|
|
|
paint={paintConfig}
|
|
|
|
|
/>
|
|
|
|
|
</Source>
|
|
|
|
|
|