WMTS capabilities issue with group layers

Hi,

Geoserver is perhaps creating invalid WMTS capabilities for group layers.
For example the demo layer Tasmania

<Layer>
<ows:Title>Tasmania</ows:Title>
<ows:Abstract>Tasmania Australia from Digital Chart of the World.</ows:Abstract>
<ows:WGS84BoundingBox>
<ows:LowerCorner>143.83482400000003 -43.648056</ows:LowerCorner>
<ows:UpperCorner>148.47914100000003 -39.573891</ows:UpperCorner>
</ows:WGS84BoundingBox>
<ows:Identifier>tasmania</ows:Identifier>
<Style isDefault="true">
<ows:Identifier/>
</Style>

The issue is that Identifier, that is mandatory by the WMTS standars, is null.
Trouble has appeared when GDAL tries to read a group layer. It builds a GetTile query according to the ResourceURL:
<ResourceURL format="image/png" resourceType="tile" template="http://localhost:8080/geoserver/gwc/service/wmts/rest/tasmania/{style}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}?

For example:
http://localhost:8080/geoserver/gwc/service/wmts/rest/tasmania//EPSG:4326/EPSG:4326:9/378/930?format=image/png

Notice empty styles after tasmania in ...tasmania//EPSG:4326/...
I made a test with Geoserver 2.25.3 that comes with GWC 1.25 and the request works. The GDAL user had problems with a service that seems to run GWC 1.22.1 and they had to shorten the url by removing the empty style, or name the style into “default”.

What do you developers think, is empty style identifier all right according to the WMTS standard? The definition of Style-Identifier in the standard is “An unambiguous reference to this style, identifying a specific version when needed, normally used by software”, and Multiplicity and use is “One (mandatory)”.
I can’t judge. Maybe, if there is only one style, even NULL is unambiguous.

GWC 1.25 works for me but I do not know if the issue with having an empty style part in the REST GetTile URL has been fixed since GWC 1.22.1 or if there is something else happening.

This is an odd situation for sure; especially now that we have introduced alternate styles for layer groups.
For GetMap I believe style has always been optional, and empty used to specify “default”.

For capabilities I think there was a question if we should generate placeholder style of some sort. Checking a WMS 1.3.0 document I see:


<Style>
<Name>default-style-tasmania</Name>
...
</Style>

Hi,
I quickly checked the schemas, here are some references:

https://schemas.opengis.net/wmts/1.0/wmtsGetCapabilities_response.xsd

<?xml version="1.0"?>
<element name="Style">
  <complexType>
    <complexContent>
      <extension base="ows:DescriptionType">
        <sequence>
          <element ref="ows:Identifier">
            <annotation>
              <documentation> An unambiguous reference to this style, identifying a specific version when needed, normally used by software </documentation>
            </annotation>
          </element>
          <element ref="wmts:LegendURL" minOccurs="0" maxOccurs="unbounded">
            <annotation>
              <documentation>Description of an image that represents the legend of the map</documentation>
            </annotation>
          </element>
        </sequence>
        <attribute name="isDefault" type="boolean">
          <annotation>
            <documentation>This style is used when no style is specified</documentation>
          </annotation>
        </attribute>
      </extension>
    </complexContent>
  </complexType>
</element>

Ok so yes, ows:Identifier, by itself, is mandatory, no minOccurs.
And then:

https://schemas.opengis.net/ows/1.1.0/owsDataIdentification.xsd

<?xml version="1.0"?>
<element name="Identifier" type="ows:CodeType">
  <annotation>
    <documentation>Unique identifier or name of this dataset. </documentation>
  </annotation>
</element>

And what is a code type:

https://schemas.opengis.net/ows/1.1.0/ows19115subset.xsd

<?xml version="1.0"?>
<complexType name="CodeType">
  <annotation>
    <documentation>Name or code with an (optional) authority. If the codeSpace attribute is present, its value shall reference a dictionary, thesaurus, or authority for the name or code, such as the organisation who assigned the value, or the dictionary from which it is taken. </documentation>
    <documentation>Type copied from basicTypes.xsd of GML 3 with documentation edited, for possible use outside the ServiceIdentification section of a service metadata document. </documentation>
  </annotation>
  <simpleContent>
    <extension base="string">
      <attribute name="codeSpace" type="anyURI" use="optional"/>
    </extension>
  </simpleContent>
</complexType>

All in all I find the descriptions confusing. On one side, I see no specification saying that the identifier contents should not be empty.
On the other end, the description seems quite specific to “datasets” and the uniqueness is unbound, while style name uniqueness is only needed within the layer referencing to the style.

Soo… hum. What GWC is doing does not seem wrong, but having a default non empty name would seem easier to handle and would not raise questions I guess.

Cheers
Andrea

I guess also that what GWC is doing with GetCapabilities is right, but what seems wrong to me is that at least this server (GWC 1.22.1 at irisnet.be) gives an error when a client sends a request that is build by interpreting the GetCapabilities so that it adds an empty “style” Identifier

https://geoservices-urbis.irisnet.be/geowebcache/service/wmts/rest/Ortho//EPSG:4326/EPSG:4326:7/27/129?format=image/jpeg

The request is accepted if the “style” part is removed,

https://geoservices-urbis.irisnet.be/geowebcache/service/wmts/rest/Ortho/EPSG:4326/EPSG:4326:7/27/129?format=image/jpeg

or if any string, like “default” or “foo” is used as “style”,

https://geoservices-urbis.irisnet.be/geowebcache/service/wmts/rest/Ortho/foo/EPSG:4326/EPSG:4326:7/27/129?format=image/jpeg

I don’t know if the “not normalized” error comes from Geoserver/GWC or from something else that irisnet.be is using
org.springframework.security.web.firewall.RequestRejectedException: The request was rejected because the URL was not normalized.

EDIT
I found this by making a seach after the error message:
Spring 5.0.3 RequestRejectedException: The request was rejected because the URL was not normalized - Stack Overflow
Does it mean that the double slash in URL can really make troubles and it might be safer to have always a real identifier for a style in WMTS GetCapabilities?

GWC 1.22.1 has been out of support for a while, not much we can do… probably a fix happened in the meantime
(seems like a Spring change in managing the URLs).

I’ve just tried with one of our demo servers, and can confirm the double slash works in recent versions.
This is a 2.27-SNAPSHOT, in particular (the latest nightly build of the dev branch, updated 3 times a day):

https://gs-main.geosolutionsgroup.com/geoserver/gwc/service/wmts/rest/tasmania//EPSG:900913/EPSG:900913:6/40/58?format=image/png