Module 6 — Polygons and spatial relationships
Modules 4 and 5 built the application’s structure with modest data — a handful of depots, a few hundred jobs. Module 6 scales up. Service area boundaries from real Australian Bureau of Statistics data. Hundreds of thousands or millions of jobs and customers. Real spatial queries on real-scale data, with the performance considerations that come with that.
The module is six lessons covering data scale, clustering, spatial joins, and the analytical reports that emerge from them.
Lesson 1 — A richer dataset. The seed task that creates the
chassis-scale data. ABS-sourced service area boundaries (340 of
them), hundreds of thousands of jobs distributed by population
weighting, customers at realistic geographic positions. The
lesson covers the import pipeline (GeoJSON to PostGIS,
multi-polygon boundaries, SRID handling) and introduces the
SEED_SCALE environment variable for choosing dataset size.
Lesson 2 — Clustering and spiderfy. With thousands of points on a map, individual markers become unworkable. MapLibre’s clustering takes care of the visual problem; the spiderfy interaction handles the case where users want to drill into a specific cluster. The lesson covers cluster setup, click behaviour, and the visual transitions between zoom levels.
Lesson 3 — Spatial joins (and when indexes earn their keep).
The first real spatial query at scale: “which service area does
each job belong to?” The lesson introduces ST_Within and
ST_Contains, walks through the GIST index pattern, and
demonstrates the performance impact (orders of magnitude) of
indexing geometry columns. EXPLAIN ANALYZE makes its first
substantial appearance here.
Lesson 4 — The choropleth report. The first analytical visualisation. Service areas coloured by job density, producing a heat-map-like view of where work is concentrated. The lesson covers data-driven styling (paint properties as expressions), breakpoint computation in SQL, and the considerations of choosing colour scales for choropleth maps.
Lesson 5 — SLA performance choropleth. A second choropleth, this time showing per-region SLA performance. Same visual technique, different operational question. The lesson reuses the choropleth infrastructure from Lesson 4, demonstrating that the pattern is a reusable mould rather than a one-off.
Lesson 6 — Map-driven sidebars. Click a region on the map, see its details in the sidebar. The two-way relationship between map state and sidebar content becomes a recurring application pattern — selection drives navigation, and the URL captures state so links work as expected. The lesson lands on a “Service Area Detail” report that surfaces region-specific metrics.
What this module produces
A populated chassis with realistic-scale operational data, plus three substantial reports — Choropleth, SLA Performance, Service Area Detail — and the reusable infrastructure for building more like them.
What this module sets up
- The seed-driven dataset that subsequent modules query against
- The choropleth pattern (data-driven styling, breakpoint SQL, click-to-drill) usable for any per-region metric
- The map-driven sidebar pattern, which Module 7 extends with sortable tables and analytical reports
- A working understanding of when spatial joins use indexes and when they don’t — foundational for Module 7’s deeper performance work