← back to Nationalrealestate
Fix commercial ETL APN normalization: strip non-digits so ArcGIS '2005-002-016' matches sqlite key '2005002016' — was duplicating every LA commercial parcel (153923->306830). Cleaned dashed dupes
ba1528f10073bb62b0d1b57e8fd36e22e413ebb3 · 2026-07-30 20:07:50 -0700 · steve@designerwallcoverings.com
Files touched
M src/ingest/commercial/arcgis_commercial.ts
Diff
commit ba1528f10073bb62b0d1b57e8fd36e22e413ebb3
Author: steve@designerwallcoverings.com <steve@designerwallcoverings.com>
Date: Thu Jul 30 20:07:50 2026 -0700
Fix commercial ETL APN normalization: strip non-digits so ArcGIS '2005-002-016' matches sqlite key '2005002016' — was duplicating every LA commercial parcel (153923->306830). Cleaned dashed dupes
---
src/ingest/commercial/arcgis_commercial.ts | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/ingest/commercial/arcgis_commercial.ts b/src/ingest/commercial/arcgis_commercial.ts
index 619b025..aab1667 100644
--- a/src/ingest/commercial/arcgis_commercial.ts
+++ b/src/ingest/commercial/arcgis_commercial.ts
@@ -55,7 +55,10 @@ export function ingestArcgisCommercial(key: string) {
const feats = j.features || [];
if (!feats.length) { offset = 0; break; } // wrapped past the end → reset cursor
for (const f of feats) {
- const a = f.attributes; const ain = s(a.APN); if (!ain) continue;
+ // Normalize APN to the canonical digits-only ain (the LA sqlite key format
+ // is '2005002016'; the ArcGIS layer returns '2005-002-016'). Without this the
+ // ON CONFLICT (county_fips, ain) never matches and every parcel DUPLICATES.
+ const a = f.attributes; const ain = (s(a.APN) || '').replace(/\D/g, '') || null; if (!ain) continue;
const ctype = classifyCommercial(s(a.UseType), s(a.UseDescription));
if (!ctype) continue; // not commercial after classification
const land = num(a.Roll_LandValue), imp = num(a.Roll_ImpValue);
← 0b13660 Add live ArcGIS commercial ETL (arcgis_commercial la-arcgis)
·
back to Nationalrealestate
·
Generalize commercial ETL for multi-county (Cody prereq): pe 92ca742 →