Add support of WMTS Get Cap read

This commit fixe #2721. It still lacks the possibility to create layer from the GetCap document. It also lacks the reading of TMS limits.
This commit is contained in:
Hadrien Tulipe
2015-02-03 14:43:49 +01:00
parent 38c80e7f9b
commit 87644a1a46
8 changed files with 3164 additions and 472 deletions

View File

@@ -44,15 +44,15 @@ describe('ol.format.OWS 1.1', function() {
var obj = parser.read(doc);
expect(obj).to.be.ok();
var serviceProvider = obj.serviceProvider;
var serviceProvider = obj.ServiceProvider;
expect(serviceProvider).to.be.ok();
expect(serviceProvider.providerName).to.eql('MiraMon');
expect(serviceProvider.ProviderName).to.eql('MiraMon');
var url = 'http://www.creaf.uab.es/miramon';
expect(serviceProvider.providerSite).to.eql(url);
expect(serviceProvider.ProviderSite).to.eql(url);
var name = 'Joan Maso Pau';
expect(serviceProvider.serviceContact.individualName).to.eql(name);
expect(serviceProvider.ServiceContact.IndividualName).to.eql(name);
var position = 'Senior Software Engineer';
expect(serviceProvider.serviceContact.positionName).to.eql(position);
expect(serviceProvider.ServiceContact.PositionName).to.eql(position);
});
it('should read ServiceIdentification tag properly', function() {
@@ -78,11 +78,11 @@ describe('ol.format.OWS 1.1', function() {
var obj = parser.readFromNode(doc.firstChild);
expect(obj).to.be.ok();
var serviceIdentification = obj.serviceIdentification;
var serviceIdentification = obj.ServiceIdentification;
expect(serviceIdentification).to.be.ok();
expect(serviceIdentification.title).to.eql('Web Map Tile Service');
expect(serviceIdentification.serviceTypeVersion).to.eql('1.0.0');
expect(serviceIdentification.serviceType).to.eql('OGC WMTS');
expect(serviceIdentification.Title).to.eql('Web Map Tile Service');
expect(serviceIdentification.ServiceTypeVersion).to.eql('1.0.0');
expect(serviceIdentification.ServiceType).to.eql('OGC WMTS');
});
it('should read OperationsMetadata tag properly', function() {
@@ -98,6 +98,7 @@ describe('ol.format.OWS 1.1', function() {
'<ows:Constraint name="GetEncoding">' +
'<ows:AllowedValues>' +
'<ows:Value>KVP</ows:Value>' +
'<ows:Value>SOAP</ows:Value>' +
'</ows:AllowedValues>' +
'</ows:Constraint>' +
'</ows:Get>' +
@@ -130,23 +131,24 @@ describe('ol.format.OWS 1.1', function() {
var obj = parser.readFromNode(doc.firstChild);
expect(obj).to.be.ok();
var operationsMetadata = obj.operationsMetadata;
var operationsMetadata = obj.OperationsMetadata;
expect(operationsMetadata).to.be.ok();
var dcp = operationsMetadata.GetCapabilities.dcp;
var getCap = operationsMetadata.GetCapabilities;
var dcp = getCap.DCP;
var url = 'http://www.miramon.uab.es/cgi-bin/MiraMon5_0.cgi?';
expect(dcp.http.get[0].url).to.eql(url);
dcp = operationsMetadata.GetCapabilities.dcp;
expect(dcp.http.get[0].constraints.GetEncoding.allowedValues).to.eql(
{'KVP': true});
expect(dcp.HTTP.Get[0].href).to.eql(url);
expect(dcp.HTTP.Get[0].Constraint[0].name).to.eql('GetEncoding');
expect(dcp.HTTP.Get[0].Constraint[0].AllowedValues.Value[0]).to.eql('KVP');
url = 'http://www.miramon.uab.es/cgi-bin/MiraMon5_0.cgi?';
dcp = operationsMetadata.GetFeatureInfo.dcp;
expect(dcp.http.get[0].url).to.eql(url);
dcp = operationsMetadata.GetFeatureInfo.dcp;
expect(dcp.http.get[0].constraints).to.be(undefined);
dcp = operationsMetadata.GetFeatureInfo.DCP;
expect(dcp.HTTP.Get[0].href).to.eql(url);
expect(dcp.HTTP.Get[0].Constraint).to.be(undefined);
url = 'http://www.miramon.uab.es/cgi-bin/MiraMon5_0.cgi?';
expect(operationsMetadata.GetTile.dcp.http.get[0].url).to.eql(url);
dcp = operationsMetadata.GetTile.dcp;
expect(dcp.http.get[0].constraints).to.be(undefined);
dcp = operationsMetadata.GetTile.DCP;
expect(dcp.HTTP.Get[0].href).to.eql(url);
expect(dcp.HTTP.Get[0].Constraint).to.be(undefined);
});
});

View File

@@ -0,0 +1,184 @@
<?xml version="1.0" encoding="UTF-8"?>
<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.0/wmtsGetCapabilities_response.xsd">
<ows:ServiceIdentification>
<ows:Title>Web Map Tile Service</ows:Title>
<ows:Abstract>Service that contrains the map
access interface to some TileMatrixSets</ows:Abstract>
<ows:Keywords>
<ows:Keyword>tile</ows:Keyword>
<ows:Keyword>tile matrix set</ows:Keyword>
<ows:Keyword>map</ows:Keyword>
</ows:Keywords>
<ows:ServiceType>OGC WMTS</ows:ServiceType>
<ows:ServiceTypeVersion>1.0.0</ows:ServiceTypeVersion>
<ows:Fees>none</ows:Fees>
<ows:AccessConstraints>none</ows:AccessConstraints>
</ows:ServiceIdentification>
<ows:ServiceProvider>
<ows:ProviderName>MiraMon</ows:ProviderName>
<ows:ProviderSite xlink:href="http://www.creaf.uab.cat/miramon"/>
<ows:ServiceContact>
<ows:IndividualName>Joan Maso Pau</ows:IndividualName>
<ows:PositionName>Senior Software Engineer</ows:PositionName>
<ows:ContactInfo>
<ows:Phone>
<ows:Voice>+34 93 581 1312</ows:Voice>
<ows:Facsimile>+34 93 581 4151</ows:Facsimile>
</ows:Phone>
<ows:Address>
<ows:DeliveryPoint>Fac Ciencies UAB</ows:DeliveryPoint>
<ows:City>Bellaterra</ows:City>
<ows:AdministrativeArea>Barcelona
</ows:AdministrativeArea>
<ows:PostalCode>08193</ows:PostalCode>
<ows:Country>Spain</ows:Country>
<ows:ElectronicMailAddress>joan.maso@uab.cat
</ows:ElectronicMailAddress>
</ows:Address>
</ows:ContactInfo>
</ows:ServiceContact>
</ows:ServiceProvider>
<ows:OperationsMetadata>
<ows:Operation name="GetCapabilities">
<ows:DCP>
<ows:HTTP>
<ows:Get xlink:href="http://www.maps.bob/cgi-bin/MiraMon5_0.cgi?">
<ows:Constraint name="GetEncoding">
<ows:AllowedValues>
<ows:Value>KVP</ows:Value>
<ows:Value>SOAP</ows:Value>
</ows:AllowedValues>
</ows:Constraint>
</ows:Get>
</ows:HTTP>
</ows:DCP>
</ows:Operation>
<ows:Operation name="GetTile">
<ows:DCP>
<ows:HTTP>
<ows:Get xlink:href="http://www.maps.bob/cgi-bin/MiraMon5_0.cgi?">
<ows:Constraint name="GetEncoding">
<ows:AllowedValues>
<ows:Value>KVP</ows:Value>
</ows:AllowedValues>
</ows:Constraint>
</ows:Get>
</ows:HTTP>
</ows:DCP>
</ows:Operation>
</ows:OperationsMetadata>
<Contents>
<Layer>
<ows:Title>Blue Marble Next Generation</ows:Title>
<ows:Abstract>Blue Marble Next Generation NASA Product
</ows:Abstract>
<ows:WGS84BoundingBox>
<ows:LowerCorner>-180 -90</ows:LowerCorner>
<ows:UpperCorner>180 90</ows:UpperCorner>
</ows:WGS84BoundingBox>
<ows:Identifier>BlueMarbleNextGeneration</ows:Identifier>
<Style isDefault="true">
<ows:Title>Dark Blue</ows:Title>
<ows:Identifier>DarkBlue</ows:Identifier>
<LegendURL format="image/png" xlink:href="http://www.miramon.uab.es/wmts/Coastlines/coastlines_darkBlue.png"/>
</Style>
<Style>
<ows:Title>Thick And Red</ows:Title>
<ows:Abstract>Specify this style if you want your maps to have thick red coastlines.
</ows:Abstract>
<ows:Identifier>thickAndRed</ows:Identifier>
</Style>
<Format>image/jpeg</Format>
<Format>image/gif</Format>
<TileMatrixSetLink>
<TileMatrixSet>BigWorldPixel</TileMatrixSet>
</TileMatrixSetLink>
<ResourceURL format="image/png" resourceType="tile" template="http://www.example.com/wmts/coastlines/{TileMatrix}/{TileRow}/{TileCol}.png"/>
<ResourceURL format="application/gml+xml; version=3.1" resourceType="FeatureInfo" template="http://www.example.com/wmts/coastlines/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}/{J}/{I}.xml"/>
</Layer>
<TileMatrixSet>
<ows:Identifier>BigWorldPixel</ows:Identifier>
<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>
<ScaleDenominator>33130800.83133142</ScaleDenominator>
<TopLeftCorner>-180 90</TopLeftCorner>
<TileWidth>640</TileWidth>
<TileHeight>480</TileHeight>
<MatrixWidth>7</MatrixWidth>
<MatrixHeight>5</MatrixHeight>
</TileMatrix>
<TileMatrix>
<ows:Identifier>20000m</ows:Identifier>
<ScaleDenominator>66261601.66266284</ScaleDenominator>
<TopLeftCorner>-180 90</TopLeftCorner>
<TileWidth>640</TileWidth>
<TileHeight>480</TileHeight>
<MatrixWidth>4</MatrixWidth>
<MatrixHeight>3</MatrixHeight>
</TileMatrix>
<TileMatrix>
<ows:Identifier>40000m</ows:Identifier>
<ScaleDenominator>132523203.3253257</ScaleDenominator>
<TopLeftCorner>-180 90</TopLeftCorner>
<TileWidth>640</TileWidth>
<TileHeight>480</TileHeight>
<MatrixWidth>2</MatrixWidth>
<MatrixHeight>2</MatrixHeight>
</TileMatrix>
<TileMatrix>
<ows:Identifier>60000m</ows:Identifier>
<ScaleDenominator>198784804.9879885</ScaleDenominator>
<TopLeftCorner>-180 90</TopLeftCorner>
<TileWidth>640</TileWidth>
<TileHeight>480</TileHeight>
<MatrixWidth>1</MatrixWidth>
<MatrixHeight>1</MatrixHeight>
</TileMatrix>
<TileMatrix>
<ows:Identifier>120000m</ows:Identifier>
<ScaleDenominator>397569609.9759771</ScaleDenominator>
<TopLeftCorner>-180 90</TopLeftCorner>
<TileWidth>640</TileWidth>
<TileHeight>480</TileHeight>
<MatrixWidth>1</MatrixWidth>
<MatrixHeight>1</MatrixHeight>
</TileMatrix>
<TileMatrix>
<ows:Identifier>240000m</ows:Identifier>
<ScaleDenominator>795139219.9519541</ScaleDenominator>
<TopLeftCorner>-180 90</TopLeftCorner>
<TileWidth>640</TileWidth>
<TileHeight>480</TileHeight>
<MatrixWidth>1</MatrixWidth>
<MatrixHeight>1</MatrixHeight>
</TileMatrix>
</TileMatrixSet>
<TileMatrixSet>
<ows:Identifier>BigWorld</ows:Identifier>
<ows:SupportedCRS>urn:ogc:def:crs:OGC:1.3:CRS84</ows:SupportedCRS>
<TileMatrix>
<ows:Identifier>1e6</ows:Identifier>
<ScaleDenominator>1e6</ScaleDenominator>
<TopLeftCorner>-180 84</TopLeftCorner>
<TileWidth>256</TileWidth>
<TileHeight>256</TileHeight>
<MatrixWidth>60000</MatrixWidth>
<MatrixHeight>50000</MatrixHeight>
</TileMatrix>
<TileMatrix>
<ows:Identifier>2.5e6</ows:Identifier>
<ScaleDenominator>2.5e6</ScaleDenominator>
<TopLeftCorner>-180 84</TopLeftCorner>
<TileWidth>256</TileWidth>
<TileHeight>256</TileHeight>
<MatrixWidth>9000</MatrixWidth>
<MatrixHeight>7000</MatrixHeight>
</TileMatrix>
</TileMatrixSet>
</Contents>
<ServiceMetadataURL xlink:href="http://www.maps.bob/wmts/1.0.0/WMTSCapabilities.xml"/>
</Capabilities>

View File

@@ -0,0 +1,106 @@
goog.provide('ol.test.format.WMTSCapabilities');
describe('ol.format.WMTSCapabilities', function() {
describe('when parsing ogcsample.xml', function() {
var parser = new ol.format.WMTSCapabilities();
var capabilities;
before(function(done) {
afterLoadText('spec/ol/format/wmts/ogcsample.xml', function(xml) {
try {
capabilities = parser.read(xml);
} catch (e) {
done(e);
}
done();
});
});
it('can read Capability.Contents.Layer', function() {
expect(capabilities.Contents.Layer).to.be.an('array');
expect(capabilities.Contents.Layer).to.have.length(1);
var layer = capabilities.Contents.Layer[0];
expect(layer.Abstract).to.be
.eql('Blue Marble Next Generation NASA Product');
expect(layer.Identifier).to.be.eql('BlueMarbleNextGeneration');
expect(layer.Title).to.be.eql('Blue Marble Next Generation');
expect(layer.Format).to.be.an('array');
expect(layer.Format).to.have.length(2);
expect(layer.Format[0]).to.be.eql('image/jpeg');
expect(layer.Style).to.be.an('array');
expect(layer.Style).to.have.length(2);
expect(layer.Style[0].Identifier).to.be.eql('DarkBlue');
expect(layer.Style[0].isDefault).to.be(true);
expect(layer.Style[0].Title).to.be.eql('Dark Blue');
expect(layer.Style[0].LegendURL[0].href).to.be
.eql('http://www.miramon.uab.es/wmts/Coastlines/' +
'coastlines_darkBlue.png');
expect(layer.Style[0].LegendURL[0].format).to.be.eql('image/png');
expect(layer.TileMatrixSetLink).to.be.an('array');
expect(layer.TileMatrixSetLink).to.have.length(1);
expect(layer.TileMatrixSetLink[0].TileMatrixSet).to.be
.eql('BigWorldPixel');
var wgs84Bbox = layer.WGS84BoundingBox;
expect(wgs84Bbox).to.be.an('array');
expect(wgs84Bbox[0]).to.be.eql(-180);
expect(wgs84Bbox[2]).to.be.eql(180);
expect(wgs84Bbox[1]).to.be.eql(-90);
expect(wgs84Bbox[3]).to.be.eql(90.0);
expect(layer.ResourceURL).to.be.an('array');
expect(layer.ResourceURL).to.have.length(2);
expect(layer.ResourceURL[0].format).to.be.eql('image/png');
expect(layer.ResourceURL[0].template).to.be
.eql('http://www.example.com/wmts/coastlines/{TileMatrix}' +
'/{TileRow}/{TileCol}.png');
});
it('Can read Capabilities.Content.TileMatrixSet', function() {
expect(capabilities.Contents.TileMatrixSet).to.be.ok();
var bigWorld = capabilities.Contents.TileMatrixSet[1];
expect(bigWorld).to.be.ok();
expect(bigWorld.Identifier).to.be.eql('BigWorld');
expect(bigWorld.SupportedCRS).to.be.eql('urn:ogc:def:crs:OGC:1.3:CRS84');
expect(bigWorld.TileMatrix).to.have.length(2);
expect(bigWorld.TileMatrix[0].Identifier).to.be.eql('1e6');
expect(bigWorld.TileMatrix[0].MatrixHeight).to.be.eql(50000);
expect(bigWorld.TileMatrix[0].MatrixWidth).to.be.eql(60000);
expect(bigWorld.TileMatrix[0].ScaleDenominator).to.be.eql(1000000);
expect(bigWorld.TileMatrix[0].TileWidth).to.be.eql(256);
expect(bigWorld.TileMatrix[0].TileHeight).to.be.eql(256);
expect(bigWorld.TileMatrix[0].TopLeftCorner).to.be.a('array');
expect(bigWorld.TileMatrix[0].TopLeftCorner[0]).to.be.eql(-180);
expect(bigWorld.TileMatrix[0].TopLeftCorner[1]).to.be.eql(84);
expect(bigWorld.TileMatrix[1].Identifier).to.be.eql('2.5e6');
expect(bigWorld.TileMatrix[1].MatrixHeight).to.be.eql(7000);
expect(bigWorld.TileMatrix[1].MatrixWidth).to.be.eql(9000);
expect(bigWorld.TileMatrix[1].ScaleDenominator).to.be.eql(2500000);
expect(bigWorld.TileMatrix[1].TileWidth).to.be.eql(256);
expect(bigWorld.TileMatrix[1].TileHeight).to.be.eql(256);
expect(bigWorld.TileMatrix[1].TopLeftCorner).to.be.a('array');
expect(bigWorld.TileMatrix[1].TopLeftCorner[0]).to.be.eql(-180);
expect(bigWorld.TileMatrix[1].TopLeftCorner[1]).to.be.eql(84);
});
it('Can read OWS tags', function() {
expect(capabilities.ServiceIdentification).to.be.ok();
expect(capabilities.OperationsMetadata).to.be.ok();
});
});
});
goog.require('ol.format.WMTSCapabilities');