fix: query persisted work area geometry
This commit is contained in:
@@ -453,7 +453,7 @@ interface MapWorkspaceProps {
|
||||
onSelectMapFeature: (feature: GeoJSON.Feature | null) => void
|
||||
onMapViewportChange: (viewport: MapViewportState) => void
|
||||
onSetMapSelectionBbox: (bbox: VectorSelectionBBox | null) => void
|
||||
onRunMapSelectionExtract: (bbox: VectorSelectionBBox) => Promise<VectorSelectionResponse | null>
|
||||
onRunMapSelectionExtract: (bbox: VectorSelectionBBox, areaId?: string) => Promise<VectorSelectionResponse | null>
|
||||
onClearMapSelectionExtract: () => void
|
||||
onExportMapSelection: (bbox: VectorSelectionBBox) => Promise<unknown>
|
||||
onDeriveMapSelectionDataset: (bbox: VectorSelectionBBox) => Promise<DatasetCreateResponse | null>
|
||||
@@ -804,17 +804,17 @@ export function MapWorkspace({
|
||||
clearTemporalComparison()
|
||||
}
|
||||
|
||||
const loadAllThemeResults = async (bbox: VectorSelectionBBox) => {
|
||||
const loadAllThemeResults = async (bbox: VectorSelectionBBox, areaId?: string) => {
|
||||
const availableThemes = DATA_THEMES.flatMap((theme) => {
|
||||
const dataset = themeDatasetMap[theme.id]
|
||||
return dataset ? [{ themeId: theme.id, dataset }] : []
|
||||
})
|
||||
await loadThemeInsights(bbox, availableThemes)
|
||||
await loadThemeInsights(bbox, availableThemes, areaId)
|
||||
}
|
||||
|
||||
const analyzeSelection = async (bbox: VectorSelectionBBox) => {
|
||||
const analyzeSelection = async (bbox: VectorSelectionBBox, areaId?: string) => {
|
||||
setSelectionBbox(bbox)
|
||||
const tasks: Array<Promise<unknown>> = [onRunMapSelectionExtract(bbox), loadAllThemeResults(bbox)]
|
||||
const tasks: Array<Promise<unknown>> = [onRunMapSelectionExtract(bbox, areaId), loadAllThemeResults(bbox, areaId)]
|
||||
if (analysisMode === 'evolution' && earlierDatasetId && laterDatasetId) {
|
||||
tasks.push(compareTemporalSnapshots(earlierDatasetId, laterDatasetId, bbox))
|
||||
}
|
||||
@@ -844,7 +844,7 @@ export function MapWorkspace({
|
||||
return
|
||||
}
|
||||
setSelectionBbox(bbox)
|
||||
void analyzeSelection(bbox)
|
||||
void analyzeSelection(bbox, selectedAreaBbox ? selectedMapArea?.id : undefined)
|
||||
}
|
||||
|
||||
const runFullGisWorkflow = async () => {
|
||||
@@ -1061,7 +1061,7 @@ export function MapWorkspace({
|
||||
|
||||
<label className="geo-scope-select">
|
||||
Werkgebied
|
||||
<select value={selectedMapAreaId} onChange={(event) => onSelectMapArea(event.target.value)} disabled={areas.length === 0}>
|
||||
<select aria-label="Werkgebied" value={selectedMapAreaId} onChange={(event) => onSelectMapArea(event.target.value)} disabled={areas.length === 0}>
|
||||
<option value="">Geen werkgebied</option>
|
||||
{areas.map((area) => (
|
||||
<option key={area.id} value={area.id}>{area.name}</option>
|
||||
@@ -1092,7 +1092,7 @@ export function MapWorkspace({
|
||||
className="secondary-action"
|
||||
disabled={!activeThemeDataset || (analysisMode === 'evolution' && activeTemporalSeries.length < 2) || !selectedAreaBbox || mapSelectionLoading || themeResultsLoading}
|
||||
type="button"
|
||||
onClick={() => selectedAreaBbox && void analyzeSelection(selectedAreaBbox)}
|
||||
onClick={() => selectedAreaBbox && void analyzeSelection(selectedAreaBbox, selectedMapArea?.id)}
|
||||
>
|
||||
Volledig werkgebied
|
||||
</button>
|
||||
@@ -1387,6 +1387,7 @@ export function MapWorkspace({
|
||||
<label>
|
||||
Area
|
||||
<select
|
||||
aria-label="Werkgebied"
|
||||
value={selectedMapAreaId}
|
||||
onChange={(event) => onSelectMapArea(event.target.value)}
|
||||
disabled={areas.length === 0}
|
||||
|
||||
@@ -28,7 +28,7 @@ export function useMapSelectionExtract({
|
||||
setMapSelectionError(null)
|
||||
}, [selectedProjectId, selectedDataset?.id])
|
||||
|
||||
const runMapSelectionExtract = async (bbox: VectorSelectionBBox) => {
|
||||
const runMapSelectionExtract = async (bbox: VectorSelectionBBox, areaId?: string) => {
|
||||
if (!selectedProjectId || !selectedDataset) {
|
||||
setMapSelectionError('Open a vector dataset before extracting a map area.')
|
||||
return null
|
||||
@@ -44,6 +44,7 @@ export function useMapSelectionExtract({
|
||||
try {
|
||||
const response = await datasetsApi.selectVectorFeatures(selectedProjectId, selectedDataset.id, {
|
||||
bbox: { ...bbox, crs: 'EPSG:4326' },
|
||||
area_id: areaId,
|
||||
limit: 1000,
|
||||
})
|
||||
setMapSelectionResult(response)
|
||||
|
||||
@@ -32,6 +32,7 @@ export function useMapThemeSelectionInsights<TThemeId extends string>(
|
||||
const loadThemeInsights = async (
|
||||
bbox: VectorSelectionBBox,
|
||||
queries: Array<MapThemeQuery<TThemeId>>,
|
||||
areaId?: string,
|
||||
): Promise<Array<MapThemeInsight<TThemeId>>> => {
|
||||
if (!selectedProjectId) {
|
||||
setThemeInsights([])
|
||||
@@ -48,6 +49,7 @@ export function useMapThemeSelectionInsights<TThemeId extends string>(
|
||||
dataset,
|
||||
result: await datasetsApi.selectVectorFeatures(selectedProjectId, dataset.id, {
|
||||
bbox,
|
||||
area_id: areaId,
|
||||
limit: 1000,
|
||||
}),
|
||||
})),
|
||||
|
||||
@@ -305,6 +305,7 @@ export interface MapViewportState {
|
||||
|
||||
export interface VectorSelectionRequest {
|
||||
bbox: VectorSelectionBBox
|
||||
area_id?: string
|
||||
limit?: number
|
||||
}
|
||||
|
||||
@@ -314,6 +315,7 @@ export interface VectorSelectionDeriveRequest extends VectorSelectionRequest {
|
||||
|
||||
export interface VectorSelectionResponse {
|
||||
selection_bbox: VectorSelectionBBox
|
||||
selection_area_id?: string | null
|
||||
feature_count: number
|
||||
total_feature_count?: number | null
|
||||
limit: number
|
||||
|
||||
Reference in New Issue
Block a user