Adding a WMTS layer and capabilities parser to work with OGC WMTS service implementations. Thanks August Town for this nice contribution. p=august,me r=me (closes #2637)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@10388 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
function test_initialize(t) {
|
||||
|
||||
t.plan(1);
|
||||
var format = new OpenLayers.Format.WMTSCapabilities({
|
||||
version: "foo"
|
||||
});
|
||||
t.eq(format.version, "foo", "version set on format");
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,275 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
function test_ows(t) {
|
||||
t.plan(17);
|
||||
var xml = document.getElementById("ogcsample").firstChild.nodeValue;
|
||||
var doc = new OpenLayers.Format.XML().read(xml);
|
||||
var obj = new OpenLayers.Format.WMTSCapabilities().read(doc);
|
||||
// ows:ServiceIdentification
|
||||
var serviceIdentification = obj.serviceIdentification;
|
||||
t.eq(serviceIdentification.title, "Web Map Tile Service", "ows:ServiceIdentification title is correct");
|
||||
t.eq(serviceIdentification.serviceTypeVersion, "1.0.0", "ows:ServiceIdentification serviceTypeVersion is correct");
|
||||
t.eq(serviceIdentification.serviceType.value, "OGC WMTS", "ows:ServiceIdentification serviceType is correct");
|
||||
|
||||
// ows:ServiceProvider
|
||||
var serviceProvider = obj.serviceProvider;
|
||||
t.eq(serviceProvider.providerName, "MiraMon", "ows:ServiceProvider providerName is correct");
|
||||
t.eq(serviceProvider.providerSite, "http://www.creaf.uab.es/miramon", "ows:ServiceProvider providerSite is correct");
|
||||
t.eq(serviceProvider.serviceContact.individualName, "Joan Maso Pau", "ows:ServiceProvider individualName is correct");
|
||||
t.eq(serviceProvider.serviceContact.positionName, "Senior Software Engineer", "ows:ServiceProvider positionName is correct");
|
||||
t.eq(serviceProvider.serviceContact.contactInfo.address.administrativeArea, "Barcelona", "ows:ServiceProvider address administrativeArea is correct");
|
||||
t.eq(serviceProvider.serviceContact.contactInfo.address.city, "Bellaterra", "ows:ServiceProvider address city is correct");
|
||||
t.eq(serviceProvider.serviceContact.contactInfo.address.country, "Spain", "ows:ServiceProvider address country is correct");
|
||||
t.eq(serviceProvider.serviceContact.contactInfo.address.deliveryPoint, "Fac Ciencies UAB", "ows:ServiceProvider address deliveryPoint is correct");
|
||||
t.eq(serviceProvider.serviceContact.contactInfo.address.electronicMailAddress, "joan.maso@uab.es", "ows:ServiceProvider address electronicMailAddress is correct");
|
||||
t.eq(serviceProvider.serviceContact.contactInfo.address.postalCode, "08193", "ows:ServiceProvider address postalCode is correct");
|
||||
t.eq(serviceProvider.serviceContact.contactInfo.phone.voice, "+34 93 581 1312", "ows:ServiceProvider phone voice is correct");
|
||||
|
||||
// ows:OperationsMetadata
|
||||
var operationsMetadata = obj.operationsMetadata;
|
||||
t.eq(operationsMetadata.GetCapabilities.dcp.http.get, "http://www.miramon.uab.es/cgi-bin/MiraMon5_0.cgi?", "ows:OperationsMetadata GetCapabilities url is correct");
|
||||
t.eq(operationsMetadata.GetFeatureInfo.dcp.http.get, "http://www.miramon.uab.es/cgi-bin/MiraMon5_0.cgi?", "ows:OperationsMetadata GetFeatureInfo url is correct");
|
||||
t.eq(operationsMetadata.GetTile.dcp.http.get, "http://www.miramon.uab.es/cgi-bin/MiraMon5_0.cgi?", "ows:OperationsMetadata GetTile url is correct");
|
||||
}
|
||||
|
||||
function test_layers(t) {
|
||||
t.plan(21);
|
||||
var xml = document.getElementById("ogcsample").firstChild.nodeValue;
|
||||
var doc = new OpenLayers.Format.XML().read(xml);
|
||||
|
||||
var obj = new OpenLayers.Format.WMTSCapabilities().read(doc);
|
||||
var contents = obj.contents;
|
||||
|
||||
var numOfLayers = contents.layers.length;
|
||||
t.eq(numOfLayers, 1, "correct count of layers");
|
||||
|
||||
var layer = contents.layers[0];
|
||||
t.eq(layer.abstract, "Coastline/shorelines (BA010)", "layer abstract is correct");
|
||||
t.eq(layer.identifier, "coastlines", "layer identifier is correct");
|
||||
t.eq(layer.title, "Coastlines", "layer title is correct");
|
||||
|
||||
var numOfFormats = layer.formats.length;
|
||||
t.eq(numOfFormats, 2, "correct count of formats");
|
||||
t.eq(layer.formats[0], "image/png", "format image/png is correct");
|
||||
t.eq(layer.formats[1], "image/gif", "format image/gif is correct");
|
||||
|
||||
var numOfStyles = layer.styles.length;
|
||||
t.eq(numOfStyles, 2, "correct count of styles");
|
||||
t.eq(layer.styles[0].identifier, "DarkBlue", "style 0 identifier is correct");
|
||||
t.eq(layer.styles[0].isDefault, "true", "style 0 isDefault is correct");
|
||||
t.eq(layer.styles[0].title, "Dark Blue", "style 0 title is correct");
|
||||
t.eq(layer.styles[1].identifier, "thickAndRed", "style 1 identifier is correct");
|
||||
t.ok(!layer.styles[1].isDefault, "style 1 isDefault is correct");
|
||||
t.eq(layer.styles[1].title, "Thick And Red", "style 1 title is correct");
|
||||
//t.eq(layer.styles[1].abstract, "Specify this style if you want your maps to have thick red coastlines. ", "style 1 abstract is correct");
|
||||
|
||||
t.eq(layer.tileMatrixSetLinks.length, 1, "correct count of tileMatrixSetLinks");
|
||||
t.eq(layer.tileMatrixSetLinks[0].tileMatrixSet, "BigWorld", "tileMatrixSet is correct");
|
||||
|
||||
var wgs84Bbox = layer.bounds;
|
||||
t.ok(wgs84Bbox instanceof OpenLayers.Bounds, "wgs84BoudingBox instance of OpenLayers.Bounds");
|
||||
t.eq(wgs84Bbox.left, -180.0, "wgs84BoudingBox left is correct");
|
||||
t.eq(wgs84Bbox.right, 180.0, "wgs84BoudingBox right is correct");
|
||||
t.eq(wgs84Bbox.bottom, -90.0, "wgs84BoudingBox bottom is correct");
|
||||
t.eq(wgs84Bbox.top, 90.0, "wgs84BoudingBox top is correct");
|
||||
|
||||
}
|
||||
|
||||
function test_tileMatrixSets(t) {
|
||||
t.plan(19);
|
||||
var xml = document.getElementById("ogcsample").firstChild.nodeValue;
|
||||
var doc = new OpenLayers.Format.XML().read(xml);
|
||||
|
||||
var obj = new OpenLayers.Format.WMTSCapabilities().read(doc);
|
||||
|
||||
var tileMatrixSets = obj.contents.tileMatrixSets;
|
||||
t.ok(tileMatrixSets['BigWorld'], "tileMatrixSets 'BigWorld' found");
|
||||
var bigWorld = tileMatrixSets['BigWorld'];
|
||||
t.eq(bigWorld.identifier, "BigWorld", "tileMatrixSets identifier is correct");
|
||||
t.eq(bigWorld.matrixIds.length, 2, "tileMatrix count is correct");
|
||||
t.eq(bigWorld.matrixIds[0].identifier, "1e6", "tileMatrix 0 identifier is correct");
|
||||
t.eq(bigWorld.matrixIds[0].matrixHeight, 50000, "tileMatrix 0 matrixHeight is correct");
|
||||
t.eq(bigWorld.matrixIds[0].matrixWidth, 60000, "tileMatrix 0 matrixWidth is correct");
|
||||
t.eq(bigWorld.matrixIds[0].scaleDenominator, 1000000, "tileMatrix 0 scaleDenominator is correct");
|
||||
t.eq(bigWorld.matrixIds[0].tileWidth, 256, "tileMatrix 0 tileWidth is correct");
|
||||
t.eq(bigWorld.matrixIds[0].tileHeight, 256, "tileMatrix 0 tileHeight is correct");
|
||||
t.eq(bigWorld.matrixIds[0].topLeftCorner.lon, -180, "tileMatrix 0 topLeftCorner.lon is correct");
|
||||
t.eq(bigWorld.matrixIds[0].topLeftCorner.lat, 84, "tileMatrix 0 topLeftCorner.lat is correct");
|
||||
|
||||
t.eq(bigWorld.matrixIds[1].identifier, "2.5e6", "tileMatrix 1 identifier is correct");
|
||||
t.eq(bigWorld.matrixIds[1].matrixHeight, 7000, "tileMatrix 1 matrixHeight is correct");
|
||||
t.eq(bigWorld.matrixIds[1].matrixWidth, 9000, "tileMatrix 1 matrixWidth is correct");
|
||||
t.eq(bigWorld.matrixIds[1].scaleDenominator, 2500000, "tileMatrix 1 scaleDenominator is correct");
|
||||
t.eq(bigWorld.matrixIds[1].tileWidth, 256, "tileMatrix 1 tileWidth is correct");
|
||||
t.eq(bigWorld.matrixIds[1].tileHeight, 256, "tileMatrix 1 tileHeight is correct");
|
||||
t.eq(bigWorld.matrixIds[1].topLeftCorner.lon, -180, "tileMatrix 1 topLeftCorner.lon is correct");
|
||||
t.eq(bigWorld.matrixIds[1].topLeftCorner.lat, 84, "tileMatrix 1 topLeftCorner.lat is correct");
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<!--
|
||||
OGC example below taken from
|
||||
http://schemas.opengis.net/wmts/1.0/examples/wmtsGetCapabilities_response.xml
|
||||
-->
|
||||
<div id="ogcsample"><!--
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Capabilities xmlns="http://www.opengis.net/wmts/1.0" 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" xmlns:gml="http://www.opengis.net/gml" xsi:schemaLocation="http://www.opengis.net/wmts/1.0 http://schemas.opengis.net/wmts/1.0/wmtsGetCapabilities_response.xsd" version="1.0.0">
|
||||
<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.es/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.es</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.miramon.uab.es/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:Operation name="GetTile">
|
||||
<ows:DCP>
|
||||
<ows:HTTP>
|
||||
<ows:Get xlink:href="http://www.miramon.uab.es/cgi-bin/MiraMon5_0.cgi?"/>
|
||||
</ows:HTTP>
|
||||
</ows:DCP>
|
||||
</ows:Operation>
|
||||
<ows:Operation name="GetFeatureInfo">
|
||||
<ows:DCP>
|
||||
<ows:HTTP>
|
||||
<ows:Get xlink:href="http://www.miramon.uab.es/cgi-bin/MiraMon5_0.cgi?"/>
|
||||
</ows:HTTP>
|
||||
</ows:DCP>
|
||||
</ows:Operation>
|
||||
</ows:OperationsMetadata>
|
||||
<Contents>
|
||||
<Layer>
|
||||
<ows:Title>Coastlines</ows:Title>
|
||||
<ows:Abstract>Coastline/shorelines (BA010)</ows:Abstract>
|
||||
<ows:WGS84BoundingBox>
|
||||
<ows:LowerCorner>-180 -90</ows:LowerCorner>
|
||||
<ows:UpperCorner>180 90</ows:UpperCorner>
|
||||
</ows:WGS84BoundingBox>
|
||||
<ows:Identifier>coastlines</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/png</Format>
|
||||
<Format>image/gif</Format>
|
||||
<Dimension>
|
||||
<ows:Title>Time</ows:Title>
|
||||
<ows:Abstract>Monthly datasets</ows:Abstract>
|
||||
<ows:Identifier>TIME</ows:Identifier>
|
||||
<Value>2007-05</Value>
|
||||
<Value>2007-06</Value>
|
||||
<Value>2007-07</Value>
|
||||
</Dimension>
|
||||
<TileMatrixSetLink>
|
||||
<TileMatrixSet>BigWorld</TileMatrixSet>
|
||||
</TileMatrixSetLink>
|
||||
</Layer>
|
||||
<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>84 -180</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>84 -180</TopLeftCorner>
|
||||
<TileWidth>256</TileWidth>
|
||||
<TileHeight>256</TileHeight>
|
||||
<MatrixWidth>9000</MatrixWidth>
|
||||
<MatrixHeight>7000</MatrixHeight>
|
||||
</TileMatrix>
|
||||
</TileMatrixSet>
|
||||
</Contents>
|
||||
<Themes>
|
||||
<Theme>
|
||||
<ows:Title>Foundation</ows:Title>
|
||||
<ows:Abstract>"Digital Chart Of The World" data</ows:Abstract>
|
||||
<ows:Identifier>Foundation</ows:Identifier>
|
||||
<Theme>
|
||||
<ows:Title>Boundaries</ows:Title>
|
||||
<ows:Identifier>Boundaries</ows:Identifier>
|
||||
<LayerRef>coastlines</LayerRef>
|
||||
<LayerRef>politicalBoundaries</LayerRef>
|
||||
<LayerRef>depthContours</LayerRef>
|
||||
</Theme>
|
||||
<Theme>
|
||||
<ows:Title>Transportation</ows:Title>
|
||||
<ows:Identifier>Transportation</ows:Identifier>
|
||||
<LayerRef>roads</LayerRef>
|
||||
<LayerRef>railroads</LayerRef>
|
||||
<LayerRef>airports</LayerRef>
|
||||
</Theme>
|
||||
</Theme>
|
||||
<Theme>
|
||||
<ows:Title>World Geology</ows:Title>
|
||||
<ows:Identifier>World Geology</ows:Identifier>
|
||||
<LayerRef>worldAgeRockType</LayerRef>
|
||||
<LayerRef>worldFaultLines</LayerRef>
|
||||
<LayerRef>felsicMagmatic</LayerRef>
|
||||
<LayerRef>maficMagmatic</LayerRef>
|
||||
</Theme>
|
||||
</Themes>
|
||||
</Capabilities>
|
||||
--></div>
|
||||
</body>
|
||||
</html>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -85,6 +85,8 @@
|
||||
<li>Format/WMSCapabilities/v1_3_0.html</li>
|
||||
<li>Format/WMSDescribeLayer.html</li>
|
||||
<li>Format/WMSGetFeatureInfo.html</li>
|
||||
<li>Format/WMTSCapabilities.html</li>
|
||||
<li>Format/WMTSCapabilities/v1_0_0.html</li>
|
||||
<li>Format/CSWGetDomain.html</li>
|
||||
<li>Format/CSWGetDomain/v2_0_2.html</li>
|
||||
<li>Format/CSWGetRecords.html</li>
|
||||
@@ -144,6 +146,7 @@
|
||||
<li>Layer/WFS.html</li>
|
||||
<li>Layer/WMS.html</li>
|
||||
<li>Layer/WMS/Post.html</li>
|
||||
<li>Layer/WMTS.html</li>
|
||||
<li>Layer/WrapDateLine.html</li>
|
||||
<li>Layer/XYZ.html</li>
|
||||
<li>Layer/Yahoo.html</li>
|
||||
|
||||
Reference in New Issue
Block a user