Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,27 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- **GRB road-crossings level evidence (`build_grb_road_crossings`).**
`prepare_grb` now also publishes `road_crossings.geoparquet` (one row per
road unit, EPSG:31370: footprint, a second `axis` geometry column,
`road_id`, `structure` = `ground` / `grade_separated` / `unknown`,
`complex_crossing`, provenance), `road_crossings_coverage.geoparquet`
(where the artifact is complete) and `road_crossings_exclusions.geoparquet`
(every area left out of coverage, with its reason). `ground` comes only
from WBN elements — captured by the GRB only where the corridor is visible
at ground level — never as a default; the footprint is the whole corridor;
fragments of one carriageway share a `road_id` (never across a junction). `grade_separated` needs carriageway axes crossing without a node
inside a KNW bridge/tunnel group, all of them taking part and none ending
inside; any other structure is `unknown`. Coverage excludes `unknown`
footprints, structures and WBN elements left unproven by an unresolved axis
(`MORF` 120, 125, −8, not in service; only a buffer around it inside a
`ground` element), footprints leaving the bbox, and a `crossing_exclusion_buffer_m`
(default 15 m) around drivable axes no unit accounts for and around
node-less crossings outside structures. `complex_crossing` comes from
`MORF` 101 autosnelweg.

### Fixed

- **`gispulse_src_osm.read_pbf_roads` works against real PBF extracts.** It
Expand Down
122 changes: 122 additions & 0 deletions plugins/gispulse-src-grb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,128 @@ drillable at grade without a separate check. No KNW polygon in this bbox is
typed `tunnel`
(12), so that path is exercised only by the unit tests' synthetic geometry.

## Road crossings: level evidence

`build_grb_road_crossings`
(`src/gispulse/capabilities/vector/grb_road_crossings.py`), wired into
`prepare_grb`, publishes three files next to the classification (it reads
WBN, Wegsegment and KNW directly, never the classification):

- `road_crossings.geoparquet` — one row per physical road unit, EPSG:31370:

| column | content |
|---|---|
| geometry (active) | footprint, `Polygon`/`MultiPolygon` |
| `axis` | second geometry column, `LineString`/`MultiLineString`, clipped to the footprint |
| `road_id` | `GRB:WBN:<first OIDN>` or `GRB:KNW:<OIDN>+<OIDN>…` |
| `structure` | `ground`, `grade_separated` or `unknown` |
| `complex_crossing` | `MORF` in `complex_morf_codes` (default 101 autosnelweg) |
| `structure_evidence`, `source`, `source_layer`, `source_ids`, `axis_ids`, `morf_codes` | provenance |

- `road_crossings_coverage.geoparquet` — one polygon: where the artifact is
complete;
- `road_crossings_exclusions.geoparquet` — every area removed from that
coverage, with its reason.

