feat: complete governed Walloon coverage sources
This commit is contained in:
@@ -9,6 +9,7 @@ import { bathymetryRasterSelectionToMapSelection } from '../lib/bathymetryRaster
|
||||
|
||||
export type MapThemeAcquisitionKind =
|
||||
| 'thematic_raster'
|
||||
| 'walous'
|
||||
| 'dhmv'
|
||||
| 'flood_hazard'
|
||||
| 'grb'
|
||||
@@ -19,6 +20,7 @@ export interface MapThemeAcquisition {
|
||||
kind: MapThemeAcquisitionKind
|
||||
productKey: string
|
||||
displayName: string
|
||||
historyProductKeys?: string[]
|
||||
}
|
||||
|
||||
export interface MapThemeQuery<TThemeId extends string> {
|
||||
@@ -113,7 +115,7 @@ export function useMapThemeSelectionInsights<TThemeId extends string>(
|
||||
const resultLimit = featureLimit ?? 1000
|
||||
if (acquisition) {
|
||||
const requestedBboxes = acquisitionBboxes?.length ? acquisitionBboxes : [bbox]
|
||||
const acquisitionResults = await settleWithConcurrency(requestedBboxes, 1, async (acquisitionBbox) => {
|
||||
const acquireProduct = async (acquisitionBbox: VectorSelectionBBox, productKey: string) => {
|
||||
const commonPayload = {
|
||||
bbox: acquisitionBbox,
|
||||
area_id: areaId,
|
||||
@@ -124,6 +126,11 @@ export function useMapThemeSelectionInsights<TThemeId extends string>(
|
||||
...commonPayload,
|
||||
product_key: acquisition.productKey,
|
||||
})
|
||||
: acquisition.kind === 'walous'
|
||||
? await datasetsApi.acquireWalous(selectedProjectId, {
|
||||
...commonPayload,
|
||||
product_key: productKey,
|
||||
})
|
||||
: acquisition.kind === 'dhmv'
|
||||
? await datasetsApi.acquireDhmv(selectedProjectId, {
|
||||
...commonPayload,
|
||||
@@ -152,13 +159,38 @@ export function useMapThemeSelectionInsights<TThemeId extends string>(
|
||||
)
|
||||
}
|
||||
return datasetsApi.get(selectedProjectId, acquisitionJob.output_dataset_id)
|
||||
})
|
||||
}
|
||||
const acquisitionResults = await settleWithConcurrency(
|
||||
requestedBboxes,
|
||||
1,
|
||||
(acquisitionBbox) => acquireProduct(acquisitionBbox, acquisition.productKey),
|
||||
)
|
||||
const failedAcquisition = acquisitionResults.find((item) => item.status === 'rejected')
|
||||
if (failedAcquisition?.status === 'rejected') {
|
||||
throw failedAcquisition.reason
|
||||
}
|
||||
acquiredDatasets = acquisitionResults.flatMap((item) => item.status === 'fulfilled' ? [item.value] : [])
|
||||
dataset = acquiredDatasets[0]
|
||||
const historyProductKeys = acquisition.kind === 'walous'
|
||||
? [...new Set(acquisition.historyProductKeys ?? [])].filter((key) => key !== acquisition.productKey)
|
||||
: []
|
||||
if (historyProductKeys.length > 0) {
|
||||
const historyRequests = historyProductKeys.flatMap((productKey) =>
|
||||
requestedBboxes.map((acquisitionBbox) => ({ acquisitionBbox, productKey })),
|
||||
)
|
||||
const historyResults = await settleWithConcurrency(
|
||||
historyRequests,
|
||||
1,
|
||||
({ acquisitionBbox, productKey }) => acquireProduct(acquisitionBbox, productKey),
|
||||
)
|
||||
const failedHistory = historyResults.find((item) => item.status === 'rejected')
|
||||
if (failedHistory?.status === 'rejected') {
|
||||
throw failedHistory.reason
|
||||
}
|
||||
acquiredDatasets.push(
|
||||
...historyResults.flatMap((item) => item.status === 'fulfilled' ? [item.value] : []),
|
||||
)
|
||||
}
|
||||
}
|
||||
if (!dataset) {
|
||||
throw new Error(`Geen persistente databron beschikbaar voor thema ${themeId}.`)
|
||||
@@ -197,8 +229,13 @@ export function useMapThemeSelectionInsights<TThemeId extends string>(
|
||||
: dataset.dataset_type === 'raster' && dataset.source_name === 'department_omgeving_thematic_raster'
|
||||
? thematicRasterSelectionToMapSelection(await datasetsApi.selectThematicRaster(selectedProjectId, dataset.id, {
|
||||
bbox,
|
||||
area_id: areaId,
|
||||
}))
|
||||
area_id: areaId,
|
||||
}))
|
||||
: dataset.dataset_type === 'raster' && dataset.source_name === 'spw_walous_land_cover'
|
||||
? thematicRasterSelectionToMapSelection(await datasetsApi.selectWalous(selectedProjectId, dataset.id, {
|
||||
bbox,
|
||||
area_id: areaId,
|
||||
}))
|
||||
: dataset.dataset_type === 'raster' && dataset.source_name === 'spw_bathymetry'
|
||||
? bathymetryRasterSelectionToMapSelection(await datasetsApi.selectBathymetryRaster(selectedProjectId, dataset.id, {
|
||||
bbox,
|
||||
|
||||
@@ -14,6 +14,7 @@ import type {
|
||||
|
||||
export interface OfficialMapProducts {
|
||||
thematic: ThematicRasterProductRead[]
|
||||
walous: ThematicRasterProductRead[]
|
||||
dhmv: DhmvProductRead[]
|
||||
floodHazard: FloodHazardProductRead[]
|
||||
grb: GrbProductRead[]
|
||||
@@ -23,6 +24,7 @@ export interface OfficialMapProducts {
|
||||
|
||||
const EMPTY_PRODUCTS: OfficialMapProducts = {
|
||||
thematic: [],
|
||||
walous: [],
|
||||
dhmv: [],
|
||||
floodHazard: [],
|
||||
grb: [],
|
||||
@@ -50,16 +52,18 @@ export function useOfficialMapProducts(selectedProjectId: string | null) {
|
||||
setError(null)
|
||||
void Promise.all([
|
||||
datasetsApi.listThematicRasterProducts(selectedProjectId),
|
||||
datasetsApi.listWalousProducts(selectedProjectId),
|
||||
datasetsApi.listDhmvProducts(selectedProjectId),
|
||||
datasetsApi.listFloodHazardProducts(selectedProjectId),
|
||||
datasetsApi.listGrbProducts(selectedProjectId),
|
||||
datasetsApi.listOfficialVectorProducts(selectedProjectId),
|
||||
datasetsApi.listBathymetrySources(selectedProjectId),
|
||||
])
|
||||
.then(([thematic, dhmv, floodHazard, grb, officialVector, bathymetry]) => {
|
||||
.then(([thematic, walous, dhmv, floodHazard, grb, officialVector, bathymetry]) => {
|
||||
if (!cancelled) {
|
||||
setProducts({
|
||||
thematic: thematic.items,
|
||||
walous: walous.items,
|
||||
dhmv: dhmv.items,
|
||||
floodHazard: floodHazard.items,
|
||||
grb: grb.items,
|
||||
|
||||
Reference in New Issue
Block a user