Aggregate regional bathymetry partitions
GeoIntel CI / docs-smoke (push) Canceled after 0s
GeoIntel CI / contract-smoke (push) Canceled after 0s

This commit is contained in:
Codex
2026-07-17 17:08:35 +02:00
parent 24247746c1
commit 4fd6c06f5c
17 changed files with 661 additions and 29 deletions
+91
View File
@@ -87,6 +87,16 @@ class ExportService:
if not dataset or dataset.project_id != payload.project_id:
raise AppError(code="DATASET_NOT_FOUND", message="Dataset not found", status_code=404)
if dataset.dataset_type in DatasetService.VECTOR_TYPES:
if payload.partitioned:
return ExportService.export_partitioned_vector_selection_geojson(
db,
dataset,
payload.bbox.model_dump(mode="json"),
partition_scope_key=payload.partition_scope_key or "",
area_id=payload.area_id,
name=payload.name,
limit=1000,
)
return ExportService.export_vector_selection_geojson(
db,
dataset.id,
@@ -198,6 +208,87 @@ class ExportService:
)
return ExportService._create_response(export)
@staticmethod
def export_partitioned_vector_selection_geojson(
db: Session,
dataset: Dataset,
bbox: dict[str, Any],
*,
partition_scope_key: str,
area_id: uuid.UUID | None = None,
limit: int = 1000,
name: str | None = None,
) -> ExportCreateResponse:
if dataset.source_name != "vmm_vha_bathymetry_profiles" or partition_scope_key != "flanders":
raise AppError(
code="PARTITIONED_VECTOR_EXPORT_UNSUPPORTED",
message="This vector source does not expose a governed partitioned export",
details={
"source_name": dataset.source_name,
"partition_scope_key": partition_scope_key,
},
status_code=400,
)
selection_geometry = None
partition_area_id = None
if area_id is not None:
area = db.get(Area, area_id)
if not area or area.project_id != dataset.project_id:
raise AppError(code="AREA_NOT_FOUND", message="Area not found", status_code=404)
selection_geometry, _covers_full_area = VectorFeatureService.constrain_bbox_to_area(
bbox,
area.geometry,
)
if str(area.name or "").lower().startswith("gemeente "):
partition_area_id = area.id
selection = VectorFeatureService.select_partitioned_features_by_bbox(
db,
project_id=dataset.project_id,
source_name=dataset.source_name,
partition_scope_key=partition_scope_key,
bbox=bbox,
limit=limit,
selection_geometry=selection_geometry,
selection_area_id=area_id,
partition_area_id=partition_area_id,
)
filename = ExportService._filename(name, "bathymetry-profile-selection.geojson", ".geojson")
export_path = StorageService.dataset_export_path(
str(dataset.project_id),
str(dataset.id),
filename,
)
metadata = {
"source": "partitioned_vector_selection",
"project_id": str(dataset.project_id),
"representative_dataset_id": str(dataset.id),
"dataset_ids": [str(value) for value in selection["dataset_ids"]],
"source_name": dataset.source_name,
"partition_scope_key": partition_scope_key,
"partition_count": selection["partition_count"],
"available_partition_count": selection["available_partition_count"],
"selection_bbox": selection["selection_bbox"],
"selection_area_id": selection.get("selection_area_id"),
"feature_count": selection["feature_count"],
"total_feature_count": selection["total_feature_count"],
"limit": selection["limit"],
"truncated": selection["truncated"],
"source_table": "vector_features",
"server_recomputed": True,
}
export = ExportService._write_json_export(
db,
project_id=dataset.project_id,
analysis_run_id=None,
export_type="partitioned_vector_selection_geojson",
storage_path=export_path,
content=selection["geojson"],
metadata=metadata,
)
return ExportService._create_response(export)
@staticmethod
def export_vector_selection_geojson(
db: Session,