This commit is contained in:
Andras Schmelczer 2026-04-04 17:44:44 +01:00
parent b94cf17d75
commit 0c6d207967
41 changed files with 1809 additions and 1204 deletions

View file

@ -134,11 +134,11 @@ export function useDeckLayers({
? colorFeatureMeta.values.length
: 0;
// --- Count ranges ---
const countRange = useMemo(() => {
if (data.length === 0) return { min: 0, max: 1 };
if (data.length === 0) return { min: 0, max: 1, total: 0 };
let min = Infinity;
let max = -Infinity;
let total = 0;
for (const d of data) {
if (viewportBounds) {
if (
@ -152,19 +152,21 @@ export function useDeckLayers({
const c = d.count as number;
if (c < min) min = c;
if (c > max) max = c;
total += c;
}
if (min === Infinity) return { min: 0, max: 1 };
if (min === max) return { min, max: min + 1 };
return { min, max };
if (min === Infinity) return { min: 0, max: 1, total: 0 };
if (min === max) return { min, max: min + 1, total };
return { min, max, total };
}, [data, viewportBounds]);
const countRangeRef = useRef(countRange);
countRangeRef.current = countRange;
const postcodeCountRange = useMemo(() => {
if (postcodeData.length === 0) return { min: 0, max: 1 };
if (postcodeData.length === 0) return { min: 0, max: 1, total: 0 };
let min = Infinity;
let max = -Infinity;
let total = 0;
for (const d of postcodeData) {
if (viewportBounds) {
const [lng, lat] = d.properties.centroid as [number, number];
@ -179,10 +181,11 @@ export function useDeckLayers({
const c = d.properties.count;
if (c < min) min = c;
if (c > max) max = c;
total += c;
}
if (min === Infinity) return { min: 0, max: 1 };
if (min === max) return { min, max: min + 1 };
return { min, max };
if (min === Infinity) return { min: 0, max: 1, total: 0 };
if (min === max) return { min, max: min + 1, total };
return { min, max, total };
}, [postcodeData, viewportBounds]);
const postcodeCountRangeRef = useRef(postcodeCountRange);