feat(analysis): A5 Grid takes a System (H3, S2, A5, anchored hexagons) as Generate Tessellation #2727
All Vouch review confidence checks passed
Residual risk 0.37 = Change Risk (0.52) × (1 − Review Confidence (0.29)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 47% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #2727"
general
weight: 0.35
github-actions[bot]
Summary
A5 Grid and Aggregate Points to A5 (#551, #573) take a System parameter, so they build a grid, or count points by cell, in one of four systems, and the same place can be compared across grids. They keep their ids and default to A5, and are renamed for what they now do:
a5Grid, was A5 Grid): the cells at a resolution over the map's extent, an input layer's polygons (or the extent of its points and lines), or the world, as polygons with their ids.a5Aggregate, was Aggregate Points to A5): a point layer counted by the cell holding each point, withcount,density_per_km2(by each cell's own area) and a numeric field's_sumand_mean.| System | Cells | Resolutions | Id (text) |
|---|---|---|---|
| H3 (
h3o0.11, BSD-3-Clause) | hexagons + 12 pentagons | 0–15 |h3: H3's hex text || S2 (
s20.2, Apache-2.0) | quadrilaterals | 0–30 |s2: S2 token || A5 (existing) | equal-area pentagons | 0–30 |
a5: as A5 Grid's || Hexagon (no crate) | flat hexagons on the map's projection | 0–24 |
hex: axialq,r, plusplane|The anchored hexagon grid. It's laid on the active map's flat projection (Web Mercator when the map is a globe). It's anchored at that projection's origin, not at a layer's corner, so a place gets the same cell whatever layer or extent it's gridded with. The ids only mean something in that projection, so every layer names it in
plane. A cell at resolution r has an A5 cell's area at r on the plane, so the two compare at one resolution.area_km2is each cell's own area on the ground. To take the corners back to longitude/latitude,Inputsgetsunproject, the inverse of the existingproject(the engine's implementation isFlat::inverse). A polygon's corners are placed on the plane only where the projection takes them back to the same place, so a projection that folds (a transverse Mercator far from its meridian) refuses the area rather than covering the wrong cells. A cell whose corners the projection can't take back is left out and counted in the message.Shared with A5.
crates/analysis/src/dggs.rsnow has aSystemand aGridwith the per-system operations: the cell of a point, a cell's outline and area, the covering of a polygon, and the world. On top of them sit the existing pieces:One tool per task rather than a second pair beside A5's: a run that names no system (every model and script saved before) gets A5, with the same layer and message as before, and a test checks that against an explicit System: A5.
How each system covers a polygon:
h3o's tiler, in Covers mode for Overlapping and ContainsCentroid for Center. Shapes are cut at ±180° first, so its transmeridian heuristic is off: that heuristic would take a world-wide view for a polygon across the antimeridian.s20.2 has no polygons. The covering descends from the six faces to the level, pruned by the polygon's boundingRect, and keeps the cells that overlap the polygon (or hold its centre), tested withgeo'sPreparedGeometry.Corners on a pole are drawn as a line along the pole. S2's face cells have them, and so do A5's cells round a pole, which fixes a gap in A5 as it is on
main: a point at 89.99° S fell outside the outline of the cell thata5Aggregateput it in (a_point_falls_in_the_cell_holding_itfails for A5 without the change). In S2 and the hexagon grid, Overlapping keeps the cells that share area with the polygon, not those that only touch its outline; H3's ish3o's own Covers mode, which keeps a cell that meets the outline. A hole without a usable outline is left out and counted, as a polygon part already was. In Web Mercator the hexagon grid stops at 85.05°: a point beyond it is left out and counted (never put in the edge cell its latitude would be clamped to), and an area past it is cut there and said to be. Asystemthat isn't text is refused.Limits, Cancel and memory.
Pace), and while they make the layer. The point loop and the layer count progress. Both tools are in the cancellation test's list of long tools,a5Gridin H3, S2 and Hexagon,a5Aggregatein H3.relatetests run on prepared geometry, so a split per polygon isn't worth its merge.Where it reaches. Both tools are in the built-in list (
TOOLS), so they reach every surface that lists or runs built-in tools:gp.toolslists them, andgp.runandgp.batchrun them;analysis::TOOLS), and the pane's forms show their parameters.They get no ribbon button, shortcut or phone entry, as A5 Grid and the other analysis tools have none: on the desktop they are reached through the Analysis pane.
Their output is a new layer, undone like any tool's. Their new names, summaries and labels are English strings that wait for the next translation pass; the
.tsvcatalogues are left alone, so the rows for the old names (A5 Grid,Aggregate Points to A5) are left for that pass to drop.A project capability,
dggs-system. An older release would leave out asystemit doesn't know and make A5 cells, warning only that it ignored the key. So a project, model file or web tool that saves a run of either tool with a system other than A5 (a step, a task, the history,gp.run,gp.batchor a script) requiresdggs-system, asslope-percentandtabulate-intersection-unitdo for their options, and an older reader refuses it by name. A blanksystem,A5or none needs nothing. It's inCAPABILITIES, the schema anddocs/maintaining.md;schema/fixtures/dggs_system.rgisis a project that requires it, anda_grid_system_other_than_a5_is_requiredcovers every saved path, and fails with the capability taken out of the table.New dependencies:
h3o0.11 (with itsgeofeature, on ourgeo0.33) ands20.2 (default features off), both pure Rust.cargo check -p rustgis-web --target wasm32-unknown-unknownpasses, andcargo xtask noticesrefreshed the threeTHIRD-PARTY-LICENSES.txtfiles.ISEA3H (
dggal) is left out until its licence is checked.Testing
cargo nextest run -p rustgis-analysis: 671 passed. The new tests indggs::testscover:- every system covering an area and counting points: each point falls in the cell whose outline holds it, and that cell is in the grid;
- points across the antimeridian, at high latitudes and round the poles, and a point at the pole on Web Mercator left out;
- the hexagon grid's polygon corners on a plane that folds, refused rather than misplaced (the test breaks without the check);
- a polygon across the antimeridian, covered on both sides;
- the world against each system's own count, and the areas summing to the sphere's (H3, S2);
- the cap, before and after the estimate;
- each system's resolution range, and an unknown system;
- ids against
h3o,s2anda5;- the hexagon grid anchored (two overlapping areas give the same cells) and regular on a projected plane;
- a run naming no system, the same as System: A5 (a model or script saved before).
the_world_and_the_capalso covers the run-wide limit on what the coverings look at: many copies of one block, each under the cap, are refused together. I broke it on purpose by removing the limit: the run went through, and the test failed.cargo nextest run --workspace: 8,905 of 8,906 passed; the one failure,portable_projects::reload::reload_reconverts_duckdb_table…, fails onmainon this machine too (local DuckDB). In it:-
tessellations_and_points_by_cell_in_every_system:gp.runin every system, every city counted, and the hexagon grid on Mollweide (its world reaching both poles) and on the globe;- the cancellation tests, with
a5Grid(H3, S2, Hexagon) anda5Aggregate(H3) in the list of long tools: Cancel at every look leaves the project unchanged;-
a5_grids_and_points_by_cellandhostile_params_never_panic.cargo xtask schema --check: the schema matches, 55 fixture projects open.cargo deny check licenses: ok.cargo xtask notices --check: up to date.cargo clippy -p rustgis-analysis -p rustgis-engine --all-targets: clean.cargo check -p rustgis-web --target wasm32-unknown-unknown: passes.UI evidence
Before and after, the form the Analysis pane builds for the tool: A5 Grid on
main, and Generate Tessellation with its System. Then the form of Aggregate Points to Grid, and captures of the same view of Bogotá with Generate Tessellation in each system, from the headlessui_shotrunner: H3 r8, S2 r13, A5 r13, and Hexagon r13 on a map in Web Mercator and on one in EPSG:9377 (MAGNA-SIRGAS / Origen-Nacional).| Before: A5 Grid on
main| After: Generate Tessellation ||---|---|
| !form-before-a5Grid.png | !form-dggsGrid.png |
Aggregate Points to Grid
!form-dggsAggregate.png
| H3 r8 | S2 r13 |
|---|---|
| !H3-mercator.png | !S2-mercator.png |
| A5 r13 | Hexagon r13, Web Mercator |
| !A5-mercator.png | !Hexagon-mercator.png |
Hexagon r13, EPSG:9377
!Hexagon-EPSG9377.png
Related issue
Closes #2726