From 3778405a13b9be11c3380864ff9904cd0adc8034 Mon Sep 17 00:00:00 2001 From: Jakob Cornell Date: Wed, 20 May 2026 23:28:15 -0500 Subject: [PATCH] Separate parcel filter and render steps --- main.js | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/main.js b/main.js index 2fc1445..39ae14d 100644 --- a/main.js +++ b/main.js @@ -5,6 +5,14 @@ const PARCEL_JSON_PATH = "//jcornell.net/static/parcels/Tax_Parcels_(Assessor_Pr const PARCEL_LOAD_KEY = "parcelsLoaded"; +const PICK_ZONINGS = new Set([ + "SR-C1", "SR-C2", "SR-C3", "SR-V1", "SR-V2", "TR-C1", "TR-C2", "TR-C3", + "TR-C4", "TR-V1", "TR-V2", "TR-U1", "TR-U2", "TR-R", "TR-P" +]); + +const MIN_LOT_SIZE_ACRES = 0.5; +const MAX_LOT_SIZE_ACRES = 1.5; + function transposeCoordinates(coordList) { return coordList.map( poly => poly.map( @@ -40,9 +48,8 @@ async function asyncMain() { } const store = db.query("features", "readonly"); - const PICK_ZONINGS = new Set(["TR-V2", "TR-U1", "TR-U2"]); - overlay.innerText = "filtering & rendering parcels"; - let matchCount = 0; + overlay.innerText = "filtering parcels"; + const matches = []; let noZoningCount = 0; let noLotSizeCount = 0; // store.getAll doesn't work for some reason. @@ -51,10 +58,8 @@ async function asyncMain() { const zoningParts = (feature.properties.ZoningAll ?? "").split(", "); const zoningMatch = zoningParts.length && new Set(zoningParts).intersection(PICK_ZONINGS).size; const lotSizeAcres = feature.properties.LotSize / 43560; - if (zoningMatch && lotSizeAcres >= 0.5 && lotSizeAcres <= 1.5) { - const leafletCoords = transposeCoordinates(feature.geometry.coordinates); - L.polygon(leafletCoords, {color: "blue", weight: 1}).addTo(map); - matchCount += 1; + if (zoningMatch && lotSizeAcres >= MIN_LOT_SIZE_ACRES && lotSizeAcres <= MAX_LOT_SIZE_ACRES) { + matches.push(feature); } if (!zoningParts.length) { noZoningCount += 1; @@ -70,11 +75,17 @@ async function asyncMain() { console.log( "Searched %d parcels: %d matches, %d with no zoning, %d with no size", await store.count(), - matchCount, + matches.length, noZoningCount, noLotSizeCount, ); + overlay.innerText = "rendering parcels"; + for (const feature of matches) { + const leafletCoords = transposeCoordinates(feature.geometry.coordinates); + L.polygon(leafletCoords, {color: "blue", weight: 1}).addTo(map); + } + overlay.style["display"] = "none"; } -- 2.39.5