Constrain selections to active work areas
This commit is contained in:
@@ -398,14 +398,20 @@ def select_vector_features(
|
||||
full_dataset_area = False
|
||||
preclipped_partition_filter = None
|
||||
if selection_area is not None:
|
||||
full_dataset_area = VectorFeatureService.can_use_full_area_fast_path(dataset, selection_area.id)
|
||||
if not full_dataset_area:
|
||||
preclipped_partition_filter = VectorFeatureService.preclipped_partition_filter(
|
||||
dataset,
|
||||
getattr(selection_area, "name", None),
|
||||
)
|
||||
selection_geometry, covers_full_area = VectorFeatureService.constrain_bbox_to_area(
|
||||
payload.bbox.model_dump(),
|
||||
selection_area.geometry,
|
||||
)
|
||||
full_dataset_area = covers_full_area and VectorFeatureService.can_use_full_area_fast_path(
|
||||
dataset,
|
||||
selection_area.id,
|
||||
)
|
||||
preclipped_partition_filter = VectorFeatureService.preclipped_partition_filter(
|
||||
dataset,
|
||||
getattr(selection_area, "name", None),
|
||||
)
|
||||
selection_kwargs.update(
|
||||
selection_geometry=selection_area.geometry,
|
||||
selection_geometry=selection_geometry,
|
||||
selection_area_id=selection_area.id,
|
||||
full_dataset_area=full_dataset_area,
|
||||
preclipped_partition_filter=preclipped_partition_filter,
|
||||
@@ -418,7 +424,7 @@ def select_vector_features(
|
||||
"total_feature_count": result.get("total_feature_count"),
|
||||
}
|
||||
if selection_area is not None:
|
||||
summary_kwargs["selection_geometry"] = selection_area.geometry
|
||||
summary_kwargs["selection_geometry"] = selection_geometry
|
||||
summary_kwargs["full_dataset_area"] = full_dataset_area
|
||||
summary_kwargs["preclipped_partition_filter"] = preclipped_partition_filter
|
||||
result["summary"] = VectorFeatureService.summarize_features_by_bbox(db, **summary_kwargs)
|
||||
@@ -437,10 +443,23 @@ def derive_vector_selection_dataset(
|
||||
raise HTTPException(status_code=404, detail="Dataset not found")
|
||||
if dataset.dataset_type not in {"vector", "geojson"}:
|
||||
raise AppError(code="DATASET_NOT_VECTOR", message="Area selection requires a vector dataset", status_code=400)
|
||||
selection_geometry = None
|
||||
selection_area_id = None
|
||||
if payload.area_id is not None:
|
||||
selection_area = db.get(Area, payload.area_id)
|
||||
if selection_area is None or selection_area.project_id != 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(
|
||||
payload.bbox.model_dump(),
|
||||
selection_area.geometry,
|
||||
)
|
||||
selection_area_id = selection_area.id
|
||||
derived = VectorOperationsService.derive_selection_dataset(
|
||||
db=db,
|
||||
dataset_id=dataset_id,
|
||||
bbox=payload.bbox.model_dump(),
|
||||
selection_geometry=selection_geometry,
|
||||
selection_area_id=selection_area_id,
|
||||
limit=payload.limit,
|
||||
output_name=payload.output_name,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user