feat(scope): make Belgium and North Sea operational default
This commit is contained in:
@@ -54,7 +54,7 @@ function formatOrthophotoError(caught: unknown): string {
|
||||
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.'
|
||||
return 'Teken de rechthoek binnen het ingeladen Belgische land- of zeegebied.'
|
||||
}
|
||||
if (code === 'ORTHOPHOTO_PROVIDER_UNAVAILABLE' || code === 'ORTHOPHOTO_PROVIDER_INVALID_RESPONSE') {
|
||||
return 'De officiële luchtbeeldbron is tijdelijk niet bereikbaar. Probeer later opnieuw.'
|
||||
|
||||
@@ -1,14 +1,8 @@
|
||||
import { FormEvent, useMemo, useRef, useState } from 'react'
|
||||
import {
|
||||
PRIMARY_FOCUS_AREA_GEOJSON,
|
||||
PRIMARY_FOCUS_AREA_NAME,
|
||||
PRIMARY_FOCUS_REGION,
|
||||
NATIONAL_WORKSPACE_PROJECT_NAME,
|
||||
NATIONAL_WORKSPACE_REGION,
|
||||
REGIONAL_WORKSPACE_PROJECT_NAME,
|
||||
isPrimaryFocusMunicipalityBoundaryDataset,
|
||||
isPrimaryFocusMunicipalityProject,
|
||||
isPrimaryFocusProject,
|
||||
isPrimaryFocusProjectData,
|
||||
} from '../config/primaryFocus'
|
||||
import { areasApi } from '../services/api/areas'
|
||||
import { datasetsApi } from '../services/api/datasets'
|
||||
@@ -54,11 +48,11 @@ export function useProjectWorkspace() {
|
||||
const [projectForm, setProjectForm] = useState<ProjectCreate>({
|
||||
name: '',
|
||||
description: '',
|
||||
region: PRIMARY_FOCUS_REGION,
|
||||
region: NATIONAL_WORKSPACE_REGION,
|
||||
})
|
||||
const [areaForm, setAreaForm] = useState({
|
||||
name: PRIMARY_FOCUS_AREA_NAME,
|
||||
geometry: PRIMARY_FOCUS_AREA_GEOJSON,
|
||||
name: '',
|
||||
geometry: '',
|
||||
crs: 'EPSG:4326',
|
||||
})
|
||||
|
||||
@@ -84,14 +78,7 @@ export function useProjectWorkspace() {
|
||||
}
|
||||
const nationalProject = items.find((project) => project.name === NATIONAL_WORKSPACE_PROJECT_NAME)
|
||||
if (nationalProject) {
|
||||
try {
|
||||
const data = await fetchProjectData(nationalProject.id)
|
||||
if (data.areas.length > 0 && data.datasets.some((dataset) => dataset.status === 'ready')) {
|
||||
return nationalProject.id
|
||||
}
|
||||
} catch {
|
||||
// Continue with regional and municipality fallbacks while national data is unavailable.
|
||||
}
|
||||
return nationalProject.id
|
||||
}
|
||||
const regionalProject = items.find((project) => project.name === REGIONAL_WORKSPACE_PROJECT_NAME)
|
||||
if (regionalProject) {
|
||||
@@ -104,22 +91,10 @@ export function useProjectWorkspace() {
|
||||
// Continue with the municipality and completeness fallbacks when regional data is unavailable.
|
||||
}
|
||||
}
|
||||
const municipalityProject = items.find(isPrimaryFocusMunicipalityProject)
|
||||
if (municipalityProject) {
|
||||
try {
|
||||
const data = await fetchProjectData(municipalityProject.id)
|
||||
if (data.areas.length > 0 && data.datasets.some(isPrimaryFocusMunicipalityBoundaryDataset)) {
|
||||
return municipalityProject.id
|
||||
}
|
||||
} catch {
|
||||
// Continue with the normal completeness ranking if the canonical workspace is temporarily unavailable.
|
||||
}
|
||||
}
|
||||
const primaryProjects = items.filter(isPrimaryFocusProject)
|
||||
const demoProjects = items.filter(isDemoProject)
|
||||
const candidates = Array.from(
|
||||
new Map(
|
||||
[...primaryProjects, ...demoProjects, ...items].map((project) => [project.id, project]),
|
||||
[...items, ...demoProjects].map((project) => [project.id, project]),
|
||||
).values(),
|
||||
).slice(0, 12)
|
||||
const inspectedCandidates: Array<{
|
||||
@@ -130,27 +105,17 @@ export function useProjectWorkspace() {
|
||||
try {
|
||||
const data = await fetchProjectData(project.id)
|
||||
inspectedCandidates.push({ project, data })
|
||||
if (
|
||||
isPrimaryFocusProjectData(project, data.datasets) &&
|
||||
hasMappedAnalysisContext(data)
|
||||
) {
|
||||
if (hasMappedAnalysisContext(data)) {
|
||||
return project.id
|
||||
}
|
||||
} catch {
|
||||
// Project list should still render if a candidate's detail endpoints are temporarily unavailable.
|
||||
}
|
||||
}
|
||||
const primaryContext = inspectedCandidates.find(
|
||||
({ project, data }) =>
|
||||
data.datasets.length > 0 && isPrimaryFocusProjectData(project, data.datasets),
|
||||
)
|
||||
if (primaryContext) {
|
||||
return primaryContext.project.id
|
||||
}
|
||||
const completeContext = inspectedCandidates.find(
|
||||
({ data }) => data.areas.length > 0 && data.datasets.length > 0,
|
||||
)
|
||||
return completeContext?.project.id ?? primaryProjects[0]?.id ?? demoProjects[0]?.id ?? items[0]?.id ?? null
|
||||
return completeContext?.project.id ?? demoProjects[0]?.id ?? items[0]?.id ?? null
|
||||
}
|
||||
|
||||
const loadProjects = async (preferredProjectId?: string | null) => {
|
||||
@@ -216,7 +181,7 @@ export function useProjectWorkspace() {
|
||||
const createdProject = await projectsApi.create({
|
||||
name: projectForm.name.trim(),
|
||||
description: projectForm.description?.trim() || undefined,
|
||||
region: projectForm.region?.trim() || PRIMARY_FOCUS_REGION,
|
||||
region: projectForm.region?.trim() || NATIONAL_WORKSPACE_REGION,
|
||||
})
|
||||
setProjectForm((previous) => ({ ...previous, name: '', description: '' }))
|
||||
setSelectedProjectId(createdProject.id)
|
||||
|
||||
@@ -59,8 +59,17 @@ export function useSegmentationWorkflow({
|
||||
try {
|
||||
const response = await segmentationApi.listModels()
|
||||
setSegmentationModels(response.models)
|
||||
if (!response.models.some((model) => model.model_id === selectedSegmentationModelId) && response.models.length > 0) {
|
||||
setSelectedSegmentationModelId(response.models[0].model_id)
|
||||
const selectionStillAvailable = response.models.some((model) => model.model_id === selectedSegmentationModelId)
|
||||
const selectionConfigured = response.models.some(
|
||||
(model) => model.model_id === selectedSegmentationModelId && model.configured,
|
||||
)
|
||||
if ((!selectionStillAvailable || !selectionConfigured) && response.models.length > 0) {
|
||||
const configuredModel = response.models.find(
|
||||
(model) => model.configured && model.model_id !== 'fixture-segmenter',
|
||||
)
|
||||
setSelectedSegmentationModelId(
|
||||
configuredModel?.model_id ?? (selectionStillAvailable ? selectedSegmentationModelId : response.models[0].model_id),
|
||||
)
|
||||
}
|
||||
} catch (error) {
|
||||
setSegmentationModelError(formatError(error, 'Failed to load segmentation models'))
|
||||
|
||||
Reference in New Issue
Block a user