Skip to content

Commit

Permalink
PB-496: Added e2e tests for external layer with time dimension and bu…
Browse files Browse the repository at this point in the history
…g fix
  • Loading branch information
ltshb committed May 16, 2024
1 parent b86430d commit de13e67
Show file tree
Hide file tree
Showing 5 changed files with 140 additions and 49 deletions.
22 changes: 19 additions & 3 deletions src/api/layers/WMTSCapabilitiesParser.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -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)
}
}
71 changes: 35 additions & 36 deletions src/api/layers/__tests__/wmts-ogc-sample.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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">
<ows:ServiceIdentification>
<ows:Title>Web Map Tile Service</ows:Title>
<ows:Abstract>Service that constrains the map
Expand Down Expand Up @@ -98,6 +97,12 @@
</Style>
<Format>image/jpeg</Format>
<Format>image/gif</Format>
<Dimension>
<ows:Identifier>Time</ows:Identifier>
<Default>20110805</Default>
<Value>20110805</Value>
<Value>20081024</Value>
</Dimension>
<TileMatrixSetLink>
<TileMatrixSet>BigWorldPixel</TileMatrixSet>
</TileMatrixSetLink>
Expand All @@ -117,21 +122,15 @@
resourceType="FeatureInfo"
template="http://www.example.com/wmts/coastlines/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}/{J}/{I}.xml"
/>
<Dimension>
<ows:Identifier>Time</ows:Identifier>
<Default>20110805</Default>
<Value>20110805</Value>
<Value>20081024</Value>
</Dimension>
</Layer>
<Layer>
<ows:Title>Blue Marble Second Generation - AG</ows:Title>
<ows:Abstract>Blue Marble Second Generation Canton Aargau Product</ows:Abstract>
<ows:Identifier>BlueMarbleSecondGenerationAG</ows:Identifier>
<ows:BoundingBox crs="urn:ogc:def:crs:CRS::84">
<ows:LowerCorner>7.8 47.09</ows:LowerCorner>
<ows:UpperCorner>8.47 47.64</ows:UpperCorner>
</ows:BoundingBox>
<ows:Identifier>BlueMarbleSecondGenerationAG</ows:Identifier>
<Style isDefault="true">
<ows:Title>Dark Blue</ows:Title>
<ows:Identifier>DarkBlue</ows:Identifier>
Expand All @@ -147,6 +146,12 @@
</Style>
<Format>image/jpeg</Format>
<Format>image/gif</Format>
<Dimension>
<ows:Identifier>Time</ows:Identifier>
<Default>20110805</Default>
<Value>20110805</Value>
<Value>20081024</Value>
</Dimension>
<TileMatrixSetLink>
<TileMatrixSet>BigWorldPixel</TileMatrixSet>
</TileMatrixSetLink>
Expand All @@ -166,12 +171,6 @@
resourceType="FeatureInfo"
template="http://www.example.com/wmts/coastlines/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}/{J}/{I}.xml"
/>
<Dimension>
<ows:Identifier>Time</ows:Identifier>
<Default>20110805</Default>
<Value>20110805</Value>
<Value>20081024</Value>
</Dimension>
</Layer>
<Layer>
<ows:Title>BlueMarbleThirdGenerationZH</ows:Title>
Expand All @@ -195,6 +194,12 @@
</Style>
<Format>image/jpeg</Format>
<Format>image/gif</Format>
<Dimension>
<ows:Identifier>Time</ows:Identifier>
<Default>2011-08-05</Default>
<Value>2011-08-05</Value>
<Value>2008-10-24</Value>
</Dimension>
<TileMatrixSetLink>
<TileMatrixSet>BigWorldPixel</TileMatrixSet>
</TileMatrixSetLink>
Expand All @@ -208,12 +213,6 @@
resourceType="FeatureInfo"
template="http://www.example.com/wmts/coastlines/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}/{J}/{I}.xml"
/>
<Dimension>
<ows:Identifier>Time</ows:Identifier>
<Default>2011-08-05</Default>
<Value>2011-08-05</Value>
<Value>2008-10-24</Value>
</Dimension>
</Layer>
<Layer>
<ows:Title>Blue Marble Fourth Generation - JU</ows:Title>
Expand All @@ -234,6 +233,12 @@
</Style>
<Format>image/jpeg</Format>
<Format>image/gif</Format>
<Dimension>
<ows:Identifier>Time</ows:Identifier>
<Default>2011-08-05T01:20:34.345Z</Default>
<Value>2011-08-05T01:20:34.345Z</Value>
<Value>2008-10-24T01:20:34.345Z</Value>
</Dimension>
<TileMatrixSetLink>
<TileMatrixSet>JURA</TileMatrixSet>
</TileMatrixSetLink>
Expand All @@ -247,16 +252,11 @@
resourceType="FeatureInfo"
template="http://www.example.com/wmts/coastlines/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}/{J}/{I}.xml"
/>
<Dimension>
<ows:Identifier>Time</ows:Identifier>
<Default>2011-08-05T01:20:34.345Z</Default>
<Value>2011-08-05T01:20:34.345Z</Value>
<Value>2008-10-24T01:20:34.345Z</Value>
</Dimension>
</Layer>
<Layer>
<ows:Title>Blue Marble Fifth Generation - GE</ows:Title>
<ows:Abstract>Blue Marble Fifth Generation Canton Geneva Product</ows:Abstract>
<ows:Identifier>BlueMarbleFifthGenerationGE</ows:Identifier>
<ows:BoundingBox crs="urn:ogc:def:crs:CRS::84">
<ows:LowerCorner>5.95 46.12</ows:LowerCorner>
<ows:UpperCorner>6.33 46.32</ows:UpperCorner>
Expand All @@ -269,7 +269,6 @@
<ows:LowerCorner>2484928.06 1108705.32</ows:LowerCorner>
<ows:UpperCorner>2514614.27 1130449.26</ows:UpperCorner>
</ows:BoundingBox>
<ows:Identifier>BlueMarbleFifthGenerationGE</ows:Identifier>
<Style isDefault="true">
<ows:Title>Dark Blue</ows:Title>
<ows:Identifier>DarkBlue</ows:Identifier>
Expand All @@ -285,6 +284,12 @@
</Style>
<Format>image/jpeg</Format>
<Format>image/gif</Format>
<Dimension>
<ows:Identifier>Time</ows:Identifier>
<Default>Time A</Default>
<Value>Time A</Value>
<Value>Time B</Value>
</Dimension>
<TileMatrixSetLink>
<TileMatrixSet>BigWorldPixel</TileMatrixSet>
</TileMatrixSetLink>
Expand All @@ -304,12 +309,6 @@
resourceType="FeatureInfo"
template="http://www.example.com/wmts/coastlines/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}/{J}/{I}.xml"
/>
<Dimension>
<ows:Identifier>Time</ows:Identifier>
<Default>Time A</Default>
<Value>Time A</Value>
<Value>Time B</Value>
</Dimension>
</Layer>
<TileMatrixSet>
<!-- -180 85.05112878 -->
Expand Down Expand Up @@ -503,11 +502,11 @@
</TileMatrixSet>
<TileMatrixSet>
<ows:Identifier>BigWorldPixel</ows:Identifier>
<ows:SupportedCRS>urn:ogc:def:crs:OGC:1.3:CRS84</ows:SupportedCRS>
<ows:BoundingBox>
<ows:LowerCorner>-180 -65</ows:LowerCorner>
<ows:UpperCorner>180 65</ows:UpperCorner>
</ows:BoundingBox>
<ows:SupportedCRS>urn:ogc:def:crs:OGC:1.3:CRS84</ows:SupportedCRS>
<WellKnownScaleSet>urn:ogc:def:wkss:OGC:1.0:GlobalCRS84Pixel</WellKnownScaleSet>
<TileMatrix>
<ows:Identifier>10000m</ows:Identifier>
Expand Down Expand Up @@ -588,11 +587,11 @@
</TileMatrixSet>
<TileMatrixSet>
<ows:Identifier>JURA</ows:Identifier>
<ows:SupportedCRS>urn:ogc:def:crs:OGC:1.3:CRS84</ows:SupportedCRS>
<ows:BoundingBox>
<ows:LowerCorner>6.81 47.12</ows:LowerCorner>
<ows:UpperCorner>7.56 47.55</ows:UpperCorner>
</ows:BoundingBox>
<ows:SupportedCRS>urn:ogc:def:crs:OGC:1.3:CRS84</ows:SupportedCRS>
<TileMatrix>
<ows:Identifier>1e6</ows:Identifier>
<ScaleDenominator>1e6</ScaleDenominator>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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,
})
}
})
Expand All @@ -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}`
}
Expand Down Expand Up @@ -121,7 +131,7 @@ function baseYear(timeEntry) {
<button
v-if="hasMultipleTimestamps"
ref="timeSelectorButton"
class="btn btn-secondary me-2"
class="btn btn-secondary me-2 btn-timestamp"
:class="{
'btn-sm': compact,
'w-13': compact,
Expand All @@ -146,7 +156,7 @@ function baseYear(timeEntry) {
<button
v-for="timeEntry in timeConfig.timeEntries"
:key="timeEntry.timestamp"
class="btn mb-1 me-1"
class="btn mb-1 me-1 btn-timestamp"
:class="{
'btn-primary': isSelected(timeEntry),
'btn-outline-primary': baseYear(timeEntry),
Expand All @@ -168,9 +178,8 @@ function baseYear(timeEntry) {
overflow-y: auto;
background: white;
grid-template-columns: 1fr 1fr 1fr;
.btn-timestamp {
white-space: nowrap;
}
}
.btn-timestamp {
white-space: nowrap;
}
</style>
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<Capabilities xmlns="http://www.opengis.net/wmts/1.0"
<Capabilities
version="1.0.0"
xmlns="http://www.opengis.net/wmts/1.0"
xmlns:gml="http://www.opengis.net/gml"
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/wmtsGetCapabilities_response.xsd"
version="1.0.0">
xsi:schemaLocation="http://www.opengis.net/wmts/1.0 http://schemas.opengis.net/wmts/1.0/wmtsGetCapabilities_response.xsd">

<!-- Service Identification -->
<ows:ServiceIdentification>
Expand Down Expand Up @@ -104,6 +106,12 @@
<ows:Identifier>default</ows:Identifier>
</Style>
<Format>image/png</Format>
<Dimension>
<ows:Identifier>Time</ows:Identifier>
<Default>20081024</Default>
<Value>20110805</Value>
<Value>20081024</Value>
</Dimension>
<TileMatrixSetLink>
<TileMatrixSet>EPSG:4326</TileMatrixSet>
</TileMatrixSetLink>
Expand All @@ -123,6 +131,12 @@
<ows:Identifier>default</ows:Identifier>
</Style>
<Format>image/png</Format>
<Dimension>
<ows:Identifier>Time</ows:Identifier>
<Default>2011-08-05T01:20:34.345Z</Default>
<Value>2011-08-05T01:20:34.345Z</Value>
<Value>2008-10-24T01:20:34.345Z</Value>
</Dimension>
<TileMatrixSetLink>
<TileMatrixSet>EPSG:4326</TileMatrixSet>
</TileMatrixSetLink>
Expand All @@ -142,6 +156,12 @@
<ows:Identifier>default</ows:Identifier>
</Style>
<Format>image/png</Format>
<Dimension>
<ows:Identifier>Time</ows:Identifier>
<Default>Time-B-is-very-long-timestamp</Default>
<Value>Time-A</Value>
<Value>Time-B-is-very-long-timestamp</Value>
</Dimension>
<TileMatrixSetLink>
<TileMatrixSet>EPSG:2056</TileMatrixSet>
</TileMatrixSetLink>
Expand Down
Loading

0 comments on commit de13e67

Please sign in to comment.