feat: synchronize regional official time series
This commit is contained in:
@@ -185,6 +185,16 @@ def series_key(theme: ThemeDefinition, scope_key: str) -> str:
|
||||
return f"department-omgeving:land-use:{theme.key}:{scope_key.strip().lower()}"
|
||||
|
||||
|
||||
def scope_identity(scope_display_name: str, raw_nis_codes: str) -> dict[str, Any]:
|
||||
nis_codes = [value.strip() for value in raw_nis_codes.split(",") if value.strip()]
|
||||
return {
|
||||
"scope_display_name": scope_display_name,
|
||||
"member_nis_codes": nis_codes,
|
||||
"municipality": scope_display_name if len(nis_codes) == 1 else None,
|
||||
"nis_code": nis_codes[0] if len(nis_codes) == 1 else None,
|
||||
}
|
||||
|
||||
|
||||
def load_boundary(path: Path):
|
||||
if not path.exists():
|
||||
raise RuntimeError(f"Boundary artifact is missing at {path}")
|
||||
@@ -326,6 +336,7 @@ def polygonize_snapshot(
|
||||
scope_key: str,
|
||||
max_features: int,
|
||||
) -> tuple[dict[str, Any], dict[str, Any]]:
|
||||
identity = scope_identity(municipality_name, nis_code)
|
||||
boundary_metric = metric_boundary(boundary)
|
||||
to_output = Transformer.from_crs(SOURCE_CRS, OUTPUT_CRS, always_xy=True)
|
||||
raster_sha256 = sha256_file(raster_path)
|
||||
@@ -397,8 +408,7 @@ def polygonize_snapshot(
|
||||
"layer_type": theme.key,
|
||||
"authority_level": "authoritative",
|
||||
"coverage_scope": scope_key,
|
||||
"municipality": municipality_name,
|
||||
"nis_code": nis_code,
|
||||
**identity,
|
||||
"observation_year": year,
|
||||
"land_use_class_ids": list(theme.class_ids),
|
||||
"land_use_class_names": [LAND_USE_CLASSES[class_id] for class_id in theme.class_ids],
|
||||
@@ -415,8 +425,7 @@ def polygonize_snapshot(
|
||||
"type": "FeatureCollection",
|
||||
"name": f"{theme.label} - {municipality_name} {year}",
|
||||
"crs": {"type": "name", "properties": {"name": OUTPUT_CRS}},
|
||||
"municipality": municipality_name,
|
||||
"nis_code": nis_code,
|
||||
**identity,
|
||||
"scope_key": scope_key,
|
||||
"observation_year": year,
|
||||
"source_coverage_id": coverage_id(year),
|
||||
@@ -529,6 +538,7 @@ def prepare_snapshot(
|
||||
)
|
||||
write_json_atomic(vector_path, payload)
|
||||
vector_sha256 = sha256_file(vector_path)
|
||||
identity = scope_identity(args.municipality_name, args.nis_code)
|
||||
manifest = {
|
||||
"schema_version": 1,
|
||||
"year": year,
|
||||
@@ -544,8 +554,7 @@ def prepare_snapshot(
|
||||
"output_crs": OUTPUT_CRS,
|
||||
"source_resolution_metres": SOURCE_RESOLUTION_METRES,
|
||||
"boundary_path": str(args.boundary_path),
|
||||
"municipality": args.municipality_name,
|
||||
"nis_code": args.nis_code,
|
||||
**identity,
|
||||
"scope_key": args.scope_key,
|
||||
"raster_path": str(raster_path),
|
||||
"vector_path": str(vector_path),
|
||||
@@ -629,6 +638,7 @@ def locate_workspace(session: requests.Session, base_url: str, args: argparse.Na
|
||||
|
||||
|
||||
def build_source_metadata(args: argparse.Namespace, snapshot: PreparedSnapshot) -> dict[str, Any]:
|
||||
identity = scope_identity(args.municipality_name, args.nis_code)
|
||||
return {
|
||||
"provider": "Departement Omgeving",
|
||||
"source_title": f"Landgebruik - Vlaanderen - toestand {snapshot.year}",
|
||||
@@ -636,8 +646,7 @@ def build_source_metadata(args: argparse.Namespace, snapshot: PreparedSnapshot)
|
||||
"coverage_id": coverage_id(snapshot.year),
|
||||
"authority_level": "authoritative",
|
||||
"coverage_scope": args.scope_key,
|
||||
"municipality": args.municipality_name,
|
||||
"nis_code": args.nis_code,
|
||||
**identity,
|
||||
"attribution": ATTRIBUTION,
|
||||
"license_note": "Publieke Vlaamse overheidsdata; raadpleeg de toegangs- en gebruiksvoorwaarden in de bronmetadata.",
|
||||
"methodology_version": "3",
|
||||
|
||||
Reference in New Issue
Block a user