No more looping through attributes and complex attributes; set all in the first pass instead.
This commit is contained in:
@@ -238,21 +238,7 @@ OpenLayers.Format.WMSCapabilities.v1 = OpenLayers.Class(
|
|||||||
obj.exception = {formats: []};
|
obj.exception = {formats: []};
|
||||||
this.readChildNodes(node, obj.exception);
|
this.readChildNodes(node, obj.exception);
|
||||||
},
|
},
|
||||||
"Layer": (function() {
|
"Layer": function(node, obj) {
|
||||||
var defaults = {
|
|
||||||
cascaded: 0,
|
|
||||||
fixedWidth: 0,
|
|
||||||
fixedHeight: 0,
|
|
||||||
queryable: false,
|
|
||||||
opaque: false,
|
|
||||||
noSubsets: false
|
|
||||||
},
|
|
||||||
attributes = ["queryable", "cascaded", "fixedWidth",
|
|
||||||
"fixedHeight", "opaque", "noSubsets", "llbbox",
|
|
||||||
"minScale", "maxScale", "attribution"],
|
|
||||||
complexAttr = ["srs", "bbox", "dimensions", "authorityURLs"];
|
|
||||||
|
|
||||||
return function(node, obj) {
|
|
||||||
var parentLayer, capability;
|
var parentLayer, capability;
|
||||||
if (obj.capability) {
|
if (obj.capability) {
|
||||||
capability = obj.capability;
|
capability = obj.capability;
|
||||||
@@ -272,20 +258,37 @@ OpenLayers.Format.WMSCapabilities.v1 = OpenLayers.Class(
|
|||||||
var noSubsets = node.getAttribute('noSubsets');
|
var noSubsets = node.getAttribute('noSubsets');
|
||||||
var fixedWidth = node.getAttribute('fixedWidth');
|
var fixedWidth = node.getAttribute('fixedWidth');
|
||||||
var fixedHeight = node.getAttribute('fixedHeight');
|
var fixedHeight = node.getAttribute('fixedHeight');
|
||||||
var layer = {nestedLayers: [], styles: [], srs: {},
|
var parent = parentLayer || {},
|
||||||
metadataURLs: [], bbox: {}, dimensions: {},
|
extend = OpenLayers.Util.extend;
|
||||||
authorityURLs: {}, identifiers: {}, keywords: [],
|
var layer = {
|
||||||
|
nestedLayers: [],
|
||||||
|
styles: parentLayer ? [].concat(parentLayer.styles) : [],
|
||||||
|
srs: parentLayer ? extend({}, parent.srs) : {},
|
||||||
|
metadataURLs: [],
|
||||||
|
bbox: parentLayer ? extend({}, parent.bbox) : {},
|
||||||
|
llbbox: parent.llbbox,
|
||||||
|
dimensions: parentLayer ? extend({}, parent.dimensions) : {},
|
||||||
|
authorityURLs: parentLayer ? extend({}, parent.authorityURLs) : {},
|
||||||
|
identifiers: {},
|
||||||
|
keywords: [],
|
||||||
queryable: (queryable && queryable !== "") ?
|
queryable: (queryable && queryable !== "") ?
|
||||||
( queryable === "1" || queryable === "true" ) : null,
|
(queryable === "1" || queryable === "true" ) :
|
||||||
cascaded: (cascaded !== null) ? parseInt(cascaded) : null,
|
(parent.queryable || false),
|
||||||
|
cascaded: (cascaded !== null) ? parseInt(cascaded) :
|
||||||
|
(parent.cascaded || 0),
|
||||||
opaque: opaque ?
|
opaque: opaque ?
|
||||||
(opaque === "1" || opaque === "true" ) : null,
|
(opaque === "1" || opaque === "true" ) :
|
||||||
|
(parent.opaque || false),
|
||||||
noSubsets: (noSubsets !== null) ?
|
noSubsets: (noSubsets !== null) ?
|
||||||
( noSubsets === "1" || noSubsets === "true" ) : null,
|
(noSubsets === "1" || noSubsets === "true" ) :
|
||||||
|
(parent.noSubsets || false),
|
||||||
fixedWidth: (fixedWidth != null) ?
|
fixedWidth: (fixedWidth != null) ?
|
||||||
parseInt(fixedWidth) : null,
|
parseInt(fixedWidth) : (parent.fixedWidth || 0),
|
||||||
fixedHeight: (fixedHeight != null) ?
|
fixedHeight: (fixedHeight != null) ?
|
||||||
parseInt(fixedHeight) : null
|
parseInt(fixedHeight) : (parent.fixedHeight || 0),
|
||||||
|
minScale: parent.minScale,
|
||||||
|
maxScale: parent.maxScale,
|
||||||
|
attribution: parent.attribution,
|
||||||
};
|
};
|
||||||
obj.nestedLayers.push(layer);
|
obj.nestedLayers.push(layer);
|
||||||
layer.capability = capability;
|
layer.capability = capability;
|
||||||
@@ -305,37 +308,8 @@ OpenLayers.Format.WMSCapabilities.v1 = OpenLayers.Class(
|
|||||||
if (layer.infoFormats === undefined && gfi) {
|
if (layer.infoFormats === undefined && gfi) {
|
||||||
layer.infoFormats = gfi.formats;
|
layer.infoFormats = gfi.formats;
|
||||||
}
|
}
|
||||||
|
|
||||||
// deal with property inheritance
|
|
||||||
if(parentLayer) {
|
|
||||||
// add style
|
|
||||||
layer.styles = layer.styles.concat(parentLayer.styles);
|
|
||||||
var parentValue, key, i, len;
|
|
||||||
|
|
||||||
for (i=0, len=attributes.length; i<len; i++) {
|
|
||||||
key = attributes[i];
|
|
||||||
if (key in parentLayer) {
|
|
||||||
// only take parent value if not present (null
|
|
||||||
// or undefined)
|
|
||||||
if (layer[key] == null) {
|
|
||||||
parentValue = parentLayer[key];
|
|
||||||
// if we haven't inherited anything from a
|
|
||||||
// parent layer set to default value
|
|
||||||
layer[key] = parentValue == null ?
|
|
||||||
defaults[key] : parentValue;
|
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}
|
|
||||||
|
|
||||||
for (i=0, len=complexAttr.length; i<len; i++) {
|
|
||||||
key = complexAttr[i];
|
|
||||||
OpenLayers.Util.applyDefaults(
|
|
||||||
layer[key], parentLayer[key]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})(),
|
|
||||||
"Attribution": function(node, obj) {
|
"Attribution": function(node, obj) {
|
||||||
obj.attribution = {};
|
obj.attribution = {};
|
||||||
this.readChildNodes(node, obj.attribution);
|
this.readChildNodes(node, obj.attribution);
|
||||||
|
|||||||
Reference in New Issue
Block a user