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
33 changes: 33 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,39 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- **Road-crossings level evidence for Wallonia and Brussels.**
- **Wallonia:** `export_picc` now also publishes `road_crossings*.geoparquet`
(`build_picc_road_crossings`).
- `Ouvrage d'art` surfaces at `NIVEAU` ≥ 1 (bridge decks) are
`grade_separated`; the level is stated by the source.
- `NIVEAU` 0 surfaces are `ground`, and so are `Tronçon`/`Carrefour`
surfaces with an empty `NIVEAU`, by a closed-world reading of the
continuous inventory. An unreadable `NIVEAU` is never read as empty.
- Tunnels (`NIVEAU` ≤ −1) are `unknown` and leave coverage: PICC axes carry
no level, so a tunnel's axis cannot be told from a street above it.
- Decks and tunnels both take priority over the ground surfaces they
cover.
- **Brussels:** new `gispulse_src_urbis.prepare` command
(`build_urbis_road_crossings`).
- Road bridges (`ROB`) are `grade_separated`, and so are road tunnels
(`ROT`) with the axes below `LVL` 0 inside them.
- Carriageway surfaces at `LVL` 0 are `ground`, with their `LVL` 0 axes.
- A level that no structure explains leaves coverage.
- All three regions now share `road_crossings_common` (axis clipping,
fragment merging, coverage accounting, output contract).
- **GRB road crossings: `MORF` 120 dienstweg is a carriageway, 125 aardeweg
is not** (explicit costing decision, reported under `axis_classes`).
In 2.5.0 both were unresolved and left out of coverage.

### Fixed

- **PICC export no longer fails on real extents.** The source now requests
XY-only geometry (`returnZ=false`). Projected server-side to WGS84 with Z,
some surfaces came back self-intersecting, and `export_picc` raised
`PICC_LAYER_INVALID` (measured on a 6 × 6 km tile at Liège).

## [2.5.0] - 2026-10-01

The source plugins below (PICC, UrbIS, GRB, and OSM for the fix) live in the
Expand Down
22 changes: 12 additions & 10 deletions plugins/gispulse-src-grb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -535,11 +535,13 @@ WBN, Wegsegment and KNW directly, never the classification):
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**.
(the classification's gate) and 120 dienstweg are carriageways. 113
voetgangerszone, 114 wandel- of fietsweg, 116 tramweg, 125 aardeweg and 130
veer are not. Everything else — −8, a carriageway not in service — is
**unresolved**. 120 and 125 are bare labels in the domain; classing them is a
costing-side decision, taken explicitly (a service road is bored under like a
road, an earthen track is trenched through) and listed in the report under
`axis_classes`.

**`ground` comes from a WBN element, never from a default.** The
objectenhandboek page *wegbaan*: "enkel de aan het maaiveld zichtbare
Expand Down Expand Up @@ -596,19 +598,19 @@ row. Footprints are never claimed twice: structures take priority over WBN
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
near Oudenaarde and Leuven), 1.2–2.5 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 % |
| Gand | 2 408 (2 417) | 21 | 8 / 7 / 3 | 1 + 0 | 31.8 km | 96.1 % |
| Oudenaarde | 1 793 (1 795) | 6 | 11 / 3 / 2 | 0 + 0 | 23.6 km | 97.4 % |
| Leuven | 1 790 (1 795) | 8 | 12 / 4 / 0 | 0 + 0 | 35.4 km | 96.2 % |

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.
private).

**Known limits.**

Expand Down
72 changes: 72 additions & 0 deletions plugins/gispulse-src-picc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,75 @@ relation table (or an equivalent channel) becomes reachable, any axis-to-
footprint association is necessarily geometric (nearest/covering match), which
is an approximation this plugin does not perform and which any consumer must
label as such, not as an official-contract match.

## Road crossings: level evidence

`export_picc` also publishes `road_crossings.geoparquet`,
`road_crossings_coverage.geoparquet` and `road_crossings_exclusions.geoparquet`,
built by `build_picc_road_crossings`
(`src/gispulse/capabilities/vector/picc_road_crossings.py`). The contract is
the GRB one: one row per road unit, in EPSG:31370, with the footprint, an
`axis` column, `road_id`, `structure`, `complex_crossing` and provenance. A
defect in the level evidence degrades that artifact only (`road_crossings:
{"status": "failed"}`), never the raw layers.

