diff --git a/src/api/layers/WMTSCapabilitiesParser.class.js b/src/api/layers/WMTSCapabilitiesParser.class.js index bef523213..6ee18769c 100644 --- a/src/api/layers/WMTSCapabilitiesParser.class.js +++ b/src/api/layers/WMTSCapabilitiesParser.class.js @@ -109,13 +109,29 @@ export default class WMTSCapabilitiesParser { * @param {CoordinateSystem} projection Projection currently used by the application * @param {number} opacity * @param {boolean} visible + * @param {Number | null} [currentYear=null] Current year to select for the time config. Only + * needed when a time config is present a year is pre-selected in the url parameter. Default + * is `null` * @param {boolean} ignoreError Don't throw exception in case of error, but return a default * value or null * @returns {[ExternalWMTSLayer]} List of ExternalWMTSLayer objects */ - getAllExternalLayerObjects(projection, opacity = 1, visible = true, ignoreError = true) { + getAllExternalLayerObjects( + projection, + opacity = 1, + visible = true, + currentYear = null, + ignoreError = true + ) { return this.Contents.Layer.map((layer) => - this._getExternalLayerObject(layer, projection, opacity, visible, ignoreError) + this._getExternalLayerObject( + layer, + projection, + opacity, + visible, + currentYear, + ignoreError + ) ).filter((layer) => !!layer) } @@ -384,6 +400,6 @@ export default class WMTSCapabilitiesParser { } const timeEntries = timeDimension.values?.map((value) => new LayerTimeConfigEntry(value)) ?? [] - return new LayerTimeConfig(null, timeEntries) + return new LayerTimeConfig(timeDimension.default ?? null, timeEntries) } } diff --git a/src/api/layers/__tests__/wmts-ogc-sample.xml b/src/api/layers/__tests__/wmts-ogc-sample.xml index d3769073c..c719491f7 100644 --- a/src/api/layers/__tests__/wmts-ogc-sample.xml +++ b/src/api/layers/__tests__/wmts-ogc-sample.xml @@ -6,8 +6,7 @@ xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://www.opengis.net/wmts/1.0 http://schemas.opengis.net/wmts/1.0.0/wmtsGetCapabilities_response.xsd" -> + xsi:schemaLocation="http://www.opengis.net/wmts/1.0 http://schemas.opengis.net/wmts/1.0/wmtsGetCapabilities_response.xsd"> Web Map Tile Service Service that constrains the map @@ -98,6 +97,12 @@ image/jpeg image/gif + + Time + 20110805 + 20110805 + 20081024 + BigWorldPixel @@ -117,21 +122,15 @@ resourceType="FeatureInfo" template="http://www.example.com/wmts/coastlines/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}/{J}/{I}.xml" /> - - Time - 20110805 - 20110805 - 20081024 - Blue Marble Second Generation - AG Blue Marble Second Generation Canton Aargau Product + BlueMarbleSecondGenerationAG 7.8 47.09 8.47 47.64 - BlueMarbleSecondGenerationAG image/jpeg image/gif + + Time + 20110805 + 20110805 + 20081024 + BigWorldPixel @@ -166,12 +171,6 @@ resourceType="FeatureInfo" template="http://www.example.com/wmts/coastlines/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}/{J}/{I}.xml" /> - - Time - 20110805 - 20110805 - 20081024 - BlueMarbleThirdGenerationZH @@ -195,6 +194,12 @@ image/jpeg image/gif + + Time + 2011-08-05 + 2011-08-05 + 2008-10-24 + BigWorldPixel @@ -208,12 +213,6 @@ resourceType="FeatureInfo" template="http://www.example.com/wmts/coastlines/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}/{J}/{I}.xml" /> - - Time - 2011-08-05 - 2011-08-05 - 2008-10-24 - Blue Marble Fourth Generation - JU @@ -234,6 +233,12 @@ image/jpeg image/gif + + Time + 2011-08-05T01:20:34.345Z + 2011-08-05T01:20:34.345Z + 2008-10-24T01:20:34.345Z + JURA @@ -247,16 +252,11 @@ resourceType="FeatureInfo" template="http://www.example.com/wmts/coastlines/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}/{J}/{I}.xml" /> - - Time - 2011-08-05T01:20:34.345Z - 2011-08-05T01:20:34.345Z - 2008-10-24T01:20:34.345Z - Blue Marble Fifth Generation - GE Blue Marble Fifth Generation Canton Geneva Product + BlueMarbleFifthGenerationGE 5.95 46.12 6.33 46.32 @@ -269,7 +269,6 @@ 2484928.06 1108705.32 2514614.27 1130449.26 - BlueMarbleFifthGenerationGE image/jpeg image/gif + + Time + Time A + Time A + Time B + BigWorldPixel @@ -304,12 +309,6 @@ resourceType="FeatureInfo" template="http://www.example.com/wmts/coastlines/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}/{J}/{I}.xml" /> - - Time - Time A - Time A - Time B - @@ -503,11 +502,11 @@ BigWorldPixel - urn:ogc:def:crs:OGC:1.3:CRS84 -180 -65 180 65 + urn:ogc:def:crs:OGC:1.3:CRS84 urn:ogc:def:wkss:OGC:1.0:GlobalCRS84Pixel 10000m @@ -588,11 +587,11 @@ JURA - urn:ogc:def:crs:OGC:1.3:CRS84 6.81 47.12 7.56 47.55 + urn:ogc:def:crs:OGC:1.3:CRS84 1e6 1e6 diff --git a/src/modules/menu/components/activeLayers/MenuActiveLayersListItemTimeSelector.vue b/src/modules/menu/components/activeLayers/MenuActiveLayersListItemTimeSelector.vue index f7ff113f2..50e8fdde5 100644 --- a/src/modules/menu/components/activeLayers/MenuActiveLayersListItemTimeSelector.vue +++ b/src/modules/menu/components/activeLayers/MenuActiveLayersListItemTimeSelector.vue @@ -39,7 +39,9 @@ const timeSelectorButton = ref(null) const timeSelectorModal = ref(null) const previewYear = computed(() => store.state.layers.previewYear) -const hasMultipleTimestamps = computed(() => timeConfig.value.timeEntries.length > 1) +const hasMultipleTimestamps = computed( + () => timeConfig.value.timeEntries.length > 1 && hasValidTimestamp.value +) const isTimeSliderActive = computed(() => store.state.ui.isTimeSliderActive) const isLayerVisible = computed(() => store.state.layers.activeLayers[layerIndex.value].visible) @@ -49,6 +51,9 @@ const humanReadableCurrentTimestamp = computed(() => { } return renderHumanReadableTimestamp(timeConfig.value.currentTimeEntry) }) +// Some external layers might have a time dimension with invalid timestamps, in this case we +// use the default timestamp as dimension and don't display the time selector. +const hasValidTimestamp = computed(() => !!timeConfig.value?.currentTimeEntry?.year) let popover = null @@ -62,6 +67,8 @@ onMounted(() => { interactive: true, arrow: true, trigger: 'click', + // Required by the cypres test to avoid CSS issues on cypress when testing the tippy content + appendTo: document.body, }) } }) @@ -84,6 +91,9 @@ function renderHumanReadableTimestamp(timeEntry) { if (timeEntry.year === YEAR_TO_DESCRIBE_ALL_OR_CURRENT_DATA) { return i18n.t('time_all') } + if (timeEntry.year === null) { + return timeEntry.timestamp + } return `${timeEntry.year}` } @@ -121,7 +131,7 @@ function baseYear(timeEntry) {