[OpenLayers-Users] Issue with WMTS layer created with WMTSGetCapabilities

Stephen Woodbridge woodbri at swoodbridge.com
Mon Mar 28 15:53:10 EDT 2011


On 3/28/2011 12:37 PM, Stephen Woodbridge wrote:
> On 3/27/2011 7:48 PM, Stephen Woodbridge wrote:
>> OK, seems to be my weekend for problems :)
>>
>> I am trying to get WMTS layer to be created from the WMTSGetCapabilities
>> document. It seems to be reading the document ok and creating the layer
>> but the layers does not work correctly.
>>
>> Here is the getCapabilities document:
>>
>> http://imaptools.com:8080/geocache/wmts?service=wmts&request=getcapabilities
>>
>>
>>
>> Here is a simple web page I'm using for testing:
>>
>> http://imaptools.com:8080/gc4.html
>>
>> This has 3 layers defined:
>>
>> 1. WMTS in spherical mercator explicitly defining all the parameters.
>> This layer works fine as far as I can tell. It is for reference and to
>> show that the service is up and running correctly.
>>
>> 2. This attempts to read the getCapabilites document and create a layer
>> identical to the above based on the document. It seems that this layer
>> is in WGS84, degrees, and resolutions, etc if I inspect the
>> map.layer[1].* properties, instead of the values from the requested
>> matrixSet.
>>
>> 3. This attempts to read the getCapabilites document and create a layer
>> that is WGS84 based on the document, and I figured it had at least some
>> chance of working given the defaults found in 2. And map.zoom==1, shows
>> two broken tiles with TILEROW=-1
>>
>> So, I'm hoping that someone that knows about about WMTS can take a peak.
>> I'm digging through the code, but have not had much luck discovering
>> anything helpful.
>
> As a follow up on this post, it seems that
> OpenLayers.Format.WMTSCapabilities() is not creating a appropriate layer
> definition from the getCapabilities document.
>
> In OpenLayers.Format.WMTSCapabilities:148 we have:
>
> layer = new OpenLayers.Layer.WMTS(
> OpenLayers.Util.applyDefaults(config, {
> url: capabilities.operationsMetadata.GetTile.dcp.http.get,
> name: layerDef.title,
> style: style,
> matrixIds: matrixSet.matrixIds
> })
> );
>
> This is not setting:
>
> layer.resolutions[]
> layer.projection
> layer.units
> layer.maxExtents
>
> from the capabilities document information so these are defaulting to
> EPSG:4326 values that are not valid for sphericalMercator layers.
>
> Another possible conclusion is that the OpenLayers.Layer.WMTS()
> constructor is not populating these items from the matrixIds if all the
> information is in there.
>
> Yes, I know that I can set these items manually via the "config"
> argument, but this seems to defeat the whole purpose of defining the
> layer via the capabilities document in the first place.
>
> Am I sizing this up correctly? Or maybe I have missed something.
>

Continuing with the conversation with myself and hoping that this is 
useful in case someone else runs into this or decides to fix it.

OpenLayers/Format/OWSCommon/v1.js does not extract the BoundingBox tags 
at all:

             "BoundingBox": function(node, obj) {
                 // FIXME: We consider that BoundingBox is the same as 
WGS84BoundingBox
                 // LowerCorner = "min_x min_y"
                 // UpperCorner = "max_x max_y"
                 // It should normally depend on the projection
                 this.readers['ows']['WGS84BoundingBox'].apply(this, 
[node, obj]);
             },

According to the standard you can have zero or more of these:

<ows:BoundingBox crs="urn:ogc:def:crs:EPSG::4326">
<ows:LowerCorner>-180.000000 -90.000000</ows:LowerCorner>
<ows:UpperCorner>180.000000 90.000000</ows:UpperCorner>
</ows:BoundingBox>

mod-geocache emits one for each supported crs on a layer and each 
TileMatrixSet has a SupportedCRS tag that points back to the appropriate 
BoundingBox. So the BoundingBox tags should get extracted as an array 
either like:

capabilities.contents.layer[n].bounds{crs} = OpenLayers.Bounds

or

capabilities.contents.layer[n].bounds[0..n] = {
   crs: crs,
   bounds: OpenLayers.Bounds
}

Then it would be possible to fix 
OpenLayers.Format.WMTSCapabilities.createLayer() to extract the 
appropriate information from the capabilities document and create a 
working layer.

So at the moment OpenLayers 2.10 is definitely broken in this respect. I 
think I will just have to live with explicitly defining WMTS layers for 
the time being. Hopefully this thread will be helpful to others.

-Steve


More information about the Users mailing list