Merge pull request #262 from bbinet/wmtsparser-resourceurl
Rework the structure of the WMTS resourceUrls property
This commit is contained in:
@@ -94,17 +94,19 @@ ol.parser.ogc.WMTSCapabilities_v1_0_0 = function() {
|
|||||||
obj['matrixHeight'] = parseInt(this.getChildValue(node), 10);
|
obj['matrixHeight'] = parseInt(this.getChildValue(node), 10);
|
||||||
},
|
},
|
||||||
'ResourceURL': function(node, obj) {
|
'ResourceURL': function(node, obj) {
|
||||||
obj['resourceUrl'] = obj['resourceUrl'] || {};
|
|
||||||
var resourceType = node.getAttribute('resourceType');
|
var resourceType = node.getAttribute('resourceType');
|
||||||
|
var format = node.getAttribute('format');
|
||||||
|
var template = node.getAttribute('template');
|
||||||
if (!obj['resourceUrls']) {
|
if (!obj['resourceUrls']) {
|
||||||
obj['resourceUrls'] = [];
|
obj['resourceUrls'] = {};
|
||||||
}
|
}
|
||||||
var resourceUrl = obj['resourceUrl'][resourceType] = {
|
if (!obj['resourceUrls'][resourceType]) {
|
||||||
'format': node.getAttribute('format'),
|
obj['resourceUrls'][resourceType] = {};
|
||||||
'template': node.getAttribute('template'),
|
}
|
||||||
'resourceType': resourceType
|
if (!obj['resourceUrls'][resourceType][format]) {
|
||||||
};
|
obj['resourceUrls'][resourceType][format] = [];
|
||||||
obj['resourceUrls'].push(resourceUrl);
|
}
|
||||||
|
obj['resourceUrls'][resourceType][format].push(template);
|
||||||
},
|
},
|
||||||
'WSDL': function(node, obj) {
|
'WSDL': function(node, obj) {
|
||||||
obj['wsdl'] = {};
|
obj['wsdl'] = {};
|
||||||
|
|||||||
@@ -105,26 +105,24 @@ describe('ol.parser.ogc.wmtscapabilities_v1_0_0', function() {
|
|||||||
expect(wgs84Bbox.maxX).toEqual(180.0);
|
expect(wgs84Bbox.maxX).toEqual(180.0);
|
||||||
expect(wgs84Bbox.minY).toEqual(-90.0);
|
expect(wgs84Bbox.minY).toEqual(-90.0);
|
||||||
expect(wgs84Bbox.maxY).toEqual(90.0);
|
expect(wgs84Bbox.maxY).toEqual(90.0);
|
||||||
expect(layer.resourceUrl.tile.format).toEqual('image/png');
|
expect(layer.resourceUrls.hasOwnProperty('tile')).toBeTruthy();
|
||||||
var tpl = 'http://www.example.com/wmts/coastlines/{TileMatrix}/' +
|
var format = 'image/png';
|
||||||
'{TileRow}/{TileCol}.png';
|
expect(layer.resourceUrls.tile.hasOwnProperty(format)).toBeTruthy();
|
||||||
expect(layer.resourceUrl.tile.template).toEqual(tpl);
|
expect(layer.resourceUrls.tile[format].length).toEqual(2);
|
||||||
var format = 'application/gml+xml; version=3.1';
|
var tpl = 'http://a.example.com/wmts/coastlines/{TileMatrix}/' +
|
||||||
expect(layer.resourceUrl.FeatureInfo.format).toEqual(format);
|
|
||||||
tpl = 'http://www.example.com/wmts/coastlines/{TileMatrixSet}/' +
|
|
||||||
'{TileMatrix}/{TileRow}/{TileCol}/{J}/{I}.xml';
|
|
||||||
expect(layer.resourceUrl.FeatureInfo.template).toEqual(tpl);
|
|
||||||
expect(layer.resourceUrls[0].format).toEqual('image/png');
|
|
||||||
expect(layer.resourceUrls[0].resourceType).toEqual('tile');
|
|
||||||
tpl = 'http://www.example.com/wmts/coastlines/{TileMatrix}/' +
|
|
||||||
'{TileRow}/{TileCol}.png';
|
'{TileRow}/{TileCol}.png';
|
||||||
expect(layer.resourceUrls[0].template).toEqual(tpl);
|
expect(layer.resourceUrls.tile[format][0]).toEqual(tpl);
|
||||||
|
tpl = 'http://b.example.com/wmts/coastlines/{TileMatrix}/' +
|
||||||
|
'{TileRow}/{TileCol}.png';
|
||||||
|
expect(layer.resourceUrls.tile[format][1]).toEqual(tpl);
|
||||||
|
expect(layer.resourceUrls.hasOwnProperty('FeatureInfo')).toBeTruthy();
|
||||||
format = 'application/gml+xml; version=3.1';
|
format = 'application/gml+xml; version=3.1';
|
||||||
expect(layer.resourceUrls[1].format).toEqual(format);
|
expect(layer.resourceUrls.FeatureInfo.hasOwnProperty(format))
|
||||||
expect(layer.resourceUrls[1].resourceType).toEqual('FeatureInfo');
|
.toBeTruthy();
|
||||||
|
expect(layer.resourceUrls.FeatureInfo[format].length).toEqual(1);
|
||||||
tpl = 'http://www.example.com/wmts/coastlines/{TileMatrixSet}/' +
|
tpl = 'http://www.example.com/wmts/coastlines/{TileMatrixSet}/' +
|
||||||
'{TileMatrix}/{TileRow}/{TileCol}/{J}/{I}.xml';
|
'{TileMatrix}/{TileRow}/{TileCol}/{J}/{I}.xml';
|
||||||
expect(layer.resourceUrls[1].template).toEqual(tpl);
|
expect(layer.resourceUrls.FeatureInfo[format][0]).toEqual(tpl);
|
||||||
expect(dimensions.length).toEqual(1);
|
expect(dimensions.length).toEqual(1);
|
||||||
expect(dimensions[0].title).toEqual('Time');
|
expect(dimensions[0].title).toEqual('Time');
|
||||||
expect(dimensions[0]['abstract']).toEqual('Monthly datasets');
|
expect(dimensions[0]['abstract']).toEqual('Monthly datasets');
|
||||||
|
|||||||
@@ -74,7 +74,9 @@
|
|||||||
</ows:WGS84BoundingBox>
|
</ows:WGS84BoundingBox>
|
||||||
<ows:Identifier>coastlines</ows:Identifier>
|
<ows:Identifier>coastlines</ows:Identifier>
|
||||||
<ResourceURL format="image/png" resourceType="tile"
|
<ResourceURL format="image/png" resourceType="tile"
|
||||||
template="http://www.example.com/wmts/coastlines/{TileMatrix}/{TileRow}/{TileCol}.png" />
|
template="http://a.example.com/wmts/coastlines/{TileMatrix}/{TileRow}/{TileCol}.png" />
|
||||||
|
<ResourceURL format="image/png" resourceType="tile"
|
||||||
|
template="http://b.example.com/wmts/coastlines/{TileMatrix}/{TileRow}/{TileCol}.png" />
|
||||||
<ResourceURL format="application/gml+xml; version=3.1" resourceType="FeatureInfo"
|
<ResourceURL format="application/gml+xml; version=3.1" resourceType="FeatureInfo"
|
||||||
template="http://www.example.com/wmts/coastlines/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}/{J}/{I}.xml" />
|
template="http://www.example.com/wmts/coastlines/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}/{J}/{I}.xml" />
|
||||||
<Style isDefault="true">
|
<Style isDefault="true">
|
||||||
|
|||||||
Reference in New Issue
Block a user