The rules rest on the absolute `NIVEAU` of `VOIRIE_SURFACE` documented above
(decision D5).

| surface | structure |
|---|---|
| `Ouvrage d'art`, `NIVEAU` ≥ 1, touching surfaces grouped | `grade_separated` (deck, stated level); takes priority over the ground under it |
| `Ouvrage d'art`, `NIVEAU` ≤ −1, touching surfaces grouped | `unknown`, with every axis inside; takes priority over the ground above it; excluded from coverage |
| `Ouvrage d'art`, `NIVEAU` 0 | `ground` (stated) |
| `Tronçon`, `Carrefour`, `Aire de repos`, `NIVEAU` empty | `ground`, by a closed-world reading of the continuous inventory (every structure surface is an `Ouvrage d'art`) |
| `NIVEAU` present but unreadable (`1,0`, `1.5`, text), an `Ouvrage d'art` with no `NIVEAU`, any other nature | excluded from coverage |

Measured on Liège: the PICC draws a `NIVEAU` 0 surface under every deck (75
overlaps with `+1` surfaces) and above every tunnel (60 with `−1`). The
`Tronçon` surfaces overlap almost nothing.

**Why tunnels are `unknown` although their level is stated.** Axes carry no
level (`NIVEAU` is empty on layer 21) and no official link to their surface.
Inside a tunnel footprint, the tunnel's axis cannot be told from a street
passing above it.
- Labelled `grade_separated`, the tunnel would hide that street: a crossing
there would count zero without an error.
- Left to the ground surface above, the tunnel's axis would be bored as a
ground crossing. A first version did this, and an adversarial review
measured 674 m of tunnel axes carried by `ground` rows on Liège.

`unknown` makes the consumer ask for proof instead. A deck has no such
ambiguity, because it takes the ground under it out of the ground units.

Axes are sorted by `NATUR_DESC`:
- `Communale`, `Nationale`, `Autoroute` and `Ring` are carriageways;
- `Piste cyclable`, `Chemin ou sentier` and `Sentier` are not (`Chemin ou
sentier` follows the decision taken for the GRB aardeweg);
- anything else is unresolved.

`complex_crossing` is true for `Autoroute`. Fragments are merged as for the
GRB: touching `Tronçon` surfaces sharing an axis and with no junction or dead
end inside are merged; a `Carrefour` is never merged. An empty layer may come
back without its property columns.

Validated live on a 6 × 6 km tile at Liège (`export_picc --write`, 4 s):

| item | value |
|---|---|
| ground units (from 3 798 ground surfaces) | 3 755 |
| bridges, `grade_separated` | 77 |
| tunnels, `unknown` | 16 |
| ground footprints overlapping | none |
| `ground` axes inside a tunnel | none |
| coverage | 98.7 % |
| surfaces carrying no axis | 174 |
| node-less axis crossings outside structures | 33 |

The artifact loads in MILOU's `load_road_crossings`. Of the tile's 31 tracés,
one now stops on `ROAD_CROSSING_LEVEL_UNKNOWN` at a tunnel, which is the
intended behaviour.

