Merge branch 'master' of github.com:openlayers/openlayers

This commit is contained in:
ahocevar
2012-03-04 11:25:10 +01:00
36 changed files with 350 additions and 400 deletions

View File

@@ -91,11 +91,9 @@ OpenLayers.Util.extend = function(destination, source) {
destination = destination || {};
if (source) {
for (var property in source) {
if (Object.prototype.hasOwnProperty.call(source, property)) {
var value = source[property];
if (value !== undefined) {
destination[property] = value;
}
var value = source[property];
if (value !== undefined) {
destination[property] = value;
}
}

View File

@@ -258,9 +258,7 @@ OpenLayers.Control.GetFeature = OpenLayers.Class(OpenLayers.Control, {
activate: function () {
if (!this.active) {
for(var i in this.handlers) {
if (this.handlers.hasOwnProperty(i)) {
this.handlers[i].activate();
}
this.handlers[i].activate();
}
}
return OpenLayers.Control.prototype.activate.apply(
@@ -278,9 +276,7 @@ OpenLayers.Control.GetFeature = OpenLayers.Class(OpenLayers.Control, {
deactivate: function () {
if (this.active) {
for(var i in this.handlers) {
if (this.handlers.hasOwnProperty(i)) {
this.handlers[i].deactivate();
}
this.handlers[i].deactivate();
}
}
return OpenLayers.Control.prototype.deactivate.apply(
@@ -564,9 +560,7 @@ OpenLayers.Control.GetFeature = OpenLayers.Class(OpenLayers.Control, {
unselectAll: function() {
// we'll want an option to supress notification here
for(var fid in this.features) {
if (this.features.hasOwnProperty(fid)) {
this.unselect(this.features[fid]);
}
this.unselect(this.features[fid]);
}
},
@@ -579,9 +573,7 @@ OpenLayers.Control.GetFeature = OpenLayers.Class(OpenLayers.Control, {
*/
setMap: function(map) {
for(var i in this.handlers) {
if (this.handlers.hasOwnProperty(i)) {
this.handlers[i].setMap(map);
}
this.handlers[i].setMap(map);
}
OpenLayers.Control.prototype.setMap.apply(this, arguments);
},

View File

@@ -231,8 +231,8 @@ OpenLayers.Control.Measure = OpenLayers.Class(OpenLayers.Control, {
* mouseposition. feature - {<OpenLayers.Feature.Vector>} The sketch feature.
*/
measureImmediate : function(point, feature, drawing) {
if (drawing && this.delayedTrigger === null &&
!this.handler.freehandMode(this.handler.evt)) {
if (drawing && !this.handler.freehandMode(this.handler.evt)) {
this.cancelDelay();
this.measure(feature.geometry, "measurepartial");
}
},

View File

@@ -193,9 +193,7 @@ OpenLayers.Control.NavigationHistory = OpenLayers.Class(OpenLayers.Control, {
this.next.destroy();
this.deactivate();
for(var prop in this) {
if (this.hasOwnProperty(prop)) {
this[prop] = null;
}
this[prop] = null;
}
},
@@ -336,27 +334,25 @@ OpenLayers.Control.NavigationHistory = OpenLayers.Class(OpenLayers.Control, {
setListeners: function() {
this.listeners = {};
for(var type in this.registry) {
if (this.registry.hasOwnProperty(type)) {
this.listeners[type] = OpenLayers.Function.bind(function() {
if(!this.restoring) {
var state = this.registry[type].apply(this, arguments);
this.previousStack.unshift(state);
if(this.previousStack.length > 1) {
this.onPreviousChange(
this.previousStack[1], this.previousStack.length - 1
);
}
if(this.previousStack.length > (this.limit + 1)) {
this.previousStack.pop();
}
if(this.nextStack.length > 0) {
this.nextStack = [];
this.onNextChange(null, 0);
}
this.listeners[type] = OpenLayers.Function.bind(function() {
if(!this.restoring) {
var state = this.registry[type].apply(this, arguments);
this.previousStack.unshift(state);
if(this.previousStack.length > 1) {
this.onPreviousChange(
this.previousStack[1], this.previousStack.length - 1
);
}
return true;
}, this);
}
if(this.previousStack.length > (this.limit + 1)) {
this.previousStack.pop();
}
if(this.nextStack.length > 0) {
this.nextStack = [];
this.onNextChange(null, 0);
}
}
return true;
}, this);
}
},
@@ -375,9 +371,7 @@ OpenLayers.Control.NavigationHistory = OpenLayers.Class(OpenLayers.Control, {
this.setListeners();
}
for(var type in this.listeners) {
if (this.listeners.hasOwnProperty(type)) {
this.map.events.register(type, this, this.listeners[type]);
}
this.map.events.register(type, this, this.listeners[type]);
}
activated = true;
if(this.previousStack.length == 0) {
@@ -411,11 +405,9 @@ OpenLayers.Control.NavigationHistory = OpenLayers.Class(OpenLayers.Control, {
if(this.map) {
if(OpenLayers.Control.prototype.deactivate.apply(this)) {
for(var type in this.listeners) {
if (this.listeners.hasOwnProperty(type)) {
this.map.events.unregister(
type, this, this.listeners[type]
);
}
this.map.events.unregister(
type, this, this.listeners[type]
);
}
if(this.clearOnDeactivate) {
this.clear();

View File

@@ -94,12 +94,13 @@ OpenLayers.Control.Permalink = OpenLayers.Class(OpenLayers.Control, {
* APIMethod: destroy
*/
destroy: function() {
if (this.element.parentNode == this.div) {
if (this.element && this.element.parentNode == this.div) {
this.div.removeChild(this.element);
this.element = null;
}
if (this.map) {
this.map.events.unregister('moveend', this, this.updateLink);
}
this.element = null;
this.map.events.unregister('moveend', this, this.updateLink);
OpenLayers.Control.prototype.destroy.apply(this, arguments);
},

View File

@@ -168,16 +168,11 @@ OpenLayers.Control.SLDSelect = OpenLayers.Class(OpenLayers.Control, {
* Take care of things that are not handled in superclass.
*/
destroy: function() {
var key;
for (key in this.layerCache) {
if (this.layerCache.hasOwnProperty(key)) {
delete this.layerCache[key];
}
for (var key in this.layerCache) {
delete this.layerCache[key];
}
for (key in this.wfsCache) {
if (this.wfsCache.hasOwnProperty(key)) {
delete this.wfsCache[key];
}
for (var key in this.wfsCache) {
delete this.wfsCache[key];
}
OpenLayers.Control.prototype.destroy.apply(this, arguments);
},

View File

@@ -456,12 +456,10 @@ OpenLayers.Control.WMSGetFeatureInfo = OpenLayers.Class(OpenLayers.Control, {
}
var layers;
for (var url in services) {
if (services.hasOwnProperty(url)) {
layers = services[url];
var wmsOptions = this.buildWMSOptions(url, layers,
clickPosition, layers[0].params.FORMAT);
OpenLayers.Request.GET(wmsOptions);
}
layers = services[url];
var wmsOptions = this.buildWMSOptions(url, layers,
clickPosition, layers[0].params.FORMAT);
OpenLayers.Request.GET(wmsOptions);
}
}
},

View File

@@ -564,14 +564,12 @@ OpenLayers.Format.GML.Base = OpenLayers.Class(OpenLayers.Format.XML, {
this.writeNode("feature:_geometry", feature.geometry, node);
}
for(var name in feature.attributes) {
if (feature.attributes.hasOwnProperty(name)) {
var value = feature.attributes[name];
if(value != null) {
this.writeNode(
"feature:_attribute",
{name: name, value: value}, node
);
}
var value = feature.attributes[name];
if(value != null) {
this.writeNode(
"feature:_attribute",
{name: name, value: value}, node
);
}
}
return node;

View File

@@ -325,17 +325,15 @@ OpenLayers.Format.GeoRSS = OpenLayers.Class(OpenLayers.Format.XML, {
featureNode.appendChild(linkNode);
}
for(var attr in feature.attributes) {
if (feature.attributes.hasOwnProperty(attr)) {
if (attr == "link" || attr == "title" || attr == "description") { continue; }
var attrText = this.createTextNode(feature.attributes[attr]);
var nodename = attr;
if (attr.search(":") != -1) {
nodename = attr.split(":")[1];
}
var attrContainer = this.createElementNS(this.featureNS, "feature:"+nodename);
attrContainer.appendChild(attrText);
featureNode.appendChild(attrContainer);
}
if (attr == "link" || attr == "title" || attr == "description") { continue; }
var attrText = this.createTextNode(feature.attributes[attr]);
var nodename = attr;
if (attr.search(":") != -1) {
nodename = attr.split(":")[1];
}
var attrContainer = this.createElementNS(this.featureNS, "feature:"+nodename);
attrContainer.appendChild(attrText);
featureNode.appendChild(attrContainer);
}
featureNode.appendChild(geometryNode);
return featureNode;

View File

@@ -140,35 +140,33 @@ OpenLayers.Format.OSM = OpenLayers.Class(OpenLayers.Format.XML, {
feat_list[i] = feat;
}
for (var node_id in nodes) {
if (nodes.hasOwnProperty(node_id)) {
var node = nodes[node_id];
if (!node.used || this.checkTags) {
var tags = null;
var node = nodes[node_id];
if (!node.used || this.checkTags) {
var tags = null;
if (this.checkTags) {
var result = this.getTags(node.node, true);
if (node.used && !result[1]) {
continue;
}
tags = result[0];
} else {
tags = this.getTags(node.node);
}
if (this.checkTags) {
var result = this.getTags(node.node, true);
if (node.used && !result[1]) {
continue;
}
tags = result[0];
} else {
tags = this.getTags(node.node);
}
var feat = new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.Point(node['lon'], node['lat']),
tags);
if (this.internalProjection && this.externalProjection) {
feat.geometry.transform(this.externalProjection,
this.internalProjection);
}
feat.osm_id = parseInt(node_id);
feat.fid = "node." + feat.osm_id;
feat_list.push(feat);
}
// Memory cleanup
node.node = null;
}
var feat = new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.Point(node['lon'], node['lat']),
tags);
if (this.internalProjection && this.externalProjection) {
feat.geometry.transform(this.externalProjection,
this.internalProjection);
}
feat.osm_id = parseInt(node_id);
feat.fid = "node." + feat.osm_id;
feat_list.push(feat);
}
// Memory cleanup
node.node = null;
}
return feat_list;
},
@@ -275,11 +273,9 @@ OpenLayers.Format.OSM = OpenLayers.Class(OpenLayers.Format.XML, {
}
if (this.checkTags) {
for(var key in way.tags) {
if (way.tags.hasOwnProperty(key)) {
if (this.areaTags[key]) {
poly_tags = true;
break;
}
if (this.areaTags[key]) {
poly_tags = true;
break;
}
}
}
@@ -434,12 +430,10 @@ OpenLayers.Format.OSM = OpenLayers.Class(OpenLayers.Format.XML, {
*/
serializeTags: function(feature, node) {
for (var key in feature.attributes) {
if (feature.attributes.hasOwnProperty(key)) {
var tag = this.createElementNS(null, "tag");
tag.setAttribute("k", key);
tag.setAttribute("v", feature.attributes[key]);
node.appendChild(tag);
}
var tag = this.createElementNS(null, "tag");
tag.setAttribute("k", key);
tag.setAttribute("v", feature.attributes[key]);
node.appendChild(tag);
}
},

View File

@@ -541,11 +541,9 @@ OpenLayers.Format.SLD.v1 = OpenLayers.Class(OpenLayers.Format.Filter.v1_0_0, {
getCssProperty: function(sym) {
var css = null;
for(var prop in this.cssMap) {
if (this.cssMap.hasOwnProperty(prop)) {
if(this.cssMap[prop] == sym) {
css = prop;
break;
}
if(this.cssMap[prop] == sym) {
css = prop;
break;
}
}
return css;
@@ -567,14 +565,12 @@ OpenLayers.Format.SLD.v1 = OpenLayers.Class(OpenLayers.Format.Filter.v1_0_0, {
getGraphicFormat: function(href) {
var format, regex;
for(var key in this.graphicFormats) {
if (this.graphicFormats.hasOwnProperty(key)) {
if(this.graphicFormats[key].test(href)) {
format = key;
break;
}
if(this.graphicFormats[key].test(href)) {
format = key;
break;
}
}
return format || this.defaultGraphicFormat;
return format || this.defautlGraphicFormat;
},
/**
@@ -680,9 +676,7 @@ OpenLayers.Format.SLD.v1 = OpenLayers.Class(OpenLayers.Format.Filter.v1_0_0, {
}
} else {
for(var name in sld.namedLayers) {
if (sld.namedLayers.hasOwnProperty(name)) {
this.writeNode("NamedLayer", sld.namedLayers[name], root);
}
this.writeNode("NamedLayer", sld.namedLayers[name], root);
}
}
return root;
@@ -775,13 +769,11 @@ OpenLayers.Format.SLD.v1 = OpenLayers.Class(OpenLayers.Format.Filter.v1_0_0, {
ruleMap[zIndex].symbolizers.push(symbolizer.clone());
}
for (zIndex in ruleMap) {
if (ruleMap.hasOwnProperty(zIndex)) {
if (!(zIndex in rulesByZ)) {
zValues.push(zIndex);
rulesByZ[zIndex] = [];
}
rulesByZ[zIndex].push(ruleMap[zIndex]);
if (!(zIndex in rulesByZ)) {
zValues.push(zIndex);
rulesByZ[zIndex] = [];
}
rulesByZ[zIndex].push(ruleMap[zIndex]);
}
} else {
// no symbolizers in rule

View File

@@ -128,12 +128,10 @@ OpenLayers.Format.SLD.v1_0_0_GeoServer = OpenLayers.Class(
var options = symbolizer.vendorOptions;
if (options) {
for (var key in symbolizer.vendorOptions) {
if (symbolizer.vendorOptions.hasOwnProperty(key)) {
this.writeNode("VendorOption", {
name: key,
value: symbolizer.vendorOptions[key]
}, node);
}
this.writeNode("VendorOption", {
name: key,
value: symbolizer.vendorOptions[key]
}, node);
}
}
return node;

View File

@@ -210,14 +210,10 @@ OpenLayers.Format.SOSGetObservation = OpenLayers.Class(OpenLayers.Format.XML, {
this.writeNode("eventTime", options, node);
}
for (var procedure in options.procedures) {
if (options.procedures.hasOwnProperty(procedure)) {
this.writeNode("procedure", options.procedures[procedure], node);
}
this.writeNode("procedure", options.procedures[procedure], node);
}
for (var observedProperty in options.observedProperties) {
if (options.observedProperties.hasOwnProperty(observedProperty)) {
this.writeNode("observedProperty", options.observedProperties[observedProperty], node);
}
this.writeNode("observedProperty", options.observedProperties[observedProperty], node);
}
if (options.foi) {
this.writeNode("featureOfInterest", options.foi, node);

View File

@@ -104,17 +104,15 @@ OpenLayers.Format.WFS = OpenLayers.Class(OpenLayers.Format.GML, {
var featureContainer = this.createElementNS(this.featureNS, "feature:" + this.featureName);
featureContainer.appendChild(geomContainer);
for(var attr in feature.attributes) {
if (feature.attributes.hasOwnProperty(attr)) {
var attrText = this.createTextNode(feature.attributes[attr]);
var nodename = attr;
if (attr.search(":") != -1) {
nodename = attr.split(":")[1];
}
var attrContainer = this.createElementNS(this.featureNS, "feature:" + nodename);
attrContainer.appendChild(attrText);
featureContainer.appendChild(attrContainer);
}
}
var attrText = this.createTextNode(feature.attributes[attr]);
var nodename = attr;
if (attr.search(":") != -1) {
nodename = attr.split(":")[1];
}
var attrContainer = this.createElementNS(this.featureNS, "feature:" + nodename);
attrContainer.appendChild(attrText);
featureContainer.appendChild(attrContainer);
}
return featureContainer;
},
@@ -168,16 +166,14 @@ OpenLayers.Format.WFS = OpenLayers.Class(OpenLayers.Format.GML, {
// add in attributes
for(var propName in feature.attributes) {
if (feature.attributes.hasOwnProperty(propName)) {
propertyNode = this.createElementNS(this.wfsns, 'wfs:Property');
nameNode = this.createElementNS(this.wfsns, 'wfs:Name');
nameNode.appendChild(this.createTextNode(propName));
propertyNode.appendChild(nameNode);
valueNode = this.createElementNS(this.wfsns, 'wfs:Value');
valueNode.appendChild(this.createTextNode(feature.attributes[propName]));
propertyNode.appendChild(valueNode);
updateNode.appendChild(propertyNode);
}
propertyNode = this.createElementNS(this.wfsns, 'wfs:Property');
nameNode = this.createElementNS(this.wfsns, 'wfs:Name');
nameNode.appendChild(this.createTextNode(propName));
propertyNode.appendChild(nameNode);
valueNode = this.createElementNS(this.wfsns, 'wfs:Value');
valueNode.appendChild(this.createTextNode(feature.attributes[propName]));
propertyNode.appendChild(valueNode);
updateNode.appendChild(propertyNode);
}

View File

@@ -332,14 +332,12 @@ OpenLayers.Format.WFST.v1 = OpenLayers.Class(OpenLayers.Format.XML, {
// add in attributes
for(var key in feature.attributes) {
if (feature.attributes.hasOwnProperty(key)) {
if(feature.attributes[key] !== undefined &&
(!modified || !modified.attributes ||
(modified.attributes && modified.attributes[key] !== undefined))) {
this.writeNode(
"Property", {name: key, value: feature.attributes[key]}, node
);
}
if(feature.attributes[key] !== undefined &&
(!modified || !modified.attributes ||
(modified.attributes && modified.attributes[key] !== undefined))) {
this.writeNode(
"Property", {name: key, value: feature.attributes[key]}, node
);
}
}
@@ -412,11 +410,9 @@ OpenLayers.Format.WFST.v1 = OpenLayers.Class(OpenLayers.Format.XML, {
var parts = [];
var uri;
for(var key in schemaLocations) {
if (schemaLocations.hasOwnProperty(key)) {
uri = this.namespaces[key];
if(uri) {
parts.push(uri + " " + schemaLocations[key]);
}
uri = this.namespaces[key];
if(uri) {
parts.push(uri + " " + schemaLocations[key]);
}
}
var value = parts.join(" ") || undefined;

View File

@@ -48,10 +48,8 @@ OpenLayers.Format.WMC.v1 = OpenLayers.Class(OpenLayers.Format.XML, {
prefix = this.namespaces[this.defaultPrefix];
} else {
for(prefix in this.namespaces) {
if (this.namespaces.hasOwnProperty(prefix)) {
if(this.namespaces[prefix] == uri) {
break;
}
if(this.namespaces[prefix] == uri) {
break;
}
}
}
@@ -676,14 +674,12 @@ OpenLayers.Format.WMC.v1 = OpenLayers.Class(OpenLayers.Format.XML, {
setAttributes: function(node, obj) {
var value;
for(var name in obj) {
if (obj.hasOwnProperty(name)) {
value = obj[name].toString();
if(value.match(/[A-Z]/)) {
// safari lowercases attributes with setAttribute
this.setAttributeNS(node, null, name, value);
} else {
node.setAttribute(name, value);
}
value = obj[name].toString();
if(value.match(/[A-Z]/)) {
// safari lowercases attributes with setAttribute
this.setAttributeNS(node, null, name, value);
} else {
node.setAttribute(name, value);
}
}
},
@@ -1095,29 +1091,25 @@ OpenLayers.Format.WMC.v1 = OpenLayers.Class(OpenLayers.Format.XML, {
userValue: true
};
for (var dim in context.dimensions) {
if (context.dimensions.hasOwnProperty(dim)) {
var attributes = {};
var dimension = context.dimensions[dim];
for (var name in dimension) {
if (dimension.hasOwnProperty(name)) {
if (typeof dimension[name] == "boolean") {
attributes[name] = Number(dimension[name]);
} else {
attributes[name] = dimension[name];
}
}
}
var values = "";
if (attributes.values) {
values = attributes.values.join(",");
delete attributes.values;
var attributes = {};
var dimension = context.dimensions[dim];
for (var name in dimension) {
if (typeof dimension[name] == "boolean") {
attributes[name] = Number(dimension[name]);
} else {
attributes[name] = dimension[name];
}
}
var values = "";
if (attributes.values) {
values = attributes.values.join(",");
delete attributes.values;
}
node.appendChild(this.createElementDefaultNS(
"Dimension", values, attributes
));
}
}
node.appendChild(this.createElementDefaultNS(
"Dimension", values, attributes
));
}
return node;
},

View File

@@ -122,9 +122,7 @@ OpenLayers.Format.WMC.v1_1_0 = OpenLayers.Class(
// optional SRS element(s)
if (context.srs) {
for(var name in context.srs) {
if (context.srs.hasOwnProperty(name)) {
node.appendChild(this.createElementDefaultNS("SRS", name));
}
node.appendChild(this.createElementDefaultNS("SRS", name));
}
}

View File

@@ -84,10 +84,8 @@ OpenLayers.Format.WMTSCapabilities = OpenLayers.Class(OpenLayers.Format.XML.Vers
matrixSet: true
};
for (var prop in required) {
if (required.hasOwnProperty(prop)) {
if (!(prop in config)) {
throw new Error("Missing property '" + prop + "' in layer configuration.");
}
if (!(prop in config)) {
throw new Error("Missing property '" + prop + "' in layer configuration.");
}
}

View File

@@ -89,9 +89,7 @@ OpenLayers.Format.XML = OpenLayers.Class(OpenLayers.Format, {
this.namespaces = OpenLayers.Util.extend({}, this.namespaces);
this.namespaceAlias = {};
for(var alias in this.namespaces) {
if (this.namespaces.hasOwnProperty(alias)) {
this.namespaceAlias[this.namespaces[alias]] = alias;
}
this.namespaceAlias[this.namespaces[alias]] = alias;
}
},
@@ -560,13 +558,11 @@ OpenLayers.Format.XML = OpenLayers.Class(OpenLayers.Format, {
setAttributes: function(node, obj) {
var value, uri;
for(var name in obj) {
if (obj.hasOwnProperty(name)) {
if(obj[name] != null && obj[name].toString) {
value = obj[name].toString();
// check for qualified attribute name ("prefix:local")
uri = this.namespaces[name.substring(0, name.indexOf(":"))] || null;
this.setAttributeNS(node, uri, name, value);
}
if(obj[name] != null && obj[name].toString) {
value = obj[name].toString();
// check for qualified attribute name ("prefix:local")
uri = this.namespaces[name.substring(0, name.indexOf(":"))] || null;
this.setAttributeNS(node, uri, name, value);
}
}
},

View File

@@ -423,9 +423,7 @@ OpenLayers.Layer = OpenLayers.Class({
getOptions: function() {
var options = {};
for(var o in this.options) {
if (this.options.hasOwnProperty(o)) {
options[o] = this[o];
}
options[o] = this[o];
}
return options;
},

View File

@@ -218,10 +218,8 @@ OpenLayers.Layer.HTTPRequest = OpenLayers.Class(OpenLayers.Layer, {
var urlParams =
OpenLayers.Util.upperCaseObject(OpenLayers.Util.getParameters(url));
for(var key in allParams) {
if (allParams.hasOwnProperty(key)) {
if(key.toUpperCase() in urlParams) {
delete allParams[key];
}
if(key.toUpperCase() in urlParams) {
delete allParams[key];
}
}
paramsString = OpenLayers.Util.getParameterString(allParams);

View File

@@ -346,10 +346,8 @@ OpenLayers.Layer.MapGuide = OpenLayers.Class(OpenLayers.Layer.Grid, {
var urlParams = OpenLayers.Util.upperCaseObject(
OpenLayers.Util.getParameters(url));
for(var key in allParams) {
if (allParams.hasOwnProperty(key)) {
if(key.toUpperCase() in urlParams) {
delete allParams[key];
}
if(key.toUpperCase() in urlParams) {
delete allParams[key];
}
}
var paramsString = OpenLayers.Util.getParameterString(allParams);

View File

@@ -142,10 +142,8 @@ OpenLayers.Layer.MapServer = OpenLayers.Class(OpenLayers.Layer.Grid, {
var urlParams = OpenLayers.Util.upperCaseObject(
OpenLayers.Util.getParameters(url));
for(var key in allParams) {
if (allParams.hasOwnProperty(key)) {
if(key.toUpperCase() in urlParams) {
delete allParams[key];
}
if(key.toUpperCase() in urlParams) {
delete allParams[key];
}
}
paramsString = OpenLayers.Util.getParameterString(allParams);

View File

@@ -509,10 +509,8 @@ OpenLayers.Layer.Vector = OpenLayers.Class(OpenLayers.Layer, {
if(!zoomChanged && coordSysUnchanged) {
for(var i in this.unrenderedFeatures) {
if (this.unrenderedFeatures.hasOwnProperty(i)) {
var feature = this.unrenderedFeatures[i];
this.drawFeature(feature);
}
var feature = this.unrenderedFeatures[i];
this.drawFeature(feature);
}
}
}
@@ -1025,4 +1023,4 @@ OpenLayers.Layer.Vector = OpenLayers.Class(OpenLayers.Layer, {
},
CLASS_NAME: "OpenLayers.Layer.Vector"
});
});

View File

@@ -229,10 +229,8 @@ OpenLayers.Layer.WMTS = OpenLayers.Class(OpenLayers.Layer.Grid, {
matrixSet: true
};
for (var prop in required) {
if (required.hasOwnProperty(prop)) {
if (!(prop in config)) {
throw new Error("Missing property '" + prop + "' in layer configuration.");
}
if (!(prop in config)) {
throw new Error("Missing property '" + prop + "' in layer configuration.");
}
}

View File

@@ -628,9 +628,9 @@ OpenLayers.Map = OpenLayers.Class({
* be properly set below.
*/
delete this.center;
this.addLayers(options.layers);
this.addLayers(options.layers);
// set center (and optionally zoom)
if (options.center) {
if (options.center && !this.getCenter()) {
// zoom can be undefined here
this.setCenter(options.center, options.zoom);
}

View File

@@ -311,9 +311,7 @@ OpenLayers.Protocol.Script = OpenLayers.Class(OpenLayers.Protocol, {
this.destroyRequest(response.priv);
} else {
for (var key in this.pendingRequests) {
if (this.pendingRequests.hasOwnProperty(key)) {
this.destroyRequest(this.pendingRequests[key]);
}
this.destroyRequest(this.pendingRequests[key]);
}
}
},

View File

@@ -181,9 +181,7 @@ OpenLayers.Request = {
config.method, url, config.async, config.user, config.password
);
for(var header in config.headers) {
if (config.headers.hasOwnProperty(header)) {
request.setRequestHeader(header, config.headers[header]);
}
request.setRequestHeader(header, config.headers[header]);
}
var events = this.events;

View File

@@ -128,9 +128,7 @@ OpenLayers.Rule = OpenLayers.Class({
*/
destroy: function() {
for (var i in this.symbolizer) {
if (this.symbolizer.hasOwnProperty(i)) {
this.symbolizer[i] = null;
}
this.symbolizer[i] = null;
}
this.symbolizer = null;
delete this.symbolizers;
@@ -218,14 +216,12 @@ OpenLayers.Rule = OpenLayers.Class({
options.symbolizer = {};
var value, type;
for(var key in this.symbolizer) {
if (this.symbolizer.hasOwnProperty(key)) {
value = this.symbolizer[key];
type = typeof value;
if(type === "object") {
options.symbolizer[key] = OpenLayers.Util.extend({}, value);
} else if(type === "string") {
options.symbolizer[key] = value;
}
value = this.symbolizer[key];
type = typeof value;
if(type === "object") {
options.symbolizer[key] = OpenLayers.Util.extend({}, value);
} else if(type === "string") {
options.symbolizer[key] = value;
}
}
}
@@ -237,4 +233,4 @@ OpenLayers.Rule = OpenLayers.Class({
},
CLASS_NAME: "OpenLayers.Rule"
});
});

View File

@@ -273,9 +273,7 @@ OpenLayers.Style = OpenLayers.Class({
OpenLayers.Util.extend(context, this.context);
for (var i in this.propertyStyles) {
if (this.propertyStyles.hasOwnProperty(i)) {
style[i] = OpenLayers.Style.createLiteral(style[i], context, feature, i);
}
style[i] = OpenLayers.Style.createLiteral(style[i], context, feature, i);
}
return style;
},
@@ -303,16 +301,14 @@ OpenLayers.Style = OpenLayers.Class({
for (var i=0, len=rules.length; i<len; i++) {
symbolizer = rules[i].symbolizer;
for (var key in symbolizer) {
if (symbolizer.hasOwnProperty(key)) {
value = symbolizer[key];
if (typeof value == "object") {
// symbolizer key is "Point", "Line" or "Polygon"
this.addPropertyStyles(propertyStyles, value);
} else {
// symbolizer is a hash of style properties
this.addPropertyStyles(propertyStyles, symbolizer);
break;
}
value = symbolizer[key];
if (typeof value == "object") {
// symbolizer key is "Point", "Line" or "Polygon"
this.addPropertyStyles(propertyStyles, value);
} else {
// symbolizer is a hash of style properties
this.addPropertyStyles(propertyStyles, symbolizer);
break;
}
}
}
@@ -333,12 +329,10 @@ OpenLayers.Style = OpenLayers.Class({
addPropertyStyles: function(propertyStyles, symbolizer) {
var property;
for (var key in symbolizer) {
if (symbolizer.hasOwnProperty(key)) {
property = symbolizer[key];
if (typeof property == "string" &&
property.match(/\$\{\w+\}/)) {
propertyStyles[key] = true;
}
property = symbolizer[key];
if (typeof property == "string" &&
property.match(/\$\{\w+\}/)) {
propertyStyles[key] = true;
}
}
return propertyStyles;

View File

@@ -63,21 +63,19 @@ OpenLayers.StyleMap = OpenLayers.Class({
this.styles["delete"] = style;
} else if(typeof style == "object") {
for(var key in style) {
if (style.hasOwnProperty(key)) {
if(style[key] instanceof OpenLayers.Style) {
// user passed a hash of style objects
this.styles[key] = style[key];
} else if(typeof style[key] == "object") {
// user passsed a hash of style hashes
this.styles[key] = new OpenLayers.Style(style[key]);
} else {
// user passed a style hash (i.e. symbolizer)
this.styles["default"] = new OpenLayers.Style(style);
this.styles["select"] = new OpenLayers.Style(style);
this.styles["temporary"] = new OpenLayers.Style(style);
this.styles["delete"] = new OpenLayers.Style(style);
break;
}
if(style[key] instanceof OpenLayers.Style) {
// user passed a hash of style objects
this.styles[key] = style[key];
} else if(typeof style[key] == "object") {
// user passsed a hash of style hashes
this.styles[key] = new OpenLayers.Style(style[key]);
} else {
// user passed a style hash (i.e. symbolizer)
this.styles["default"] = new OpenLayers.Style(style);
this.styles["select"] = new OpenLayers.Style(style);
this.styles["temporary"] = new OpenLayers.Style(style);
this.styles["delete"] = new OpenLayers.Style(style);
break;
}
}
}
@@ -89,9 +87,7 @@ OpenLayers.StyleMap = OpenLayers.Class({
*/
destroy: function() {
for(var key in this.styles) {
if (this.styles.hasOwnProperty(key)) {
this.styles[key].destroy();
}
this.styles[key].destroy();
}
this.styles = null;
},
@@ -148,17 +144,15 @@ OpenLayers.StyleMap = OpenLayers.Class({
addUniqueValueRules: function(renderIntent, property, symbolizers, context) {
var rules = [];
for (var value in symbolizers) {
if (symbolizers.hasOwnProperty(value)) {
rules.push(new OpenLayers.Rule({
symbolizer: symbolizers[value],
context: context,
filter: new OpenLayers.Filter.Comparison({
type: OpenLayers.Filter.Comparison.EQUAL_TO,
property: property,
value: value
})
}));
}
rules.push(new OpenLayers.Rule({
symbolizer: symbolizers[value],
context: context,
filter: new OpenLayers.Filter.Comparison({
type: OpenLayers.Filter.Comparison.EQUAL_TO,
property: property,
value: value
})
}));
}
this.styles[renderIntent].addRules(rules);
},

View File

@@ -163,14 +163,12 @@ OpenLayers.Tile.Image.IFrame = {
field;
for(var par in params) {
if (params.hasOwnProperty(par)) {
field = document.createElement('input');
field.type = 'hidden';
field.name = par;
field.value = params[par];
form.appendChild(field);
}
}
field = document.createElement('input');
field.type = 'hidden';
field.name = par;
field.value = params[par];
form.appendChild(field);
}
return form;
},

View File

@@ -127,16 +127,14 @@ OpenLayers.Tween = OpenLayers.Class({
play: function() {
var value = {};
for (var i in this.begin) {
if (this.begin.hasOwnProperty(i)) {
var b = this.begin[i];
var f = this.finish[i];
if (b == null || f == null || isNaN(b) || isNaN(f)) {
throw new TypeError('invalid value for Tween');
}
var c = f - b;
value[i] = this.easing.apply(this, [this.time, b, c, this.duration]);
var b = this.begin[i];
var f = this.finish[i];
if (b == null || f == null || isNaN(b) || isNaN(f)) {
throw new TypeError('invalid value for Tween');
}
var c = f - b;
value[i] = this.easing.apply(this, [this.time, b, c, this.duration]);
}
this.time++;

View File

@@ -441,9 +441,7 @@ OpenLayers.Util.createAlphaImageDiv = function(id, px, sz, imgURL,
OpenLayers.Util.upperCaseObject = function (object) {
var uObject = {};
for (var key in object) {
if (object.hasOwnProperty(key)) {
uObject[key.toUpperCase()] = object[key];
}
uObject[key.toUpperCase()] = object[key];
}
return uObject;
};
@@ -511,29 +509,27 @@ OpenLayers.Util.getParameterString = function(params) {
var paramsArray = [];
for (var key in params) {
if (params.hasOwnProperty(key)) {
var value = params[key];
if ((value != null) && (typeof value != 'function')) {
var encodedValue;
if (typeof value == 'object' && value.constructor == Array) {
/* value is an array; encode items and separate with "," */
var encodedItemArray = [];
var item;
for (var itemIndex=0, len=value.length; itemIndex<len; itemIndex++) {
item = value[itemIndex];
encodedItemArray.push(encodeURIComponent(
(item === null || item === undefined) ? "" : item)
);
}
encodedValue = encodedItemArray.join(",");
}
else {
/* value is a string; simply encode */
encodedValue = encodeURIComponent(value);
}
paramsArray.push(encodeURIComponent(key) + "=" + encodedValue);
}
var value = params[key];
if ((value != null) && (typeof value != 'function')) {
var encodedValue;
if (typeof value == 'object' && value.constructor == Array) {
/* value is an array; encode items and separate with "," */
var encodedItemArray = [];
var item;
for (var itemIndex=0, len=value.length; itemIndex<len; itemIndex++) {
item = value[itemIndex];
encodedItemArray.push(encodeURIComponent(
(item === null || item === undefined) ? "" : item)
);
}
encodedValue = encodedItemArray.join(",");
}
else {
/* value is a string; simply encode */
encodedValue = encodeURIComponent(value);
}
paramsArray.push(encodeURIComponent(key) + "=" + encodedValue);
}
}
return paramsArray.join("&");
@@ -1304,30 +1300,24 @@ OpenLayers.Util.isEquivalentUrl = function(url1, url2, options) {
var urlObj2 = OpenLayers.Util.createUrlObject(url2, options);
//compare all keys except for "args" (treated below)
for (var key in urlObj1) {
if (urlObj1.hasOwnProperty(key)) {
if(key !== "args") {
if(urlObj1[key] != urlObj2[key]) {
return false;
}
for(var key in urlObj1) {
if(key !== "args") {
if(urlObj1[key] != urlObj2[key]) {
return false;
}
}
}
// compare search args - irrespective of order
for (var key in urlObj1.args) {
if (urlObj1.args.hasOwnProperty(key)) {
if(urlObj1.args[key] != urlObj2.args[key]) {
return false;
}
delete urlObj2.args[key];
}
}
// urlObj2 shouldn't have any args left
for (var key in urlObj2.args) {
if (urlObj2.args.hasOwnProperty(key)) {
for(var key in urlObj1.args) {
if(urlObj1.args[key] != urlObj2.args[key]) {
return false;
}
delete urlObj2.args[key];
}
// urlObj2 shouldn't have any args left
for(var key in urlObj2.args) {
return false;
}
return true;

View File

@@ -289,16 +289,16 @@
// move 10 pixels
trigger("mousemove", 0, 10);
t.eq(log.length, 0, "a) no event fired yet");
t.eq(log.length, 1, "a) has fired an event");
t.delay_call(
delay, function() {
// confirm measurepartial is fired
t.eq(log.length, 1, "a) event logged");
t.eq(log.length, 1, "a) one event logged");
t.ok(log[0] && log[0].type == "measurepartial", "a) correct type");
// mousemove within the partialDelay fires no event, so the
// measure below is the one of the initial point
t.ok(log[0] && log[0].measure == 0, "a) correct measure");
t.eq(log[0]?log[0].measure:-1 , 10, "a) correct measure");
// b) move 10 pixels
trigger("mousemove", 0, 20);

View File

@@ -11,6 +11,7 @@
t.eq(control.displayClass, "olControlPermalink", "displayClass is correct");
t.eq(control.base, document.location.href, "base is correct");
t.ok(!control.anchor, "anchor is correct");
control.destroy();
control = new OpenLayers.Control.Permalink('permalink', 'test.html');
t.ok(control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object");
@@ -18,6 +19,7 @@
t.eq(control.base, 'test.html', "base is correct");
t.ok(OpenLayers.Util.isElement(control.element), "element is a dom object");
t.ok(!control.anchor, "anchor is correct");
control.destroy();
control = new OpenLayers.Control.Permalink('permalink');
t.ok(control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object");
@@ -25,6 +27,7 @@
t.eq(control.base, document.location.href, "base is correct");
t.ok(OpenLayers.Util.isElement(control.element), "element is a dom object");
t.ok(!control.anchor, "anchor is correct");
control.destroy();
control = new OpenLayers.Control.Permalink(OpenLayers.Util.getElement('permalink'));
t.ok(control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object");
@@ -32,6 +35,7 @@
t.eq(control.base, document.location.href, "base is correct");
t.ok(OpenLayers.Util.isElement(control.element), "element is a dom object");
t.ok(!control.anchor, "anchor is correct");
control.destroy();
control = new OpenLayers.Control.Permalink({anchor: true});
t.ok(control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object");
@@ -39,18 +43,21 @@
t.eq(control.base, document.location.href, "base is correct");
t.ok(control.element == null, "element is null");
t.ok(control.anchor, "anchor is correct");
control.destroy();
control = new OpenLayers.Control.Permalink({anchor: false});
t.ok(control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object");
t.eq(control.displayClass, "olControlPermalink", "displayClass is correct");
t.eq(control.base, document.location.href, "base is correct");
t.ok(!control.anchor, "anchor is correct");
control.destroy();
control = new OpenLayers.Control.Permalink({});
t.ok(control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object");
t.eq(control.displayClass, "olControlPermalink", "displayClass is correct");
t.eq(control.base, document.location.href, "base is correct");
t.ok(!control.anchor, "anchor is correct");
control.destroy();
control = new OpenLayers.Control.Permalink({element: 'permalink', base: 'test.html'});
t.ok(control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object");
@@ -58,6 +65,7 @@
t.eq(control.base, 'test.html', "base is correct");
t.ok(OpenLayers.Util.isElement(control.element), "element is a dom object");
t.ok(!control.anchor, "anchor is correct");
control.destroy();
control = new OpenLayers.Control.Permalink({element: 'permalink', base: 'test.html', anchor: true});
t.ok(control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object");
@@ -65,6 +73,7 @@
t.eq(control.base, 'test.html', "base is correct");
t.ok(OpenLayers.Util.isElement(control.element), "element is a dom object");
t.ok(control.anchor, "anchor is correct");
control.destroy();
}
function test_Control_Permalink_uncentered (t) {
t.plan( 1 );
@@ -74,12 +83,14 @@
map.addControl(control);
map.events.triggerEvent("changelayer", {});
t.ok(true, "permalink didn't bomb out.");
map.destroy();
}
function test_Control_Permalink_initwithelem (t) {
t.plan( 1 );
control = new OpenLayers.Control.Permalink(OpenLayers.Util.getElement('permalink'));
t.ok(true, "If the above line doesn't throw an error, we're safe.");
control.destroy();
}
function test_Control_Permalink_updateLinks (t) {
t.plan( 3 );
@@ -100,6 +111,7 @@
map.layers[1].setVisibility(false);
t.ok(OpenLayers.Util.isEquivalentUrl(OpenLayers.Util.getElement('permalink').href, location+"?zoom=2&lat=0&lon=1.75781&layers=BF"), 'setVisibility sets permalink');
map.destroy();
}
function test_Control_Permalink_updateLinksBase (t) {
t.plan( 2 );
@@ -114,6 +126,7 @@
map.pan(5, 0, {animate:false});
OpenLayers.Util.getElement('edit_permalink').href = './edit.html?zoom=2&lat=0&lon=1.75781&layers=B';
t.eq(OpenLayers.Util.getElement('permalink').href, OpenLayers.Util.getElement('edit_permalink').href, "Panning sets permalink with base");
map.destroy();
}
function test_Control_Permalink_noElement (t) {
t.plan( 2 );
@@ -122,6 +135,7 @@
map = new OpenLayers.Map('map');
map.addControl(control);
t.eq(map.controls[4].div.firstChild.nodeName, "A", "Permalink control creates div with 'a' inside." );
map.destroy();
}
function test_Control_Permalink_base_with_query (t) {
t.plan( 3 );
@@ -147,6 +161,7 @@
map.pan(5, 0, {animate:false});
map.pan(-5, 0, {animate:false});
t.eq(OpenLayers.Util.getElement('permalink').href, OpenLayers.Util.getElement('edit_permalink').href, "Panning sets permalink with base and querystring ending with '?'");
map.destroy();
}
@@ -163,6 +178,7 @@
map.pan(5, 0, {animate:false});
OpenLayers.Util.getElement('edit_permalink').href = './edit.html?zoom=2&lat=0&lon=1.75781&layers=B';
t.eq(OpenLayers.Util.getElement('permalink').href, OpenLayers.Util.getElement('edit_permalink').href, "Panning sets permalink with existing zoom in base");
map.destroy();
}
function test_Control_Permalink_customized(t) {
@@ -189,6 +205,7 @@
t.eq(this.map.controls[this.map.controls.length-1].CLASS_NAME, "CustomArgParser", "Custom ArgParser added correctly.");
t.eq(control.div.firstChild.getAttribute("href"), "./edit.html?zoom=2&lat=0&lon=1.75781&layers=B&customParam=foo", "Custom parameter encoded correctly.");
map.destroy();
}
function test_Control_Permalink_createParams(t) {
@@ -300,6 +317,7 @@
map.layers[1].setVisibility(false);
t.ok(OpenLayers.Util.isEquivalentUrl(OpenLayers.Util.getParameterString(control.createParams()), "zoom=2&lat=0&lon=1.75781&layers=BF"), 'setVisibility sets permalink');
map.destroy();
}
function test_Control_Permalink_AnchorBaseElement (t) {
@@ -320,10 +338,15 @@
map.layers[1].setVisibility(false);
t.ok(OpenLayers.Util.isEquivalentUrl(OpenLayers.Util.getElement('permalink').href, location+"#zoom=2&lat=0&lon=1.75781&layers=BF"), 'setVisibility sets permalink');
map.destroy();
}
function test_arrayCenter(t) {
t.plan(1);
function test_center_from_map(t) {
t.plan(7);
var previous = window.location.hash;
window.location.hash = "";
var err;
try {
var map = new OpenLayers.Map({
@@ -331,8 +354,8 @@
controls: [
new OpenLayers.Control.Permalink({anchor: true})
],
center: [0, 0],
zoom: 1
center: [1, 2],
zoom: 3
});
} catch (e) {
err = e;
@@ -342,6 +365,51 @@
} else {
t.ok(true, "Map construction works");
}
// confirm that map center is correctly set
var center = map.getCenter();
t.eq(center.lon, 1, "map x");
t.eq(center.lat, 2, "map y")
t.eq(map.getZoom(), 3, "map z");
// confirm that location from map options has been added to url
var params = OpenLayers.Util.getParameters(window.location.hash.replace("#", "?"));
t.eq(params.lon, "1", "url x");
t.eq(params.lat, "2", "url y");
t.eq(params.zoom, "3", "url z");
map.destroy();
window.location.hash = previous;
}
function test_center_from_url(t) {
t.plan(6);
// In cases where the location is specified in the URL and given in
// the map options, we respect the location in the URL.
var previous = window.location.hash;
window.location.hash = "#zoom=6&lat=5&lon=4&layers=B"
var map = new OpenLayers.Map({
layers: [new OpenLayers.Layer(null, {isBaseLayer: true})],
controls: [new OpenLayers.Control.Permalink({anchor: true})],
center: [0, 0],
zoom: 0
});
// confirm that map center is correctly set
var center = map.getCenter();
t.eq(center.lon, 4, "map x");
t.eq(center.lat, 5, "map y")
t.eq(map.getZoom(), 6, "map z");
var params = OpenLayers.Util.getParameters(window.location.hash.replace("#", "?"));
t.eq(params.lon, "4", "x set");
t.eq(params.lat, "5", "y set");
t.eq(params.zoom, "6", "z set");
map.destroy();
window.location.hash = previous;
}
</script>