extract and test the four-step GIS workflow
Extracted for its error paths, not its size. Every step can fail or return nothing, and each outcome has to leave the operator with a status that says where the chain stopped — a workflow reporting "afgerond" after a step produced nothing tells them a result exists when it does not. Inline in the component, none of that was exercised; it now has fourteen tests covering each stopping point, both rejection kinds, the reuse path and the preconditions. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -7,6 +7,7 @@ import { useOfficialMapProducts } from '../../hooks/useOfficialMapProducts'
|
||||
import { useTemporalComparison } from '../../hooks/useTemporalComparison'
|
||||
import { isValueRampRasterSource, useMapImageOverlays } from '../../hooks/useMapImageOverlays'
|
||||
import { useMapRectangleSelection } from '../../hooks/useMapRectangleSelection'
|
||||
import { useFullGisWorkflow } from '../../hooks/useFullGisWorkflow'
|
||||
import { getDatasetDisplayName, getDatasetSourceDisplayName } from '../../lib/datasetDisplay'
|
||||
import { TemporalTrendChart } from './TemporalTrendChart'
|
||||
import { MunicipalitySearch } from './MunicipalitySearch'
|
||||
@@ -324,10 +325,6 @@ export function MapWorkspace({
|
||||
bboxInput,
|
||||
setBboxInput,
|
||||
} = rectangle
|
||||
const [fullWorkflowRunning, setFullWorkflowRunning] = useState(false)
|
||||
const [fullWorkflowStatus, setFullWorkflowStatus] = useState('Klaar om de volledige GIS-werkstroom uit te voeren.')
|
||||
const [fullWorkflowError, setFullWorkflowError] = useState<string | null>(null)
|
||||
const [fullWorkflowMode, setFullWorkflowMode] = useState<'new' | 'reuse'>('new')
|
||||
const [mapAnalysisDurationMs, setMapAnalysisDurationMs] = useState<number | null>(null)
|
||||
const mapAnalysisRequestSequence = useRef(0)
|
||||
const regionalScopeSelected = Boolean(selectedMapArea && !isMunicipalityAreaName(selectedMapArea.name))
|
||||
@@ -1463,75 +1460,26 @@ export function MapWorkspace({
|
||||
void analyzeSelection(bbox, areaIdForSelection(bbox))
|
||||
}
|
||||
|
||||
const runFullGisWorkflow = async () => {
|
||||
const bbox = currentSelectionBbox ?? selectedAreaBbox ?? activeLayerBbox
|
||||
if (fullWorkflowMode === 'reuse') {
|
||||
if (!latestSelectionDataset) {
|
||||
setFullWorkflowError('Bewaar eerst een kaartselectie voordat je het laatste resultaat opnieuw gebruikt.')
|
||||
return
|
||||
}
|
||||
if (!selectedMapQaReferenceDatasetId) {
|
||||
setFullWorkflowError('Kies eerst een referentielaag voor de kwaliteitscontrole.')
|
||||
return
|
||||
}
|
||||
setFullWorkflowRunning(true)
|
||||
setFullWorkflowError(null)
|
||||
try {
|
||||
setFullWorkflowStatus('Laatste bewaarde resultaatlaag opnieuw controleren...')
|
||||
const qaResult = await onRunMapSelectionQa(latestSelectionDataset)
|
||||
setFullWorkflowStatus(qaResult ? 'Het laatste bewaarde resultaat is opnieuw gebruikt en gecontroleerd.' : 'Het laatste resultaat is gebruikt, maar de kwaliteitscontrole is niet afgerond.')
|
||||
} catch (error) {
|
||||
setFullWorkflowError(error instanceof Error ? error.message : 'Full GIS workflow failed.')
|
||||
setFullWorkflowStatus('De werkstroom is gestopt.')
|
||||
} finally {
|
||||
setFullWorkflowRunning(false)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if (!selectedMapDataset || !bbox) {
|
||||
setFullWorkflowError('Kies een kaartlaag en een werkgebied of laagbegrenzing.')
|
||||
return
|
||||
}
|
||||
|
||||
setFullWorkflowRunning(true)
|
||||
setFullWorkflowError(null)
|
||||
try {
|
||||
setFullWorkflowStatus('1/4 Bewaarde kaartobjecten selecteren...')
|
||||
setSelectionBbox(bbox)
|
||||
const selectionAreaId = areaIdForSelection(bbox)
|
||||
const selection = await onRunMapSelectionExtract(bbox, selectionAreaId)
|
||||
if (!selection) {
|
||||
setFullWorkflowError('De ruimtelijke selectie kon niet worden afgerond.')
|
||||
setFullWorkflowStatus('Stopped at query.')
|
||||
return
|
||||
}
|
||||
|
||||
setFullWorkflowStatus('2/4 Saving derived result dataset...')
|
||||
const derived = await onDeriveMapSelectionDataset(bbox, selectionAreaId)
|
||||
if (!derived) {
|
||||
setFullWorkflowError('De afgeleide resultaatlaag kon niet worden aangemaakt.')
|
||||
setFullWorkflowStatus('Stopped at dataset save.')
|
||||
return
|
||||
}
|
||||
|
||||
setFullWorkflowStatus('3/4 Saving GeoJSON export artifact...')
|
||||
await onExportMapSelection(bbox, selectionAreaId)
|
||||
|
||||
if (selectedMapQaReferenceDatasetId) {
|
||||
setFullWorkflowStatus('4/4 Kwaliteit vergelijken met de gekozen referentielaag...')
|
||||
const qaResult = await onRunMapSelectionQa(derived)
|
||||
setFullWorkflowStatus(qaResult ? 'De volledige GIS-werkstroom en kwaliteitscontrole zijn afgerond.' : 'Resultaat en download zijn gereed; de kwaliteitscontrole is niet afgerond.')
|
||||
} else {
|
||||
setFullWorkflowStatus('Resultaat en download zijn gereed. Kies een referentielaag om de kwaliteit te controleren.')
|
||||
}
|
||||
} catch (error) {
|
||||
setFullWorkflowError(error instanceof Error ? error.message : 'Full GIS workflow failed.')
|
||||
setFullWorkflowStatus('De werkstroom is gestopt.')
|
||||
} finally {
|
||||
setFullWorkflowRunning(false)
|
||||
}
|
||||
}
|
||||
const fullWorkflow = useFullGisWorkflow({
|
||||
selectedDataset: selectedMapDataset,
|
||||
latestSelectionDataset,
|
||||
qaReferenceDatasetId: selectedMapQaReferenceDatasetId,
|
||||
resolveBbox: () => currentSelectionBbox ?? selectedAreaBbox ?? activeLayerBbox,
|
||||
resolveAreaId: areaIdForSelection,
|
||||
setSelectionBbox,
|
||||
onRunSelectionExtract: onRunMapSelectionExtract,
|
||||
onDeriveDataset: onDeriveMapSelectionDataset,
|
||||
onExportSelection: onExportMapSelection,
|
||||
onRunQa: onRunMapSelectionQa,
|
||||
})
|
||||
const {
|
||||
running: fullWorkflowRunning,
|
||||
status: fullWorkflowStatus,
|
||||
error: fullWorkflowError,
|
||||
mode: fullWorkflowMode,
|
||||
setMode: setFullWorkflowMode,
|
||||
run: runFullGisWorkflow,
|
||||
} = fullWorkflow
|
||||
|
||||
if (!advancedMode) {
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user