The source requests XY-only geometry (`returnZ=false`). Projected
server-side to WGS84 *with* Z, two surfaces of that tile came back
self-intersecting, although the same features are valid in XY or in
EPSG:31370. The export used to fail on them (`PICC_LAYER_INVALID`).
65 changes: 60 additions & 5 deletions plugins/gispulse-src-picc/gispulse_src_picc/export.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Bounded local PICC export; dry-run by default, no client classification."""
"""Bounded local PICC export with road-crossings level evidence; dry-run by default."""

from __future__ import annotations

Expand All @@ -11,7 +11,12 @@
from datetime import UTC, datetime
from pathlib import Path

import geopandas as gpd
import shapely
from shapely.geometry import box

from gispulse.adapters.rest.rest_fetcher import RestGeoJsonFetcher
from gispulse.capabilities.vector.picc_road_crossings import build_picc_road_crossings
from gispulse.core.io.geoparquet import write_geoparquet
from gispulse_src_picc.source import PiccSource

Expand All @@ -24,11 +29,15 @@ def export_picc(
page_size: int = 2000,
max_pages: int = 1000,
max_features: int = 1_000_000,
crossing_exclusion_buffer_m: float = 15.0,
) -> dict:
"""Publish both raw layers only after successful fetch and validation.
"""Publish both raw layers only after successful fetch and validation, then
the road-crossings level evidence built from them.

Bounds apply per layer. The report records source counts, checksums and CRS;
it does not certify a remote snapshot or interpret NIVEAU as ground level.
it does not certify a remote snapshot. Level evidence is published apart
(``road_crossings*.geoparquet``, see ``picc_road_crossings``); a defect in it
degrades that artifact alone, never the raw layers.
"""
if (
len(bbox) != 4
Expand All @@ -39,6 +48,8 @@ def export_picc(
raise ValueError("PICC_EXTENT_INVALID: ordered finite WGS84 bbox required")
if page_size > 2000:
raise ValueError("PICC_PAGE_SIZE_INVALID: service limit is 2000")
if not math.isfinite(crossing_exclusion_buffer_m) or crossing_exclusion_buffer_m <= 0:
raise ValueError("PICC_TOLERANCE_INVALID: positive finite crossing buffer required")
source = PiccSource()
accesses = []
for entry in source.entries():
Expand All @@ -61,13 +72,14 @@ def export_picc(
"max_features": max_features,
"entries": [e.id for e, _ in accesses],
"output": str(output),
"crossing_exclusion_buffer_m": crossing_exclusion_buffer_m,
}
if not write:
return report
output.parent.mkdir(parents=True, exist_ok=True)
staging = Path(tempfile.mkdtemp(prefix=".picc-", dir=output.parent))
try:
layers = []
layers, frames = [], {}
for entry, access in accesses:
result = RestGeoJsonFetcher().fetch(access, extent=bbox)
frame = result.data.to_crs(31370)
Expand All @@ -87,6 +99,7 @@ def export_picc(
raise ValueError(
f"PICC_LAYER_INVALID: inspect raw geometry/schema of {entry.id}"
)
frames[entry.id] = frame
filename = f"{entry.id}.geoparquet"
target = staging / filename
write_geoparquet(frame, str(target), compression="zstd")
Expand All @@ -102,7 +115,15 @@ def export_picc(
**result.metadata,
}
)
report.update(status="complete", layers=layers, fetched_at=datetime.now(UTC).isoformat())
crossings_report = _publish_crossings(
frames, bbox, staging, crossing_exclusion_buffer_m, layers
)
report.update(
status="complete",
layers=layers,
fetched_at=datetime.now(UTC).isoformat(),
road_crossings=crossings_report,
)
(staging / "report.json").write_text(json.dumps(report, indent=2) + "\n")
if output.exists():
raise ValueError("PICC_OUTPUT_EXISTS: output appeared during extraction")
Expand All @@ -113,6 +134,38 @@ def export_picc(
return report


def _publish_crossings(frames, bbox, staging, buffer_m, layers) -> dict:
"""Write the level-evidence artifact; degrade on a PICC data defect only."""
# The PICC is queried by a WGS84 envelope: its projection, not a rectangle,
# is the area the acquisition is complete for.
area = gpd.GeoSeries([shapely.segmentize(box(*bbox), 1e-4)], crs=4326).to_crs(31370).iloc[0]
try:
crossings, coverage, exclusions, report = build_picc_road_crossings(
frames["picc-road-surfaces-wa"],
frames["picc-road-axes-wa"],
coverage_area=area,
length_tolerance_m=1e-6,
area_tolerance_m2=1e-6,
boundary_tolerance_m=1e-3,
exclusion_buffer_m=buffer_m,
)
except ValueError as exc:
if not str(exc).startswith("PICC_CROSSINGS_"):
raise
return {"status": "failed", "error": str(exc)}
for name, frame in [
("road_crossings", crossings),
("road_crossings_coverage", coverage),
("road_crossings_exclusions", exclusions),
]:
target = staging / f"{name}.geoparquet"
write_geoparquet(frame, str(target), compression="zstd")
with target.open("rb") as stream:
digest = hashlib.file_digest(stream, "sha256").hexdigest()
layers.append({"entry": name, "file": target.name, "sha256": digest, "derived": True})
return {"status": "prepared", **report}


def main() -> int:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--bbox", type=float, nargs=4, required=True)
Expand All @@ -121,6 +174,7 @@ def main() -> int:
parser.add_argument("--max-pages", type=int, default=1000)
parser.add_argument("--max-features", type=int, default=1_000_000)
parser.add_argument("--write", action="store_true")
parser.add_argument("--crossing-exclusion-buffer-m", type=float, default=15.0)
args = parser.parse_args()
try:
report = export_picc(
Expand All @@ -130,6 +184,7 @@ def main() -> int:
page_size=args.page_size,
max_pages=args.max_pages,
max_features=args.max_features,
crossing_exclusion_buffer_m=args.crossing_exclusion_buffer_m,
)
except Exception as exc: # noqa: BLE001 - CLI boundary
print(
Expand Down
6 changes: 5 additions & 1 deletion plugins/gispulse-src-picc/gispulse_src_picc/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ def _access(layer: int) -> AccessSpec:
"where": "1=1",
"outFields": "*",
"outSR": "4326",
"returnZ": "true",
# XY only: projected server-side to WGS84 *with* Z, some surfaces
# come back self-intersecting (measured on Liège, OBJECTID
# 201373/201374) although the same features are valid in XY or in
# EPSG:31370. No consumer reads the Z ordinate; PRECIS_Z is kept.
"returnZ": "false",
"returnGeometry": "true",
"f": "geojson",
"orderByFields": "OBJECTID ASC",
Expand Down
51 changes: 51 additions & 0 deletions plugins/gispulse-src-urbis/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,54 @@ to join on and must stay geometric and level-aware (nearest covering axis,
filtered by matching relative `lvl` within the local neighbourhood) — this
plugin does not perform that match, and any consumer building one must document
it as a geometric approximation, not a sourced identity.

## Road crossings: level evidence

`python -m gispulse_src_urbis.prepare --bbox <EPSG:31370> --output <dir>
--write` fetches the four layers and publishes them with
`road_crossings.geoparquet`, `road_crossings_coverage.geoparquet` and
`road_crossings_exclusions.geoparquet`. These are built by
`build_urbis_road_crossings`
(`src/gispulse/capabilities/vector/urbis_road_crossings.py`). The contract is
the GRB one. Without `--write` the command is a dry run, and a defect in the
level evidence degrades that artifact only.

`LVL` is relative, so it never proves anything alone. The rules pair it with
the official structure polygons (decision D5).

| unit | structure |
|---|---|
| touching road bridges (`Bridges` `ROB`), every carriageway axis inside | `grade_separated` |
| touching road tunnels (`Tunnels` `ROT`), the carriageway axes below `LVL` 0 inside | `grade_separated` |
| carriageway surfaces (`StreetSurfaces` `S`, `I`, `C`, `SC`, `IC`) at `LVL` 0, with their `LVL` 0 axes only | `ground` |
| a carriageway surface above 0 outside a road bridge, or below 0 outside any tunnel | excluded (`surface_level_without_structure`) |

A road bridge takes priority over the surface it covers, as for the GRB and
the PICC. A tunnel does not: the road above it stays ground and keeps only its
own `LVL` 0 axis. Railway, metro and pedestrian bridges and tunnels (`RAB`,
`MB`, `PB`, `RAT`, `MT`, …) leave the road under or above them at ground.

Footprints are carriageway surfaces, not the corridor: UrbIS draws sidewalks
and medians as separate surfaces with no axis. Axes are sorted by `TYPE`:
- `S`, `I`, `B`, `T`, `C`, `SC` and `IC` are carriageways;
- `PT`, `PB`, `MT` and `RT` are not;
- ramps `A`/`AC`, galleries `G`, places `P`, parking `K` and anything else are
unresolved.

`complex_crossing` is true for `HIERARCHY` `H`. Touching `S` surfaces sharing
an axis are merged; an `I` intersection is never merged.

Validated live on a 5 × 5 km tile, Brussels centre-east (5.4 s):

| item | value |
|---|---|
| ground units (from 8 001 surfaces) | 7 774 |
| `grade_separated` | 42 (20 road bridges, 22 road tunnels) |
| `unknown` | 0 |
| ground footprints overlapping | none |
| coverage | 93.8 % |
| level contradictions | 35 |

The largest hole, 44.6 ha, is the 2 687 carriageway surfaces that no axis
crosses. They are excluded because a crossing there would count zero without
an error. The artifact loads in MILOU's `load_road_crossings`.
Loading
Loading