Merge pull request #3026 from htulipe/wmts-getcap
Add support of reading WMTS Get Cap document
This commit is contained in:
File diff suppressed because it is too large
Load Diff
49
examples/wmts-capabilities.html
Normal file
49
examples/wmts-capabilities.html
Normal file
@@ -0,0 +1,49 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="chrome=1">
|
||||
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
|
||||
<link rel="stylesheet" href="../css/ol.css" type="text/css">
|
||||
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap.min.css" type="text/css">
|
||||
<link rel="stylesheet" href="../resources/layout.css" type="text/css">
|
||||
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
|
||||
<title>WMTS GetCapabilities parsing example</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container">
|
||||
<a class="brand" href="./"><img src="../resources/logo.png"> OpenLayers 3 Examples</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="container-fluid">
|
||||
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="span4">
|
||||
<h4 id="title">WMTS GetCapabilities parsing example</h4>
|
||||
<p id="shortdesc">Example of parsing a WMTS GetCapabilities response.</p>
|
||||
<div id="docs">
|
||||
<p>See the <a href="wmts-capabilities.js" target="_blank">wmts-capabilities.js source</a> to see how this is done.</p>
|
||||
</div>
|
||||
<div id="tags">wmts, capabilities, getcapabilities</div>
|
||||
</div>
|
||||
|
||||
<div class="span8">
|
||||
<pre id="log"></pre>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script src="../resources/jquery.min.js" type="text/javascript"></script>
|
||||
<script src="../resources/example-behaviour.js" type="text/javascript"></script>
|
||||
<script src="loader.js?id=wmts-capabilities" type="text/javascript"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
8
examples/wmts-capabilities.js
Normal file
8
examples/wmts-capabilities.js
Normal file
@@ -0,0 +1,8 @@
|
||||
goog.require('ol.format.WMTSCapabilities');
|
||||
|
||||
var parser = new ol.format.WMTSCapabilities();
|
||||
|
||||
$.ajax('data/WMTSCapabilities.xml').then(function(response) {
|
||||
var result = parser.read(response);
|
||||
$('#log').html(window.JSON.stringify(result, null, 2));
|
||||
});
|
||||
@@ -83,20 +83,13 @@ ol.format.OWS.readAllowedValues_ = function(node, objectStack) {
|
||||
ol.format.OWS.readConstraint_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
|
||||
goog.asserts.assert(node.localName == 'Constraint');
|
||||
var object = objectStack[objectStack.length - 1];
|
||||
goog.asserts.assert(goog.isObject(object));
|
||||
var name = node.getAttribute('name');
|
||||
var value = ol.xml.pushParseAndPop({},
|
||||
ol.format.OWS.CONSTRAINT_PARSERS_, node,
|
||||
objectStack);
|
||||
if (!goog.isDef(value)) {
|
||||
if (!goog.isDef(name)) {
|
||||
return undefined;
|
||||
}
|
||||
if (!goog.isDef(object.constraints)) {
|
||||
object.constraints = {};
|
||||
}
|
||||
object.constraints[name] = value;
|
||||
|
||||
return ol.xml.pushParseAndPop({'name': name},
|
||||
ol.format.OWS.CONSTRAINT_PARSERS_, node,
|
||||
objectStack);
|
||||
};
|
||||
|
||||
|
||||
@@ -137,22 +130,12 @@ ol.format.OWS.readDcp_ = function(node, objectStack) {
|
||||
ol.format.OWS.readGet_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
|
||||
goog.asserts.assert(node.localName == 'Get');
|
||||
var object = objectStack[objectStack.length - 1];
|
||||
var url = ol.format.XLink.readHref(node);
|
||||
goog.asserts.assert(goog.isObject(object));
|
||||
var value = ol.xml.pushParseAndPop({'url': url},
|
||||
ol.format.OWS.REQUEST_METHOD_PARSERS_, node, objectStack);
|
||||
if (!goog.isDef(value)) {
|
||||
var href = ol.format.XLink.readHref(node);
|
||||
if (!goog.isDef(href)) {
|
||||
return undefined;
|
||||
}
|
||||
var get = object['get'];
|
||||
if (!goog.isDef(get)) {
|
||||
object['get'] = [value];
|
||||
}else {
|
||||
goog.asserts.assert(goog.isArray(get));
|
||||
get.push(value);
|
||||
}
|
||||
|
||||
return ol.xml.pushParseAndPop({'href': href},
|
||||
ol.format.OWS.REQUEST_METHOD_PARSERS_, node, objectStack);
|
||||
};
|
||||
|
||||
|
||||
@@ -273,18 +256,12 @@ ol.format.OWS.readServiceProvider_ = function(node, objectStack) {
|
||||
* @param {Node} node Node.
|
||||
* @param {Array.<*>} objectStack Object stack.
|
||||
* @private
|
||||
* @return {Object|undefined}
|
||||
* @return {string|undefined}
|
||||
*/
|
||||
ol.format.OWS.readValue_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
|
||||
goog.asserts.assert(node.localName == 'Value');
|
||||
var object = objectStack[objectStack.length - 1];
|
||||
goog.asserts.assert(goog.isObject(object));
|
||||
var key = ol.format.XSD.readString(node);
|
||||
if (!goog.isDef(key)) {
|
||||
return undefined;
|
||||
}
|
||||
object[key] = true;
|
||||
return ol.format.XSD.readString(node);
|
||||
};
|
||||
|
||||
|
||||
@@ -307,14 +284,11 @@ ol.format.OWS.NAMESPACE_URIS_ = [
|
||||
ol.format.OWS.PARSERS_ = ol.xml.makeParsersNS(
|
||||
ol.format.OWS.NAMESPACE_URIS_, {
|
||||
'ServiceIdentification': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.OWS.readServiceIdentification_,
|
||||
'serviceIdentification'),
|
||||
ol.format.OWS.readServiceIdentification_),
|
||||
'ServiceProvider': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.OWS.readServiceProvider_,
|
||||
'serviceProvider'),
|
||||
ol.format.OWS.readServiceProvider_),
|
||||
'OperationsMetadata': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.OWS.readOperationsMetadata_,
|
||||
'operationsMetadata')
|
||||
ol.format.OWS.readOperationsMetadata_)
|
||||
});
|
||||
|
||||
|
||||
@@ -326,17 +300,14 @@ ol.format.OWS.PARSERS_ = ol.xml.makeParsersNS(
|
||||
ol.format.OWS.ADDRESS_PARSERS_ = ol.xml.makeParsersNS(
|
||||
ol.format.OWS.NAMESPACE_URIS_, {
|
||||
'DeliveryPoint': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.XSD.readString, 'deliveryPoint'),
|
||||
'City': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString,
|
||||
'city'),
|
||||
ol.format.XSD.readString),
|
||||
'City': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString),
|
||||
'AdministrativeArea': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.XSD.readString, 'administrativeArea'),
|
||||
'PostalCode': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString,
|
||||
'postalCode'),
|
||||
'Country': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.XSD.readString, 'country'),
|
||||
ol.format.XSD.readString),
|
||||
'PostalCode': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString),
|
||||
'Country': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString),
|
||||
'ElectronicMailAddress': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.XSD.readString, 'electronicMailAddress')
|
||||
ol.format.XSD.readString)
|
||||
});
|
||||
|
||||
|
||||
@@ -347,7 +318,7 @@ ol.format.OWS.ADDRESS_PARSERS_ = ol.xml.makeParsersNS(
|
||||
*/
|
||||
ol.format.OWS.ALLOWED_VALUES_PARSERS_ = ol.xml.makeParsersNS(
|
||||
ol.format.OWS.NAMESPACE_URIS_, {
|
||||
'Value': ol.format.OWS.readValue_
|
||||
'Value': ol.xml.makeObjectPropertyPusher(ol.format.OWS.readValue_)
|
||||
});
|
||||
|
||||
|
||||
@@ -359,8 +330,7 @@ ol.format.OWS.ALLOWED_VALUES_PARSERS_ = ol.xml.makeParsersNS(
|
||||
ol.format.OWS.CONSTRAINT_PARSERS_ = ol.xml.makeParsersNS(
|
||||
ol.format.OWS.NAMESPACE_URIS_, {
|
||||
'AllowedValues': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.OWS.readAllowedValues_, 'allowedValues'
|
||||
)
|
||||
ol.format.OWS.readAllowedValues_)
|
||||
});
|
||||
|
||||
|
||||
@@ -371,10 +341,8 @@ ol.format.OWS.CONSTRAINT_PARSERS_ = ol.xml.makeParsersNS(
|
||||
*/
|
||||
ol.format.OWS.CONTACT_INFO_PARSERS_ = ol.xml.makeParsersNS(
|
||||
ol.format.OWS.NAMESPACE_URIS_, {
|
||||
'Phone': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.OWS.readPhone_, 'phone'),
|
||||
'Address': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.OWS.readAddress_, 'address')
|
||||
'Phone': ol.xml.makeObjectPropertySetter(ol.format.OWS.readPhone_),
|
||||
'Address': ol.xml.makeObjectPropertySetter(ol.format.OWS.readAddress_)
|
||||
});
|
||||
|
||||
|
||||
@@ -385,8 +353,7 @@ ol.format.OWS.CONTACT_INFO_PARSERS_ = ol.xml.makeParsersNS(
|
||||
*/
|
||||
ol.format.OWS.DCP_PARSERS_ = ol.xml.makeParsersNS(
|
||||
ol.format.OWS.NAMESPACE_URIS_, {
|
||||
'HTTP': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.OWS.readHttp_, 'http')
|
||||
'HTTP': ol.xml.makeObjectPropertySetter(ol.format.OWS.readHttp_)
|
||||
});
|
||||
|
||||
|
||||
@@ -397,7 +364,7 @@ ol.format.OWS.DCP_PARSERS_ = ol.xml.makeParsersNS(
|
||||
*/
|
||||
ol.format.OWS.HTTP_PARSERS_ = ol.xml.makeParsersNS(
|
||||
ol.format.OWS.NAMESPACE_URIS_, {
|
||||
'Get': ol.format.OWS.readGet_,
|
||||
'Get': ol.xml.makeObjectPropertyPusher(ol.format.OWS.readGet_),
|
||||
'Post': undefined // TODO
|
||||
});
|
||||
|
||||
@@ -409,8 +376,7 @@ ol.format.OWS.HTTP_PARSERS_ = ol.xml.makeParsersNS(
|
||||
*/
|
||||
ol.format.OWS.OPERATION_PARSERS_ = ol.xml.makeParsersNS(
|
||||
ol.format.OWS.NAMESPACE_URIS_, {
|
||||
'DCP': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.OWS.readDcp_, 'dcp')
|
||||
'DCP': ol.xml.makeObjectPropertySetter(ol.format.OWS.readDcp_)
|
||||
});
|
||||
|
||||
|
||||
@@ -432,10 +398,8 @@ ol.format.OWS.OPERATIONS_METADATA_PARSERS_ = ol.xml.makeParsersNS(
|
||||
*/
|
||||
ol.format.OWS.PHONE_PARSERS_ = ol.xml.makeParsersNS(
|
||||
ol.format.OWS.NAMESPACE_URIS_, {
|
||||
'Voice': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString,
|
||||
'voice'),
|
||||
'Facsimile': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString,
|
||||
'facsimile')
|
||||
'Voice': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString),
|
||||
'Facsimile': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString)
|
||||
});
|
||||
|
||||
|
||||
@@ -446,7 +410,8 @@ ol.format.OWS.PHONE_PARSERS_ = ol.xml.makeParsersNS(
|
||||
*/
|
||||
ol.format.OWS.REQUEST_METHOD_PARSERS_ = ol.xml.makeParsersNS(
|
||||
ol.format.OWS.NAMESPACE_URIS_, {
|
||||
'Constraint': ol.format.OWS.readConstraint_
|
||||
'Constraint': ol.xml.makeObjectPropertyPusher(
|
||||
ol.format.OWS.readConstraint_)
|
||||
});
|
||||
|
||||
|
||||
@@ -459,11 +424,10 @@ ol.format.OWS.SERVICE_CONTACT_PARSERS_ =
|
||||
ol.xml.makeParsersNS(
|
||||
ol.format.OWS.NAMESPACE_URIS_, {
|
||||
'IndividualName': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.XSD.readString, 'individualName'),
|
||||
'PositionName': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString,
|
||||
'positionName'),
|
||||
ol.format.XSD.readString),
|
||||
'PositionName': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString),
|
||||
'ContactInfo': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.OWS.readContactInfo_, 'contactInfo')
|
||||
ol.format.OWS.readContactInfo_)
|
||||
});
|
||||
|
||||
|
||||
@@ -475,12 +439,10 @@ ol.format.OWS.SERVICE_CONTACT_PARSERS_ =
|
||||
ol.format.OWS.SERVICE_IDENTIFICATION_PARSERS_ =
|
||||
ol.xml.makeParsersNS(
|
||||
ol.format.OWS.NAMESPACE_URIS_, {
|
||||
'Title': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString,
|
||||
'title'),
|
||||
'Title': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString),
|
||||
'ServiceTypeVersion': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.XSD.readString, 'serviceTypeVersion'),
|
||||
'ServiceType': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.XSD.readString, 'serviceType')
|
||||
ol.format.XSD.readString),
|
||||
'ServiceType': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString)
|
||||
});
|
||||
|
||||
|
||||
@@ -492,10 +454,8 @@ ol.format.OWS.SERVICE_IDENTIFICATION_PARSERS_ =
|
||||
ol.format.OWS.SERVICE_PROVIDER_PARSERS_ =
|
||||
ol.xml.makeParsersNS(
|
||||
ol.format.OWS.NAMESPACE_URIS_, {
|
||||
'ProviderName': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString,
|
||||
'providerName'),
|
||||
'ProviderSite': ol.xml.makeObjectPropertySetter(ol.format.XLink.readHref,
|
||||
'providerSite'),
|
||||
'ProviderName': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString),
|
||||
'ProviderSite': ol.xml.makeObjectPropertySetter(ol.format.XLink.readHref),
|
||||
'ServiceContact': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.OWS.readServiceContact_, 'serviceContact')
|
||||
ol.format.OWS.readServiceContact_)
|
||||
});
|
||||
|
||||
400
src/ol/format/wmtscapabilitiesformat.js
Normal file
400
src/ol/format/wmtscapabilitiesformat.js
Normal file
@@ -0,0 +1,400 @@
|
||||
goog.provide('ol.format.WMTSCapabilities');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('goog.dom.NodeType');
|
||||
goog.require('goog.object');
|
||||
goog.require('goog.string');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.format.OWS');
|
||||
goog.require('ol.format.XLink');
|
||||
goog.require('ol.format.XML');
|
||||
goog.require('ol.format.XSD');
|
||||
goog.require('ol.xml');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
* Format for reading WMTS capabilities data.
|
||||
*
|
||||
* @constructor
|
||||
* @extends {ol.format.XML}
|
||||
* @api
|
||||
*/
|
||||
ol.format.WMTSCapabilities = function() {
|
||||
goog.base(this);
|
||||
|
||||
/**
|
||||
* @type {ol.format.OWS}
|
||||
* @private
|
||||
*/
|
||||
this.owsParser_ = new ol.format.OWS();
|
||||
};
|
||||
goog.inherits(ol.format.WMTSCapabilities, ol.format.XML);
|
||||
|
||||
|
||||
/**
|
||||
* Read a WMTS capabilities document.
|
||||
*
|
||||
* @function
|
||||
* @param {Document|Node|string} source The XML source.
|
||||
* @return {Object} An object representing the WMTS capabilities.
|
||||
* @api
|
||||
*/
|
||||
ol.format.WMTSCapabilities.prototype.read;
|
||||
|
||||
|
||||
/**
|
||||
* @param {Document} doc Document.
|
||||
* @return {Object} WMTS Capability object.
|
||||
*/
|
||||
ol.format.WMTSCapabilities.prototype.readFromDocument = function(doc) {
|
||||
goog.asserts.assert(doc.nodeType == goog.dom.NodeType.DOCUMENT);
|
||||
for (var n = doc.firstChild; !goog.isNull(n); n = n.nextSibling) {
|
||||
if (n.nodeType == goog.dom.NodeType.ELEMENT) {
|
||||
return this.readFromNode(n);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {Node} node Node.
|
||||
* @return {Object} WMTS Capability object.
|
||||
*/
|
||||
ol.format.WMTSCapabilities.prototype.readFromNode = function(node) {
|
||||
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
|
||||
goog.asserts.assert(node.localName == 'Capabilities');
|
||||
this.version = goog.string.trim(node.getAttribute('version'));
|
||||
goog.asserts.assertString(this.version);
|
||||
var WMTSCapabilityObject = this.owsParser_.readFromNode(node);
|
||||
if (!goog.isDef(WMTSCapabilityObject)) {
|
||||
return null;
|
||||
}
|
||||
goog.object.set(WMTSCapabilityObject, 'version', this.version);
|
||||
WMTSCapabilityObject = ol.xml.pushParseAndPop(WMTSCapabilityObject,
|
||||
ol.format.WMTSCapabilities.PARSERS_, node, []);
|
||||
return goog.isDef(WMTSCapabilityObject) ? WMTSCapabilityObject : null;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {Node} node Node.
|
||||
* @param {Array.<*>} objectStack Object stack.
|
||||
* @return {Object|undefined} Attribution object.
|
||||
*/
|
||||
ol.format.WMTSCapabilities.readContents_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
|
||||
goog.asserts.assert(node.localName == 'Contents');
|
||||
|
||||
return ol.xml.pushParseAndPop({},
|
||||
ol.format.WMTSCapabilities.CONTENTS_PARSERS_, node, objectStack);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {Node} node Node.
|
||||
* @param {Array.<*>} objectStack Object stack.
|
||||
* @return {Object|undefined} Layers object.
|
||||
*/
|
||||
ol.format.WMTSCapabilities.readLayer_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
|
||||
goog.asserts.assert(node.localName == 'Layer');
|
||||
return ol.xml.pushParseAndPop({},
|
||||
ol.format.WMTSCapabilities.LAYER_PARSERS_, node, objectStack);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {Node} node Node.
|
||||
* @param {Array.<*>} objectStack Object stack.
|
||||
* @return {Object|undefined} Tile Matrix Set object.
|
||||
*/
|
||||
ol.format.WMTSCapabilities.readTileMatrixSet_ = function(node, objectStack) {
|
||||
return ol.xml.pushParseAndPop({},
|
||||
ol.format.WMTSCapabilities.TMS_PARSERS_, node, objectStack);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {Node} node Node.
|
||||
* @param {Array.<*>} objectStack Object stack.
|
||||
* @return {Object|undefined} Style object.
|
||||
*/
|
||||
ol.format.WMTSCapabilities.readStyle_ = function(node, objectStack) {
|
||||
var style = ol.xml.pushParseAndPop({},
|
||||
ol.format.WMTSCapabilities.STYLE_PARSERS_, node, objectStack);
|
||||
if (!goog.isDef(style)) {
|
||||
return undefined;
|
||||
}
|
||||
var isDefault = node.getAttribute('isDefault') === 'true';
|
||||
style['isDefault'] = isDefault;
|
||||
return style;
|
||||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {Node} node Node.
|
||||
* @param {Array.<*>} objectStack Object stack.
|
||||
* @return {Object|undefined} Tile Matrix Set Link object.
|
||||
*/
|
||||
ol.format.WMTSCapabilities.readTileMatrixSetLink_ = function(node,
|
||||
objectStack) {
|
||||
return ol.xml.pushParseAndPop({},
|
||||
ol.format.WMTSCapabilities.TMS_LINKS_PARSERS_, node, objectStack);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {Node} node Node.
|
||||
* @param {Array.<*>} objectStack Object stack.
|
||||
* @return {Object|undefined} Resource URL object.
|
||||
*/
|
||||
ol.format.WMTSCapabilities.readResourceUrl_ = function(node, objectStack) {
|
||||
var format = node.getAttribute('format');
|
||||
var template = node.getAttribute('template');
|
||||
var resourceType = node.getAttribute('resourceType');
|
||||
var resource = {};
|
||||
if (goog.isDef(format)) {
|
||||
resource['format'] = format;
|
||||
}
|
||||
if (goog.isDef(template)) {
|
||||
resource['template'] = template;
|
||||
}
|
||||
if (goog.isDef(resourceType)) {
|
||||
resource['resourceType'] = resourceType;
|
||||
}
|
||||
return resource;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {Node} node Node.
|
||||
* @param {Array.<*>} objectStack Object stack.
|
||||
* @return {Object|undefined} WGS84 BBox object.
|
||||
*/
|
||||
ol.format.WMTSCapabilities.readWgs84BoundingBox_ = function(node, objectStack) {
|
||||
var coordinates = ol.xml.pushParseAndPop([],
|
||||
ol.format.WMTSCapabilities.WGS84_BBOX_READERS_, node, objectStack);
|
||||
if (coordinates.length != 2) {
|
||||
return undefined;
|
||||
}
|
||||
return ol.extent.boundingExtent(coordinates);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {Node} node Node.
|
||||
* @param {Array.<*>} objectStack Object stack.
|
||||
* @return {Object|undefined} Legend object.
|
||||
*/
|
||||
ol.format.WMTSCapabilities.readLegendUrl_ = function(node, objectStack) {
|
||||
var legend = {};
|
||||
legend['format'] = node.getAttribute('format');
|
||||
legend['href'] = ol.format.XLink.readHref(node);
|
||||
return legend;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {Node} node Node.
|
||||
* @param {Array.<*>} objectStack Object stack.
|
||||
* @return {Object|undefined} Coordinates object.
|
||||
*/
|
||||
ol.format.WMTSCapabilities.readCoordinates_ = function(node, objectStack) {
|
||||
var coordinates = ol.format.XSD.readString(node).split(' ');
|
||||
if (!goog.isDef(coordinates) || coordinates.length != 2) {
|
||||
return undefined;
|
||||
}
|
||||
var x = +coordinates[0];
|
||||
var y = +coordinates[1];
|
||||
if (isNaN(x) || isNaN(y)) {
|
||||
return undefined;
|
||||
}
|
||||
return [x, y];
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {Node} node Node.
|
||||
* @param {Array.<*>} objectStack Object stack.
|
||||
* @return {Object|undefined} TileMatrix object.
|
||||
*/
|
||||
ol.format.WMTSCapabilities.readTileMatrix_ = function(node, objectStack) {
|
||||
return ol.xml.pushParseAndPop({},
|
||||
ol.format.WMTSCapabilities.TM_PARSERS_, node, objectStack);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @private
|
||||
* @type {Array.<string>}
|
||||
*/
|
||||
ol.format.WMTSCapabilities.NAMESPACE_URIS_ = [
|
||||
null,
|
||||
'http://www.opengis.net/wmts/1.0'
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @private
|
||||
* @type {Array.<string>}
|
||||
*/
|
||||
ol.format.WMTSCapabilities.OWS_NAMESPACE_URIS_ = [
|
||||
null,
|
||||
'http://www.opengis.net/ows/1.1'
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, ol.xml.Parser>>}
|
||||
* @private
|
||||
*/
|
||||
ol.format.WMTSCapabilities.PARSERS_ = ol.xml.makeParsersNS(
|
||||
ol.format.WMTSCapabilities.NAMESPACE_URIS_, {
|
||||
'Contents': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.WMTSCapabilities.readContents_)
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, ol.xml.Parser>>}
|
||||
* @private
|
||||
*/
|
||||
ol.format.WMTSCapabilities.CONTENTS_PARSERS_ = ol.xml.makeParsersNS(
|
||||
ol.format.WMTSCapabilities.NAMESPACE_URIS_, {
|
||||
'Layer': ol.xml.makeObjectPropertyPusher(
|
||||
ol.format.WMTSCapabilities.readLayer_),
|
||||
'TileMatrixSet': ol.xml.makeObjectPropertyPusher(
|
||||
ol.format.WMTSCapabilities.readTileMatrixSet_)
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, ol.xml.Parser>>}
|
||||
* @private
|
||||
*/
|
||||
ol.format.WMTSCapabilities.LAYER_PARSERS_ = ol.xml.makeParsersNS(
|
||||
ol.format.WMTSCapabilities.NAMESPACE_URIS_, {
|
||||
'Style': ol.xml.makeObjectPropertyPusher(
|
||||
ol.format.WMTSCapabilities.readStyle_),
|
||||
'Format': ol.xml.makeObjectPropertyPusher(
|
||||
ol.format.XSD.readString),
|
||||
'TileMatrixSetLink': ol.xml.makeObjectPropertyPusher(
|
||||
ol.format.WMTSCapabilities.readTileMatrixSetLink_),
|
||||
'ResourceURL': ol.xml.makeObjectPropertyPusher(
|
||||
ol.format.WMTSCapabilities.readResourceUrl_)
|
||||
}, ol.xml.makeParsersNS(ol.format.WMTSCapabilities.OWS_NAMESPACE_URIS_, {
|
||||
'Title': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.XSD.readString),
|
||||
'Abstract': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.XSD.readString),
|
||||
'WGS84BoundingBox': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.WMTSCapabilities.readWgs84BoundingBox_),
|
||||
'Identifier': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.XSD.readString)
|
||||
}));
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, ol.xml.Parser>>}
|
||||
* @private
|
||||
*/
|
||||
ol.format.WMTSCapabilities.STYLE_PARSERS_ = ol.xml.makeParsersNS(
|
||||
ol.format.WMTSCapabilities.NAMESPACE_URIS_, {
|
||||
'LegendURL': ol.xml.makeObjectPropertyPusher(
|
||||
ol.format.WMTSCapabilities.readLegendUrl_)
|
||||
}, ol.xml.makeParsersNS(ol.format.WMTSCapabilities.OWS_NAMESPACE_URIS_, {
|
||||
'Title': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.XSD.readString),
|
||||
'Identifier': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.XSD.readString)
|
||||
}));
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, ol.xml.Parser>>}
|
||||
* @private
|
||||
*/
|
||||
ol.format.WMTSCapabilities.TMS_LINKS_PARSERS_ = ol.xml.makeParsersNS(
|
||||
ol.format.WMTSCapabilities.NAMESPACE_URIS_, {
|
||||
'TileMatrixSet': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.XSD.readString)
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, ol.xml.Parser>>}
|
||||
* @private
|
||||
*/
|
||||
ol.format.WMTSCapabilities.WGS84_BBOX_READERS_ = ol.xml.makeParsersNS(
|
||||
ol.format.WMTSCapabilities.OWS_NAMESPACE_URIS_, {
|
||||
'LowerCorner': ol.xml.makeArrayPusher(
|
||||
ol.format.WMTSCapabilities.readCoordinates_),
|
||||
'UpperCorner': ol.xml.makeArrayPusher(
|
||||
ol.format.WMTSCapabilities.readCoordinates_)
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, ol.xml.Parser>>}
|
||||
* @private
|
||||
*/
|
||||
ol.format.WMTSCapabilities.TMS_PARSERS_ = ol.xml.makeParsersNS(
|
||||
ol.format.WMTSCapabilities.NAMESPACE_URIS_, {
|
||||
'WellKnownScaleSet': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.XSD.readString),
|
||||
'TileMatrix': ol.xml.makeObjectPropertyPusher(
|
||||
ol.format.WMTSCapabilities.readTileMatrix_)
|
||||
}, ol.xml.makeParsersNS(ol.format.WMTSCapabilities.OWS_NAMESPACE_URIS_, {
|
||||
'SupportedCRS': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.XSD.readString),
|
||||
'Identifier': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.XSD.readString)
|
||||
}));
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, ol.xml.Parser>>}
|
||||
* @private
|
||||
*/
|
||||
ol.format.WMTSCapabilities.TM_PARSERS_ = ol.xml.makeParsersNS(
|
||||
ol.format.WMTSCapabilities.NAMESPACE_URIS_, {
|
||||
'TopLeftCorner': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.WMTSCapabilities.readCoordinates_),
|
||||
'ScaleDenominator': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.XSD.readDecimal),
|
||||
'TileWidth': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.XSD.readNonNegativeInteger),
|
||||
'TileHeight': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.XSD.readNonNegativeInteger),
|
||||
'MatrixWidth': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.XSD.readNonNegativeInteger),
|
||||
'MatrixHeight': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.XSD.readNonNegativeInteger)
|
||||
}, ol.xml.makeParsersNS(ol.format.WMTSCapabilities.OWS_NAMESPACE_URIS_, {
|
||||
'Identifier': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.XSD.readString)
|
||||
}));
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
184
test/spec/ol/format/wmts/ogcsample.xml
Normal file
184
test/spec/ol/format/wmts/ogcsample.xml
Normal 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>
|
||||
106
test/spec/ol/format/wmtscapabilitiesformat.test.js
Normal file
106
test/spec/ol/format/wmtscapabilitiesformat.test.js
Normal 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');
|
||||
Reference in New Issue
Block a user