Keep map selections within active areas
This commit is contained in:
@@ -528,6 +528,12 @@ combined cell statistics. A monolithic full-region 5 m calculation remains
|
||||
disabled because it exceeds the governed raster-cell limit; users draw a
|
||||
bounded rectangle without first choosing a municipality.
|
||||
|
||||
Every selection entry path forwards the active Area id. This includes dragged
|
||||
and coordinate rectangles, manual bbox input, temporal comparison, saving a
|
||||
derived selection Dataset and the advanced GIS workflow. Backend geometry
|
||||
intersection therefore remains the authority for the municipality or regional
|
||||
boundary even when a rectangle extends beyond it.
|
||||
|
||||
## Useful repository scripts
|
||||
|
||||
- `bash scripts/frontend_install.sh`
|
||||
|
||||
@@ -676,7 +676,7 @@ interface MapWorkspaceProps {
|
||||
onRunMapSelectionExtract: (bbox: VectorSelectionBBox, areaId?: string) => Promise<VectorSelectionResponse | null>
|
||||
onClearMapSelectionExtract: () => void
|
||||
onExportMapSelection: (bbox: VectorSelectionBBox) => Promise<unknown>
|
||||
onDeriveMapSelectionDataset: (bbox: VectorSelectionBBox) => Promise<DatasetCreateResponse | null>
|
||||
onDeriveMapSelectionDataset: (bbox: VectorSelectionBBox, areaId?: string) => Promise<DatasetCreateResponse | null>
|
||||
onSelectMapQaReferenceDataset: (datasetId: string) => void
|
||||
onRunMapSelectionQa: (candidateDataset?: DatasetCreateResponse | null) => Promise<QaComparisonResult | null>
|
||||
onOpenMapSelectionQualityEvidence: () => void
|
||||
@@ -1123,7 +1123,7 @@ export function MapWorkspace({
|
||||
setSelectionBbox(bbox)
|
||||
setFirstSelectionCorner(null)
|
||||
setBboxSelectionMode(false)
|
||||
void analyzeSelection(bbox)
|
||||
void analyzeSelection(bbox, selectedMapArea?.id)
|
||||
}
|
||||
|
||||
const runAreaExtract = () => {
|
||||
@@ -1131,7 +1131,7 @@ export function MapWorkspace({
|
||||
if (!bbox) {
|
||||
return
|
||||
}
|
||||
void analyzeSelection(bbox)
|
||||
void analyzeSelection(bbox, selectedMapArea?.id)
|
||||
}
|
||||
|
||||
const clearAreaSelection = () => {
|
||||
@@ -1183,7 +1183,7 @@ export function MapWorkspace({
|
||||
if (!bbox) {
|
||||
return
|
||||
}
|
||||
onDeriveMapSelectionDataset(bbox)
|
||||
onDeriveMapSelectionDataset(bbox, selectedMapArea?.id)
|
||||
}
|
||||
|
||||
const openSelectedDatabaseLayer = (datasetId: string) => {
|
||||
@@ -1251,8 +1251,7 @@ export function MapWorkspace({
|
||||
if (!mapSelectionBbox || !earlierDatasetId || !laterDatasetId) {
|
||||
return
|
||||
}
|
||||
const areaId = selectedAreaBbox && bboxesEqual(mapSelectionBbox, selectedAreaBbox) ? selectedMapAreaId : undefined
|
||||
void compareTemporalSnapshots(earlierDatasetId, laterDatasetId, mapSelectionBbox, areaId)
|
||||
void compareTemporalSnapshots(earlierDatasetId, laterDatasetId, mapSelectionBbox, selectedMapArea?.id)
|
||||
}
|
||||
|
||||
const handleMapBboxPreview = (bbox: VectorSelectionBBox) => {
|
||||
@@ -1262,7 +1261,7 @@ export function MapWorkspace({
|
||||
const handleMapBboxSelect = (bbox: VectorSelectionBBox) => {
|
||||
setFirstSelectionCorner(null)
|
||||
setBboxSelectionMode(false)
|
||||
void analyzeSelection(bbox)
|
||||
void analyzeSelection(bbox, selectedMapArea?.id)
|
||||
}
|
||||
|
||||
const runQuickAoiExtract = () => {
|
||||
@@ -1271,7 +1270,7 @@ export function MapWorkspace({
|
||||
return
|
||||
}
|
||||
setSelectionBbox(bbox)
|
||||
void analyzeSelection(bbox, selectedAreaBbox ? selectedMapArea?.id : undefined)
|
||||
void analyzeSelection(bbox, selectedMapArea?.id)
|
||||
}
|
||||
|
||||
const runFullGisWorkflow = async () => {
|
||||
@@ -1310,7 +1309,7 @@ export function MapWorkspace({
|
||||
try {
|
||||
setFullWorkflowStatus('1/4 Querying persisted vector_features...')
|
||||
setSelectionBbox(bbox)
|
||||
const selection = await onRunMapSelectionExtract(bbox)
|
||||
const selection = await onRunMapSelectionExtract(bbox, selectedMapArea?.id)
|
||||
if (!selection) {
|
||||
setFullWorkflowError('Persisted vector query did not complete.')
|
||||
setFullWorkflowStatus('Stopped at query.')
|
||||
@@ -1318,7 +1317,7 @@ export function MapWorkspace({
|
||||
}
|
||||
|
||||
setFullWorkflowStatus('2/4 Saving derived result dataset...')
|
||||
const derived = await onDeriveMapSelectionDataset(bbox)
|
||||
const derived = await onDeriveMapSelectionDataset(bbox, selectedMapArea?.id)
|
||||
if (!derived) {
|
||||
setFullWorkflowError('Derived result dataset was not created.')
|
||||
setFullWorkflowStatus('Stopped at dataset save.')
|
||||
|
||||
@@ -24,7 +24,7 @@ export function useMapSelectionDataset({
|
||||
const [selectionDatasetError, setSelectionDatasetError] = useState<string | null>(null)
|
||||
const [latestSelectionDataset, setLatestSelectionDataset] = useState<DatasetCreateResponse | null>(null)
|
||||
|
||||
const deriveMapSelectionDataset = async (bbox: VectorSelectionBBox) => {
|
||||
const deriveMapSelectionDataset = async (bbox: VectorSelectionBBox, areaId?: string) => {
|
||||
if (!selectedProjectId || !selectedDataset || !isVectorDatasetType(selectedDataset.dataset_type)) {
|
||||
setSelectionDatasetError('Select a vector dataset before saving the area as a dataset.')
|
||||
return null
|
||||
@@ -34,6 +34,7 @@ export function useMapSelectionDataset({
|
||||
try {
|
||||
const derived = await datasetsApi.deriveVectorSelection(selectedProjectId, selectedDataset.id, {
|
||||
bbox: { ...bbox, crs: 'EPSG:4326' },
|
||||
area_id: areaId,
|
||||
limit: 250,
|
||||
output_name: `${selectedDataset.name.replace(/\.(geo)?json$/i, '')}-selection-dataset`,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user