Axes are sorted by `MORF`/`STATUS` only. In-service (`STATUS` 4) 101–112
are carriageways (the classification's gate). 113 voetgangerszone, 114
wandel- of fietsweg, 116 tramweg and 130 veer, documented as closed to
general motor traffic, are not. Everything else — 120 dienstweg and 125
aardeweg (bare labels in the domain), −8, a carriageway not in service — is
**unresolved**.

**`ground` comes from a WBN element, never from a default.** The
objectenhandboek page *wegbaan*: "enkel de aan het maaiveld zichtbare
wegcorridor wordt opgenomen als wegbaan. Waar de wegcorridor ingetunneld is,
op een overbrugging gelegen is of door een overbrugging wordt afgedekt, wordt
geen wegbaan (Wbn) opgenomen." WBN elements carrying a carriageway axis are
therefore positive evidence of a ground-level corridor. **The footprint is
the whole WBN corridor** (sidewalks and verges inside it), not a
carriageway-only surface. Touching `wegsegment`-type elements sharing a
carriageway axis and the same `complex_crossing` are fragments of one
carriageway: one `road_id`, footprints united, the original axes clipped
against the union so they stay continuous across arbitrary element cuts. A
`kruispuntzone` (WBN `TYPE` 1), an element holding an axis end that is not a
plain pass-through node — three or more ends (a junction not mapped as a
kruispuntzone: a side street, a parking entrance) or a single one (a dead
end, possibly another street reaching into the corridor) — and an element
with an undocumented `TYPE` are never merged. Where such a rule blocks a
genuine continuation, the boundary behaves element by element (a crossing
very close to the cut is bored a little short).

**`grade_separated` needs a level relation, not a bridge polygon.** Touching
KNW `overbrugging` (1) / `tunnelmond` (12) polygons form one structure. It
is `grade_separated` when at least two carriageway axes cross inside it
without a node, every such axis takes part in such a crossing, and none ends
inside. The OSLO Wegenregister profile defines a Wegknoop as the object
describing connectivity between two segments: axes crossing with no node are
not connected there, and the KNW polygon documents the structure separating
them. This is an **inference from two official facts**, not a stated rule
(the Wegenregister `OngelijkgrondseKruising` relation states it directly
and is not exposed by any WFS). Measured on a Gand sample: 91 of the 101
node-less crossings of carriageway axes lie inside a KNW 1/12 polygon.

**`unknown`**: any other structure carrying a carriageway axis —
`single_axis` (a road over water, or under a railway bridge: KNW alone
cannot tell which), `axis_ends_inside` (a junction or dead end on or under
the structure), `axis_not_crossed`.

**Coverage** starts from the bbox and excludes:

| reason | what |
|---|---|
| `structure_<reason>` | every `unknown` footprint |
| `structure_axes_unresolved` | every structure carrying an unresolved axis (it could change the verdict) |
| `wbn_axes_unresolved` | a WBN element carrying only unresolved axes; inside a `ground` element, a buffer around the unresolved axis only (a trench crossing that axis alone would see none) |
| `wbn_without_axis` | a WBN element with no axis at all |
| `footprint_crosses_bounds` | every footprint leaving the bbox: axes entirely outside were never acquired, so its verdict cannot be trusted |
| `axis_without_unit` | a `crossing_exclusion_buffer_m` buffer (default 15 m) around drivable axis length no unit accounts for: a road with no footprint (a private road the GRB did not capture, a tunnel body) or one lying exactly on a boundary |
| `nodeless_crossing_outside_structure` | the same buffer around node-less crossings and self-crossings of drivable axes outside every structure: level evidence contradicting the ground rule |

A structure with no drivable axis is no road and stays covered; a WBN
element carrying only documented non-motor axes stays covered without a
row. Footprints are never claimed twice: structures take priority over WBN
("een wegbaanelement houdt op ter hoogte van een kunstwerk"), then the lower
WBN `OIDN`.

**Validated live** on three bboxes (Gand 5.5 × 6.5 km, two 6 × 6 km tiles
near Oudenaarde and Leuven), 1.4–2.0 s each, with 9, 2 and 5 merged
units:

| bbox | ground units (elements) | grade_separated | unknown: single / ends inside / not crossed | ground elements with an unresolved axis + unresolved-only elements | drivable axis without unit | coverage |
|---|---|---|---|---|---|---|
| Gand | 2 405 (2 414) | 21 | 8 / 7 / 3 | 87 + 19 | 61.1 km | 93.3 % |
| Oudenaarde | 1 793 (1 795) | 6 | 11 / 3 / 2 | 33 + 2 | 35.9 km | 96.3 % |
| Leuven | 1 790 (1 795) | 8 | 12 / 4 / 0 | 146 + 19 | 87.2 km | 91.4 % |

No WBN element overlaps a KNW 1/12 polygon and no two WBN elements overlap
(above 0.01 m²); every axis is simple. Most axes without a unit are local
access roads the GRB maps with no WBN (in Gand, 57 of 85 sampled were
private) and aardewegen.

**Known limits.**

- KNW completeness: `ground` relies on the GRB not having missed a
structure; the node-less-crossing exclusion catches part of these.
- Up/down is never resolved. `grade_separated` holds for an excavation that
follows one of the crossing roads through the structure; an excavation dug
at ground level under a deck, off any mapped road, would cross the lower
road there and is not represented. `single_axis` structures stay
`unknown` even when the road is plainly on the deck.
- `complex_crossing` is per unit: a corridor carrying an autosnelweg and its
parallelweg is complex as a whole.
- The footprint is the whole corridor. A consumer that bores "the full
length inside the footprint" over-bores a trench that runs *along* a road
inside its corridor and wavers across its axis: run against 25 real MILOU
tracés, that accounts for 36 such "crossings" totalling 7.35 km (up to
922 m). Telling a longitudinal run from a crossing belongs to the consumer.
- `road_id` is stable for one acquisition only; bundles from different
bounds must be deduplicated on `source_ids`, never concatenated.
- An axis piece ending within floating-point distance of a footprint
boundary, or at a self-crossing split, is a measure-zero consumer edge case.
- The exclusion buffer has no source basis; it is an explicit, reported
parameter. Flanders only: PICC/UrbIS level evidence is not wired here.

## Validation

2026-09-08, the Gand bbox above, page size 5: 52 WBN (11 pages), 139 WGO
Expand Down
40 changes: 39 additions & 1 deletion plugins/gispulse-src-grb/gispulse_src_grb/prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from gispulse.adapters.rest.offset_pages import OffsetPagination
from gispulse.capabilities.vector.classify_faces import validate_functional_faces
from gispulse.capabilities.vector.classify_grb_faces import classify_grb_faces
from gispulse.capabilities.vector.grb_road_crossings import build_grb_road_crossings
from gispulse.capabilities.vector.polygon_partition import partition_polygons
from gispulse.capabilities.vector.reconcile_knw_structures import reconcile_knw_structures
from gispulse.core.io.geoparquet import write_geoparquet
Expand All @@ -28,8 +29,9 @@
"grb-kunstwerk-vl",
)

