Skip to Content
suntzu rcdocs
Bits

census.import — Public registers become places and hosts

  • Trigger: pnpm census [dataset…] (datasets: fria, fixed-sites, airports, airspace, zip-codes; none named runs all five, in that order). A schedule once deployed (needs Itaca engineering, see AGENTS.md).
  • Who: the crew, from the command line.
  • Path: apps/api/src/census.ts → places/census/run.ts → http.ts (one request at a time, 1 s apart, the engine's User-Agent) → the FAA's ArcGIS services (arcgis.ts) or the Census Bureau's Gazetteer file (unzip.ts) → readers (fria.ts, fixed-sites.ts, airports.ts, airspace.ts, zip-codes.ts) → matching (match.ts) → PostgreSQL (load.ts), one transaction per dataset.
  • Data: reads the FAA's FAA-Recognized Identification Areas, Recreational Flyer Fixed Sites, US_Airport and Class_Airspace layers and the Census Bureau's ZCTA Gazetteer (all public domain; URLs in DECISIONS.md, 2026-10-27). Writes places and hosts (register faa-fria / faa-fixed-site, registerId the FAA record), airports, airspace and zip_codes.
  • Rules:
    • No personal data. The queries name their fields and never ask for the requester's address, the point of contact or the sponsor's ZIP code. Titles that put a person's name in front of a site are replaced (TITLE_FIXES in fria.ts). Reports name records by id and places by slug.
    • Nothing twice. A record finds its own row by (register, registerId); else the nearest flying field within 300 m; else its club's field from the other FAA register within 1,200 m (a FRIA is an area, a fixed site a point). Hosts match by record, AMA charter number, name or alias however spelled, then a name one or two typos away. Running twice changes nothing.
    • Hand-checked places win. A crew place a record lands on gets the FRIA flag, the record id and its source link; its name, notes, address and access stay as the crew wrote them. A place or host the census created only gets its register facts refreshed on later runs (FRIA flag, source link, newer date, a missing host), so stewards' corrections stay.
    • An AMA club's field is hosted by the club (charter number from the title), not by the AMA; other recognised organisations' sites by that organisation (sanctioning-body); school areas have no host. New places are flying-field, access permission, verifiedAt the record's approval or last-edit date, sourceUrl the FAA's map of the register centred on the site.
    • Airports, airspace and ZIP codes are copies of their registers: upserted by key, and rows the register dropped are removed (unless it suddenly returned less than half of what we hold). Airspace keeps class B, C, D and E surface areas that reach the ground, plus class B shelves with their floor; outlines are simplified to within 15 m.
  • Errors: a dataset that fails (network, unexpected response) writes nothing and the others still run; the command exits 1. Records it can't use are counted as skipped (outside Florida, expired, closed, no position). Places whose record has left the register are listed for the crew, never deleted.
  • Test: unit tests on records trimmed from the real registers (apps/api/src/places/census/fixtures/, without personal data), never the internet: apps/api/src/places/census/fria.test.ts, apps/api/src/places/census/fixed-sites.test.ts, apps/api/src/places/census/airports.test.ts, apps/api/src/places/census/airspace.test.ts, apps/api/src/places/census/zip-codes.test.ts (the readers), apps/api/src/places/census/arcgis.test.ts (paging), apps/api/src/places/census/sites.test.ts, apps/api/src/places/census/match.test.ts, apps/api/src/places/census/names.test.ts (records to places and hosts, nothing twice) and apps/api/src/places/census/geometry.test.ts. Not covered: the census's load.ts (the writes, "hand-checked places win", removals), which needs a database.
  • Observe: the run report printed by the command (counts, places linked or merged, records gone).
  • Status: verified — 2026-11-18 (unit tests on saved pages)