fix: scope map image analysis to Kempen
GeoIntel CI / docs-smoke (push) Canceled after 0s
GeoIntel CI / contract-smoke (push) Canceled after 0s

This commit is contained in:
Codex
2026-07-15 02:08:24 +02:00
parent daccd3869a
commit ec1e1af8a9
3 changed files with 36 additions and 3 deletions
+2 -1
View File
@@ -472,7 +472,8 @@ function App(): JSX.Element {
})
const mapOrthophotoAnalysis = useMapOrthophotoAnalysis({
selectedProjectId,
selectedAreaId: selectedMapAreaId,
selectedAreaId: areas.find((area) => /vervoerregio|operationele grens/i.test(area.name))?.id ?? selectedMapAreaId,
selectionBbox: mapSelectionBbox,
datasets,
loadProjectData,
prepareAndRunDetection: (datasetId) => prepareAndRunDetection(datasetId, 'yolo-configured'),
+31 -2
View File
@@ -1,4 +1,4 @@
import { useState } from 'react'
import { useEffect, useState } from 'react'
import { datasetsApi } from '../services/api'
import type {
DatasetCreateResponse,
@@ -20,6 +20,7 @@ export type MapOrthophotoAnalysisStage =
interface MapOrthophotoAnalysisOptions {
selectedProjectId: string | null
selectedAreaId: string
selectionBbox: VectorSelectionBBox | null
datasets: DatasetCreateResponse[]
loadProjectData: (projectId: string) => Promise<unknown>
prepareAndRunDetection: (datasetId?: string) => Promise<DetectionRunResponse | null>
@@ -40,9 +41,30 @@ function findBuildingReference(datasets: DatasetCreateResponse[]): DatasetCreate
) ?? null
}
function formatOrthophotoError(caught: unknown): string {
const code = caught instanceof Error ? (caught as Error & { code?: string }).code : undefined
if (code === 'ORTHOPHOTO_SELECTION_TOO_SMALL') {
return 'Maak de rechthoek minstens 128 bij 128 meter groot.'
}
if (code === 'ORTHOPHOTO_SELECTION_TOO_LARGE') {
return 'Maak de rechthoek maximaal 1.024 bij 1.024 meter groot.'
}
if (code === 'ORTHOPHOTO_SELECTION_OUTSIDE_AREA') {
return 'Teken de rechthoek binnen de ingeladen regio Kempen.'
}
if (code === 'ORTHOPHOTO_PROVIDER_UNAVAILABLE' || code === 'ORTHOPHOTO_PROVIDER_INVALID_RESPONSE') {
return 'De officiële luchtbeeldbron is tijdelijk niet bereikbaar. Probeer later opnieuw.'
}
if (code === 'ORTHOPHOTO_NOT_CONFIGURED') {
return 'Luchtbeelden ophalen is uitgeschakeld door de beheerder.'
}
return formatError(caught, 'De kaartgestuurde beeldanalyse is mislukt')
}
export function useMapOrthophotoAnalysis({
selectedProjectId,
selectedAreaId,
selectionBbox,
datasets,
loadProjectData,
prepareAndRunDetection,
@@ -54,6 +76,13 @@ export function useMapOrthophotoAnalysis({
const [error, setError] = useState<string | null>(null)
const [lastResult, setLastResult] = useState<OrthophotoAcquisitionResult | null>(null)
useEffect(() => {
setStage('idle')
setStatus('')
setError(null)
setLastResult(null)
}, [selectionBbox?.min_x, selectionBbox?.min_y, selectionBbox?.max_x, selectionBbox?.max_y])
const run = async (bbox: VectorSelectionBBox): Promise<boolean> => {
if (!selectedProjectId) {
setError('De regionale werkruimte is nog niet geladen.')
@@ -103,7 +132,7 @@ export function useMapOrthophotoAnalysis({
onAnalysisReady()
return true
} catch (caught) {
setError(formatError(caught, 'De kaartgestuurde beeldanalyse is mislukt'))
setError(formatOrthophotoError(caught))
setStatus('Analyse gestopt.')
setStage('failed')
return false