Complete live Mol register validation
GeoIntel CI / docs-smoke (push) Canceled after 0s
GeoIntel CI / contract-smoke (push) Canceled after 0s

This commit is contained in:
Codex
2026-07-15 17:36:33 +02:00
parent e9db219a80
commit 0e36d750c0
6 changed files with 126 additions and 10 deletions
@@ -58,7 +58,7 @@ SOURCE_NAME = "digitaal_vlaanderen_buildings_addresses_register"
DEFAULT_PROJECT_NAME = "Kempen Regional Workbench"
DEFAULT_AREA_NAME = "Gemeente Mol - officiele grens"
DEFAULT_API_URL = "http://127.0.0.1:8000"
DEFAULT_OUTPUT_ROOT = Path("/app/storage/operator-evidence/buildings-addresses-register/mol")
DEFAULT_OUTPUT_ROOT = Path("/app/storage/operator-evidence/buildings-addresses-register")
DEFAULT_PAGE_LIMIT = 1000
DEFAULT_MAX_BUILDINGS = 150_000
DEFAULT_MAX_UNITS = 200_000
@@ -247,6 +247,22 @@ def normalize_area_name(value: str) -> str:
return unicodedata.normalize("NFKD", value).encode("ascii", "ignore").decode("ascii").casefold()
def area_storage_key(value: str) -> str:
normalized = normalize_area_name(value)
if normalized.startswith("gemeente "):
municipality = normalized.removeprefix("gemeente ").split(" - ", maxsplit=1)[0].strip()
if municipality:
return "-".join(municipality.split())
key = "-".join(part for part in compact_key(value).split() if part)
return key or "area"
def boundary_checksum(boundary_wgs84) -> str:
return sha256_bytes(
json.dumps(mapping(boundary_wgs84), sort_keys=True).encode("utf-8")
)
def locate_workspace(
session: requests.Session,
base_url: str,
@@ -763,7 +779,13 @@ def build_output_features(
}
def reusable_snapshot(snapshot_dir: Path) -> tuple[Path, Path, dict[str, Any]] | None:
def reusable_snapshot(
snapshot_dir: Path,
*,
area_name: str,
observed_date: date,
expected_boundary_checksum: str,
) -> tuple[Path, Path, dict[str, Any]] | None:
artifact_path = snapshot_dir / "buildings_addresses_register.geojson"
manifest_path = snapshot_dir / "buildings_addresses_register.manifest.json"
if not artifact_path.is_file() or not manifest_path.is_file():
@@ -774,6 +796,10 @@ def reusable_snapshot(snapshot_dir: Path) -> tuple[Path, Path, dict[str, Any]] |
return None
if manifest.get("schema_version") != SCHEMA_VERSION:
return None
if manifest.get("coverage_area") != area_name or manifest.get("observed_at") != observed_date.isoformat():
return None
if manifest.get("boundary_sha256") != expected_boundary_checksum:
return None
if manifest.get("artifact_sha256") != sha256_file(artifact_path):
return None
for collection in manifest.get("collections") or []:
@@ -804,8 +830,14 @@ def prepare_snapshot(
timeout: int,
force: bool,
) -> tuple[Path, Path, dict[str, Any]]:
expected_boundary_checksum = boundary_checksum(boundary_wgs84)
if not force:
reusable = reusable_snapshot(snapshot_dir)
reusable = reusable_snapshot(
snapshot_dir,
area_name=area_name,
observed_date=observed_date,
expected_boundary_checksum=expected_boundary_checksum,
)
if reusable:
return reusable
snapshot_dir.mkdir(parents=True, exist_ok=True)
@@ -892,7 +924,7 @@ def prepare_snapshot(
"crs_source": "EPSG:4326",
"crs_clip": "EPSG:31370",
"crs_persisted": "EPSG:4326",
"boundary_sha256": sha256_bytes(json.dumps(mapping(boundary_wgs84), sort_keys=True).encode("utf-8")),
"boundary_sha256": expected_boundary_checksum,
"boundary_bbox_wgs84": list(boundary_wgs84.bounds),
"collections": [buildings_source, units_source, addresses_source],
"building_filter": building_filter,
@@ -1113,7 +1145,7 @@ def main() -> int:
print(json.dumps({"status": "error", "message": "Invalid page or feature safety limits"}), file=sys.stderr)
return 2
base_url = args.base_url.rstrip("/")
snapshot_dir = args.output_root / args.observed_date.isoformat()
snapshot_dir = args.output_root / area_storage_key(args.area_name) / args.observed_date.isoformat()
try:
with requests.Session() as api_session:
project_id, area_id, boundary, datasets = locate_workspace(