Adding more complete WMS capabilities parsing. Thanks trondmm for the comprehensive patch. Some minor changes by me - including leaving the srs member value an object. r=me (closes #2164)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@9664 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -63,6 +63,183 @@ OpenLayers.Format.WMSCapabilities.v1_1 = OpenLayers.Class(
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method: read_cap_Service
|
||||||
|
*/
|
||||||
|
read_cap_Service: function(capabilities, node) {
|
||||||
|
var service = {};
|
||||||
|
this.runChildNodes(service, node);
|
||||||
|
capabilities.service = service;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method: read_cap_Fees
|
||||||
|
*/
|
||||||
|
read_cap_Fees: function(service, node) {
|
||||||
|
var fees = this.getChildValue(node);
|
||||||
|
if (fees && fees.toLowerCase() != "none") {
|
||||||
|
service.fees = fees;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method: read_cap_AccessConstraints
|
||||||
|
*/
|
||||||
|
read_cap_AccessConstraints: function(service, node) {
|
||||||
|
var constraints = this.getChildValue(node);
|
||||||
|
if (constraints && constraints.toLowerCase() != "none") {
|
||||||
|
service.accessConstraints = constraints;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method: read_cap_ContactInformation
|
||||||
|
*/
|
||||||
|
read_cap_ContactInformation: function(service, node) {
|
||||||
|
var contact = {};
|
||||||
|
this.runChildNodes(contact, node);
|
||||||
|
service.contactInformation = contact;
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method: read_cap_ContactPersonPrimary
|
||||||
|
*/
|
||||||
|
read_cap_ContactPersonPrimary: function(contact, node) {
|
||||||
|
var personPrimary = {};
|
||||||
|
this.runChildNodes(personPrimary, node);
|
||||||
|
contact.personPrimary = personPrimary;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method: read_cap_ContactPerson
|
||||||
|
*/
|
||||||
|
read_cap_ContactPerson: function(primaryPerson, node) {
|
||||||
|
var person = this.getChildValue(node);
|
||||||
|
if (person) {
|
||||||
|
primaryPerson.person = person;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method: read_cap_ContactOrganization
|
||||||
|
*/
|
||||||
|
read_cap_ContactOrganization: function(primaryPerson, node) {
|
||||||
|
var organization = this.getChildValue(node);
|
||||||
|
if (organization) {
|
||||||
|
primaryPerson.organization = organization;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method: read_cap_ContactPosition
|
||||||
|
*/
|
||||||
|
read_cap_ContactPosition: function(contact, node) {
|
||||||
|
var position = this.getChildValue(node);
|
||||||
|
if (position) {
|
||||||
|
contact.position = position;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method: read_cap_ContactAddress
|
||||||
|
*/
|
||||||
|
read_cap_ContactAddress: function(contact, node) {
|
||||||
|
var contactAddress = {};
|
||||||
|
this.runChildNodes(contactAddress, node);
|
||||||
|
contact.contactAddress = contactAddress;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method: read_cap_AddressType
|
||||||
|
*/
|
||||||
|
read_cap_AddressType: function(contactAddress, node) {
|
||||||
|
var type = this.getChildValue(node);
|
||||||
|
if (type) {
|
||||||
|
contactAddress.type = type;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method: read_cap_Address
|
||||||
|
*/
|
||||||
|
read_cap_Address: function(contactAddress, node) {
|
||||||
|
var address = this.getChildValue(node);
|
||||||
|
if (address) {
|
||||||
|
contactAddress.address = address;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method: read_cap_City
|
||||||
|
*/
|
||||||
|
read_cap_City: function(contactAddress, node) {
|
||||||
|
var city = this.getChildValue(node);
|
||||||
|
if (city) {
|
||||||
|
contactAddress.city = city;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method: read_cap_StateOrProvince
|
||||||
|
*/
|
||||||
|
read_cap_StateOrProvince: function(contactAddress, node) {
|
||||||
|
var stateOrProvince = this.getChildValue(node);
|
||||||
|
if (stateOrProvince) {
|
||||||
|
contactAddress.stateOrProvince = stateOrProvince;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method: read_cap_PostCode
|
||||||
|
*/
|
||||||
|
read_cap_PostCode: function(contactAddress, node) {
|
||||||
|
var postcode = this.getChildValue(node);
|
||||||
|
if (postcode) {
|
||||||
|
contactAddress.postcode = postcode;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method: read_cap_Country
|
||||||
|
*/
|
||||||
|
read_cap_Country: function(contactAddress, node) {
|
||||||
|
var country = this.getChildValue(node);
|
||||||
|
if (country) {
|
||||||
|
contactAddress.country = country;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method: read_cap_ContactVoiceTelephone
|
||||||
|
*/
|
||||||
|
read_cap_ContactVoiceTelephone: function(contact, node) {
|
||||||
|
var phone = this.getChildValue(node);
|
||||||
|
if (phone) {
|
||||||
|
contact.phone = phone;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method: read_cap_ContactFacsimileTelephone
|
||||||
|
*/
|
||||||
|
read_cap_ContactFacsimileTelephone: function(contact, node) {
|
||||||
|
var fax = this.getChildValue(node);
|
||||||
|
if (fax) {
|
||||||
|
contact.fax = fax;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method: read_cap_ContactElectronicMailAddress
|
||||||
|
*/
|
||||||
|
read_cap_ContactElectronicMailAddress: function(contact, node) {
|
||||||
|
var email = this.getChildValue(node);
|
||||||
|
if (email) {
|
||||||
|
contact.email = email;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method: read_cap_Capability
|
* Method: read_cap_Capability
|
||||||
*/
|
*/
|
||||||
@@ -94,6 +271,72 @@ OpenLayers.Format.WMSCapabilities.v1_1 = OpenLayers.Class(
|
|||||||
request.getmap = getmap;
|
request.getmap = getmap;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method: read_cap_GetCapabilities
|
||||||
|
*/
|
||||||
|
read_cap_GetCapabilities: function(request, node) {
|
||||||
|
var getcapabilities = {
|
||||||
|
formats: []
|
||||||
|
};
|
||||||
|
this.runChildNodes(getcapabilities, node);
|
||||||
|
request.getcapabilities = getcapabilities;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method: read_cap_GetFeatureInfo
|
||||||
|
*/
|
||||||
|
read_cap_GetFeatureInfo: function(request, node) {
|
||||||
|
var getfeatureinfo = {
|
||||||
|
formats: []
|
||||||
|
};
|
||||||
|
this.runChildNodes(getfeatureinfo, node);
|
||||||
|
request.getfeatureinfo = getfeatureinfo;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method: read_cap_DescribeLayer
|
||||||
|
*/
|
||||||
|
read_cap_DescribeLayer: function(request, node) {
|
||||||
|
var describelayer = {
|
||||||
|
formats: []
|
||||||
|
};
|
||||||
|
this.runChildNodes(describelayer, node);
|
||||||
|
request.describelayer = describelayer;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method: read_cap_GetLegendGraphic
|
||||||
|
*/
|
||||||
|
read_cap_GetLegendGraphic: function(request, node) {
|
||||||
|
var getlegendgraphic = {
|
||||||
|
formats: []
|
||||||
|
};
|
||||||
|
this.runChildNodes(getlegendgraphic, node);
|
||||||
|
request.getlegendgraphic = getlegendgraphic;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method: read_cap_GetStyles
|
||||||
|
*/
|
||||||
|
read_cap_GetStyles: function(request, node) {
|
||||||
|
var getstyles = {
|
||||||
|
formats: []
|
||||||
|
};
|
||||||
|
this.runChildNodes(getstyles, node);
|
||||||
|
request.getstyles = getstyles;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method: read_cap_PutStyles
|
||||||
|
*/
|
||||||
|
read_cap_PutStyles: function(request, node) {
|
||||||
|
var putstyles = {
|
||||||
|
formats: []
|
||||||
|
};
|
||||||
|
this.runChildNodes(putstyles, node);
|
||||||
|
request.putstyles = putstyles;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method: read_cap_Format
|
* Method: read_cap_Format
|
||||||
*/
|
*/
|
||||||
@@ -119,12 +362,27 @@ OpenLayers.Format.WMSCapabilities.v1_1 = OpenLayers.Class(
|
|||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method: read_cap_Service
|
* Method: read_cap_Exception
|
||||||
*/
|
*/
|
||||||
read_cap_Service: function(capabilities, node) {
|
read_cap_Exception: function(capability, node) {
|
||||||
var service = {};
|
var exception = {
|
||||||
this.runChildNodes(service, node);
|
formats: []
|
||||||
capabilities.service = service;
|
};
|
||||||
|
this.runChildNodes(exception, node);
|
||||||
|
capability.exception = exception;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method: read_cap_UserDefinedSymbolization
|
||||||
|
*/
|
||||||
|
read_cap_UserDefinedSymbolization: function(capability, node) {
|
||||||
|
var userSymbols = {
|
||||||
|
supportSLD: parseInt(node.getAttribute("SupportSLD")) == 1,
|
||||||
|
userLayer: parseInt(node.getAttribute("UserLayer")) == 1,
|
||||||
|
userStyle: parseInt(node.getAttribute("UserStyle")) == 1,
|
||||||
|
remoteWFS: parseInt(node.getAttribute("RemoteWFS")) == 1
|
||||||
|
};
|
||||||
|
capability.userSymbols = userSymbols;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -134,20 +392,82 @@ OpenLayers.Format.WMSCapabilities.v1_1 = OpenLayers.Class(
|
|||||||
var layer = {
|
var layer = {
|
||||||
formats: capability.request.getmap.formats || [],
|
formats: capability.request.getmap.formats || [],
|
||||||
styles: [],
|
styles: [],
|
||||||
|
srs: {},
|
||||||
|
bbox: {},
|
||||||
|
dimensions: {},
|
||||||
metadataURLs: [],
|
metadataURLs: [],
|
||||||
keywords: [],
|
authorityURLs: {},
|
||||||
queryable: (node.getAttribute("queryable") === "1"
|
identifiers: {},
|
||||||
|| node.getAttribute("queryable") === "true")
|
keywords: []
|
||||||
};
|
};
|
||||||
|
|
||||||
// deal with property inheritance
|
// deal with property inheritance
|
||||||
if(parentLayer) {
|
if(parentLayer) {
|
||||||
// add style
|
// add style
|
||||||
layer.styles = layer.styles.concat(parentLayer.styles);
|
layer.styles = layer.styles.concat(parentLayer.styles);
|
||||||
// use llbbox
|
|
||||||
layer.llbbox = parentLayer.llbbox;
|
var attributes = ["queryable",
|
||||||
// use min/maxScale
|
"cascaded",
|
||||||
layer.minScale = parentLayer.minScale;
|
"fixedWidth",
|
||||||
layer.maxScale = parentLayer.maxScale;
|
"fixedHeight",
|
||||||
|
"opaque",
|
||||||
|
"noSubsets",
|
||||||
|
"llbbox",
|
||||||
|
"minScale",
|
||||||
|
"maxScale",
|
||||||
|
"attribution"];
|
||||||
|
|
||||||
|
var complexAttr = ["srs",
|
||||||
|
"bbox",
|
||||||
|
"dimensions",
|
||||||
|
"authorityURLs"];
|
||||||
|
|
||||||
|
var key;
|
||||||
|
for (var i=0; i<attributes.length; i++) {
|
||||||
|
key = attributes[i];
|
||||||
|
if (key in parentLayer) {
|
||||||
|
layer[key] = parentLayer[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var i=0; i<complexAttr.length; i++) {
|
||||||
|
key = complexAttr[i];
|
||||||
|
layer[key] = OpenLayers.Util.extend(
|
||||||
|
layer[key], parentLayer[key]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
var intAttr = ["cascaded", "fixedWidth", "fixedHeight"];
|
||||||
|
var boolAttr = ["queryable", "opaque", "noSubsets"];
|
||||||
|
|
||||||
|
for (var i=0; i<intAttr.length; i++) {
|
||||||
|
var attr = intAttr[i];
|
||||||
|
var attrNode = node.getAttributeNode(attr);
|
||||||
|
if (attrNode && attrNode.specified) {
|
||||||
|
// if attribute is present, override inherited value
|
||||||
|
layer[attr] = parseInt(attrNode.value);
|
||||||
|
} else if (! (attr in layer)) {
|
||||||
|
// if attribute isn't present, and we haven't
|
||||||
|
// inherited anything from a parent layer
|
||||||
|
// set to default value
|
||||||
|
layer[attr] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (var i=0; i<boolAttr.length; i++) {
|
||||||
|
var attr = boolAttr[i];
|
||||||
|
var attrNode = node.getAttributeNode(attr);
|
||||||
|
if (attrNode && attrNode.specified) {
|
||||||
|
// if attribute is present, override inherited value
|
||||||
|
var value = attrNode.value;
|
||||||
|
layer[attr] = ( value === "1" || value === "true" );
|
||||||
|
} else if (! (attr in layer)) {
|
||||||
|
// if attribute isn't present, and we haven't
|
||||||
|
// inherited anything from a parent layer
|
||||||
|
// set to default value
|
||||||
|
layer[attr] = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
var children = node.childNodes;
|
var children = node.childNodes;
|
||||||
var childNode, nodeName, processor;
|
var childNode, nodeName, processor;
|
||||||
@@ -163,6 +483,7 @@ OpenLayers.Format.WMSCapabilities.v1_1 = OpenLayers.Class(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(layer.name) {
|
if(layer.name) {
|
||||||
var index = layer.name.indexOf(":");
|
var index = layer.name.indexOf(":");
|
||||||
if(index > 0) {
|
if(index > 0) {
|
||||||
@@ -251,6 +572,55 @@ OpenLayers.Format.WMSCapabilities.v1_1 = OpenLayers.Class(
|
|||||||
layer.metadataURLs.push(metadataURL);
|
layer.metadataURLs.push(metadataURL);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method: read_cap_DataURL
|
||||||
|
*/
|
||||||
|
read_cap_DataURL: function(layer, node) {
|
||||||
|
layer.dataURL = {};
|
||||||
|
this.runChildNodes(layer.dataURL, node);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method: read_cap_FeatureListURL
|
||||||
|
*/
|
||||||
|
read_cap_FeatureListURL: function(layer, node) {
|
||||||
|
layer.featureListURL = {};
|
||||||
|
this.runChildNodes(layer.featureListURL, node);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method: read_cap_AuthorityURL
|
||||||
|
*/
|
||||||
|
read_cap_AuthorityURL: function(layer, node) {
|
||||||
|
var name = node.getAttribute("name");
|
||||||
|
if (! (name in layer.authorityURLs)) {
|
||||||
|
var authority = {};
|
||||||
|
this.runChildNodes(authority, node);
|
||||||
|
layer.authorityURLs[name] = authority.href;
|
||||||
|
} else {
|
||||||
|
// A child Layer SHALL NOT define an AuthorityURL with the
|
||||||
|
// same name attribute as one inherited from a parent
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method: read_cap_Identifier
|
||||||
|
*/
|
||||||
|
read_cap_Identifier: function(layer, node) {
|
||||||
|
var authority = node.getAttribute("authority");
|
||||||
|
|
||||||
|
if (authority in layer.authorityURLs) {
|
||||||
|
layer.identifiers[authority] = this.getChildValue(node);
|
||||||
|
} else {
|
||||||
|
// A layer SHALL NOT declare an Identifier unless a
|
||||||
|
// corresponding authorityURL has been declared or
|
||||||
|
// inherited earlier in the Capabilities XML
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method: read_cap_KeywordList
|
* Method: read_cap_KeywordList
|
||||||
*/
|
*/
|
||||||
@@ -280,6 +650,29 @@ OpenLayers.Format.WMSCapabilities.v1_1 = OpenLayers.Class(
|
|||||||
];
|
];
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method: read_cap_BoundingBox
|
||||||
|
*/
|
||||||
|
read_cap_BoundingBox: function(layer, node) {
|
||||||
|
var bbox = {};
|
||||||
|
bbox.srs = node.getAttribute("SRS");
|
||||||
|
bbox.bbox = [
|
||||||
|
parseFloat(node.getAttribute("minx")),
|
||||||
|
parseFloat(node.getAttribute("miny")),
|
||||||
|
parseFloat(node.getAttribute("maxx")),
|
||||||
|
parseFloat(node.getAttribute("maxy"))
|
||||||
|
];
|
||||||
|
var res = {
|
||||||
|
x: parseFloat(node.getAttribute("resx")),
|
||||||
|
y: parseFloat(node.getAttribute("resy"))
|
||||||
|
};
|
||||||
|
|
||||||
|
if (! (isNaN(res.x) && isNaN(res.y))) {
|
||||||
|
bbox.res = res;
|
||||||
|
}
|
||||||
|
layer.bbox[bbox.srs] = bbox;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method: read_cap_Style
|
* Method: read_cap_Style
|
||||||
*/
|
*/
|
||||||
@@ -289,6 +682,51 @@ OpenLayers.Format.WMSCapabilities.v1_1 = OpenLayers.Class(
|
|||||||
layer.styles.push(style);
|
layer.styles.push(style);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method: read_cap_Dimension
|
||||||
|
*/
|
||||||
|
read_cap_Dimension: function(layer, node) {
|
||||||
|
var name = node.getAttribute("name").toLowerCase();
|
||||||
|
|
||||||
|
if (name in layer["dimensions"]) {
|
||||||
|
// "A child SHALL NOT redefine a Dimension with the same
|
||||||
|
// name attribute as one that was inherited"
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var dim = {
|
||||||
|
name: name,
|
||||||
|
units: node.getAttribute("units"),
|
||||||
|
unitsymbol: node.getAttribute("unitSymbol")
|
||||||
|
};
|
||||||
|
|
||||||
|
layer.dimensions[dim.name] = dim;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method: read_cap_Extent
|
||||||
|
*/
|
||||||
|
read_cap_Extent: function(layer, node) {
|
||||||
|
var name = node.getAttribute("name").toLowerCase();
|
||||||
|
|
||||||
|
if (name in layer["dimensions"]) {
|
||||||
|
var extent = layer.dimensions[name];
|
||||||
|
|
||||||
|
extent.nearestVal = node.getAttribute("nearestValue") === "1";
|
||||||
|
extent.multipleVal = node.getAttribute("multipleValues") === "1";
|
||||||
|
extent.current = node.getAttribute("current") === "1";
|
||||||
|
extent["default"] = node.getAttribute("default") || "";
|
||||||
|
var values = this.getChildValue(node);
|
||||||
|
extent.values = values.split(",");
|
||||||
|
} else {
|
||||||
|
// A layer SHALL NOT declare an Extent unless a Dimension
|
||||||
|
// with the same name has been declared or inherited
|
||||||
|
// earlier in the Capabilities XML
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method: read_cap_LegendURL
|
* Method: read_cap_LegendURL
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -32,6 +32,17 @@ OpenLayers.Format.WMSCapabilities.v1_1_0 = OpenLayers.Class(
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method: read_cap_SRS
|
||||||
|
*/
|
||||||
|
read_cap_SRS: function(layer, node) {
|
||||||
|
var srs = this.getChildValue(node);
|
||||||
|
var values = srs.split(/ +/);
|
||||||
|
for (var i=0, len=values.length; i<len; i++) {
|
||||||
|
layer.srs[values[i]] = true;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
CLASS_NAME: "OpenLayers.Format.WMSCapabilities.v1_1_0"
|
CLASS_NAME: "OpenLayers.Format.WMSCapabilities.v1_1_0"
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -32,6 +32,22 @@ OpenLayers.Format.WMSCapabilities.v1_1_1 = OpenLayers.Class(
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method: read_cap_SRS
|
||||||
|
*/
|
||||||
|
read_cap_SRS: function(layer, node) {
|
||||||
|
var srs = this.getChildValue(node);
|
||||||
|
if (srs.indexOf(" ")) {
|
||||||
|
// v1.1.0 style SRS
|
||||||
|
var values = srs.split(/ +/);
|
||||||
|
for (var i=0, len=values.length; i<len; i++) {
|
||||||
|
layer.srs[values[i]] = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
layer.srs[srs] = true;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
CLASS_NAME: "OpenLayers.Format.WMSCapabilities.v1_1_1"
|
CLASS_NAME: "OpenLayers.Format.WMSCapabilities.v1_1_1"
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -51,8 +51,222 @@
|
|||||||
);
|
);
|
||||||
t.eq(layer.queryable, true, "[2] correct queryable attribute");
|
t.eq(layer.queryable, true, "[2] correct queryable attribute");
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function test_layers(t) {
|
||||||
|
|
||||||
|
t.plan(22);
|
||||||
|
|
||||||
|
var xml = document.getElementById("ogcsample").firstChild.nodeValue;
|
||||||
|
var doc = new OpenLayers.Format.XML().read(xml);
|
||||||
|
|
||||||
|
var obj = new OpenLayers.Format.WMSCapabilities().read(doc);
|
||||||
|
var capability = obj.capability;
|
||||||
|
|
||||||
|
var layers = {};
|
||||||
|
for (var i=0, len=capability.layers.length; i<len; i++) {
|
||||||
|
if ("name" in capability.layers[i]) {
|
||||||
|
layers[ capability.layers[i].name ] = capability.layers[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var rootlayer = capability.layers[ capability.layers.length - 1];
|
||||||
|
|
||||||
|
t.eq(rootlayer.srs,
|
||||||
|
{"EPSG:4326": true},
|
||||||
|
"SRS parsed correctly for root layer");
|
||||||
|
t.eq(layers["ROADS_RIVERS"].srs,
|
||||||
|
{"EPSG:4326": true, "EPSG:26986": true},
|
||||||
|
"Inheritance of SRS handled correctly when adding SRSes");
|
||||||
|
t.eq(layers["Temperature"].srs,
|
||||||
|
{"EPSG:4326": true},
|
||||||
|
"Inheritance of SRS handled correctly when redeclaring an inherited SRS");
|
||||||
|
|
||||||
|
var bbox = layers["ROADS_RIVERS"].bbox["EPSG:26986"];
|
||||||
|
t.eq(bbox.bbox,
|
||||||
|
[189000, 834000, 285000, 962000],
|
||||||
|
"Correct bbox from BoundingBox");
|
||||||
|
t.eq(bbox.res, {x: 1, y: 1}, "Correct resolution");
|
||||||
|
|
||||||
|
bbox = layers["ROADS_1M"].bbox["EPSG:26986"];
|
||||||
|
t.eq(bbox.bbox,
|
||||||
|
[189000, 834000, 285000, 962000],
|
||||||
|
"Correctly inherited bbox");
|
||||||
|
t.eq(bbox.res, {x: 1, y: 1}, "Correctly inherited resolution");
|
||||||
|
|
||||||
|
|
||||||
|
var identifiers = layers["ROADS_RIVERS"].identifiers;
|
||||||
|
var authorities = layers["ROADS_RIVERS"].authorityURLs;
|
||||||
|
|
||||||
|
t.ok(identifiers, "got identifiers from layer ROADS_RIVERS");
|
||||||
|
t.ok("DIF_ID" in identifiers,
|
||||||
|
"authority attribute from Identifiers parsed correctly");
|
||||||
|
t.eq(identifiers["DIF_ID"],
|
||||||
|
"123456",
|
||||||
|
"Identifier value parsed correctly");
|
||||||
|
t.ok("DIF_ID" in authorities,
|
||||||
|
"AuthorityURLs parsed and inherited correctly");
|
||||||
|
t.eq(authorities["DIF_ID"],
|
||||||
|
"http://gcmd.gsfc.nasa.gov/difguide/whatisadif.html",
|
||||||
|
"OnlineResource in AuthorityURLs parsed correctly");
|
||||||
|
|
||||||
|
var featurelist = layers["ROADS_RIVERS"].featureListURL;
|
||||||
|
t.ok(featurelist, "layer has FeatureListURL");
|
||||||
|
t.eq(featurelist.format,
|
||||||
|
"application/vnd.ogc.se_xml",
|
||||||
|
"FeatureListURL format parsed correctly");
|
||||||
|
t.eq(featurelist.href,
|
||||||
|
"http://www.university.edu/data/roads_rivers.gml",
|
||||||
|
"FeatureListURL OnlineResource parsed correctly");
|
||||||
|
|
||||||
|
t.eq(layers["Pressure"].queryable,
|
||||||
|
true,
|
||||||
|
"queryable property inherited correctly");
|
||||||
|
t.eq(layers["ozone_image"].queryable,
|
||||||
|
false,
|
||||||
|
"queryable property has correct default value");
|
||||||
|
t.eq(layers["population"].cascaded,
|
||||||
|
1,
|
||||||
|
"cascaded property parsed correctly");
|
||||||
|
t.eq(layers["ozone_image"].fixedWidth,
|
||||||
|
512,
|
||||||
|
"fixedWidth property correctly parsed");
|
||||||
|
t.eq(layers["ozone_image"].fixedHeight,
|
||||||
|
256,
|
||||||
|
"fixedHeight property correctly parsed");
|
||||||
|
t.eq(layers["ozone_image"].opaque,
|
||||||
|
true,
|
||||||
|
"opaque property parsed correctly");
|
||||||
|
t.eq(layers["ozone_image"].noSubsets,
|
||||||
|
true,
|
||||||
|
"noSubsets property parsed correctly");
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function test_dimensions(t) {
|
||||||
|
|
||||||
|
t.plan(8);
|
||||||
|
|
||||||
|
var xml = document.getElementById("ogcsample").firstChild.nodeValue;
|
||||||
|
var doc = new OpenLayers.Format.XML().read(xml);
|
||||||
|
|
||||||
|
var obj = new OpenLayers.Format.WMSCapabilities().read(doc);
|
||||||
|
var capability = obj.capability;
|
||||||
|
|
||||||
|
var layers = {};
|
||||||
|
for (var i=0, len=capability.layers.length; i<len; i++) {
|
||||||
|
if ("name" in capability.layers[i]) {
|
||||||
|
layers[ capability.layers[i].name ] = capability.layers[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var time = layers["Clouds"].dimensions.time;
|
||||||
|
t.eq(time["default"], "2000-08-22", "Default time value parsed correctly");
|
||||||
|
t.eq(time.values.length, 1, "Currect number of time extent values/periods");
|
||||||
|
t.eq(time.values[0], "1999-01-01/2000-08-22/P1D", "Time extent values parsed correctly");
|
||||||
|
|
||||||
|
var elevation = layers["Pressure"].dimensions.elevation;
|
||||||
|
t.eq(elevation.units, "EPSG:5030", "Dimension units parsed correctly");
|
||||||
|
t.eq(elevation["default"], "0", "Default elevation value parsed correctly");
|
||||||
|
t.eq(elevation.nearestVal, true, "NearestValue parsed correctly");
|
||||||
|
t.eq(elevation.multipleVal, false, "Absense of MultipleValues handled correctly");
|
||||||
|
t.eq(elevation.values,
|
||||||
|
["0","1000","3000","5000","10000"],
|
||||||
|
"Parsing of comma-separated values done correctly");
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function test_contactinfo(t) {
|
||||||
|
t.plan(15);
|
||||||
|
|
||||||
|
var xml = document.getElementById("ogcsample").firstChild.nodeValue;
|
||||||
|
var doc = new OpenLayers.Format.XML().read(xml);
|
||||||
|
|
||||||
|
var obj = new OpenLayers.Format.WMSCapabilities().read(doc);
|
||||||
|
var service = obj.service;
|
||||||
|
|
||||||
|
var contactinfo = service.contactInformation;
|
||||||
|
t.ok(contactinfo, "object contains contactInformation property");
|
||||||
|
|
||||||
|
var personPrimary = contactinfo.personPrimary;
|
||||||
|
t.ok(personPrimary, "object contains personPrimary property");
|
||||||
|
|
||||||
|
t.eq(personPrimary.person, "Jeff deLaBeaujardiere", "ContactPerson parsed correctly");
|
||||||
|
t.eq(personPrimary.organization, "NASA", "ContactOrganization parsed correctly");
|
||||||
|
|
||||||
|
t.eq(contactinfo.position,
|
||||||
|
"Computer Scientist",
|
||||||
|
"ContactPosition parsed correctly");
|
||||||
|
|
||||||
|
|
||||||
|
var addr = contactinfo.contactAddress;
|
||||||
|
t.ok(addr, "object contains contactAddress property");
|
||||||
|
|
||||||
|
t.eq(addr.type, "postal", "AddressType parsed correctly");
|
||||||
|
t.eq(addr.address,
|
||||||
|
"NASA Goddard Space Flight Center, Code 933",
|
||||||
|
"Address parsed correctly");
|
||||||
|
t.eq(addr.city, "Greenbelt", "City parsed correctly");
|
||||||
|
t.eq(addr.stateOrProvince, "MD", "StateOrProvince parsed correctly");
|
||||||
|
t.eq(addr.postcode, "20771", "PostCode parsed correctly");
|
||||||
|
t.eq(addr.country, "USA", "Country parsed correctly");
|
||||||
|
|
||||||
|
t.eq(contactinfo.phone,
|
||||||
|
"+1 301 286-1569",
|
||||||
|
"ContactVoiceTelephone parsed correctly");
|
||||||
|
t.eq(contactinfo.fax,
|
||||||
|
"+1 301 286-1777",
|
||||||
|
"ContactFacsimileTelephone parsed correctly");
|
||||||
|
t.eq(contactinfo.email,
|
||||||
|
"delabeau@iniki.gsfc.nasa.gov",
|
||||||
|
"ContactElectronicMailAddress parsed correctly");
|
||||||
|
}
|
||||||
|
|
||||||
|
function test_feesAndConstraints(t) {
|
||||||
|
t.plan(2);
|
||||||
|
|
||||||
|
var obj = new OpenLayers.Format.WMSCapabilities().read(doc);
|
||||||
|
var service = obj.service;
|
||||||
|
|
||||||
|
t.ok(! ("fees" in service), "Fees=none handled correctly");
|
||||||
|
t.ok(! ("accessConstraints" in service), "AccessConstraints=none handled correctly");
|
||||||
|
}
|
||||||
|
|
||||||
|
function test_requests(t) {
|
||||||
|
t.plan(13);
|
||||||
|
|
||||||
|
var obj = new OpenLayers.Format.WMSCapabilities().read(doc);
|
||||||
|
var request = obj.capability.request;
|
||||||
|
|
||||||
|
t.ok(request, "request property exists");
|
||||||
|
t.ok("getmap" in request, "got GetMap request");
|
||||||
|
|
||||||
|
t.ok("getfeatureinfo" in request, "got GetFeatureInfo request");
|
||||||
|
t.eq(request.getfeatureinfo.formats,
|
||||||
|
["text/plain", "text/html", "application/vnd.ogc.gml"],
|
||||||
|
"GetFeatureInfo formats correctly parsed");
|
||||||
|
|
||||||
|
t.ok("describelayer" in request, "got DescribeLayer request");
|
||||||
|
|
||||||
|
t.ok("getlegendgraphic" in request, "got GetLegendGraphic request");
|
||||||
|
|
||||||
|
var exception = obj.capability.exception;
|
||||||
|
t.ok(exception, "exception property exists");
|
||||||
|
t.eq(exception.formats,
|
||||||
|
["application/vnd.ogc.se_xml"],
|
||||||
|
"Exception Format parsed");
|
||||||
|
|
||||||
|
var userSymbols = obj.capability.userSymbols;
|
||||||
|
t.ok(userSymbols, "userSymbols property exists");
|
||||||
|
t.eq(userSymbols.supportSLD, true, "supportSLD parsed");
|
||||||
|
t.eq(userSymbols.userLayer, true, "userLayer parsed");
|
||||||
|
t.eq(userSymbols.userStyle, true, "userStyle parsed");
|
||||||
|
t.eq(userSymbols.remoteWFS, true, "remoteWFS parsed");
|
||||||
|
|
||||||
|
}
|
||||||
function test_ogc(t) {
|
function test_ogc(t) {
|
||||||
t.plan(14)
|
t.plan(14)
|
||||||
|
|
||||||
@@ -250,14 +464,16 @@ Changes:
|
|||||||
<VendorSpecificCapabilities />
|
<VendorSpecificCapabilities />
|
||||||
<UserDefinedSymbolization SupportSLD="1" UserLayer="1" UserStyle="1"
|
<UserDefinedSymbolization SupportSLD="1" UserLayer="1" UserStyle="1"
|
||||||
RemoteWFS="1" />
|
RemoteWFS="1" />
|
||||||
<Layer>
|
|
||||||
|
|
||||||
|
<Layer>
|
||||||
<Title>Acme Corp. Map Server</Title>
|
<Title>Acme Corp. Map Server</Title>
|
||||||
<SRS>EPSG:4326</SRS>
|
<SRS>EPSG:4326</SRS>
|
||||||
<AuthorityURL name="DIF_ID">
|
<AuthorityURL name="DIF_ID">
|
||||||
<OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple"
|
<OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple"
|
||||||
xlink:href="http://gcmd.gsfc.nasa.gov/difguide/whatisadif.html" />
|
xlink:href="http://gcmd.gsfc.nasa.gov/difguide/whatisadif.html" />
|
||||||
</AuthorityURL>
|
</AuthorityURL>
|
||||||
|
|
||||||
|
|
||||||
<Layer>
|
<Layer>
|
||||||
<Name>ROADS_RIVERS</Name>
|
<Name>ROADS_RIVERS</Name>
|
||||||
<Title>Roads and Rivers</Title>
|
<Title>Roads and Rivers</Title>
|
||||||
@@ -282,7 +498,7 @@ Changes:
|
|||||||
</Attribution>
|
</Attribution>
|
||||||
<Identifier authority="DIF_ID">123456</Identifier>
|
<Identifier authority="DIF_ID">123456</Identifier>
|
||||||
<FeatureListURL>
|
<FeatureListURL>
|
||||||
<Format>application/vnd.ogc.se_xml"</Format>
|
<Format>application/vnd.ogc.se_xml</Format>
|
||||||
<OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple"
|
<OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple"
|
||||||
xlink:href="http://www.university.edu/data/roads_rivers.gml" />
|
xlink:href="http://www.university.edu/data/roads_rivers.gml" />
|
||||||
</FeatureListURL>
|
</FeatureListURL>
|
||||||
@@ -307,6 +523,8 @@ Changes:
|
|||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
<ScaleHint min="4000" max="35000"></ScaleHint>
|
<ScaleHint min="4000" max="35000"></ScaleHint>
|
||||||
|
|
||||||
|
|
||||||
<Layer queryable="1">
|
<Layer queryable="1">
|
||||||
<Name>ROADS_1M</Name>
|
<Name>ROADS_1M</Name>
|
||||||
<Title>Roads at 1:1M scale</Title>
|
<Title>Roads at 1:1M scale</Title>
|
||||||
@@ -320,7 +538,6 @@ Changes:
|
|||||||
<Identifier authority="DIF_ID">123456</Identifier>
|
<Identifier authority="DIF_ID">123456</Identifier>
|
||||||
<MetadataURL type="FGDC">
|
<MetadataURL type="FGDC">
|
||||||
<Format>text/plain</Format>
|
<Format>text/plain</Format>
|
||||||
|
|
||||||
<OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink"
|
<OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
xlink:type="simple"
|
xlink:type="simple"
|
||||||
xlink:href="http://www.university.edu/metadata/roads.txt" />
|
xlink:href="http://www.university.edu/metadata/roads.txt" />
|
||||||
@@ -365,41 +582,45 @@ Changes:
|
|||||||
<LatLonBoundingBox minx="-180" miny="-90" maxx="180" maxy="90" />
|
<LatLonBoundingBox minx="-180" miny="-90" maxx="180" maxy="90" />
|
||||||
<Dimension name="time" units="ISO8601" />
|
<Dimension name="time" units="ISO8601" />
|
||||||
<Extent name="time" default="2000-08-22">1999-01-01/2000-08-22/P1D</Extent>
|
<Extent name="time" default="2000-08-22">1999-01-01/2000-08-22/P1D</Extent>
|
||||||
<Layer>
|
|
||||||
|
|
||||||
|
<Layer>
|
||||||
<Name>Clouds</Name>
|
<Name>Clouds</Name>
|
||||||
<Title>Forecast cloud cover</Title>
|
<Title>Forecast cloud cover</Title>
|
||||||
</Layer>
|
</Layer>
|
||||||
|
|
||||||
<Layer>
|
<Layer>
|
||||||
<Name>Temperature</Name>
|
<Name>Temperature</Name>
|
||||||
<Title>Forecast temperature</Title>
|
<Title>Forecast temperature</Title>
|
||||||
</Layer>
|
</Layer>
|
||||||
<Layer>
|
|
||||||
|
|
||||||
|
<Layer>
|
||||||
<Name>Pressure</Name>
|
<Name>Pressure</Name>
|
||||||
<Title>Forecast barometric pressure</Title>
|
<Title>Forecast barometric pressure</Title>
|
||||||
<Dimension name="time" units="ISO8601" />
|
<Dimension name="time" units="ISO8601" />
|
||||||
<Dimension name="elevation" units="EPSG:5030" />
|
<Dimension name="elevation" units="EPSG:5030" />
|
||||||
<Extent name="time" default="2000-08-22">1999-01-01/2000-08-22/P1D</Extent>
|
<Extent name="time" default="2000-08-22">1999-01-01/2000-08-22/P1D</Extent>
|
||||||
<Extent name="elevation" default="0" nearestValue="1">0,1000,3000,5000,10000</Extent>
|
<Extent name="elevation" default="0" nearestValue="1">0,1000,3000,5000,10000</Extent>
|
||||||
|
|
||||||
</Layer>
|
</Layer>
|
||||||
|
|
||||||
</Layer>
|
</Layer>
|
||||||
|
|
||||||
<Layer opaque="1" noSubsets="1" fixedWidth="512" fixedHeight="256">
|
<Layer opaque="1" noSubsets="1" fixedWidth="512" fixedHeight="256">
|
||||||
<Name>ozone_image</Name>
|
<Name>ozone_image</Name>
|
||||||
<Title>Global ozone distribution (1992)</Title>
|
<Title>Global ozone distribution (1992)</Title>
|
||||||
<LatLonBoundingBox minx="-180" miny="-90" maxx="180" maxy="90" />
|
<LatLonBoundingBox minx="-180" miny="-90" maxx="180" maxy="90" />
|
||||||
<Extent name="time" default="1992">1992</Extent>
|
<Extent name="time" default="1992">1992</Extent>
|
||||||
|
|
||||||
</Layer>
|
</Layer>
|
||||||
|
|
||||||
<Layer cascaded="1">
|
<Layer cascaded="1">
|
||||||
<Name>population</Name>
|
<Name>population</Name>
|
||||||
<Title>World population, annual</Title>
|
<Title>World population, annual</Title>
|
||||||
<LatLonBoundingBox minx="-180" miny="-90" maxx="180" maxy="90" />
|
<LatLonBoundingBox minx="-180" miny="-90" maxx="180" maxy="90" />
|
||||||
<Extent name="time" default="2000">1990/2000/P1Y</Extent>
|
<Extent name="time" default="2000">1990/2000/P1Y</Extent>
|
||||||
|
|
||||||
</Layer>
|
</Layer>
|
||||||
|
|
||||||
</Layer>
|
</Layer>
|
||||||
|
|
||||||
|
|
||||||
</Capability>
|
</Capability>
|
||||||
</WMT_MS_Capabilities>
|
</WMT_MS_Capabilities>
|
||||||
--></div>
|
--></div>
|
||||||
|
|||||||
Reference in New Issue
Block a user