Merge pull request #40 from elemoine/wmtscaps
Make OWSCommon v1 support constraints in Get and Post nodes, and respect the 1..* cardinality.
This commit is contained in:
@@ -171,12 +171,24 @@ OpenLayers.Format.OWSCommon.v1 = OpenLayers.Class(OpenLayers.Format.XML, {
|
|||||||
this.readChildNodes(node, dcp.http);
|
this.readChildNodes(node, dcp.http);
|
||||||
},
|
},
|
||||||
"Get": function(node, http) {
|
"Get": function(node, http) {
|
||||||
http.get = this.getAttributeNS(node,
|
if (!http.get) {
|
||||||
this.namespaces.xlink, "href");
|
http.get = [];
|
||||||
|
}
|
||||||
|
var obj = {
|
||||||
|
url: this.getAttributeNS(node, this.namespaces.xlink, "href")
|
||||||
|
};
|
||||||
|
this.readChildNodes(node, obj);
|
||||||
|
http.get.push(obj);
|
||||||
},
|
},
|
||||||
"Post": function(node, http) {
|
"Post": function(node, http) {
|
||||||
http.post = this.getAttributeNS(node,
|
if (!http.post) {
|
||||||
this.namespaces.xlink, "href");
|
http.post = [];
|
||||||
|
}
|
||||||
|
var obj = {
|
||||||
|
url: this.getAttributeNS(node, this.namespaces.xlink, "href")
|
||||||
|
};
|
||||||
|
this.readChildNodes(node, obj);
|
||||||
|
http.post.push(obj);
|
||||||
},
|
},
|
||||||
"Parameter": function(node, operation) {
|
"Parameter": function(node, operation) {
|
||||||
if (!operation.parameters) {
|
if (!operation.parameters) {
|
||||||
@@ -186,6 +198,14 @@ OpenLayers.Format.OWSCommon.v1 = OpenLayers.Class(OpenLayers.Format.XML, {
|
|||||||
operation.parameters[name] = {};
|
operation.parameters[name] = {};
|
||||||
this.readChildNodes(node, operation.parameters[name]);
|
this.readChildNodes(node, operation.parameters[name]);
|
||||||
},
|
},
|
||||||
|
"Constraint": function(node, obj) {
|
||||||
|
if (!obj.constraints) {
|
||||||
|
obj.constraints = {};
|
||||||
|
}
|
||||||
|
var name = node.getAttribute("name");
|
||||||
|
obj.constraints[name] = {};
|
||||||
|
this.readChildNodes(node, obj.constraints[name]);
|
||||||
|
},
|
||||||
"Value": function(node, allowedValues) {
|
"Value": function(node, allowedValues) {
|
||||||
allowedValues[this.getChildValue(node)] = true;
|
allowedValues[this.getChildValue(node)] = true;
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ OpenLayers.Format.WMTSCapabilities = OpenLayers.Class(OpenLayers.Format.XML.Vers
|
|||||||
OpenLayers.Util.applyDefaults(config, {
|
OpenLayers.Util.applyDefaults(config, {
|
||||||
url: config.requestEncoding === "REST" && layerDef.resourceUrl ?
|
url: config.requestEncoding === "REST" && layerDef.resourceUrl ?
|
||||||
layerDef.resourceUrl.tile.template :
|
layerDef.resourceUrl.tile.template :
|
||||||
capabilities.operationsMetadata.GetTile.dcp.http.get,
|
capabilities.operationsMetadata.GetTile.dcp.http.get[0].url,
|
||||||
name: layerDef.title,
|
name: layerDef.title,
|
||||||
style: style.identifier,
|
style: style.identifier,
|
||||||
matrixIds: matrixSet.matrixIds,
|
matrixIds: matrixSet.matrixIds,
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
function test_read_exception(t) {
|
function test_read_exception(t) {
|
||||||
t.plan(6);
|
t.plan(6);
|
||||||
var text = '<?xml version="1.0" encoding="UTF-8"?>' +
|
var text = '<?xml version="1.0" encoding="UTF-8"?>' +
|
||||||
'<ows:ExceptionReport xml:lang="en" version="1.0.0"' +
|
'<ows:ExceptionReport xml:lang="en" version="1.1.0"' +
|
||||||
' xsi:schemaLocation="http://www.opengis.net/ows http://schemas.opengis.net/ows/1.1.0/owsExceptionReport.xsd"' +
|
' xsi:schemaLocation="http://www.opengis.net/ows http://schemas.opengis.net/ows/1.1.0/owsExceptionReport.xsd"' +
|
||||||
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ows="http://www.opengis.net/ows/1.1">' +
|
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ows="http://www.opengis.net/ows/1.1">' +
|
||||||
' <ows:Exception locator="foo" exceptionCode="InvalidParameterValue">' +
|
' <ows:Exception locator="foo" exceptionCode="InvalidParameterValue">' +
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
var format = new OpenLayers.Format.OWSCommon();
|
var format = new OpenLayers.Format.OWSCommon();
|
||||||
var result = format.read(text);
|
var result = format.read(text);
|
||||||
var report = result.exceptionReport;
|
var report = result.exceptionReport;
|
||||||
t.eq(report.version, "1.0.0", "Version parsed correctly");
|
t.eq(report.version, "1.1.0", "Version parsed correctly");
|
||||||
t.eq(report.language, "en", "Language parsed correctly");
|
t.eq(report.language, "en", "Language parsed correctly");
|
||||||
var exception = report.exceptions[0];
|
var exception = report.exceptions[0];
|
||||||
t.eq(exception.code, "InvalidParameterValue", "exceptionCode properly parsed");
|
t.eq(exception.code, "InvalidParameterValue", "exceptionCode properly parsed");
|
||||||
|
|||||||
@@ -40,7 +40,7 @@
|
|||||||
t.eq(obj.serviceProvider.serviceContact.contactInfo.phone.voice, "+49-251-83-30088", "Voice phone correctly parsed");
|
t.eq(obj.serviceProvider.serviceContact.contactInfo.phone.voice, "+49-251-83-30088", "Voice phone correctly parsed");
|
||||||
|
|
||||||
// operationsMetadata (from OWSCommon)
|
// operationsMetadata (from OWSCommon)
|
||||||
t.eq(obj.operationsMetadata.DescribeSensor.dcp.http.post, "http://v-swe.uni-muenster.de:8080/WeatherSOS/sos", "POST url for DescribeSensor correctly parsed");
|
t.eq(obj.operationsMetadata.DescribeSensor.dcp.http.post[0].url, "http://v-swe.uni-muenster.de:8080/WeatherSOS/sos", "POST url for DescribeSensor correctly parsed");
|
||||||
var counter = 0;
|
var counter = 0;
|
||||||
for (var key in obj.operationsMetadata.DescribeSensor.parameters.procedure.allowedValues) {
|
for (var key in obj.operationsMetadata.DescribeSensor.parameters.procedure.allowedValues) {
|
||||||
if (counter == 0) {
|
if (counter == 0) {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
function test_ows(t) {
|
function test_ows(t) {
|
||||||
t.plan(17);
|
t.plan(20);
|
||||||
var xml = document.getElementById("ogcsample").firstChild.nodeValue;
|
var xml = document.getElementById("ogcsample").firstChild.nodeValue;
|
||||||
var doc = new OpenLayers.Format.XML().read(xml);
|
var doc = new OpenLayers.Format.XML().read(xml);
|
||||||
var obj = new OpenLayers.Format.WMTSCapabilities().read(doc);
|
var obj = new OpenLayers.Format.WMTSCapabilities().read(doc);
|
||||||
@@ -31,8 +31,17 @@
|
|||||||
// ows:OperationsMetadata
|
// ows:OperationsMetadata
|
||||||
var operationsMetadata = obj.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.GetCapabilities.dcp.http.get, "http://www.miramon.uab.es/cgi-bin/MiraMon5_0.cgi?", "ows:OperationsMetadata GetCapabilities url is correct");
|
||||||
|
t.eq(operationsMetadata.GetCapabilities.dcp.http.constraints.get.GetEncoding.allowedValues,
|
||||||
|
{'KVP': true},
|
||||||
|
"ows:OperationsMetadata GetCapabilities Constraints Get 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.GetFeatureInfo.dcp.http.get, "http://www.miramon.uab.es/cgi-bin/MiraMon5_0.cgi?", "ows:OperationsMetadata GetFeatureInfo url is correct");
|
||||||
|
t.eq(operationsMetadata.GetFeatureInfo.dcp.http.constraints.get,
|
||||||
|
undefined,
|
||||||
|
"ows:OperationsMetadata GetFeatureInfo Constraints Get 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");
|
t.eq(operationsMetadata.GetTile.dcp.http.get, "http://www.miramon.uab.es/cgi-bin/MiraMon5_0.cgi?", "ows:OperationsMetadata GetTile url is correct");
|
||||||
|
t.eq(operationsMetadata.GetTile.dcp.http.constraints.get,
|
||||||
|
undefined,
|
||||||
|
"ows:OperationsMetadata GetTile Constraints Get is correct");
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_layers(t) {
|
function test_layers(t) {
|
||||||
@@ -47,7 +56,7 @@
|
|||||||
t.eq(numOfLayers, 1, "correct count of layers");
|
t.eq(numOfLayers, 1, "correct count of layers");
|
||||||
|
|
||||||
var layer = contents.layers[0];
|
var layer = contents.layers[0];
|
||||||
t.eq(layer.abstract, "Coastline/shorelines (BA010)", "layer abstract is correct");
|
t.eq(layer['abstract'], "Coastline/shorelines (BA010)", "layer abstract is correct");
|
||||||
t.eq(layer.identifier, "coastlines", "layer identifier is correct");
|
t.eq(layer.identifier, "coastlines", "layer identifier is correct");
|
||||||
t.eq(layer.title, "Coastlines", "layer title is correct");
|
t.eq(layer.title, "Coastlines", "layer title is correct");
|
||||||
|
|
||||||
@@ -90,7 +99,7 @@
|
|||||||
var dimensions = layer.dimensions;
|
var dimensions = layer.dimensions;
|
||||||
t.eq(dimensions.length, 1, "correct count of dimensions");
|
t.eq(dimensions.length, 1, "correct count of dimensions");
|
||||||
t.eq(dimensions[0].title, "Time", "first dimension title is correct");
|
t.eq(dimensions[0].title, "Time", "first dimension title is correct");
|
||||||
t.eq(dimensions[0].abstract, "Monthly datasets", "first dimension abstract is correct");
|
t.eq(dimensions[0]['abstract'], "Monthly datasets", "first dimension abstract is correct");
|
||||||
t.eq(dimensions[0].identifier, "TIME", "first dimension identifier is correct");
|
t.eq(dimensions[0].identifier, "TIME", "first dimension identifier is correct");
|
||||||
t.eq(dimensions[0]['default'], "default", "first dimension default is correct");
|
t.eq(dimensions[0]['default'], "default", "first dimension default is correct");
|
||||||
t.eq(dimensions[0].values.length, 3, "first dimension has correct count of values");
|
t.eq(dimensions[0].values.length, 3, "first dimension has correct count of values");
|
||||||
|
|||||||
Reference in New Issue
Block a user