From a04e5faebe347f3b11da7e8bb3fab149e053495b Mon Sep 17 00:00:00 2001 From: Stan Runge Date: Sat, 24 Oct 2026 15:45:26 +0000 Subject: [PATCH] houses: zero-pad Leefbaarometer grid cell ids (cells west of x=100 km, e.g. Zevenhuizen, Rotterdam) --- src/lib/house-tracker/liveability.test.ts | 1 + src/lib/house-tracker/liveability.ts | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/lib/house-tracker/liveability.test.ts b/src/lib/house-tracker/liveability.test.ts index 303d590..3a4beb6 100644 --- a/src/lib/house-tracker/liveability.test.ts +++ b/src/lib/house-tracker/liveability.test.ts @@ -5,6 +5,7 @@ describe('leefbaarometer helpers', () => { it('names the 100 m cell by its lower-left corner in hectometres', () => { expect(gridCellId([106050.4, 446899.9])).toBe('E1060N4468'); expect(gridCellId([105866.161, 446838.902])).toBe('E1058N4468'); + expect(gridCellId([92050, 437250])).toBe('E0920N4372'); }); it('labels classes 1-9', () => { expect(lbmClassLabel(1)).toBe('zeer onvoldoende'); diff --git a/src/lib/house-tracker/liveability.ts b/src/lib/house-tracker/liveability.ts index 1573196..2a405e5 100644 --- a/src/lib/house-tracker/liveability.ts +++ b/src/lib/house-tracker/liveability.ts @@ -243,9 +243,10 @@ async function wfsArea(layer: string, cql: string): Promise { }; } -/** 100 m cell id as used by the Leefbaarometer grid: lower-left corner in hectometres. */ +/** 100 m cell id as used by the Leefbaarometer grid: lower-left corner in hectometres, + * zero-padded to 4 digits (E0920N4372 west of x = 100 km, e.g. Rotterdam, Zevenhuizen). */ export const gridCellId = ([x, y]: [number, number]) => - `E${Math.floor(x / 100)}N${Math.floor(y / 100)}`; + `E${String(Math.floor(x / 100)).padStart(4, '0')}N${String(Math.floor(y / 100)).padStart(4, '0')}`; export async function liveabilityAt(parts: AddressParts): Promise { const geo = await geocode(parts);