Senior Application Developer

loc: Maynooth, ON K0L 2S0tel: 613-553-0960email: rgsamways@gmail.com
Robin Samways

$ Atlas · Architecture

How a building’s coordinates actually resolve to a rurality classification.

## SPATIAL_JOIN


The backend, farpost-atlas-geo, is a genuinely separate Python/FastAPI service — promoted out of this site’s shared api/ from day one, not prototyped there first. Shapely is a real runtime dependency of a live spatial join, not a one-off local script — geopandas, used only in the one-time ingestion step below, deliberately isn’t.

No PostGIS. At this scale — a few dozen North Hastings Dissemination Area polygons, a dozen-odd tracked buildings — a spatial database extension would be real weight for no real benefit. Instead, a small in-memory Shapely STRtree is built once at application startup from a pre-processed GeoJSON file, and every GET /api/buildings/{id} request runs a genuine point-in-polygon query against it. Tracked buildings and their records themselves live in an ordinary small Postgres database — only the boundary-polygon lookup gets the spatial index.

The one-time ingestion step is where geopandas actually earns its keep: reprojecting Statistics Canada’s 2021 Census Dissemination Area boundary file out of its native Lambert conformal conic projection into the WGS84 coordinates Leaflet expects, simplifying geometry for web rendering, and joining each polygon’s real, StatCan-computed population-density figure by DAUID. That step runs once, locally, before this page ever ships — never part of the live request path.

The frontend calls farpost-atlas-geo directly from the browser, the same relationship Farpost Pulse has with its own backend — nothing sensitive is at stake here (every building is seeded and fictional), so a server-side proxy through this site’s own api/ would add complexity without adding real protection.

## HTTP_ENDPOINTS


EndpointReturns
GET /api/buildingsAll seeded buildings, with coordinates and a rollup staleness flag.
GET /api/buildings/{id}One building’s full tracked-record list, each with per-record staleness, plus its rurality classification from the spatial join.
GET /api/boundariesA GeoJSON FeatureCollection of North Hastings Dissemination Area polygons, each carrying a population-density property.

Feedback on this page