fix(map): honor raster coverage and temporal dates
This commit is contained in:
@@ -21,6 +21,8 @@ import {
|
||||
bboxToInputState,
|
||||
bboxesEqual,
|
||||
copyText,
|
||||
datasetIntersectsSelection,
|
||||
deduplicateTemporalSnapshots,
|
||||
downloadJsonFile,
|
||||
formatArea,
|
||||
formatBboxLabel,
|
||||
@@ -571,13 +573,11 @@ function listThemeTemporalSeries(datasets: DatasetCreateResponse[], theme: DataT
|
||||
groups.set(dataset.temporal_series_key, items)
|
||||
}
|
||||
return Array.from(groups.entries())
|
||||
.filter(([, items]) => items.length >= 2)
|
||||
.map(([key, items]) => {
|
||||
const ordered = [...items].sort(
|
||||
(left, right) => new Date(left.observed_at ?? 0).getTime() - new Date(right.observed_at ?? 0).getTime(),
|
||||
)
|
||||
const ordered = deduplicateTemporalSnapshots(items)
|
||||
return { key, label: temporalSeriesLabel(ordered), items: ordered }
|
||||
})
|
||||
.filter((group) => group.items.length >= 2)
|
||||
.sort((left, right) => {
|
||||
if (right.items.length !== left.items.length) {
|
||||
return right.items.length - left.items.length
|
||||
@@ -1048,7 +1048,7 @@ export function MapWorkspace({
|
||||
productKey: product.key,
|
||||
displayName: product.display_name,
|
||||
theme: product.theme,
|
||||
availabilityLabel: `${product.native_resolution_m} m · ${product.observation_year} · laad bij selectie`,
|
||||
availabilityLabel: `${product.native_resolution_m} m · ${product.observation_year} · automatisch bij selectie`,
|
||||
attribution: product.attribution,
|
||||
limitationMessage: product.limitation_message,
|
||||
})
|
||||
@@ -1059,7 +1059,7 @@ export function MapWorkspace({
|
||||
productKey: product.key,
|
||||
displayName: product.display_name,
|
||||
theme: product.key,
|
||||
availabilityLabel: 'officiële vectorbron · laad bij selectie',
|
||||
availabilityLabel: 'officiële vectorbron · automatisch bij selectie',
|
||||
attribution: product.attribution,
|
||||
limitationMessage: product.limitation_message,
|
||||
})
|
||||
@@ -1075,7 +1075,7 @@ export function MapWorkspace({
|
||||
productKey: source.key,
|
||||
displayName: source.display_name,
|
||||
theme: 'bathymetry',
|
||||
availabilityLabel: 'historische profielpunten · laad bij selectie',
|
||||
availabilityLabel: 'historische profielpunten · automatisch bij selectie',
|
||||
attribution: source.attribution,
|
||||
limitationMessage: source.limitation_message,
|
||||
})
|
||||
@@ -1089,7 +1089,7 @@ export function MapWorkspace({
|
||||
productKey: product.key,
|
||||
displayName: product.display_name,
|
||||
theme: product.theme,
|
||||
availabilityLabel: `${product.observation_label} · officiële vectorbron · laad bij selectie`,
|
||||
availabilityLabel: `${product.observation_label} · officiële vectorbron · automatisch bij selectie`,
|
||||
attribution: product.attribution,
|
||||
limitationMessage: product.limitation_message,
|
||||
})
|
||||
@@ -1103,7 +1103,7 @@ export function MapWorkspace({
|
||||
productKey: dhmvProduct.key,
|
||||
displayName: dhmvProduct.display_name,
|
||||
theme: 'elevation',
|
||||
availabilityLabel: `${dhmvProduct.native_resolution_m} m · ${dhmvProduct.acquisition_period} · laad bij selectie`,
|
||||
availabilityLabel: `${dhmvProduct.native_resolution_m} m · ${dhmvProduct.acquisition_period} · automatisch bij selectie`,
|
||||
attribution: dhmvProduct.attribution,
|
||||
limitationMessage: dhmvProduct.limitation_message,
|
||||
})
|
||||
@@ -1119,7 +1119,7 @@ export function MapWorkspace({
|
||||
productKey: floodProduct.key,
|
||||
displayName: floodProduct.display_name,
|
||||
theme: 'flood_hazard',
|
||||
availabilityLabel: `${floodProduct.native_resolution_m} m · ${floodProduct.climate_context} · T${floodProduct.return_period_years} · laad bij selectie`,
|
||||
availabilityLabel: `${floodProduct.native_resolution_m} m · ${floodProduct.climate_context} · T${floodProduct.return_period_years} · automatisch bij selectie`,
|
||||
attribution: floodProduct.attribution,
|
||||
limitationMessage: floodProduct.limitation_message,
|
||||
})
|
||||
@@ -1329,6 +1329,19 @@ export function MapWorkspace({
|
||||
const activeTemporalSeriesGroup = activeTemporalSeriesGroups.find((group) => group.key === selectedTemporalSeriesKey)
|
||||
?? activeTemporalSeriesGroups[0]
|
||||
const activeTemporalSeries = activeTemporalSeriesGroup?.items ?? EMPTY_TEMPORAL_SERIES
|
||||
const earlierTemporalOptions = activeTemporalSeries.slice(0, -1)
|
||||
const selectedEarlierSnapshot = activeTemporalSeries.find((dataset) => dataset.id === earlierDatasetId)
|
||||
const selectedLaterSnapshot = activeTemporalSeries.find((dataset) => dataset.id === laterDatasetId)
|
||||
const selectedEarlierTime = new Date(selectedEarlierSnapshot?.observed_at ?? 0).getTime()
|
||||
const laterTemporalOptions = activeTemporalSeries.filter(
|
||||
(dataset) => new Date(dataset.observed_at ?? 0).getTime() > selectedEarlierTime,
|
||||
)
|
||||
const temporalSelectionValid = Boolean(
|
||||
selectedEarlierSnapshot
|
||||
&& selectedLaterSnapshot
|
||||
&& selectedEarlierSnapshot.id !== selectedLaterSnapshot.id
|
||||
&& selectedEarlierTime < new Date(selectedLaterSnapshot.observed_at ?? 0).getTime(),
|
||||
)
|
||||
const activeSeriesIsDailyGrb = activeTemporalSeries.length >= 2
|
||||
&& activeTemporalSeries.every((dataset) => dataset.source_name === 'grb')
|
||||
&& new Date(activeTemporalSeries[activeTemporalSeries.length - 1].observed_at ?? 0).getTime()
|
||||
@@ -1378,7 +1391,7 @@ export function MapWorkspace({
|
||||
activeSelectionResult.total_feature_count
|
||||
?? activeSelectionResult.feature_count
|
||||
).toLocaleString('nl-BE')} objecten gemeten`
|
||||
: 'Op aanvraag'
|
||||
: 'Automatisch bij selectie'
|
||||
: null
|
||||
onSetContextLayerLabel(contextLayerLabel)
|
||||
return () => onSetContextLayerLabel(null)
|
||||
@@ -1841,13 +1854,26 @@ export function MapWorkspace({
|
||||
const resultFeatureLimit = selectionFeatureLimit(bbox)
|
||||
for (const theme of DATA_THEMES) {
|
||||
const dataset = themeDatasetMap[theme.id]
|
||||
if (dataset && persistedDatasetSupportsSelection(dataset, bbox)) {
|
||||
const partitioned = Boolean(
|
||||
dataset
|
||||
&& regionalScopeSelected
|
||||
&& (isPartitionedRaster(dataset) || isPartitionedBathymetry(dataset)),
|
||||
)
|
||||
const coveringPartitions = partitioned
|
||||
? themePartitionMap[theme.id].filter((partition) => datasetIntersectsSelection(partition, bbox))
|
||||
: []
|
||||
const persistedCoverageAvailable = Boolean(
|
||||
dataset
|
||||
&& persistedDatasetSupportsSelection(dataset, bbox)
|
||||
&& (!partitioned || coveringPartitions.length > 0),
|
||||
)
|
||||
if (dataset && persistedCoverageAvailable) {
|
||||
availableThemes.push({
|
||||
themeId: theme.id,
|
||||
dataset,
|
||||
datasetIds: coveringPartitions.map((partition) => partition.id),
|
||||
featureLimit: resultFeatureLimit,
|
||||
partitioned: regionalScopeSelected
|
||||
&& (isPartitionedRaster(dataset) || isPartitionedBathymetry(dataset)),
|
||||
partitioned,
|
||||
})
|
||||
continue
|
||||
}
|
||||
@@ -1877,16 +1903,20 @@ export function MapWorkspace({
|
||||
const startedAt = Date.now()
|
||||
setMapAnalysisDurationMs(null)
|
||||
setSelectionBbox(bbox)
|
||||
const tasks: Array<Promise<unknown>> = [loadAllThemeResults(bbox, areaId)]
|
||||
const tasks: Array<Promise<unknown>> = analysisMode === 'current'
|
||||
? [loadAllThemeResults(bbox, areaId)]
|
||||
: []
|
||||
const activeDatasetSupportsSelection = !activeThemeDataset
|
||||
|| persistedDatasetSupportsSelection(activeThemeDataset, bbox)
|
||||
if (
|
||||
activeThemeAvailable && !regionalPartitionedThemeActive && !onDemandThemeActive
|
||||
analysisMode === 'current'
|
||||
&& advancedMode
|
||||
&& activeThemeAvailable && !regionalPartitionedThemeActive && !onDemandThemeActive
|
||||
&& activeDatasetSupportsSelection
|
||||
) {
|
||||
tasks.push(onRunMapSelectionExtract(bbox, areaId))
|
||||
}
|
||||
if (analysisMode === 'evolution' && earlierDatasetId && laterDatasetId) {
|
||||
if (analysisMode === 'evolution' && temporalSelectionValid) {
|
||||
tasks.push(compareTemporalSnapshots(earlierDatasetId, laterDatasetId, bbox, areaId))
|
||||
}
|
||||
try {
|
||||
@@ -1899,7 +1929,7 @@ export function MapWorkspace({
|
||||
}
|
||||
|
||||
const runTemporalComparison = () => {
|
||||
if (!mapSelectionBbox || !earlierDatasetId || !laterDatasetId) {
|
||||
if (!mapSelectionBbox || !temporalSelectionValid) {
|
||||
return
|
||||
}
|
||||
void compareTemporalSnapshots(
|
||||
@@ -2127,7 +2157,7 @@ export function MapWorkspace({
|
||||
? 'Alleen huidige toestand'
|
||||
: 'Bron nog niet ingeladen'
|
||||
: dataset
|
||||
? datasetAvailabilityLabel(dataset, partitions)
|
||||
? `${datasetAvailabilityLabel(dataset, partitions)}${onDemandProduct ? ' · zo nodig automatisch aangevuld' : ''}`
|
||||
: onDemandProduct
|
||||
? onDemandProduct.availabilityLabel
|
||||
: 'Bron nog niet ingeladen'}
|
||||
@@ -2138,7 +2168,7 @@ export function MapWorkspace({
|
||||
? 'Laden'
|
||||
: analysisMode === 'evolution'
|
||||
? evolutionAvailable ? 'Tijdreeks' : dataset ? 'Alleen huidig' : 'Ontbreekt'
|
||||
: dataset ? 'Beschikbaar' : onDemandProduct ? 'Op aanvraag' : 'Ontbreekt'}
|
||||
: dataset ? 'Beschikbaar' : onDemandProduct ? 'Automatisch' : 'Ontbreekt'}
|
||||
</i>
|
||||
</button>
|
||||
)
|
||||
@@ -2172,7 +2202,7 @@ export function MapWorkspace({
|
||||
: regionalBathymetryThemeActive
|
||||
? `${activeThemePartitions.length} gecontroleerde gemeentepartities · selectie wordt ruimtelijk samengevoegd`
|
||||
: activeThemeDataset
|
||||
? `${getDatasetSourceDisplayName(activeThemeDataset)} · ${formatDatasetObservation(activeThemeDataset)}`
|
||||
? `${getDatasetSourceDisplayName(activeThemeDataset)} · ${formatDatasetObservation(activeThemeDataset)}${onDemandProductMap.get(activeTheme.id) ? ' · ontbrekende lokale dekking wordt automatisch aangevuld' : ''}`
|
||||
: activeOnDemandMapProduct
|
||||
? `${activeOnDemandMapProduct.attribution} · wordt alleen voor de gekozen selectie ingeladen`
|
||||
: activeTheme.description}
|
||||
@@ -2286,16 +2316,32 @@ export function MapWorkspace({
|
||||
) : null}
|
||||
<label>
|
||||
Van
|
||||
<select value={earlierDatasetId} onChange={(event) => { setEarlierDatasetId(event.target.value); clearTemporalComparison() }} disabled={activeTemporalSeries.length < 2}>
|
||||
{activeTemporalSeries.map((dataset) => (
|
||||
<select
|
||||
value={earlierDatasetId}
|
||||
onChange={(event) => {
|
||||
const nextEarlierId = event.target.value
|
||||
const nextEarlier = activeTemporalSeries.find((dataset) => dataset.id === nextEarlierId)
|
||||
setEarlierDatasetId(nextEarlierId)
|
||||
if (
|
||||
nextEarlier
|
||||
&& new Date(selectedLaterSnapshot?.observed_at ?? 0).getTime()
|
||||
<= new Date(nextEarlier.observed_at ?? 0).getTime()
|
||||
) {
|
||||
setLaterDatasetId(activeTemporalSeries[activeTemporalSeries.length - 1]?.id ?? '')
|
||||
}
|
||||
clearTemporalComparison()
|
||||
}}
|
||||
disabled={earlierTemporalOptions.length === 0}
|
||||
>
|
||||
{earlierTemporalOptions.map((dataset) => (
|
||||
<option key={dataset.id} value={dataset.id}>{formatObservationDate(dataset.observed_at)}</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<label>
|
||||
Naar
|
||||
<select value={laterDatasetId} onChange={(event) => { setLaterDatasetId(event.target.value); clearTemporalComparison() }} disabled={activeTemporalSeries.length < 2}>
|
||||
{activeTemporalSeries.map((dataset) => (
|
||||
<select value={laterDatasetId} onChange={(event) => { setLaterDatasetId(event.target.value); clearTemporalComparison() }} disabled={laterTemporalOptions.length === 0}>
|
||||
{laterTemporalOptions.map((dataset) => (
|
||||
<option key={dataset.id} value={dataset.id}>{formatObservationDate(dataset.observed_at)}</option>
|
||||
))}
|
||||
</select>
|
||||
@@ -2303,7 +2349,7 @@ export function MapWorkspace({
|
||||
<button
|
||||
className="primary-action"
|
||||
type="button"
|
||||
disabled={!mapSelectionBbox || !earlierDatasetId || !laterDatasetId || temporalComparisonLoading}
|
||||
disabled={!mapSelectionBbox || !temporalSelectionValid || temporalComparisonLoading}
|
||||
onClick={runTemporalComparison}
|
||||
>
|
||||
{temporalComparisonLoading ? 'Vergelijken…' : 'Vergelijk periode'}
|
||||
|
||||
Reference in New Issue
Block a user