Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check if location exist before reroute #1141

Merged
merged 3 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions src/components/spatialdisplay/SpatialDisplay.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
:location-id="props.locationId"
:latitude="props.latitude"
:longitude="props.longitude"
:filter-ids="props.filterIds"
:locations="locations"
:geojson="geojson"
@changeLocationId="onLocationChange"
:layer-capabilities="layerCapabilities"
:times="times"
Expand Down Expand Up @@ -48,6 +49,7 @@ import circle from '@turf/circle'
import bbox from '@turf/bbox'
import { useUserSettingsStore } from '@/stores/userSettings'
import { UseDisplayConfigOptions } from '@/services/useDisplayConfig'
import { useFilterLocations } from '@/services/useFilterLocations'

interface Props {
layerName?: string
Expand All @@ -72,6 +74,10 @@ const { layerCapabilities, times } = useWmsLayerCapabilities(
baseUrl,
() => props.layerName,
)
const { locations, geojson } = useFilterLocations(
baseUrl,
() => props.filterIds,
)

const start = computed(() => {
if (!times.value || times.value.length === 0) return null
Expand Down Expand Up @@ -249,11 +255,23 @@ function closeTimeSeriesDisplay(): void {
}

watch(
() => props.layerName,
() => locations.value,
() => {
if (currentLocationId.value && !props.locationId) {
openLocationTimeSeriesDisplay(currentLocationId.value)
if (
locations.value?.find((l) => l.locationId === currentLocationId.value)
) {
openLocationTimeSeriesDisplay(currentLocationId.value)
} else {
currentLocationId.value = undefined
}
}
},
)

watch(
() => props.layerName,
() => {
if (
currentLatitude.value &&
currentLongitude.value &&
Expand Down
13 changes: 5 additions & 8 deletions src/components/spatialdisplay/SpatialDisplayComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,10 @@ import {
} from 'maplibre-gl'
import { configManager } from '@/services/application-config'
import type { Layer, Style } from '@deltares/fews-wms-requests'
import type { Location } from '@deltares/fews-pi-requests'
import { LayerKind } from '@/lib/streamlines'
import { useColourScalesStore } from '@/stores/colourScales'
import { useDisplay } from 'vuetify'
import { useFilterLocations } from '@/services/useFilterLocations'
import ColourLegend from '@/components/wms/ColourLegend.vue'
import {
getLegendTitle,
Expand All @@ -165,6 +165,7 @@ import { useWorkflowsStore } from '@/stores/workflows'
import { TimeSeriesData } from '@/lib/timeseries/types/SeriesData'
import CoordinateSelectorLayer from '@/components/wms/CoordinateSelectorLayer.vue'
import CoordinateSelectorControl from '@/components/map/CoordinateSelectorControl.vue'
import { FeatureCollection, Geometry } from 'geojson'

interface ElevationWithUnitSymbol {
units?: string
Expand All @@ -178,8 +179,9 @@ interface Props {
times?: Date[]
layerCapabilities?: Layer
elevation?: number
locations?: Location[]
geojson: FeatureCollection<Geometry, Location>
locationId?: string
filterIds?: string[]
latitude?: string
longitude?: string
currentTime?: Date
Expand Down Expand Up @@ -235,11 +237,6 @@ const workflowsStore = useWorkflowsStore()

const showLocationsLayer = ref<boolean>(true)

const { locations, geojson } = useFilterLocations(
baseUrl,
() => props.filterIds,
)

// Set the start and end time for the workflow based on the WMS layer capabilities.
watchEffect(() => {
workflowsStore.startTime = props.layerCapabilities?.firstValueTime ?? ''
Expand Down Expand Up @@ -327,7 +324,7 @@ const selectedCoordinate = computed(() => {
})

const hasLocations = computed(() => {
return locations.value?.length
return props.locations?.length
})

function onLocationClick(event: MapLayerMouseEvent | MapLayerTouchEvent): void {
Expand Down
Loading