# GeoJSON empties omit property schemas; the classification reads these codes.
# GeoJSON empties omit property schemas; classification and crossings read these codes.
_CLASSIFIED_FIELDS = {
"grb-wegbaan-vl": ("TYPE",),
"grb-wegopdeling-vl": ("TYPE",),
"grb-wegsegment-vl": ("WS_OIDN", "VERH", "STATUS", "MORF"),
"grb-kunstwerk-vl": ("TYPE",),
Expand All @@ -51,12 +53,16 @@ def prepare_grb(
axis_min_extent_m: float = 5.0,
unsplit_max_width_m: float = 12.0,
dienstweg_unpaved_evidence: bool = False,
crossing_exclusion_buffer_m: float = 15.0,
) -> dict:
"""Publish raw layers, unclassified candidate faces and an evidence-based classification.

Tolerances account for numerical residuals only; no snapping or simplification.
Limits apply per layer. The bbox is in the native EPSG:31370 CRS. The
classification thresholds are explicit and recorded in the report.
``crossing_exclusion_buffer_m`` is the half-width the road-crossings
coverage removes around a drivable axis with no footprint (see
``grb_road_crossings``).
"""
if (
len(bbox) != 4
Expand All @@ -77,6 +83,8 @@ def prepare_grb(
)
or not math.isfinite(unsplit_max_width_m)
or unsplit_max_width_m <= 0
or not math.isfinite(crossing_exclusion_buffer_m)
or crossing_exclusion_buffer_m <= 0
):
raise ValueError("GRB_TOLERANCE_INVALID: nonnegative finite tolerances required")
if not math.isfinite(axis_coverage_ratio_min) or not 0.0 <= axis_coverage_ratio_min <= 1.0:
Expand Down Expand Up @@ -109,6 +117,7 @@ def prepare_grb(
"axis_min_extent_m": axis_min_extent_m,
"unsplit_max_width_m": unsplit_max_width_m,
"dienstweg_unpaved_evidence": dienstweg_unpaved_evidence,
"crossing_exclusion_buffer_m": crossing_exclusion_buffer_m,
"ready_for_costing": False,
}
if not write:
Expand Down Expand Up @@ -153,6 +162,32 @@ def prepare_grb(
write_geoparquet(
diagnostics, str(staging / "partition_diagnostics.geoparquet"), compression="zstd"
)
# Level evidence for road crossings reads WBN, Wegsegment and KNW
# directly, never the classification: a defect in one of them degrades
# this artifact alone, like the classification below.
try:
crossings, coverage, exclusions, crossings_report = build_grb_road_crossings(
frames["grb-wegbaan-vl"],
frames["grb-wegsegment-vl"],
frames["grb-kunstwerk-vl"],
coverage_bounds=bbox,
length_tolerance_m=length_tolerance_m,
area_tolerance_m2=area_tolerance_m2,
boundary_tolerance_m=boundary_tolerance_m,
exclusion_buffer_m=crossing_exclusion_buffer_m,
)
except ValueError as exc:
if not str(exc).startswith("GRB_CROSSINGS_"):
raise
crossings_report = {"status": "failed", "error": str(exc)}
else:
for name, frame in [
("road_crossings", crossings),
("road_crossings_coverage", coverage),
("road_crossings_exclusions", exclusions),
]:
write_geoparquet(frame, str(staging / f"{name}.geoparquet"), compression="zstd")
crossings_report = {"status": "prepared", **crossings_report}
try:
classified, classification = classify_grb_faces(
faces,
Expand Down Expand Up @@ -219,6 +254,7 @@ def prepare_grb(
candidate_faces=len(faces),
topology=diagnostics.status.value_counts().sort_index().to_dict(),
classification=classification_report,
road_crossings=crossings_report,
)
(staging / "report.json").write_text(json.dumps(report, indent=2) + "\n")
if output.exists():
Expand Down Expand Up @@ -249,6 +285,7 @@ def main() -> int:
action="store_true",
help="also count MORF=120 (dienstweg) axes coded VERH=2 as unpaved evidence",
)
parser.add_argument("--crossing-exclusion-buffer-m", type=float, default=15.0)
args = parser.parse_args()
try:
report = prepare_grb(
Expand All @@ -265,6 +302,7 @@ def main() -> int:
axis_min_extent_m=args.axis_min_extent_m,
unsplit_max_width_m=args.unsplit_max_width_m,
dienstweg_unpaved_evidence=args.dienstweg_unpaved_evidence,
crossing_exclusion_buffer_m=args.crossing_exclusion_buffer_m,
)
except Exception as exc: # noqa: BLE001 - CLI boundary
print(
Expand Down
Loading
Loading