Add map area selection extraction
This commit is contained in:
@@ -24,6 +24,9 @@ from app.schemas import (
|
||||
VectorBufferRequest,
|
||||
VectorClipRequest,
|
||||
VectorIntersectRequest,
|
||||
VectorSelectionBBox,
|
||||
VectorSelectionRequest,
|
||||
VectorSelectionResponse,
|
||||
)
|
||||
from app.schemas.job import JobCreate
|
||||
from app.schemas.dataset import DatasetCreateResponse
|
||||
@@ -31,6 +34,7 @@ from app.schemas.operations import VectorOperationResult
|
||||
from app.services.job_service import JobService
|
||||
from app.services.raster_operations_service import RasterOperationsService
|
||||
from app.services.vector_operations_service import VectorOperationsService
|
||||
from app.services.vector_feature_service import VectorFeatureService
|
||||
from app.services.dataset_service import DatasetService
|
||||
from app.utils.response import envelope
|
||||
|
||||
@@ -180,6 +184,27 @@ def vector_stats(
|
||||
return envelope(VectorOperationsService.stats(db, dataset_id))
|
||||
|
||||
|
||||
@router.post("/datasets/{dataset_id}/vector/select", response_model=dict)
|
||||
def select_vector_features(
|
||||
project_id: UUID,
|
||||
dataset_id: UUID,
|
||||
payload: VectorSelectionRequest,
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
dataset = DatasetService.get_dataset(db, dataset_id)
|
||||
if dataset.project_id != project_id:
|
||||
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)
|
||||
result = VectorFeatureService.select_features_by_bbox(
|
||||
db,
|
||||
dataset_id=dataset_id,
|
||||
bbox=payload.bbox.model_dump(),
|
||||
limit=payload.limit,
|
||||
)
|
||||
return envelope(VectorSelectionResponse(**result).model_dump())
|
||||
|
||||
|
||||
@router.post("/datasets/{dataset_id}/vector/clip", status_code=201, response_model=dict)
|
||||
def clip_vector_dataset(
|
||||
project_id: UUID,
|
||||
|
||||
Reference in New Issue
Block a user