From eae04c92bcd785ea81693b3c6ae8f2cda589f209 Mon Sep 17 00:00:00 2001 From: Xavier Mamano Date: Wed, 16 Nov 2011 19:51:28 +0100 Subject: [PATCH 001/119] cancelDelay before measureImmediate + changes in tests. --- lib/OpenLayers/Control/Measure.js | 4 ++-- tests/Control/Measure.html | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/OpenLayers/Control/Measure.js b/lib/OpenLayers/Control/Measure.js index f57f6c4465..a8f66dd89a 100644 --- a/lib/OpenLayers/Control/Measure.js +++ b/lib/OpenLayers/Control/Measure.js @@ -230,8 +230,8 @@ OpenLayers.Control.Measure = OpenLayers.Class(OpenLayers.Control, { * mouseposition. feature - {} 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"); } }, diff --git a/tests/Control/Measure.html b/tests/Control/Measure.html index 045f807d36..fb55fc9364 100644 --- a/tests/Control/Measure.html +++ b/tests/Control/Measure.html @@ -289,7 +289,7 @@ // move 10 pixels trigger("mousemove", 0, 10); - t.eq(log.length, 0, "a) no event fired yet"); + t.eq(log.length, 1, "a) no event fired yet"); t.delay_call( delay, function() { @@ -298,7 +298,7 @@ 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); From 43ef0920c2d9bf006cd1d769d2391b9b75a92cf8 Mon Sep 17 00:00:00 2001 From: Tom MacWright Date: Sun, 20 Nov 2011 23:47:37 -0500 Subject: [PATCH 002/119] Removing camelize method. --- lib/OpenLayers/BaseTypes.js | 22 ---------------------- lib/OpenLayers/BaseTypes/Element.js | 4 ++-- lib/OpenLayers/Control/OverviewMap.js | 6 +++--- lib/OpenLayers/Handler/Box.js | 8 ++++---- lib/OpenLayers/Popup.js | 8 ++++---- tests/BaseTypes.html | 27 --------------------------- tests/Handler/Box.html | 2 +- 7 files changed, 14 insertions(+), 63 deletions(-) diff --git a/lib/OpenLayers/BaseTypes.js b/lib/OpenLayers/BaseTypes.js index 05b06b8d3d..f19a70d223 100644 --- a/lib/OpenLayers/BaseTypes.js +++ b/lib/OpenLayers/BaseTypes.js @@ -60,28 +60,6 @@ OpenLayers.String = { return str.replace(/^\s\s*/, '').replace(/\s\s*$/, ''); }, - /** - * APIFunction: camelize - * Camel-case a hyphenated string. - * Ex. "chicken-head" becomes "chickenHead", and - * "-chicken-head" becomes "ChickenHead". - * - * Parameters: - * str - {String} The string to be camelized. The original is not modified. - * - * Returns: - * {String} The string, camelized - */ - camelize: function(str) { - var oStringList = str.split('-'); - var camelizedString = oStringList[0]; - for (var i=1, len=oStringList.length; i Date: Mon, 21 Nov 2011 15:42:46 -0500 Subject: [PATCH 003/119] Moving camelize and its tests to deprecated --- lib/deprecated.js | 24 ++++++++++++++++ tests/deprecated/BaseTypes.html | 40 ++++++++++++++++++++++++++ tests/deprecated/BaseTypes/String.html | 40 ++++++++++++++++++++++++++ tests/list-tests.html | 1 + 4 files changed, 105 insertions(+) create mode 100644 tests/deprecated/BaseTypes.html create mode 100644 tests/deprecated/BaseTypes/String.html diff --git a/lib/deprecated.js b/lib/deprecated.js index 23f0d976b8..ebe9725b30 100644 --- a/lib/deprecated.js +++ b/lib/deprecated.js @@ -85,6 +85,30 @@ OpenLayers.Util.clearArray = function(array) { array.length = 0; }; + +/** + * APIFunction: camelize + * Camel-case a hyphenated string. + * Ex. "chicken-head" becomes "chickenHead", and + * "-chicken-head" becomes "ChickenHead". + * + * Parameters: + * str - {String} The string to be camelized. The original is not modified. + * + * Returns: + * {String} The string, camelized + */ + +OpenLayers.String.camelize = function(str) { + var oStringList = str.split('-'); + var camelizedString = oStringList[0]; + for (var i=1, len=oStringList.length; i + + + + + + + + + + diff --git a/tests/deprecated/BaseTypes/String.html b/tests/deprecated/BaseTypes/String.html new file mode 100644 index 0000000000..b8a66b8574 --- /dev/null +++ b/tests/deprecated/BaseTypes/String.html @@ -0,0 +1,40 @@ + + + + + + + + + + + diff --git a/tests/list-tests.html b/tests/list-tests.html index adc9580f73..af7b6b29d6 100644 --- a/tests/list-tests.html +++ b/tests/list-tests.html @@ -226,6 +226,7 @@
  • deprecated/Ajax.html
  • deprecated/BaseTypes/Class.html
  • deprecated/BaseTypes/Element.html
  • +
  • deprecated/BaseTypes/String.html
  • deprecated/Control/MouseToolbar.html
  • deprecated/Layer/MapServer/Untiled.html
  • deprecated/Layer/MultiMap.html
  • From 7c76b90a2de0f27f5b4c6d7e5c6ba7b451f24d33 Mon Sep 17 00:00:00 2001 From: Xavier Mamano Date: Tue, 17 Jan 2012 22:45:25 +0100 Subject: [PATCH 004/119] Test Measure: Correct the text of expected result. --- tests/Control/Measure.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Control/Measure.html b/tests/Control/Measure.html index fb55fc9364..58df363f6e 100644 --- a/tests/Control/Measure.html +++ b/tests/Control/Measure.html @@ -289,12 +289,12 @@ // move 10 pixels trigger("mousemove", 0, 10); - t.eq(log.length, 1, "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 From 1996f5cb25cb41446d8a8b0e5a33561edeae2e14 Mon Sep 17 00:00:00 2001 From: Xavier Mamano Date: Sat, 28 Jan 2012 19:13:28 +0100 Subject: [PATCH 005/119] Monitor the errors from the merge process. --- build/build.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/build/build.py b/build/build.py index ebb07d358f..0ca2a74a0e 100755 --- a/build/build.py +++ b/build/build.py @@ -51,10 +51,14 @@ def build(config_file = None, output_file = None, options = None): outputFilename = output_file print "Merging libraries." - if use_compressor == "closure": - sourceFiles = mergejs.getNames(sourceDirectory, configFilename) - else: - merged = mergejs.run(sourceDirectory, None, configFilename) + try: + if use_compressor == "closure": + sourceFiles = mergejs.getNames(sourceDirectory, configFilename) + else: + merged = mergejs.run(sourceDirectory, None, configFilename) + except mergejs.MissingImport, E: + print "\nAbnormal termination." + sys.exit("ERROR: %s" % E) print "Compressing using %s" % use_compressor if use_compressor == "jsmin": From fa3d89f5727d7170d77270f8f936a05aa9da27d1 Mon Sep 17 00:00:00 2001 From: Xavier Mamano Date: Mon, 30 Jan 2012 19:42:23 +0100 Subject: [PATCH 006/119] A popup can be destroyed before obtaining the images of `contentDiv`. --- lib/OpenLayers/Popup.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/OpenLayers/Popup.js b/lib/OpenLayers/Popup.js index 36f666e73f..774ecb8c03 100644 --- a/lib/OpenLayers/Popup.js +++ b/lib/OpenLayers/Popup.js @@ -685,7 +685,9 @@ OpenLayers.Popup = OpenLayers.Class({ // 'img' properties in the context. // var onImgLoad = function() { - + if (this.popup.id === null) { // this.popup has been destroyed! + return; + } this.popup.updateSize(); if ( this.popup.visible() && this.popup.panMapIfOutOfView ) { From 9732cf77aa87ae3780fda6c321fba21823baf72b Mon Sep 17 00:00:00 2001 From: Peter Robins Date: Wed, 8 Feb 2012 11:20:06 +0000 Subject: [PATCH 007/119] HTTP protocol: enable POST for update/delete --- lib/OpenLayers/Protocol/HTTP.js | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/lib/OpenLayers/Protocol/HTTP.js b/lib/OpenLayers/Protocol/HTTP.js index ebfacac705..e7414d8e99 100644 --- a/lib/OpenLayers/Protocol/HTTP.js +++ b/lib/OpenLayers/Protocol/HTTP.js @@ -62,12 +62,27 @@ OpenLayers.Protocol.HTTP = OpenLayers.Class(OpenLayers.Protocol, { scope: null, /** - * Property: readWithPOST + * APIProperty: readWithPOST * {Boolean} true if read operations are done with POST requests * instead of GET, defaults to false. */ readWithPOST: false, + /** + * APIProperty: updateWithPOST + * {Boolean} true if update operations are done with POST requests + * defaults to false. + */ + updateWithPOST: false, + + /** + * APIProperty: deleteWithPOST + * {Boolean} true if delete operations are done with POST requests + * defaults to false. + * if true, POST data is set to output of format.write(). + */ + deleteWithPOST: false, + /** * Property: wildcarded. * {Boolean} If true percent signs are added around values @@ -293,7 +308,8 @@ OpenLayers.Protocol.HTTP = OpenLayers.Class(OpenLayers.Protocol, { requestType: "update" }); - resp.priv = OpenLayers.Request.PUT({ + var method = this.updateWithPOST ? "POST" : "PUT"; + resp.priv = OpenLayers.Request[method]({ url: url, callback: this.createCallback(this.handleUpdate, resp, options), headers: options.headers, @@ -344,11 +360,16 @@ OpenLayers.Protocol.HTTP = OpenLayers.Class(OpenLayers.Protocol, { requestType: "delete" }); - resp.priv = OpenLayers.Request.DELETE({ + var method = this.deleteWithPOST ? "POST" : "DELETE"; + var requestOptions = { url: url, callback: this.createCallback(this.handleDelete, resp, options), headers: options.headers - }); + }; + if (this.deleteWithPOST) { + requestOptions.data = this.format.write(feature); + } + resp.priv = OpenLayers.Request[method](requestOptions); return resp; }, From 3a23f15041193e2e8d2b1712c0edaf42922ddba5 Mon Sep 17 00:00:00 2001 From: Bart van den Eijnden Date: Thu, 9 Feb 2012 14:10:49 +0100 Subject: [PATCH 008/119] implement readers for URL endpoints in WFS 1.1 --- lib/OpenLayers/Format/WFSCapabilities/v1.js | 2 +- .../Format/WFSCapabilities/v1_1_0.js | 50 +++++++++++++++++++ tests/Format/WFSCapabilities/v1.html | 4 +- 3 files changed, 54 insertions(+), 2 deletions(-) diff --git a/lib/OpenLayers/Format/WFSCapabilities/v1.js b/lib/OpenLayers/Format/WFSCapabilities/v1.js index fbdfb7373b..1a5059bbf9 100644 --- a/lib/OpenLayers/Format/WFSCapabilities/v1.js +++ b/lib/OpenLayers/Format/WFSCapabilities/v1.js @@ -59,7 +59,7 @@ OpenLayers.Format.WFSCapabilities.v1 = OpenLayers.Class( for(var i=0; iDS_giant_polygongiant_polygonurn:x-ogc:def:crs:EPSG:4326-180.0 -90.0180.0 90.0gml:Envelopegml:Pointgml:LineStringgml:PolygonLessThanGreaterThanLessThanEqualToGreaterThanEqualToEqualToNotEqualToLikeBetweenNullCheckabsabs_2abs_3abs_4acosAreaasinatanatan2betweenboundaryboundaryDimensionbufferbufferWithSegmentsCategorizeceilcentroidclassifyCollection_AverageCollection_BoundsCollection_CountCollection_MaxCollection_MedianCollection_MinCollection_SumCollection_UniqueConcatenatecontainsconvexHullcoscrossesdateFormatdateParsedifferencedimensiondisjointdistancedouble2boolendPointenvelopeEqualIntervalequalsExactequalsExactToleranceequalToexpexteriorRingfloorgeometryTypegeomFromWKTgeomLengthgetGeometryNgetXgetYgetZgreaterEqualThangreaterThanidIEEEremainderif_then_elsein10in2in3in4in5in6in7in8in9int2bboolint2ddoubleinteriorPointinteriorRingNintersectionintersectsisClosedisEmptyisLikeisNullisRingisSimpleisValidisWithinDistancelengthlessEqualThanlessThanlogmaxmax_2max_3max_4minmin_2min_3min_4notnotEqualTonumGeometriesnumInteriorRingnumPointsoverlapsparseBooleanparseDoubleparseIntpipointNpowPropertyExistsQuantilerandomrelaterelatePatternrintroundround_2roundDoublesinsqrtStandardDeviationstartPointstrConcatstrEndsWithstrEqualsIgnoreCasestrIndexOfstrLastIndexOfstrLengthstrMatchesstrReplacestrStartsWithstrSubstringstrSubstringStartstrToLowerCasestrToUpperCasestrTrimsymDifferencetantoDegreestoRadianstouchestoWKTunionUniqueIntervalwithin'; var res = parser.read(text); + t.eq(res.capability.request.getfeature.href.get, "http://localhost:80/geoserver/wfs?", "GetFeature GET endpoint correctly parsed"); + t.eq(res.capability.request.getfeature.href.post, "http://localhost:80/geoserver/wfs?", "GetFeature POST endpoint correctly parsed"); var ft = res.featureTypeList.featureTypes; t.eq(ft.length, 14, "number of feature types correct"); t.eq(ft[0]["abstract"], "Manhattan landmarks, identifies water, lakes, parks, interesting buildilngs", "abstract of first feature type correct"); From f08119b01e81cd03296d687ce916c05ee13d4e34 Mon Sep 17 00:00:00 2001 From: Peter Robins Date: Thu, 9 Feb 2012 10:40:58 +0000 Subject: [PATCH 009/119] Change Protocol/Script registry to object --- lib/OpenLayers/Protocol/Script.js | 43 ++++++++++++++++++------------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/lib/OpenLayers/Protocol/Script.js b/lib/OpenLayers/Protocol/Script.js index 49e332b7f0..5d4509a9d4 100644 --- a/lib/OpenLayers/Protocol/Script.js +++ b/lib/OpenLayers/Protocol/Script.js @@ -54,20 +54,12 @@ OpenLayers.Protocol.Script = OpenLayers.Class(OpenLayers.Protocol, { callback: null, /** - * APIProperty: scope - * {Object} Optional ``this`` object for the callback. Read-only, set - * through the options passed to the constructor. + * APIProperty: callbackTemplate + * {String} Template for creating a unique callback function name + * for the registry. Should include ${id}. + * Default is "OpenLayers.Protocol.Script.registry[${id}]". */ - scope: null, - - /** - * APIProperty: format - * {} Format for parsing features. Default is an - * format. If an alternative is provided, - * the format's read method must take an object and return an array - * of features. - */ - format: null, + callbackTemplate: "OpenLayers.Protocol.Script.registry[${id}]", /** * APIProperty: callbackKey @@ -88,6 +80,22 @@ OpenLayers.Protocol.Script = OpenLayers.Class(OpenLayers.Protocol, { */ callbackPrefix: "", + /** + * APIProperty: scope + * {Object} Optional ``this`` object for the callback. Read-only, set + * through the options passed to the constructor. + */ + scope: null, + + /** + * APIProperty: format + * {} Format for parsing features. Default is an + * format. If an alternative is provided, + * the format's read method must take an object and return an array + * of features. + */ + format: null, + /** * Property: pendingRequests * {Object} References all pending requests. Property names are script @@ -212,7 +220,7 @@ OpenLayers.Protocol.Script = OpenLayers.Class(OpenLayers.Protocol, { */ createRequest: function(url, params, callback) { var id = OpenLayers.Protocol.Script.register(callback); - var name = "OpenLayers.Protocol.Script.registry[" + id + "]"; + var name = OpenLayers.String.format(this.callbackTemplate, {id: id}); params = OpenLayers.Util.extend({}, params); params[this.callbackKey] = this.callbackPrefix + name; url = OpenLayers.Util.urlAppend( @@ -333,7 +341,7 @@ OpenLayers.Protocol.Script = OpenLayers.Class(OpenLayers.Protocol, { (function() { var o = OpenLayers.Protocol.Script; var counter = 0; - o.registry = []; + o.registry = {}; /** * Function: OpenLayers.Protocol.Script.register @@ -345,12 +353,11 @@ OpenLayers.Protocol.Script = OpenLayers.Class(OpenLayers.Protocol, { * that is the JSON returned by the service. * * Returns: - * {Number} An identifier for retreiving the registered callback. + * {Number} An identifier for retrieving the registered callback. */ o.register = function(callback) { - var id = ++counter; + var id = "c"+(++counter); o.registry[id] = function() { - o.unregister(id); callback.apply(this, arguments); }; return id; From 21d06b092a738e13117f4d56361fe393a0c00ae0 Mon Sep 17 00:00:00 2001 From: Peter Robins Date: Thu, 9 Feb 2012 15:58:41 +0000 Subject: [PATCH 010/119] Protocol/Script: add test for callbackTemplate --- tests/Protocol/Script.html | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/Protocol/Script.html b/tests/Protocol/Script.html index a676e61821..ee8ac89018 100644 --- a/tests/Protocol/Script.html +++ b/tests/Protocol/Script.html @@ -135,7 +135,7 @@ } function test_createRequest(t) { - t.plan(3); + t.plan(4); var protocol = new OpenLayers.Protocol.Script({ callbackKey: 'cb_key', callbackPrefix: 'cb_prefix:' @@ -155,7 +155,13 @@ t.eq(script.id, 'OpenLayers_Protocol_Script_bar', 'created script has a correct id'); + protocol.callbackTemplate = "OpenLayers.Protocol.Script.registry.${id}"; + script = protocol.createRequest('http://bar_url/', {'k': 'bar_param'}, 'bar_callback'); + t.eq(script.src, 'http://bar_url/?k=bar_param&cb_key=cb_prefix%3AOpenLayers.Protocol.Script.registry.bar', + 'created script has a correct url with different template'); + OpenLayers.Protocol.Script.register = _register; + } function test_destroyRequest(t) { From 6bbcb20fac614936e85afc05e27c866f62810824 Mon Sep 17 00:00:00 2001 From: Bart van den Eijnden Date: Fri, 10 Feb 2012 10:12:55 +0100 Subject: [PATCH 011/119] rewrite WFSCapabilities parser to the new readers structure, and use OWSCommon readers. This will mean that the return structure will differ for WFS 1.0 and WFS 1.1, but I think it's better to adhere to OWSCommon structures here since this will allow similar structures over different OGC Web Services --- lib/OpenLayers.js | 8 +- lib/OpenLayers/Format/WFSCapabilities/v1.js | 137 ++++++------ .../Format/WFSCapabilities/v1_0_0.js | 205 +++++++----------- .../Format/WFSCapabilities/v1_1_0.js | 84 +++---- tests/Format/WFSCapabilities/v1.html | 4 +- 5 files changed, 178 insertions(+), 260 deletions(-) diff --git a/lib/OpenLayers.js b/lib/OpenLayers.js index 3ffa1b6a84..773009e158 100644 --- a/lib/OpenLayers.js +++ b/lib/OpenLayers.js @@ -269,6 +269,10 @@ "OpenLayers/Format/KML.js", "OpenLayers/Format/GeoRSS.js", "OpenLayers/Format/WFS.js", + "OpenLayers/Format/OWSCommon.js", + "OpenLayers/Format/OWSCommon/v1.js", + "OpenLayers/Format/OWSCommon/v1_0_0.js", + "OpenLayers/Format/OWSCommon/v1_1_0.js", "OpenLayers/Format/WFSCapabilities.js", "OpenLayers/Format/WFSCapabilities/v1.js", "OpenLayers/Format/WFSCapabilities/v1_0_0.js", @@ -287,10 +291,6 @@ "OpenLayers/Format/SLD.js", "OpenLayers/Format/SLD/v1.js", "OpenLayers/Format/SLD/v1_0_0.js", - "OpenLayers/Format/OWSCommon.js", - "OpenLayers/Format/OWSCommon/v1.js", - "OpenLayers/Format/OWSCommon/v1_0_0.js", - "OpenLayers/Format/OWSCommon/v1_1_0.js", "OpenLayers/Format/CSWGetDomain.js", "OpenLayers/Format/CSWGetDomain/v2_0_2.js", "OpenLayers/Format/CSWGetRecords.js", diff --git a/lib/OpenLayers/Format/WFSCapabilities/v1.js b/lib/OpenLayers/Format/WFSCapabilities/v1.js index 1a5059bbf9..6d7bbd5aef 100644 --- a/lib/OpenLayers/Format/WFSCapabilities/v1.js +++ b/lib/OpenLayers/Format/WFSCapabilities/v1.js @@ -15,7 +15,23 @@ * - */ OpenLayers.Format.WFSCapabilities.v1 = OpenLayers.Class( - OpenLayers.Format.WFSCapabilities, { + OpenLayers.Format.XML, { + + /** + * Property: namespaces + * {Object} Mapping of namespace aliases to namespace URIs. + */ + namespaces: { + wfs: "http://www.opengis.net/wfs", + xlink: "http://www.w3.org/1999/xlink", + xsi: "http://www.w3.org/2001/XMLSchema-instance", + ows: "http://www.opengis.net/ows" + }, + + /** + * Property: defaultPrefix + */ + defaultPrefix: "wfs", /** * Constructor: OpenLayers.Format.WFSCapabilities.v1_1 @@ -25,10 +41,6 @@ OpenLayers.Format.WFSCapabilities.v1 = OpenLayers.Class( * options - {Object} An optional object whose properties will be set on * this instance. */ - initialize: function(options) { - OpenLayers.Format.XML.prototype.initialize.apply(this, [options]); - this.options = options; - }, /** * APIMethod: read @@ -44,83 +56,64 @@ OpenLayers.Format.WFSCapabilities.v1 = OpenLayers.Class( if(typeof data == "string") { data = OpenLayers.Format.XML.prototype.read.apply(this, [data]); } + var raw = data; + if(data && data.nodeType == 9) { + data = data.documentElement; + } var capabilities = {}; - var root = data.documentElement; - this.runChildNodes(capabilities, root); + this.readNode(data, capabilities); return capabilities; }, - + /** - * Method: runChildNodes + * Property: readers + * Contains public functions, grouped by namespace prefix, that will + * be applied when a namespaced node is found matching the function + * name. The function will be applied in the scope of this parser + * with two arguments: the node being read and a context object passed + * from the parent. */ - runChildNodes: function(obj, node) { - var children = node.childNodes; - var childNode, processor; - for(var i=0; i 0) { + obj.featureNS = this.lookupNamespaceURI(node, parts[0]); + } + } + }, + "Title": function(node, obj) { + var title = this.getChildValue(node); + if(title) { + obj.title = title; + } + }, + "Abstract": function(node, obj) { + var abst = this.getChildValue(node); + if(abst) { + obj["abstract"] = abst; } } } }, - - /** - * Method: read_cap_FeatureTypeList - */ - read_cap_FeatureTypeList: function(request, node) { - var featureTypeList = { - featureTypes: [] - }; - this.runChildNodes(featureTypeList, node); - request.featureTypeList = featureTypeList; - }, - - /** - * Method: read_cap_FeatureType - */ - read_cap_FeatureType: function(featureTypeList, node, parentLayer) { - var featureType = {}; - this.runChildNodes(featureType, node); - featureTypeList.featureTypes.push(featureType); - }, - - /** - * Method: read_cap_Name - */ - read_cap_Name: function(obj, node) { - var name = this.getChildValue(node); - if(name) { - var parts = name.split(":"); - obj.name = parts.pop(); - if(parts.length > 0) { - obj.featureNS = this.lookupNamespaceURI(node, parts[0]); - } - } - }, - - /** - * Method: read_cap_Title - */ - read_cap_Title: function(obj, node) { - var title = this.getChildValue(node); - if(title) { - obj.title = title; - } - }, - /** - * Method: read_cap_Abstract - */ - read_cap_Abstract: function(obj, node) { - var abst = this.getChildValue(node); - if(abst) { - obj["abstract"] = abst; - } - }, - CLASS_NAME: "OpenLayers.Format.WFSCapabilities.v1" }); diff --git a/lib/OpenLayers/Format/WFSCapabilities/v1_0_0.js b/lib/OpenLayers/Format/WFSCapabilities/v1_0_0.js index 8b86487b65..0dc41f67fb 100644 --- a/lib/OpenLayers/Format/WFSCapabilities/v1_0_0.js +++ b/lib/OpenLayers/Format/WFSCapabilities/v1_0_0.js @@ -25,136 +25,89 @@ OpenLayers.Format.WFSCapabilities.v1_0_0 = OpenLayers.Class( * options - {Object} An optional object whose properties will be set on * this instance. */ - - /** - * 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_OnlineResource - */ - read_cap_OnlineResource: function(service, node) { - var onlineResource = this.getChildValue(node); - if (onlineResource && onlineResource.toLowerCase() != "none") { - service.onlineResource = onlineResource; - } - }, - - /** - * Method: read_cap_Keywords - */ - read_cap_Keywords: function(service, node) { - var keywords = this.getChildValue(node); - if (keywords && keywords.toLowerCase() != "none") { - service.keywords = keywords.split(', '); - } - }, - - /** - * Method: read_cap_Capability - */ - read_cap_Capability: function(capabilities, node) { - var capability = {}; - this.runChildNodes(capability, node); - capabilities.capability = capability; - }, - - /** - * Method: read_cap_Request - */ - read_cap_Request: function(obj, node) { - var request = {}; - this.runChildNodes(request, node); - obj.request = request; - }, - - /** - * Method: read_cap_GetFeature + * Property: readers + * Contains public functions, grouped by namespace prefix, that will + * be applied when a namespaced node is found matching the function + * name. The function will be applied in the scope of this parser + * with two arguments: the node being read and a context object passed + * from the parent. */ - read_cap_GetFeature: function(request, node) { - var getfeature = { - href: {}, // DCPType - formats: [] // ResultFormat - }; - this.runChildNodes(getfeature, node); - request.getfeature = getfeature; - }, - - /** - * Method: read_cap_ResultFormat - */ - read_cap_ResultFormat: function(obj, node) { - var children = node.childNodes; - var childNode; - for(var i=0; iDS_giant_polygongiant_polygonurn:x-ogc:def:crs:EPSG:4326-180.0 -90.0180.0 90.0gml:Envelopegml:Pointgml:LineStringgml:PolygonLessThanGreaterThanLessThanEqualToGreaterThanEqualToEqualToNotEqualToLikeBetweenNullCheckabsabs_2abs_3abs_4acosAreaasinatanatan2betweenboundaryboundaryDimensionbufferbufferWithSegmentsCategorizeceilcentroidclassifyCollection_AverageCollection_BoundsCollection_CountCollection_MaxCollection_MedianCollection_MinCollection_SumCollection_UniqueConcatenatecontainsconvexHullcoscrossesdateFormatdateParsedifferencedimensiondisjointdistancedouble2boolendPointenvelopeEqualIntervalequalsExactequalsExactToleranceequalToexpexteriorRingfloorgeometryTypegeomFromWKTgeomLengthgetGeometryNgetXgetYgetZgreaterEqualThangreaterThanidIEEEremainderif_then_elsein10in2in3in4in5in6in7in8in9int2bboolint2ddoubleinteriorPointinteriorRingNintersectionintersectsisClosedisEmptyisLikeisNullisRingisSimpleisValidisWithinDistancelengthlessEqualThanlessThanlogmaxmax_2max_3max_4minmin_2min_3min_4notnotEqualTonumGeometriesnumInteriorRingnumPointsoverlapsparseBooleanparseDoubleparseIntpipointNpowPropertyExistsQuantilerandomrelaterelatePatternrintroundround_2roundDoublesinsqrtStandardDeviationstartPointstrConcatstrEndsWithstrEqualsIgnoreCasestrIndexOfstrLastIndexOfstrLengthstrMatchesstrReplacestrStartsWithstrSubstringstrSubstringStartstrToLowerCasestrToUpperCasestrTrimsymDifferencetantoDegreestoRadianstouchestoWKTunionUniqueIntervalwithin'; var res = parser.read(text); - t.eq(res.capability.request.getfeature.href.get, "http://localhost:80/geoserver/wfs?", "GetFeature GET endpoint correctly parsed"); - t.eq(res.capability.request.getfeature.href.post, "http://localhost:80/geoserver/wfs?", "GetFeature POST endpoint correctly parsed"); + t.eq(res.operationsMetadata["GetFeature"].dcp.http.get[0].url, "http://localhost:80/geoserver/wfs?", "GetFeature GET endpoint correctly parsed"); + t.eq(res.operationsMetadata["GetFeature"].dcp.http.post[0].url, "http://localhost:80/geoserver/wfs?", "GetFeature POST endpoint correctly parsed"); var ft = res.featureTypeList.featureTypes; t.eq(ft.length, 14, "number of feature types correct"); t.eq(ft[0]["abstract"], "Manhattan landmarks, identifies water, lakes, parks, interesting buildilngs", "abstract of first feature type correct"); From 48a47b993a6332a12a2b6801912692733b51a852 Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Wed, 15 Feb 2012 09:38:57 +0100 Subject: [PATCH 012/119] Fix a Format.WKT test that failed due to rounding / precision of values. --- tests/Format/WKT.html | 48 +++++++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 15 deletions(-) diff --git a/tests/Format/WKT.html b/tests/Format/WKT.html index 15d2b2cf62..4850925d25 100644 --- a/tests/Format/WKT.html +++ b/tests/Format/WKT.html @@ -254,21 +254,39 @@ t.plan(1); var projections = { - src: new OpenLayers.Projection("EPSG:4326"), - dest: new OpenLayers.Projection("EPSG:900913") - }; - - var points = { - src: new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(-87.9, 41.9)), - dest: new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(-9784983.2393667, 5146011.6785665)) - }; - - var format = new OpenLayers.Format.WKT({ - externalProjection: projections["src"], - internalProjection: projections["dest"] - }); - var feature = format.read("GEOMETRYCOLLECTION(POINT(" + points["src"].geometry.x + " " + points["src"].geometry.y + "))")[0]; - t.eq(feature.geometry.toString(), points["dest"].geometry.toString(), + src: new OpenLayers.Projection("EPSG:4326"), + dest: new OpenLayers.Projection("EPSG:900913") + }, + points = { + src: new OpenLayers.Feature.Vector( + new OpenLayers.Geometry.Point(-87.9, 41.9) + ), + dest: new OpenLayers.Feature.Vector( + new OpenLayers.Geometry.Point(-9784983.2393667, 5146011.6785665) + ) + }, + format = new OpenLayers.Format.WKT({ + externalProjection: projections["src"], + internalProjection: projections["dest"] + }), + gc_wkt_parts = [ + "GEOMETRYCOLLECTION(", + "POINT(", + points["src"].geometry.x, + " ", + points["src"].geometry.y, + ")", + ")" + ], + feature = format.read( gc_wkt_parts.join("") )[0], + gotGeom = feature.geometry, + expectGeom = points["dest"].geometry, + // we don't use geometry::toString because we might run into + // precision issues + got = gotGeom.x.toFixed(7) + ' ' + gotGeom.y.toFixed(7), + expected = expectGeom.x.toFixed(7) + ' ' + expectGeom.y.toFixed(7); + + t.eq(got, expected, "Geometry collections aren't transformed twice when reprojection."); } From 5faea8e083dc6081a23a038dd0e238b3e61b711b Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Wed, 15 Feb 2012 09:54:58 +0100 Subject: [PATCH 013/119] Fix Strategy.BBOX test that failed due to mixed precision of coordinates. --- tests/Strategy/BBOX.html | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/tests/Strategy/BBOX.html b/tests/Strategy/BBOX.html index c0ff4ff401..f976d04634 100644 --- a/tests/Strategy/BBOX.html +++ b/tests/Strategy/BBOX.html @@ -80,9 +80,26 @@ strategy.update({force: true}); var from = map.getProjectionObject(); var to = layer.projection; - t.eq(strategy.bounds.toString(), map.getExtent().transform(from, to).toString(), "[force update different proj] bounds transformed"); - + var strategyBounds = strategy.bounds, + mapExtent = map.getExtent().transform(from, to), + // we don't use bounds::toString because we might run into + // precision issues + precision = 7, + strategyBoundsGot = [ + strategyBounds.left.toFixed( precision ), + strategyBounds.bottom.toFixed( precision ), + strategyBounds.right.toFixed( precision ), + strategyBounds.top.toFixed( precision ) + ].join(','), + mapExtentExpected = [ + mapExtent.left.toFixed( precision ), + mapExtent.bottom.toFixed( precision ), + mapExtent.right.toFixed( precision ), + mapExtent.top.toFixed( precision ) + ].join(','); + t.eq(strategyBoundsGot, mapExtentExpected, + "[force update different proj] bounds transformed"); } function test_events(t) { From c776dac2c26e2420e63cac643a201ea4d3d0ede6 Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Wed, 15 Feb 2012 10:02:33 +0100 Subject: [PATCH 014/119] Make precision in test configurable. --- tests/Format/WKT.html | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/Format/WKT.html b/tests/Format/WKT.html index 4850925d25..bdfc2337bc 100644 --- a/tests/Format/WKT.html +++ b/tests/Format/WKT.html @@ -283,8 +283,9 @@ expectGeom = points["dest"].geometry, // we don't use geometry::toString because we might run into // precision issues - got = gotGeom.x.toFixed(7) + ' ' + gotGeom.y.toFixed(7), - expected = expectGeom.x.toFixed(7) + ' ' + expectGeom.y.toFixed(7); + precision = 7, + got = gotGeom.x.toFixed(precision) + ' ' + gotGeom.y.toFixed(precision), + expected = expectGeom.x.toFixed(precision) + ' ' + expectGeom.y.toFixed(precision); t.eq(got, expected, "Geometry collections aren't transformed twice when reprojection."); From 436301c9ede591c1d336b0ec9d22a1009e4380e6 Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Wed, 15 Feb 2012 10:44:34 +0100 Subject: [PATCH 015/119] Fix Format.XML test where a defined variable wasn't used. This resulted in an "DOM Exception: INVALID_CHARACTER_ERR (5)" in Chrome 17. --- tests/Format/XML.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Format/XML.html b/tests/Format/XML.html index 8da8fbf1e3..ff663c3f5e 100644 --- a/tests/Format/XML.html +++ b/tests/Format/XML.html @@ -147,7 +147,7 @@ var uri = "http://foo.com"; var prefix = "foo"; var localName = "bar"; - var qualifiedName = prefix + ":" + name; + var qualifiedName = prefix + ":" + localName; var node = format.createElementNS(uri, qualifiedName); t.eq(node.nodeType, 1, "node has correct type"); From 79540f346da76697d2dad0585377f68239653919 Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Wed, 15 Feb 2012 11:09:45 +0100 Subject: [PATCH 016/119] Reformatting of testfile prior to fixing failing test in Firefox 10.0.1. No functional change. --- tests/Control/OverviewMap.html | 141 ++++++++++++++++++++------------- 1 file changed, 88 insertions(+), 53 deletions(-) diff --git a/tests/Control/OverviewMap.html b/tests/Control/OverviewMap.html index fce7a24d28..d367a4d94b 100644 --- a/tests/Control/OverviewMap.html +++ b/tests/Control/OverviewMap.html @@ -3,19 +3,23 @@ -
    +
    From e15dde05614d62807a05a732f728c14594efc67f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Tue, 24 Jan 2012 13:58:44 +0100 Subject: [PATCH 017/119] make the keyboard handler work on the map div as opposed to the document --- lib/OpenLayers/Handler/Keyboard.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/OpenLayers/Handler/Keyboard.js b/lib/OpenLayers/Handler/Keyboard.js index 0372564299..c446cb0988 100644 --- a/lib/OpenLayers/Handler/Keyboard.js +++ b/lib/OpenLayers/Handler/Keyboard.js @@ -73,7 +73,7 @@ OpenLayers.Handler.Keyboard = OpenLayers.Class(OpenLayers.Handler, { if (OpenLayers.Handler.prototype.activate.apply(this, arguments)) { for (var i=0, len=this.KEY_EVENTS.length; i Date: Tue, 24 Jan 2012 13:59:00 +0100 Subject: [PATCH 018/119] improve the accessible.html example --- examples/accessible.html | 57 ++++++++++++++++++++++++++-------------- 1 file changed, 38 insertions(+), 19 deletions(-) diff --git a/examples/accessible.html b/examples/accessible.html index d9b8a777b3..fcde73ebdb 100644 --- a/examples/accessible.html +++ b/examples/accessible.html @@ -31,6 +31,15 @@ font-size:1em; text-decoration:underline; } + a.accesskey { + color: white; + } + a.accesskey:focus { + color: #436976; + } + a.zoom { + padding-right: 20px; + } @@ -880,5 +905,27 @@ -->
    +
    From c7a631c2e5b43616e0ae494855c466c69a068021 Mon Sep 17 00:00:00 2001 From: Bart van den Eijnden Date: Fri, 24 Feb 2012 15:59:14 +0100 Subject: [PATCH 027/119] correct typo --- lib/OpenLayers/Format/SLD/v1.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/OpenLayers/Format/SLD/v1.js b/lib/OpenLayers/Format/SLD/v1.js index 49592aef71..8244c09909 100644 --- a/lib/OpenLayers/Format/SLD/v1.js +++ b/lib/OpenLayers/Format/SLD/v1.js @@ -239,7 +239,7 @@ OpenLayers.Format.SLD.v1 = OpenLayers.Class(OpenLayers.Format.Filter.v1_0_0, { labelAlign += 'b'; } else if (y > 1/3 && y < 2/3) { labelAlign += 'm'; - } else if (x >= 2/3) { + } else if (y >= 2/3) { labelAlign += 't'; } symbolizer.labelAlign = labelAlign; From 66d3b8192910ec9b5b9b5e3a0bd98d3ea65e2f4c Mon Sep 17 00:00:00 2001 From: Bart van den Eijnden Date: Fri, 24 Feb 2012 17:03:49 +0100 Subject: [PATCH 028/119] remove accidentally commited swap file --- lib/OpenLayers/Feature/.Vector.js.swp | Bin 16384 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 lib/OpenLayers/Feature/.Vector.js.swp diff --git a/lib/OpenLayers/Feature/.Vector.js.swp b/lib/OpenLayers/Feature/.Vector.js.swp deleted file mode 100644 index 264aae31ffdf200292c7a018095878b91b52334f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16384 zcmeHNO>87b6)t|V5R&kdAR$0Pg;!*3WA}J%SkP=R%-UYouxnfEnJh>fK}~m!yX>Cs zp}TsV*^L)P;*u2-KPMy({N<1XC>KC*iv&4ucy{gwW)mwOU{WATSw?uHglaSr7FKs^chkue6-b_f3rE(N-RdeE{ z+RcwxJRk6Qo{QZW_iTQ^{9cmm%@5PWixQtjnWWxscA_$_(lOu|IEH}-$kO7O1yy-^>Vx#52fN3#bH$DU z$ADwNG2j?*3^)cH1C9a5!0V9#IXp$ajDfw;4DP_(-*D*unz?*ae)CZMe@*?qDS!D; z{eMjTiYfn`>A?2$Z&SZz>c4%c{!OO*L397xp?Xv7ZjJ%RfMdWh;23ZWI0hU8jseGj zW56-s7;p?6!2k;gSw#7HwE=+N|Lyz#kKaK^1Uw9!0`39+@peLP1HS`)27Dj*DzFbo zAOjNM5-$$23!JGfsX8l{a0_@6=mTBgGVlm+4p;)-54`wRj34+4kOM;?1U>`28@M0%`&$V4D{vcl9vA@) z;La&Ro(8S~4*}2LL&$X?12}LE_#|)^m;t7MKjKWrcYtpJw}2;s5NHD*0X__T0C*4Z zD{PoN0n7upVcQphUjsh{eggauxCuN4bOB}mHt_#nR9&-li=}M9CC+iQh$*u7l@up9 zIAwICPjJwFaiGJaWrHNnWSXnv9W7d&{P4`l53e}+p<6d+XDO_RYmfw@FL=e*bqscuRxnyo%e`$@oUXSOzEBVMvwJ+C=el!YSRp^?}tY*#wq)sV-avTkP@vWyN` zz^#KQ8O9-Nn$0N#YmYE0SWS+n!Wyqdmp6O6@O1k~ImRQ0*6t%_5F3TR7OL$F8Pdzj zzsDv7<_f1wv|!_^5l&a>LEDZ@?Onc;QJldV@>GtM&$0;N7{L5GDg)Z%@Bj|SR~!m? zcfeGSdo}l(h#hSo5UE{?ioVv?s@0x|GMM9Vm}E5Rm*HG9g7S6*ft6Et=#?avX%cx8 zBrVU;{ZRO!>L623QfrfvfO2%b@ks$Prvq?56;i^3dSk1Cl4+a;9-@ZH$8?{AzQTNg zM_2MR<*`J3>1m|SypB3Wz7=<)aFheuj;S%8HofY`hK?p@Vl2wOwHQeHR$O~)eajfS zRr0ATF>C6({s;8}p039jnna8SywCDTPT47>oI!7FW5$ek4lv892efpvQ7PiQTERd>C%vu4Dxc*!-OKIRz`}M*b zOBYZvpga%(zAvH({!b;_gJ==MgPD)0k7do~6Rbk(awz&kCdUy!W+0_`bxX{C6QcB! z#S*9&HH^CWmPxFZ$BDEyu_7zF^gKadty2UzvT`m^Qzr1KQgmQ~ey9D-eVVLwd;BzOPB5njyXo!feZ#N-l#0ssEI8Ez(cfrCYf=S zVj*I*p_OVVT?|9Uu``pg@;YJGuGCk|!H#VhCV^z)L9D~Ev-CAwy!tOA@G}tIs zrS*;NwJRMoU5^ne(v)^LKD)7bbpyrScrQ-&V^glCQ#~7I$~$U)v#n-U_|^^5Y|_q^ z_Vz{ExwyVfl;(ZBL{P~emns=iR=}G9j>;0ui(~6vlI}E- zK*xKvv+Pa#w1hyNVXHjG^b!foljy})NsM|YNz!b_qg#0oH6fe_6Bu$rrNm0aSxV1u zuU6_%kVsdO;TSI&p`_FP3|(AUI6J?%aAr|W-_>~0s_KAFXBYuPo{!!&n za11yG90QI4$ADwNG2j?*3^)cH1FusC4$i4pd7}QAABgZN5ZMrK%-C^`lb9F32sQK; zE^pW$f)3{JE^e-f^?0?}k&@Ly_EWV?&4*(2m4Tj7on{ ztLfvt*gkc7L0`36>~3dTpeS~ZYE{Doo5Va_8>wwgNF9kxV9Rccsp6p4Fifz0x}{oo zW1)80KXhc}6&8pbg3g%DcWAA Date: Fri, 24 Feb 2012 17:48:35 +0100 Subject: [PATCH 029/119] do not use rotation but use labelRotation instead (thanks @ahocevar for the catch) --- lib/OpenLayers/Format/SLD/v1.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/OpenLayers/Format/SLD/v1.js b/lib/OpenLayers/Format/SLD/v1.js index 8244c09909..3d5bc87c9a 100644 --- a/lib/OpenLayers/Format/SLD/v1.js +++ b/lib/OpenLayers/Format/SLD/v1.js @@ -224,7 +224,10 @@ OpenLayers.Format.SLD.v1 = OpenLayers.Class(OpenLayers.Format.Filter.v1_0_0, { this.readChildNodes(node, symbolizer); }, "PointPlacement": function(node, symbolizer) { - this.readChildNodes(node, symbolizer); + var config = {}; + this.readChildNodes(node, config); + config.labelRotation = config.rotation; + delete config.rotation; var labelAlign, x = symbolizer.labelAnchorPointX, y = symbolizer.labelAnchorPointY; @@ -242,7 +245,8 @@ OpenLayers.Format.SLD.v1 = OpenLayers.Class(OpenLayers.Format.Filter.v1_0_0, { } else if (y >= 2/3) { labelAlign += 't'; } - symbolizer.labelAlign = labelAlign; + config.labelAlign = labelAlign; + OpenLayers.Util.applyDefaults(symbolizer, config); }, "AnchorPoint": function(node, symbolizer) { this.readChildNodes(node, symbolizer); @@ -999,8 +1003,8 @@ OpenLayers.Format.SLD.v1 = OpenLayers.Class(OpenLayers.Format.Filter.v1_0_0, { symbolizer.labelYOffset != null) { this.writeNode("Displacement", symbolizer, node); } - if (symbolizer.rotation != null) { - this.writeNode("Rotation", symbolizer.rotation, node); + if (symbolizer.labelRotation != null) { + this.writeNode("Rotation", symbolizer.labelRotation, node); } return node; }, From 617ba736a29a47e6d218ad9f40b808ab36824494 Mon Sep 17 00:00:00 2001 From: Bart van den Eijnden Date: Fri, 24 Feb 2012 18:20:41 +0100 Subject: [PATCH 030/119] if labelAlign is set, translate to AnchorPointX and AnchorPointY --- lib/OpenLayers/Format/SLD/v1.js | 67 ++++++++++++++++++++++++--------- 1 file changed, 49 insertions(+), 18 deletions(-) diff --git a/lib/OpenLayers/Format/SLD/v1.js b/lib/OpenLayers/Format/SLD/v1.js index 3d5bc87c9a..cfd67fa3f7 100644 --- a/lib/OpenLayers/Format/SLD/v1.js +++ b/lib/OpenLayers/Format/SLD/v1.js @@ -948,22 +948,26 @@ OpenLayers.Format.SLD.v1 = OpenLayers.Class(OpenLayers.Format.Filter.v1_0_0, { } // add in optional Font if(symbolizer.fontFamily != null || - symbolizer.fontSize != null || - symbolizer.fontWeight != null || - symbolizer.fontStyle != null) { - this.writeNode("Font", symbolizer, node); + symbolizer.fontSize != null || + symbolizer.fontWeight != null || + symbolizer.fontStyle != null) { + this.writeNode("Font", symbolizer, node); } // add in optional LabelPlacement - if ((symbolizer.labelAnchorPointX != null || - symbolizer.labelAnchorPointY != null) || + if (symbolizer.labelAnchorPointX != null || + symbolizer.labelAnchorPointY != null || + symbolizer.labelAlign != null || + symbolizer.labelXOffset != null || + symbolizer.labelYOffset != null || + symbolizer.labelRotation != null || symbolizer.labelPerpendicularOffset != null) { - this.writeNode("LabelPlacement", symbolizer, node); + this.writeNode("LabelPlacement", symbolizer, node); } // add in optional Halo if(symbolizer.haloRadius != null || - symbolizer.haloColor != null || - symbolizer.haloOpacity != null) { - this.writeNode("Halo", symbolizer, node); + symbolizer.haloColor != null || + symbolizer.haloOpacity != null) { + this.writeNode("Halo", symbolizer, node); } // add in optional Fill if(symbolizer.fillColor != null || @@ -975,8 +979,12 @@ OpenLayers.Format.SLD.v1 = OpenLayers.Class(OpenLayers.Format.Filter.v1_0_0, { "LabelPlacement": function(symbolizer) { var node = this.createElementNSPlus("sld:LabelPlacement"); if (symbolizer.labelAnchorPointX != null || - symbolizer.labelAnchorPointY != null) { - this.writeNode("PointPlacement", symbolizer, node); + symbolizer.labelAnchorPointY != null || + symbolizer.labelAlign != null || + symbolizer.labelXOffset != null || + symbolizer.labelYOffset != null || + symbolizer.labelRotation != null) { + this.writeNode("PointPlacement", symbolizer, node); } if (symbolizer.labelPerpendicularOffset != null) { this.writeNode("LinePlacement", symbolizer, node); @@ -996,7 +1004,8 @@ OpenLayers.Format.SLD.v1 = OpenLayers.Class(OpenLayers.Format.Filter.v1_0_0, { "PointPlacement": function(symbolizer) { var node = this.createElementNSPlus("sld:PointPlacement"); if (symbolizer.labelAnchorPointX != null || - symbolizer.labelAnchorPointY != null) { + symbolizer.labelAnchorPointY != null || + symbolizer.labelAlign != null) { this.writeNode("AnchorPoint", symbolizer, node); } if (symbolizer.labelXOffset != null || @@ -1010,11 +1019,33 @@ OpenLayers.Format.SLD.v1 = OpenLayers.Class(OpenLayers.Format.Filter.v1_0_0, { }, "AnchorPoint": function(symbolizer) { var node = this.createElementNSPlus("sld:AnchorPoint"); - if (symbolizer.labelAnchorPointX != null) { - this.writeNode("AnchorPointX", symbolizer.labelAnchorPointX, node); - } - if (symbolizer.labelAnchorPointY != null) { - this.writeNode("AnchorPointY", symbolizer.labelAnchorPointY, node); + var x = symbolizer.labelAnchorPointX, + y = symbolizer.labelAnchorPointY; + if (x != null) { + this.writeNode("AnchorPointX", x, node); + } + if (y != null) { + this.writeNode("AnchorPointY", y, node); + } + if (x == null && y == null) { + var xAlign = symbolizer.labelAlign.substr(0, 1), + yAlign = symbolizer.labelAlign.substr(1, 1); + if (xAlign === "l") { + x = 0; + } else if (xAlign === "c") { + x = 0.5; + } else if (xAlign === "r") { + x = 1; + } + if (yAlign === "b") { + y = 0; + } else if (yAlign === "m") { + y = 0.5; + } else if (yAlign === "t") { + y = 1; + } + this.writeNode("AnchorPointX", x, node); + this.writeNode("AnchorPointY", y, node); } return node; }, From 12d8220992ba5a6bebb6ac0e9b5989c867729024 Mon Sep 17 00:00:00 2001 From: Bart van den Eijnden Date: Fri, 24 Feb 2012 18:35:20 +0100 Subject: [PATCH 031/119] add a testcase for the labelAlign to AnchorPoint translation --- tests/Format/SLD/v1_0_0.html | 41 ++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/tests/Format/SLD/v1_0_0.html b/tests/Format/SLD/v1_0_0.html index 7b3c50acf2..6fdcd2bf7e 100644 --- a/tests/Format/SLD/v1_0_0.html +++ b/tests/Format/SLD/v1_0_0.html @@ -549,6 +549,28 @@ t.xml_eq(got, exp, "LinePlacement written out correctly"); } + function test_labelAlignToAnchorPosition(t) { + t.plan(1); + var format = new OpenLayers.Format.SLD.v1_0_0({ + multipleSymbolizers: true + }); + var style = new OpenLayers.Style2({ + rules: [ + new OpenLayers.Rule({ + symbolizers: [ + new OpenLayers.Symbolizer.Text({ + label: "${FOO}", + labelAlign: "rb" + }) + ] + }) + ] + }); + var got = format.writeNode("sld:UserStyle", style); + var exp = readXML("label_pointplacement_test.sld").documentElement; + t.xml_eq(got, exp, "PointPlacement with labelAlign written out correctly"); + } + function test_read_FeatureTypeStyles(t) { t.plan(13); @@ -927,5 +949,24 @@ --> +
    From 5444fbcfc8adaa28ad0f05caaf0d1545deb6c05a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Tue, 28 Feb 2012 09:06:47 +0100 Subject: [PATCH 032/119] make the Google Closure compiler happier, no functional change --- lib/OpenLayers/Kinetic.js | 5 +++-- lib/OpenLayers/Tween.js | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/OpenLayers/Kinetic.js b/lib/OpenLayers/Kinetic.js index 451a66ef7d..b744e24653 100644 --- a/lib/OpenLayers/Kinetic.js +++ b/lib/OpenLayers/Kinetic.js @@ -1,8 +1,9 @@ /* Copyright (c) 2006-2012 by OpenLayers Contributors (see authors.txt for * full list of contributors). Published under the Clear BSD license. * See http://svn.openlayers.org/trunk/openlayers/license.txt for the - * full text of the license. - * + * full text of the license. */ + +/** * @requires OpenLayers/BaseTypes/Class.js * @requires OpenLayers/Animation.js */ diff --git a/lib/OpenLayers/Tween.js b/lib/OpenLayers/Tween.js index e30d5d607b..85718c0953 100644 --- a/lib/OpenLayers/Tween.js +++ b/lib/OpenLayers/Tween.js @@ -1,8 +1,9 @@ /* Copyright (c) 2006-2012 by OpenLayers Contributors (see authors.txt for * full list of contributors). Published under the Clear BSD license. * See http://svn.openlayers.org/trunk/openlayers/license.txt for the - * full text of the license. - * + * full text of the license. */ + +/** * @requires OpenLayers/BaseTypes/Class.js * @requires OpenLayers/Animation.js */ From acf6a8a97d7f9d67b8bc4bbd38e866f3c542bc4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Tue, 28 Feb 2012 09:53:10 +0100 Subject: [PATCH 033/119] indicate that String.camelize is deprecated in the 2.12 release notes, refs #64, no functional change --- notes/2.12.md | 1 + 1 file changed, 1 insertion(+) diff --git a/notes/2.12.md b/notes/2.12.md index 3aa2db8eda..759cbf83d2 100644 --- a/notes/2.12.md +++ b/notes/2.12.md @@ -109,6 +109,7 @@ A number of properties, methods, and constructors have been marked as deprecated * OpenLayers.Util.setOpacity * OpenLayers.Util.safeStopPropagation * OpenLayers.Util.getArgs + * OpenLayers.Sring.camelize * OpenLayers.nullHandler * OpenLayers.loadURL * OpenLayers.parseXMLString From f3c48d696334649e43e8177b6fee6d96023123e0 Mon Sep 17 00:00:00 2001 From: fredj Date: Fri, 13 Jan 2012 14:36:21 +0100 Subject: [PATCH 034/119] Store the original map options into 'options' property --- lib/OpenLayers/Map.js | 10 ++++++++++ tests/Map.html | 17 +++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index 15b3bb03dd..f861721c59 100644 --- a/lib/OpenLayers/Map.js +++ b/lib/OpenLayers/Map.js @@ -239,6 +239,12 @@ OpenLayers.Map = OpenLayers.Class({ */ panRatio: 1.5, + /** + * APIProperty: options + * {Object} The options object passed to the class constructor. Read-only. + */ + options: null, + // Options /** @@ -480,6 +486,9 @@ OpenLayers.Map = OpenLayers.Class({ this.theme = OpenLayers._getScriptLocation() + 'theme/default/style.css'; + // backup original options + this.options = OpenLayers.Util.extend({}, options); + // now override default options OpenLayers.Util.extend(this, options); @@ -731,6 +740,7 @@ OpenLayers.Map = OpenLayers.Class({ this.events.destroy(); this.events = null; + this.options = null; }, /** diff --git a/tests/Map.html b/tests/Map.html index 6adfba83c4..ee8b8e7fb2 100644 --- a/tests/Map.html +++ b/tests/Map.html @@ -2000,6 +2000,23 @@ t.eq(map.layerContainerDiv.style.top, '0px', 'layer container top correct'); } + function test_options(t) { + t.plan(2); + + var map = new OpenLayers.Map('map'); + t.eq(map.options, {}, 'map.options is empty with no options'); + map.destroy(); + + var options = { + resolutions: [1,2,3,5], + projection: "EPSG:4326", + units: 'm' + }; + var map = new OpenLayers.Map('map', options); + t.eq(map.options, options, 'map.options is a copy of the constructor option'); + map.destroy(); + } + function test_adjustZoom(t) { t.plan(4); var map = new OpenLayers.Map({ From 4efa03eb59a43bde442bac2ea6360a2d7a987595 Mon Sep 17 00:00:00 2001 From: Arjen Kopinga Date: Wed, 22 Feb 2012 17:39:11 +0100 Subject: [PATCH 035/119] Fix for being able to select a feature from an invisible layer that uses the Canvas renderer --- lib/OpenLayers/Renderer/Canvas.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/OpenLayers/Renderer/Canvas.js b/lib/OpenLayers/Renderer/Canvas.js index 35939afdd2..199ca8f10d 100644 --- a/lib/OpenLayers/Renderer/Canvas.js +++ b/lib/OpenLayers/Renderer/Canvas.js @@ -787,6 +787,10 @@ OpenLayers.Renderer.Canvas = OpenLayers.Class(OpenLayers.Renderer, { */ getFeatureIdFromEvent: function(evt) { var featureId, feature; + + // if the drawing canvas isn't visible, return undefined. + if (this.root.style.display === "none") return feature; + if (this.hitDetection) { // this dragging check should go in the feature handler if (!this.map.dragging) { From bf834e6b8ef97f06904ea18b94d0fb92315a4737 Mon Sep 17 00:00:00 2001 From: Arjen Kopinga Date: Wed, 22 Feb 2012 17:44:31 +0100 Subject: [PATCH 036/119] being a good coder and adding braces around if statement body --- lib/OpenLayers/Renderer/Canvas.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/OpenLayers/Renderer/Canvas.js b/lib/OpenLayers/Renderer/Canvas.js index 199ca8f10d..30ab7a6d99 100644 --- a/lib/OpenLayers/Renderer/Canvas.js +++ b/lib/OpenLayers/Renderer/Canvas.js @@ -789,7 +789,7 @@ OpenLayers.Renderer.Canvas = OpenLayers.Class(OpenLayers.Renderer, { var featureId, feature; // if the drawing canvas isn't visible, return undefined. - if (this.root.style.display === "none") return feature; + if (this.root.style.display === "none") { return feature; } if (this.hitDetection) { // this dragging check should go in the feature handler From f8189f2862b2010f149d1f135879496ab0e9dce9 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 23 Feb 2012 10:23:23 +0100 Subject: [PATCH 037/119] Added unit tests for hit detection on invisible canvas layer --- tests/Renderer/Canvas.html | 86 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/tests/Renderer/Canvas.html b/tests/Renderer/Canvas.html index bdec99948c..a19aa1f56f 100644 --- a/tests/Renderer/Canvas.html +++ b/tests/Renderer/Canvas.html @@ -348,6 +348,92 @@ } + // Extra test: hit detection on an invisible canvas should return undefined + function test_hitDetectionOnInvisibleLayer(t) { + if (!supported) { + t.plan(0); + return; + } + + var layer = new OpenLayers.Layer.Vector(null, { + isBaseLayer: true, + resolutions: [1], + styleMap: new OpenLayers.StyleMap({ + pointRadius: 5, + strokeWidth: 3, + fillColor: "red", + fillOpacity: 0.5, + strokeColor: "blue", + strokeOpacity: 0.75 + }), + renderers: ["Canvas"] + }); + + var map = new OpenLayers.Map({ + div: "map", + controls: [], + layers: [layer], + center: new OpenLayers.LonLat(0, 0), + zoom: 0 + }); + + layer.addFeatures([ + new OpenLayers.Feature.Vector( + new OpenLayers.Geometry.Point(-100, 0) + ), + new OpenLayers.Feature.Vector( + OpenLayers.Geometry.fromWKT("LINESTRING(-50 0, 50 0)") + ), + new OpenLayers.Feature.Vector( + OpenLayers.Geometry.fromWKT("POLYGON((100 -25, 150 -25, 150 25, 100 25, 100 -25), (120 -5, 130 -5, 130 5, 120 5, 120 -5))") + ) + ]); + + var cases = [{ + msg: "center of invisible point", x: -100, y: 0, id: layer.features[0].id + }, { + msg: "edge of invisible point", x: -103, y: 3, id: layer.features[0].id + }, { + msg: "outside invisible point", x: -110, y: 3, id: null + }, { + msg: "center of invisible line", x: 0, y: 0, id: layer.features[1].id + }, { + msg: "edge of invisible line", x: 0, y: 1, id: layer.features[1].id + }, { + msg: "outside invisible line", x: 0, y: 5, id: null + }, { + msg: "inside invisible polygon", x: 110, y: 0, id: layer.features[2].id + }, { + msg: "edge of invisible polygon", x: 99, y: 0, id: layer.features[2].id + }, { + msg: "inside invisible polygon hole", x: 125, y: 0, id: null + }, { + msg: "outside invisible polygon", x: 155, y: 0, id: null + }]; + + function px(x, y) { + return map.getPixelFromLonLat( + new OpenLayers.LonLat(x, y) + ); + } + + var num = cases.length; + t.plan(num); + var c, feature; + + // Hit detection on an invisible canvas layer should always return undefined + layer.setVisibility(false); + + for (var i=0; i Date: Tue, 28 Feb 2012 10:15:55 +0100 Subject: [PATCH 038/119] simplified unit test for hit detection on invisible canvas --- tests/Renderer/Canvas.html | 94 +++----------------------------------- 1 file changed, 7 insertions(+), 87 deletions(-) diff --git a/tests/Renderer/Canvas.html b/tests/Renderer/Canvas.html index a19aa1f56f..303b56732d 100644 --- a/tests/Renderer/Canvas.html +++ b/tests/Renderer/Canvas.html @@ -336,104 +336,24 @@ } var num = cases.length; - t.plan(num); + t.plan(2 * num); var c, feature; for (var i=0; i Date: Tue, 28 Feb 2012 10:45:18 +0100 Subject: [PATCH 039/119] Simplifying logic that returns undefined when root is invisible. --- lib/OpenLayers/Renderer/Canvas.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/OpenLayers/Renderer/Canvas.js b/lib/OpenLayers/Renderer/Canvas.js index 30ab7a6d99..ee90db4e38 100644 --- a/lib/OpenLayers/Renderer/Canvas.js +++ b/lib/OpenLayers/Renderer/Canvas.js @@ -788,10 +788,7 @@ OpenLayers.Renderer.Canvas = OpenLayers.Class(OpenLayers.Renderer, { getFeatureIdFromEvent: function(evt) { var featureId, feature; - // if the drawing canvas isn't visible, return undefined. - if (this.root.style.display === "none") { return feature; } - - if (this.hitDetection) { + if (this.hitDetection && this.root.style.display !== "none") { // this dragging check should go in the feature handler if (!this.map.dragging) { var xy = evt.xy; From eb700d98e14ffab037d66149a0c88e3154f16d94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Tue, 28 Feb 2012 10:46:49 +0100 Subject: [PATCH 040/119] add an example for an accessible click control implementation --- examples/click-keyboard.html | 69 ++++++++++++ examples/click-keyboard.js | 199 +++++++++++++++++++++++++++++++++++ 2 files changed, 268 insertions(+) create mode 100644 examples/click-keyboard.html create mode 100644 examples/click-keyboard.js diff --git a/examples/click-keyboard.html b/examples/click-keyboard.html new file mode 100644 index 0000000000..c81917cef2 --- /dev/null +++ b/examples/click-keyboard.html @@ -0,0 +1,69 @@ + + + + + + + Accessible Custom Click Control + + + + + + + + + +

    An accessible click control implementation

    + +
    + click, control, accessibility +
    + + + Jump to map + + +
    + +

    + Demonstrate the KeyboardDefaults control as well as a control that + allows clicking on the map using the keyboard. + First focus the map (using tab key or mouse), then press the 'i' + key to activate the query control. You can then move the point + using arrow keys. Press 'RETURN' to get the coordinate. Press 'i' + again to deactivate the control. +

    + + + diff --git a/examples/click-keyboard.js b/examples/click-keyboard.js new file mode 100644 index 0000000000..328e0da768 --- /dev/null +++ b/examples/click-keyboard.js @@ -0,0 +1,199 @@ +var map, navigationControl, queryControl; + +function init(){ + map = new OpenLayers.Map('map', {controls: []}); + var layer = new OpenLayers.Layer.WMS( + "OpenLayers WMS", + "http://vmap0.tiles.osgeo.org/wms/vmap0", + {layers: 'basic'} + ); + map.addLayers([layer]); + + navigationControl = new OpenLayers.Control.KeyboardDefaults({ + observeElement: 'map' + }); + map.addControl(navigationControl); + + queryControl = new OpenLayers.Control.KeyboardClick({ + observeElement: 'map' + }); + map.addControl(queryControl); + + map.zoomToMaxExtent(); +} + +/** + * Class: OpenLayers.Control.KeyboardClick + * + * A custom control that (a) adds a vector point that can be moved using the + * arrow keys of the keyboard, and (b) displays a browser alert window when the + * RETURN key is pressed. The control can be activated/deactivated using the + * "i" key. When activated the control deactivates any KeyboardDefaults control + * in the map so that the map is not moved when the arrow keys are pressed. + * + * This control relies on the OpenLayers.Handler.KeyboardPoint custom handler. + */ +OpenLayers.Control.KeyboardClick = OpenLayers.Class(OpenLayers.Control, { + initialize: function(options) { + OpenLayers.Control.prototype.initialize.apply(this, [options]); + var observeElement = this.observeElement || document; + this.handler = new OpenLayers.Handler.KeyboardPoint(this, { + done: this.onClick, + cancel: this.deactivate + }, { + observeElement: observeElement + }); + OpenLayers.Event.observe( + observeElement, + "keydown", + OpenLayers.Function.bindAsEventListener( + function(evt) { + if (evt.keyCode == 73) { // "i" + if (this.active) { + this.deactivate(); + } else { + this.activate(); + } + } + }, + this + ) + ); + }, + + onClick: function(geometry) { + alert("You clicked near " + geometry.x + " N, " + + geometry.y + " E"); + }, + + activate: function() { + if(!OpenLayers.Control.prototype.activate.apply(this, arguments)) { + return false; + } + // deactivate any KeyboardDefaults control + var keyboardDefaults = this.map.getControlsByClass( + 'OpenLayers.Control.KeyboardDefaults')[0]; + if (keyboardDefaults) { + keyboardDefaults.deactivate(); + } + return true; + }, + + deactivate: function() { + if(!OpenLayers.Control.prototype.deactivate.apply(this, arguments)) { + return false; + } + // reactivate any KeyboardDefaults control + var keyboardDefaults = this.map.getControlsByClass( + 'OpenLayers.Control.KeyboardDefaults')[0]; + if (keyboardDefaults) { + keyboardDefaults.activate(); + } + return true; + } +}); + +/** + * Class: OpenLayers.Handler.KeyboardPoint + * + * A custom handler that displays a vector point that can be moved + * using the arrow keys of the keyboard. + */ +OpenLayers.Handler.KeyboardPoint = OpenLayers.Class(OpenLayers.Handler, { + + KEY_EVENTS: ["keydown"], + + + initialize: function(control, callbacks, options) { + OpenLayers.Handler.prototype.initialize.apply(this, arguments); + // cache the bound event listener method so it can be unobserved later + this.eventListener = OpenLayers.Function.bindAsEventListener( + this.handleKeyEvent, this + ); + }, + + activate: function() { + if(!OpenLayers.Handler.prototype.activate.apply(this, arguments)) { + return false; + } + this.layer = new OpenLayers.Layer.Vector(this.CLASS_NAME); + this.map.addLayer(this.layer); + this.observeElement = this.observeElement || document; + for (var i=0, len=this.KEY_EVENTS.length; i Date: Tue, 28 Feb 2012 10:48:50 +0100 Subject: [PATCH 041/119] click-keyboard example renamed to accessible-click-control --- examples/{click-keyboard.html => accessible-click-control.html} | 2 +- examples/{click-keyboard.js => accessible-click-control.js} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename examples/{click-keyboard.html => accessible-click-control.html} (97%) rename examples/{click-keyboard.js => accessible-click-control.js} (100%) diff --git a/examples/click-keyboard.html b/examples/accessible-click-control.html similarity index 97% rename from examples/click-keyboard.html rename to examples/accessible-click-control.html index c81917cef2..c8d97cde88 100644 --- a/examples/click-keyboard.html +++ b/examples/accessible-click-control.html @@ -38,7 +38,7 @@ - +

    An accessible click control implementation

    diff --git a/examples/click-keyboard.js b/examples/accessible-click-control.js similarity index 100% rename from examples/click-keyboard.js rename to examples/accessible-click-control.js From 1c6d44e5d5f1dce796ecb6ad6d59560bd8257bf2 Mon Sep 17 00:00:00 2001 From: Arjen Kopinga Date: Tue, 28 Feb 2012 11:17:46 +0100 Subject: [PATCH 042/119] Moved symbol definitions to Renderer.js --- lib/OpenLayers/Renderer.js | 15 +++++++++++++++ lib/OpenLayers/Renderer/Elements.js | 14 -------------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/lib/OpenLayers/Renderer.js b/lib/OpenLayers/Renderer.js index 45de3a6f3f..3d7ffa1596 100644 --- a/lib/OpenLayers/Renderer.js +++ b/lib/OpenLayers/Renderer.js @@ -415,3 +415,18 @@ OpenLayers.Renderer.defaultSymbolizer = { labelAlign: 'cm' }; + + +/** + * Constant: OpenLayers.Renderer.symbol + * Coordinate arrays for well known (named) symbols. + */ +OpenLayers.Renderer.symbol = { + "star": [350,75, 379,161, 469,161, 397,215, 423,301, 350,250, 277,301, + 303,215, 231,161, 321,161, 350,75], + "cross": [4,0, 6,0, 6,4, 10,4, 10,6, 6,6, 6,10, 4,10, 4,6, 0,6, 0,4, 4,4, + 4,0], + "x": [0,0, 25,0, 50,35, 75,0, 100,0, 65,50, 100,100, 75,100, 50,65, 25,100, 0,100, 35,50, 0,0], + "square": [0,0, 0,1, 1,1, 1,0, 0,0], + "triangle": [0,10, 10,10, 5,0, 0,10] +}; \ No newline at end of file diff --git a/lib/OpenLayers/Renderer/Elements.js b/lib/OpenLayers/Renderer/Elements.js index 7e1d89e5b1..11735f4eeb 100644 --- a/lib/OpenLayers/Renderer/Elements.js +++ b/lib/OpenLayers/Renderer/Elements.js @@ -1051,17 +1051,3 @@ OpenLayers.Renderer.Elements = OpenLayers.Class(OpenLayers.Renderer, { CLASS_NAME: "OpenLayers.Renderer.Elements" }); - -/** - * Constant: OpenLayers.Renderer.symbol - * Coordinate arrays for well known (named) symbols. - */ -OpenLayers.Renderer.symbol = { - "star": [350,75, 379,161, 469,161, 397,215, 423,301, 350,250, 277,301, - 303,215, 231,161, 321,161, 350,75], - "cross": [4,0, 6,0, 6,4, 10,4, 10,6, 6,6, 6,10, 4,10, 4,6, 0,6, 0,4, 4,4, - 4,0], - "x": [0,0, 25,0, 50,35, 75,0, 100,0, 65,50, 100,100, 75,100, 50,65, 25,100, 0,100, 35,50, 0,0], - "square": [0,0, 0,1, 1,1, 1,0, 0,0], - "triangle": [0,10, 10,10, 5,0, 0,10] -}; From 94e8fff9e6ce8c9457ce1b09f7adf6099130ad8f Mon Sep 17 00:00:00 2001 From: ahocevar Date: Tue, 28 Feb 2012 12:04:38 +0100 Subject: [PATCH 043/119] Fixing test (see #249) --- tests/Layer/Grid.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/Layer/Grid.html b/tests/Layer/Grid.html index 366627caa3..9cd87a705c 100644 --- a/tests/Layer/Grid.html +++ b/tests/Layer/Grid.html @@ -226,9 +226,10 @@ map.setCenter([-10, 0], 5); var log = []; + var origDeferMoveGriddedTiles = layer.deferMoveGriddedTiles; layer.deferMoveGriddedTiles = function() { log.push("deferMoveGriddedTiles"); - OpenLayers.Layer.WMS.prototype.deferMoveGriddedTiles.apply(this, arguments); + origDeferMoveGriddedTiles.apply(this, arguments); } layer.moveGriddedTiles = function() { log.push("moveGriddedTiles"); From 2f3f84959726e0baf13be33617014a48a8b64c70 Mon Sep 17 00:00:00 2001 From: Peter Robins Date: Tue, 28 Feb 2012 12:14:43 +0000 Subject: [PATCH 044/119] Remove doc/walkthru.html --- doc/walkthru.html | 96 ----------------------------------------------- 1 file changed, 96 deletions(-) delete mode 100644 doc/walkthru.html diff --git a/doc/walkthru.html b/doc/walkthru.html deleted file mode 100644 index b135e63523..0000000000 --- a/doc/walkthru.html +++ /dev/null @@ -1,96 +0,0 @@ - - -OpenLayers examples walkthrough - - - - -

    <ol>

    -

    API documentation: http://dev.openlayers.org/docs/

    -

    Examples: http://openlayers.org/dev/examples/

    -

    Maps

    -
      -
    1. Basic example
    2. -
    3. Layer switcher (aka legend)
    4. -
    5. Base layers versus overlays
    6. -
    7. Multiple WMS mirrors
    8. -
    9. Full screen map
    10. -
    11. Wrapping the date line
    12. -
    13. Other cartographic projections
    14. -
    15. Translucent overlays
    16. -
    - -

    Raster Layers

    -
      -
    1. Untiled WMS layer
    2. -
    3. Ka-Map layer
    4. -
    5. MapServer layer
    6. -
    7. Worldwind layer
    8. -
    9. TMS layer
    10. -
    11. Image layer
    12. -
    13. Google layer
    14. -
    15. VirtualEarth layer
    16. -
    17. Spherical Mercator ("EPSG:900913")
    18. -
    19. TileCache
    20. -
    - -

    Marker Layers

    -
      -
    1. Markers
    2. -
    3. Changing marker properties dynamically
    4. -
    5. Popups
    6. -
    7. GeoRSS (example data)
    8. -
    9. GeoRSS with custom markers
    10. -
    11. Point layer from WFS
    12. -
    13. WFS GetFeatureInfo example
    14. -
    - -

    Events and Controls

    -
      -
    1. Navigation tools on the map
    2. -
    3. Navigation toolbar off the map
    4. -
    5. Tracking the mouse position
    6. -
    7. Overview map
    8. -
    9. Layer attribution
    10. -
    11. Full range of controls
    12. -
    13. Custom controls #1
    14. -
    15. Custom controls #2
    16. -
    17. Custom control styles
    18. -
    19. Trapping click events
    20. -
    21. Tracking map events
    22. -
    - -

    Vector Layers

    -
      -
    1. Generating features in JavaScript
    2. -
    3. Loading features from GML
    4. -
    5. Loading features from KML
    6. -
    7. Serializing features to GML
    8. -
    9. Serializing to other formats
    10. -
    11. Selecting features
    12. -
    13. Attaching popups to features
    14. -
    - -

    Editing Tools

    -
      -
    1. Drawing features
    2. -
    3. Editing toolbar (outside the map)
    4. -
    5. Creating regular polygons
    6. -
    7. Modifying features
    8. -
    9. Resizing features
    10. -
    11. Rotating features
    12. -
    13. Transactional WFS example
    14. -
    15. FeatureServer
    16. -
    - -

    Testing

    -
      -
    1. Test.AnotherWay suite
    2. -
    - -

    </ol>

    - - From f9b64d945a9ae682d2e88597e8f0c99a3065e8dc Mon Sep 17 00:00:00 2001 From: Peter Robins Date: Tue, 28 Feb 2012 12:52:53 +0000 Subject: [PATCH 045/119] Fix broken link in readme --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 596b316b92..074556beb6 100644 --- a/readme.md +++ b/readme.md @@ -9,7 +9,7 @@ Please see license.txt in this distribution for more details. ## Getting OpenLayers -OpenLayers lives at http://www.openlayers.org/. Find details on downloading stable releases or the development version the [development site](http://trac.osgeo.org/openlayers/wiki/HowToDownload.) +OpenLayers lives at http://www.openlayers.org/. Find details on downloading stable releases or the development version the [development site](http://trac.osgeo.org/openlayers/wiki/HowToDownload). ## Installing OpenLayers From 2e6fe7d330bfcf408ab5595c6a2604a260b5726f Mon Sep 17 00:00:00 2001 From: ahocevar Date: Tue, 28 Feb 2012 15:07:03 +0100 Subject: [PATCH 046/119] Notes about wrapDateLine. --- notes/2.12.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/notes/2.12.md b/notes/2.12.md index 759cbf83d2..b77d87739d 100644 --- a/notes/2.12.md +++ b/notes/2.12.md @@ -98,6 +98,10 @@ If you were previously using the `OpenLayers.Layer.SphericalMercator.forwardMerc The internal `OpenLayers.Layer.getURLasync` function now take a bound, a callback and a scope. The function no longer needs update the passed property but simply to return to url. +## Changes when base layer configured with wrapDateLine: true + +Vector editing across the date line works reliably now. To make this work, OpenLayers won't zoom out to resolutions where more than one world is visible any more. For maps that have base layers with wrapDateLine set to false, no zoom restrictions apply. + ## Deprecated Components A number of properties, methods, and constructors have been marked as deprecated for multiple releases in the 2.x series. For the 2.12 release this deprecated functionality has been moved to a separate deprecated.js file. If you use any of the constructors or methods below, you will have to explicitly include the deprecated.js file in your build (or add it in a separate ` From aedc96f030a67c0a221fb84730315bb056167531 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Tue, 7 Feb 2012 17:19:49 +0100 Subject: [PATCH 051/119] [examples] add an accessible-panel example --- examples/accessible-panel.html | 124 +++++++++++++++++++++++++++++++++ examples/accessible-panel.js | 64 +++++++++++++++++ 2 files changed, 188 insertions(+) create mode 100644 examples/accessible-panel.html create mode 100644 examples/accessible-panel.js diff --git a/examples/accessible-panel.html b/examples/accessible-panel.html new file mode 100644 index 0000000000..39754ceccc --- /dev/null +++ b/examples/accessible-panel.html @@ -0,0 +1,124 @@ + + + + + + + Custom and accessible panel + + + + + + + +

    Custom and accessible panel

    +
    + panels, CSS, style, accessibility, button +
    +

    + Create a custom and accessible panel, styled entirely with + CSS. +

    +
    +
    + +
    + +

    Accessibility: + +

      +
    • The buttons are actual HTML buttons. You can therefore + use the TAB key to give the focus to the panel's buttons, and the "ENTER" + key to activate or trigger the corresponding control.
    • +
    • The buttons include text and titles (displayed when a button + is hovered).
    • +
    • If you remove colors from the page (for example using FireFox's No + Color extension) the buttons are still visible, and + accessible using the keyboard.
    • +
    +

    + +

    By default a panel creates buttons as divs. In this example the + createControlMarkup panel function is overridden to create + a more accessible markup for the buttons. See the accessible-panel.js + source to see how this is done.

    + +
    + + + diff --git a/examples/accessible-panel.js b/examples/accessible-panel.js new file mode 100644 index 0000000000..f982fc624b --- /dev/null +++ b/examples/accessible-panel.js @@ -0,0 +1,64 @@ +var lon = 5; +var lat = 40; +var zoom = 5; +var map, layer; + +function init() { + map = new OpenLayers.Map( 'map', { controls: [] } ); + layer = new OpenLayers.Layer.WMS( "OpenLayers WMS", + "http://vmap0.tiles.osgeo.org/wms/vmap0", {layers: 'basic'} ); + map.addLayer(layer); + + vlayer = new OpenLayers.Layer.Vector( "Editable" ); + map.addLayer(vlayer); + + zb = new OpenLayers.Control.ZoomBox({ + title: "Zoom box: zoom clicking and dragging", + text: "Zoom" + }); + + var panel = new OpenLayers.Control.Panel({ + defaultControl: zb, + createControlMarkup: function(control) { + var button = document.createElement('button'), + iconSpan = document.createElement('span'), + textSpan = document.createElement('span'); + iconSpan.innerHTML = ' '; + button.appendChild(iconSpan); + if (control.text) { + textSpan.innerHTML = control.text; + } + button.appendChild(textSpan); + return button; + } + }); + + panel.addControls([ + zb, + new OpenLayers.Control.DrawFeature(vlayer, OpenLayers.Handler.Path, + {title:'Draw a feature', text: 'Draw'}), + new OpenLayers.Control.ZoomToMaxExtent({ + title:"Zoom to the max extent", + text: "World" + }) + ]); + + nav = new OpenLayers.Control.NavigationHistory({ + previousOptions: { + title: "Go to previous map position", + text: "Prev" + }, + nextOptions: { + title: "Go to next map position", + text: "Next" + }, + displayClass: "navHistory" + }); + // parent control must be added to the map + map.addControl(nav); + panel.addControls([nav.next, nav.previous]); + + map.addControl(panel); + + map.setCenter(new OpenLayers.LonLat(lon, lat), zoom); +} From 0f0e60c3361caa6b300315481574a25ad384a588 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Wed, 8 Feb 2012 10:05:21 +0100 Subject: [PATCH 052/119] [examples] more docs in the accessible-panel example --- examples/accessible-panel.html | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/accessible-panel.html b/examples/accessible-panel.html index 39754ceccc..d46d4fbfee 100644 --- a/examples/accessible-panel.html +++ b/examples/accessible-panel.html @@ -97,7 +97,7 @@

    Custom and accessible panel

    -

    Accessibility: +

    An accessible panel:

    • The buttons are actual HTML buttons. You can therefore @@ -118,6 +118,12 @@

      Custom and accessible panel

      href="accessible-panel.js" target="_blank"> accessible-panel.js source to see how this is done.

      +

      Note: in IE 8, when a button is pressed its content shifts by 1 pixel. + This is a known + IE8 bug, with known workarounds. No workaround is applied in this + example though.

      +
    From 3b7585be24bec60f5ef9cbc6122ce3c560e4b007 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Wed, 15 Feb 2012 16:06:06 +0100 Subject: [PATCH 053/119] avoid useless deref --- lib/OpenLayers/Control/Panel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/OpenLayers/Control/Panel.js b/lib/OpenLayers/Control/Panel.js index c1760f03c0..7a936b6ff1 100644 --- a/lib/OpenLayers/Control/Panel.js +++ b/lib/OpenLayers/Control/Panel.js @@ -253,7 +253,7 @@ OpenLayers.Control.Panel = OpenLayers.Class(OpenLayers.Control, { if (control.title != "") { element.title = control.title; } - controls[i].panel_div = element; + control.panel_div = element; } if (this.map) { // map.addControl() has already been called on the panel From 9e488252055799dfa28f3d0898f6d8190a12586f Mon Sep 17 00:00:00 2001 From: Xavier Mamano Date: Sat, 18 Feb 2012 17:51:36 +0100 Subject: [PATCH 054/119] Preserve the title and the className if they are set in `createControlMarkup`. --- lib/OpenLayers/Control/Panel.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/OpenLayers/Control/Panel.js b/lib/OpenLayers/Control/Panel.js index 7a936b6ff1..f141671445 100644 --- a/lib/OpenLayers/Control/Panel.js +++ b/lib/OpenLayers/Control/Panel.js @@ -249,8 +249,10 @@ OpenLayers.Control.Panel = OpenLayers.Class(OpenLayers.Control, { for (var i=0, len=controls.length; i Date: Wed, 29 Feb 2012 00:56:52 +0100 Subject: [PATCH 055/119] [Event.buttonclick] make buttonclick work if target element is a child of the clicked button --- lib/OpenLayers/Events/buttonclick.js | 41 ++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/lib/OpenLayers/Events/buttonclick.js b/lib/OpenLayers/Events/buttonclick.js index f4de405997..f772c761f4 100644 --- a/lib/OpenLayers/Events/buttonclick.js +++ b/lib/OpenLayers/Events/buttonclick.js @@ -97,6 +97,31 @@ OpenLayers.Events.buttonclick = OpenLayers.Class({ delete this.target; }, + /** + * Method: getPressedButton + * Get the pressed button, if any. Returns undefined if no button + * was pressed. + * + * Arguments: + * element - {DOMElement} The event target. + * + * Returns: + * {DOMElement} The button element, or undefined. + */ + getPressedButton: function(element) { + var depth = 5, // limit the search depth + button; + do { + if(OpenLayers.Element.hasClass(element, "olButton")) { + // hit! + button = element; + break; + } + element = element.parentNode; + } while(--depth > 0 && element); + return button; + }, + /** * Method: buttonClick * Check if a button was clicked, and fire the buttonclick event @@ -108,27 +133,25 @@ OpenLayers.Events.buttonclick = OpenLayers.Class({ var propagate = true, element = OpenLayers.Event.element(evt); if (element && (OpenLayers.Event.isLeftClick(evt) || !~evt.type.indexOf("mouse"))) { - if (element.nodeType === 3 || OpenLayers.Element.hasClass(element, "olAlphaImg")) { - element = element.parentNode; - } - if (OpenLayers.Element.hasClass(element, "olButton")) { + // was a button pressed? + var button = this.getPressedButton(element); + if (button) { if (evt.type === "keydown") { switch (evt.keyCode) { case OpenLayers.Event.KEY_RETURN: case OpenLayers.Event.KEY_SPACE: this.target.triggerEvent("buttonclick", { - buttonElement: element + buttonElement: button }); OpenLayers.Event.stop(evt); propagate = false; break; } - } - if (this.startEvt) { + } else if (this.startEvt) { if (this.completeRegEx.test(evt.type)) { - var pos = OpenLayers.Util.pagePosition(element); + var pos = OpenLayers.Util.pagePosition(button); this.target.triggerEvent("buttonclick", { - buttonElement: element, + buttonElement: button, buttonXY: { x: this.startEvt.clientX - pos[0], y: this.startEvt.clientY - pos[1] From 366742869279d95d4e560f58e89bf8b439bbb0cd Mon Sep 17 00:00:00 2001 From: Matt Priour Date: Tue, 28 Feb 2012 22:52:40 -0600 Subject: [PATCH 056/119] Add LayerSwitcher and remove vector editing --- build/light.cfg | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/build/light.cfg b/build/light.cfg index 6a2948038e..4b1ddb8bea 100644 --- a/build/light.cfg +++ b/build/light.cfg @@ -1,5 +1,4 @@ [first] -OpenLayers/SingleFile.js [last] @@ -13,32 +12,25 @@ OpenLayers/Layer/Bing.js OpenLayers/Layer/WMS.js OpenLayers/Layer/Google/v3.js OpenLayers/Popup/FramedCloud.js -OpenLayers/Control/TouchNavigation.js OpenLayers/Control/Navigation.js -OpenLayers/Control/Geolocate.js OpenLayers/Control/ZoomPanel.js OpenLayers/Control/Attribution.js OpenLayers/Control/SelectFeature.js -OpenLayers/Control/DrawFeature.js -OpenLayers/Control/ModifyFeature.js OpenLayers/Control/WMSGetFeatureInfo.js -OpenLayers/Control/GetFeature.js OpenLayers/Control/Panel.js -OpenLayers/Handler/Point.js -OpenLayers/Handler/Path.js -OpenLayers/Handler/Polygon.js +OpenLayers/Control/LayerSwitcher.js OpenLayers/Renderer/SVG.js OpenLayers/Renderer/Canvas.js OpenLayers/Renderer/VML.js OpenLayers/Format/GeoJSON.js OpenLayers/Format/KML.js OpenLayers/Format/GML/v2.js -OpenLayers/Format/GML/v3.js OpenLayers/Protocol/HTTP.js -OpenLayers/Protocol/WFS/v1_0_0.js OpenLayers/Strategy/Fixed.js OpenLayers/Strategy/BBOX.js OpenLayers/StyleMap.js OpenLayers/Rule.js +OpenLayers/Filter/Comparison.js +OpenLayers/Filter/Logical.js [exclude] From b7eba35077a1f6d9404d203ad2893c88127cee42 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Wed, 29 Feb 2012 08:11:14 +0100 Subject: [PATCH 057/119] Notes on incorrect maxResolution of 156543.0339 and defaults coupled with projection --- notes/2.12.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/notes/2.12.md b/notes/2.12.md index b77d87739d..a027464c07 100644 --- a/notes/2.12.md +++ b/notes/2.12.md @@ -84,8 +84,39 @@ The `OpenLayers.Tile.Image` class now has a method to get a canvas context for p tileOptions: {crossOriginKeyword: null} +Both `OpenLayers.Layer.OSM` and `OpenLayers.Layer.Bing` do not have defaults for `maxExtent`, `maxResolutions` and `units` any more. This may break maps that are configured with a `maxResolution` of `156543.0339`, which was used in examples before 2.11, but is incorrect. The correct value is `156543.03390625`, but it is no longer necessary to specify a maxResolution, maxExtent and units if the correct resolution is set. See "Projection and Spherical Mercator" below. + ## Projection & SphericalMercator +When working with Web Mercator layers (e.g. Google, Bing, OSM), it was previously necessary to configure the map or the base layer with the correct `projection`, `maxExtent`, `maxResolutions` and `units`. Now OpenLayers has defaults for WGS84 and Web Mercator in `OpenLayers.Projection.defaults`, so it is enough to provide the `projection`. + +Old: + + new OpenLayers.Map({ + div: "map", + projection: "EPSG:900913", + maxResolution: 156543.03390625, + maxExtent: new OpenLayers.Bounds(-20037508.34, -20037508.34, 20037508.34, 20037508.34), + units: "m", + layers: [ + new OpenLayers.Layer.Google("Google Streets"), + new OpenLayers.Layer.OSM(null, null, {isBaseLayer: false, opcity: 0.7}) + ], + zoom: 1 + }); + +New: + + new OpenLayers.Map({ + div: "map", + projection: "EPSG:900913", + layers: [ + new OpenLayers.Layer.Google("Google Streets"), + new OpenLayers.Layer.OSM(null, null, {isBaseLayer: false, opcity: 0.7}) + ], + zoom: 1 + }); + In previous releases, coordinate transforms between EPSG:4326 and EPSG:900913 were defined in the SphericalMercator.js script. In 2.12, these default transforms are included in the Projection.js script. The Projection.js script is included as a dependency in builds with any layer types, so no special build configuration is necessary to get the web mercator transforms. If you were previously using the `OpenLayers.Layer.SphericalMercator.forwardMercator` or `inverseMercator` methods, you may have to explicitly include the SphericalMercator.js script in your build. The Google layer is the only layer that depends on the SphericalMercator mixin. If you are not using the Google layer but want to use the SphericalMercator methods listed above, you have to explicitly include the SphericalMercator.js script in your build. From d0c782ca745104aa19e31f758e8327b1cce0a320 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Wed, 29 Feb 2012 10:40:45 +0100 Subject: [PATCH 058/119] Making LayerSwitcher work again outside viewport. --- lib/OpenLayers/Control/LayerSwitcher.js | 10 ++++++++-- tests/Control/LayerSwitcher.html | 6 ++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/OpenLayers/Control/LayerSwitcher.js b/lib/OpenLayers/Control/LayerSwitcher.js index a0e480e385..b1f2cc49cb 100644 --- a/lib/OpenLayers/Control/LayerSwitcher.js +++ b/lib/OpenLayers/Control/LayerSwitcher.js @@ -120,7 +120,7 @@ OpenLayers.Control.LayerSwitcher = initialize: function(options) { OpenLayers.Control.prototype.initialize.apply(this, arguments); this.layerStates = []; - + if(this.roundedCorner) { OpenLayers.Console.warn('roundedCorner option is deprecated'); } @@ -143,6 +143,7 @@ OpenLayers.Control.LayerSwitcher = changebaselayer: this.redraw, scope: this }); + this.events.unregister("buttonclick", this, this.onButtonClick); OpenLayers.Control.prototype.destroy.apply(this, arguments); }, @@ -157,13 +158,18 @@ OpenLayers.Control.LayerSwitcher = OpenLayers.Control.prototype.setMap.apply(this, arguments); this.map.events.on({ - buttonclick: this.onButtonClick, addlayer: this.redraw, changelayer: this.redraw, removelayer: this.redraw, changebaselayer: this.redraw, scope: this }); + if (this.outsideViewport) { + this.events.attachToElement(this.div); + this.events.register("buttonclick", this, this.onButtonClick); + } else { + this.map.events.register("buttonclick", this, this.onButtonClick); + } }, /** diff --git a/tests/Control/LayerSwitcher.html b/tests/Control/LayerSwitcher.html index 47895857d2..0094e77108 100644 --- a/tests/Control/LayerSwitcher.html +++ b/tests/Control/LayerSwitcher.html @@ -25,15 +25,17 @@ t.ok( div != null, "draw returns its div" ); } function test_Control_LayerSwitcher_outsideViewport (t) { - t.plan( 2 ); + t.plan( 4 ); map = new OpenLayers.Map('map'); control = new OpenLayers.Control.LayerSwitcher({'div':OpenLayers.Util.getElement('layerswitcher')}); map.addControl(control); - t.eq(control.div.style.width, "250px", "Div is not minimized when added."); + t.eq(control.div.style.width, "250px", "Div is not minimized when added."); + t.ok(control.events.element && control.events.listeners.buttonclick, "[outside] Events instance attached to div and has buttonclick event"); control = new OpenLayers.Control.LayerSwitcher(); map.addControl(control); t.eq(control.div.style.width, "0px", "Div is minimized when added."); + t.ok(!control.events.element && map.events.listeners.buttonclick, "[inside] Events instance not attached to div and buttonclick event registered on map"); } function test_Control_LayerSwitcher_loadContents(t) { From 557d7ab0d77a910c26d65867467aae99d81663c3 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Wed, 29 Feb 2012 10:49:40 +0100 Subject: [PATCH 059/119] Fixing typo. --- notes/2.12.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/notes/2.12.md b/notes/2.12.md index a027464c07..e4e9b09ca3 100644 --- a/notes/2.12.md +++ b/notes/2.12.md @@ -100,7 +100,7 @@ Old: units: "m", layers: [ new OpenLayers.Layer.Google("Google Streets"), - new OpenLayers.Layer.OSM(null, null, {isBaseLayer: false, opcity: 0.7}) + new OpenLayers.Layer.OSM(null, null, {isBaseLayer: false, opacity: 0.7}) ], zoom: 1 }); @@ -112,7 +112,7 @@ New: projection: "EPSG:900913", layers: [ new OpenLayers.Layer.Google("Google Streets"), - new OpenLayers.Layer.OSM(null, null, {isBaseLayer: false, opcity: 0.7}) + new OpenLayers.Layer.OSM(null, null, {isBaseLayer: false, opacity: 0.7}) ], zoom: 1 }); From b699afa57f7b9a6e03815558ac89f64922719186 Mon Sep 17 00:00:00 2001 From: Bart van den Eijnden Date: Wed, 29 Feb 2012 10:57:08 +0100 Subject: [PATCH 060/119] make vendorOptions an object instead of an array, which makes it more convenient to prevent duplicate vendorOptions --- lib/OpenLayers/Format/SLD/v1_0_0_GeoServer.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/OpenLayers/Format/SLD/v1_0_0_GeoServer.js b/lib/OpenLayers/Format/SLD/v1_0_0_GeoServer.js index 49596be1c4..bee661311b 100644 --- a/lib/OpenLayers/Format/SLD/v1_0_0_GeoServer.js +++ b/lib/OpenLayers/Format/SLD/v1_0_0_GeoServer.js @@ -58,12 +58,9 @@ OpenLayers.Format.SLD.v1_0_0_GeoServer = OpenLayers.Class( }, "VendorOption": function(node, obj) { if (!obj.vendorOptions) { - obj.vendorOptions = []; + obj.vendorOptions = {}; } - obj.vendorOptions.push({ - name: node.getAttribute("name"), - value: this.getChildValue(node) - }); + obj.vendorOptions[node.getAttribute("name")] = this.getChildValue(node); } }, OpenLayers.Format.SLD.v1_0_0.prototype.readers["sld"]) }, OpenLayers.Format.SLD.v1_0_0.prototype.readers), @@ -130,8 +127,11 @@ OpenLayers.Format.SLD.v1_0_0_GeoServer = OpenLayers.Class( addVendorOptions: function(node, symbolizer) { var options = symbolizer.vendorOptions; if (options) { - for (var i=0, ii=options.length; i Date: Wed, 29 Feb 2012 10:40:20 +0000 Subject: [PATCH 061/119] Make layer opacity api property --- lib/OpenLayers/Layer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/OpenLayers/Layer.js b/lib/OpenLayers/Layer.js index 1a2a1999e4..788b6e7633 100644 --- a/lib/OpenLayers/Layer.js +++ b/lib/OpenLayers/Layer.js @@ -34,7 +34,7 @@ OpenLayers.Layer = OpenLayers.Class({ div: null, /** - * Property: opacity + * APIProperty: opacity * {Float} The layer's opacity. Float number between 0.0 and 1.0. Default * is 1. */ From 6a43fcaefcf7f5ffee2f2d6a4ee1a4bd864e5add Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Wed, 29 Feb 2012 13:34:47 +0100 Subject: [PATCH 062/119] change buttonclick.getPressedButton depth value from 5 to 3, this allows buttons with grand children (2 levels) --- lib/OpenLayers/Events/buttonclick.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/OpenLayers/Events/buttonclick.js b/lib/OpenLayers/Events/buttonclick.js index f772c761f4..6520b83a0d 100644 --- a/lib/OpenLayers/Events/buttonclick.js +++ b/lib/OpenLayers/Events/buttonclick.js @@ -109,7 +109,7 @@ OpenLayers.Events.buttonclick = OpenLayers.Class({ * {DOMElement} The button element, or undefined. */ getPressedButton: function(element) { - var depth = 5, // limit the search depth + var depth = 3, // limit the search depth button; do { if(OpenLayers.Element.hasClass(element, "olButton")) { From 98ff5473a6658e9f052947f5036579c464d29a70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Wed, 29 Feb 2012 13:36:07 +0100 Subject: [PATCH 063/119] add tests for buttonclick.getPressedButton --- tests/Events/buttonclick.html | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/tests/Events/buttonclick.html b/tests/Events/buttonclick.html index 7d12710cf6..35ebb81f8a 100644 --- a/tests/Events/buttonclick.html +++ b/tests/Events/buttonclick.html @@ -27,6 +27,41 @@ buttonClick.destroy(); events.destroy(); } + + function test_getPressedButton(t) { + t.plan(4); + + // set up + + events = new OpenLayers.Events({}, element); + buttonClick = new OpenLayers.Events.buttonclick(events); + + var button = document.createElement('button'), + span1 = document.createElement('span'), + span2 = document.createElement('span'), + span3 = document.createElement('span'); + button.className = 'olButton'; + button.appendChild(span1); + span1.appendChild(span2); + span2.appendChild(span3); + + t.ok(buttonClick.getPressedButton(button) === button, + 'getPressedButton returns button when element is button'); + t.ok(buttonClick.getPressedButton(span1) === button, + 'getPressedButton returns button when element is button descendant level 1'); + t.ok(buttonClick.getPressedButton(span2) === button, + 'getPressedButton returns button when element is button descendant level 2'); + t.eq(buttonClick.getPressedButton(span3), undefined, + 'getPressedButton returns undefined when element is button descendant level 3'); + + // test + + + // tear down + + buttonClick.destroy(); + events.destroy(); + } function test_ButtonClick_buttonClick(t) { t.plan(27); From 0e1a30b3cdcd26efbe092dba144833552e045fe6 Mon Sep 17 00:00:00 2001 From: Bart van den Eijnden Date: Wed, 29 Feb 2012 14:42:11 +0100 Subject: [PATCH 064/119] PointPlacement and LinePlacement are choices, so don't output both --- lib/OpenLayers/Format/SLD/v1.js | 6 ++++-- tests/Format/SLD/v1_0_0.html | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/OpenLayers/Format/SLD/v1.js b/lib/OpenLayers/Format/SLD/v1.js index f934f80d65..cd32810be9 100644 --- a/lib/OpenLayers/Format/SLD/v1.js +++ b/lib/OpenLayers/Format/SLD/v1.js @@ -990,12 +990,14 @@ OpenLayers.Format.SLD.v1 = OpenLayers.Class(OpenLayers.Format.Filter.v1_0_0, { }, "LabelPlacement": function(symbolizer) { var node = this.createElementNSPlus("sld:LabelPlacement"); - if (symbolizer.labelAnchorPointX != null || + // PointPlacement and LinePlacement are choices, so don't output both + if ((symbolizer.labelAnchorPointX != null || symbolizer.labelAnchorPointY != null || symbolizer.labelAlign != null || symbolizer.labelXOffset != null || symbolizer.labelYOffset != null || - symbolizer.labelRotation != null) { + symbolizer.labelRotation != null) && + symbolizer.labelPerpendicularOffset == null) { this.writeNode("PointPlacement", symbolizer, node); } if (symbolizer.labelPerpendicularOffset != null) { diff --git a/tests/Format/SLD/v1_0_0.html b/tests/Format/SLD/v1_0_0.html index af58c30c7d..46794902f0 100644 --- a/tests/Format/SLD/v1_0_0.html +++ b/tests/Format/SLD/v1_0_0.html @@ -538,7 +538,8 @@ }), new OpenLayers.Symbolizer.Text({ label: "${FOO}", - labelPerpendicularOffset: 10 + labelPerpendicularOffset: 10, + labelAlign: "rb" }) ] }) From 2421ed6da3d5b7985172dec93aca85e5c77a38a5 Mon Sep 17 00:00:00 2001 From: Bart van den Eijnden Date: Wed, 29 Feb 2012 14:53:20 +0100 Subject: [PATCH 065/119] add comments to the test (suggestion by @ahocevar) --- tests/Format/SLD/v1_0_0.html | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/Format/SLD/v1_0_0.html b/tests/Format/SLD/v1_0_0.html index 46794902f0..a295a746b8 100644 --- a/tests/Format/SLD/v1_0_0.html +++ b/tests/Format/SLD/v1_0_0.html @@ -528,6 +528,7 @@ var format = new OpenLayers.Format.SLD.v1_0_0({ multipleSymbolizers: true }); + // labelPerpendicularOffset takes precedence over labelAlign var style = new OpenLayers.Style2({ rules: [ new OpenLayers.Rule({ From fa30c1da5c37702f048bdeb33496f49adce83f2d Mon Sep 17 00:00:00 2001 From: ahocevar Date: Wed, 29 Feb 2012 16:48:59 +0100 Subject: [PATCH 066/119] Don't overwrite params, and use params in Layer.ArcGISCache --- lib/OpenLayers/Layer/ArcGISCache.js | 4 +++- lib/OpenLayers/Layer/HTTPRequest.js | 4 +++- tests/Layer/ArcGISCache.html | 7 ++++--- tests/Layer/HTTPRequest.html | 9 ++++++--- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/lib/OpenLayers/Layer/ArcGISCache.js b/lib/OpenLayers/Layer/ArcGISCache.js index 9c500e4533..27173392c4 100644 --- a/lib/OpenLayers/Layer/ArcGISCache.js +++ b/lib/OpenLayers/Layer/ArcGISCache.js @@ -452,7 +452,9 @@ OpenLayers.Layer.ArcGISCache = OpenLayers.Class(OpenLayers.Layer.XYZ, { // Write the values into our formatted url url = OpenLayers.String.format(url, {'x': x, 'y': y, 'z': z}); - return url; + return OpenLayers.Util.urlAppend( + url, OpenLayers.Util.getParameterString(this.params) + ); }, /** diff --git a/lib/OpenLayers/Layer/HTTPRequest.js b/lib/OpenLayers/Layer/HTTPRequest.js index 7855cb6b03..d1e9bf2219 100644 --- a/lib/OpenLayers/Layer/HTTPRequest.js +++ b/lib/OpenLayers/Layer/HTTPRequest.js @@ -60,7 +60,9 @@ OpenLayers.Layer.HTTPRequest = OpenLayers.Class(OpenLayers.Layer, { initialize: function(name, url, params, options) { OpenLayers.Layer.prototype.initialize.apply(this, [name, options]); this.url = url; - this.params = OpenLayers.Util.extend( {}, params); + if (!this.params) { + this.params = OpenLayers.Util.extend({}, params); + } }, /** diff --git a/tests/Layer/ArcGISCache.html b/tests/Layer/ArcGISCache.html index d1ae00ed93..0b54464493 100644 --- a/tests/Layer/ArcGISCache.html +++ b/tests/Layer/ArcGISCache.html @@ -53,7 +53,8 @@ //initialize the layer using the JSON object from an arcgis server //SEE: ArcGISCache.json var layer = new OpenLayers.Layer.ArcGISCache(name, url, { - layerInfo: layerInfo + layerInfo: layerInfo, + params: {foo: "bar"} }); var map = new OpenLayers.Map('map', { maxExtent: layer.maxExtent, @@ -98,14 +99,14 @@ } ]; - t.plan( urlSets.length ); + t.plan( urlSets.length ); for(var i=0;i Date: Wed, 29 Feb 2012 09:57:22 -0600 Subject: [PATCH 067/119] Build full, light & mobile minified & debug versions of OpenLayers during release & dev dir update process --- tools/release.sh | 6 ++++++ tools/update_dev_dir.sh | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/tools/release.sh b/tools/release.sh index 85124e8790..5465766473 100755 --- a/tools/release.sh +++ b/tools/release.sh @@ -9,7 +9,13 @@ svn export http://svn.openlayers.org/tags/openlayers/release-$VERSION OpenLayers cd OpenLayers-$VERSION/build mv ../../compiler.jar ../tools/closure-compiler.jar ./build.py -c closure full +./build.py -c closure mobile OpenLayers.mobile.js +./build.py -c closure light OpenLayers.light.js +./build.py -c none full OpenLayers.debug.js +./build.py -c none mobile OpenLayers.mobile.debug.js +./build.py -c none light OpenLayers.light.debug.js cp OpenLayers.js .. +cp OpenLayers.*.js .. rm ../tools/closure-compiler.jar cd .. diff --git a/tools/update_dev_dir.sh b/tools/update_dev_dir.sh index 743bfc8f15..9c272293fc 100755 --- a/tools/update_dev_dir.sh +++ b/tools/update_dev_dir.sh @@ -26,9 +26,13 @@ if [ ! o$GITREV = $OLD_GITREV ]; then cd /osgeo/openlayers/docs/dev/build ./build.py -c closure tests.cfg ./build.py -c closure mobile.cfg OpenLayers.mobile.js + ./build.py -c closure light.cfg OpenLayers.light.js + ./build.py -c none tests.cfg OpenLayers.debug.js + ./build.py -c none mobile.cfg OpenLayers.mobile.debug.js + ./build.py -c none light.cfg OpenLayers.light.debug.js cp OpenLayers.js .. - cp OpenLayers.mobile.js .. + cp OpenLayers.*.js .. cd .. for i in google ie6-style style; do From fe33e2900009658536a5e459476d11c059d215e0 Mon Sep 17 00:00:00 2001 From: Xavier Mamano Date: Wed, 29 Feb 2012 17:07:41 +0100 Subject: [PATCH 068/119] If using `OpenLayers` namespace must have at least one requirement. --- build/mobile.cfg | 1 - lib/OpenLayers/BaseTypes.js | 4 ++++ lib/OpenLayers/BaseTypes/Date.js | 4 ++++ lib/OpenLayers/Spherical.js | 4 ++++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/build/mobile.cfg b/build/mobile.cfg index 0fe32aaa6a..7bba251270 100644 --- a/build/mobile.cfg +++ b/build/mobile.cfg @@ -1,5 +1,4 @@ [first] -OpenLayers/SingleFile.js [last] diff --git a/lib/OpenLayers/BaseTypes.js b/lib/OpenLayers/BaseTypes.js index 241f43437a..d07b429d17 100644 --- a/lib/OpenLayers/BaseTypes.js +++ b/lib/OpenLayers/BaseTypes.js @@ -3,6 +3,10 @@ * See http://svn.openlayers.org/trunk/openlayers/license.txt for the * full text of the license. */ +/** + * @requires OpenLayers/SingleFile.js + */ + /** * Header: OpenLayers Base Types * OpenLayers custom string, number and function functions are described here. diff --git a/lib/OpenLayers/BaseTypes/Date.js b/lib/OpenLayers/BaseTypes/Date.js index 9af051c8b6..3b645fe852 100644 --- a/lib/OpenLayers/BaseTypes/Date.js +++ b/lib/OpenLayers/BaseTypes/Date.js @@ -3,6 +3,10 @@ * See http://svn.openlayers.org/trunk/openlayers/license.txt for the * full text of the license. */ +/** + * @requires OpenLayers/SingleFile.js + */ + /** * Namespace: OpenLayers.Date * Contains implementations of Date.parse and date.toISOString that match the diff --git a/lib/OpenLayers/Spherical.js b/lib/OpenLayers/Spherical.js index 4a8956a5b7..b3957d4910 100644 --- a/lib/OpenLayers/Spherical.js +++ b/lib/OpenLayers/Spherical.js @@ -3,6 +3,10 @@ * See http://svn.openlayers.org/trunk/openlayers/license.txt for the * full text of the license. */ +/** + * @requires OpenLayers/SingleFile.js + */ + /** * Namespace: Spherical * The OpenLayers.Spherical namespace includes utility functions for From 5c42b2f3ff2b593f58eb6bd79326db6053e313ea Mon Sep 17 00:00:00 2001 From: Matt Priour Date: Wed, 29 Feb 2012 10:13:57 -0600 Subject: [PATCH 069/119] Remove canvas renderer, as it is redundant with SVG and SVG is better supported and more robust across non-IE browsers --- build/light.cfg | 1 - 1 file changed, 1 deletion(-) diff --git a/build/light.cfg b/build/light.cfg index 4b1ddb8bea..cd2790db4b 100644 --- a/build/light.cfg +++ b/build/light.cfg @@ -20,7 +20,6 @@ OpenLayers/Control/WMSGetFeatureInfo.js OpenLayers/Control/Panel.js OpenLayers/Control/LayerSwitcher.js OpenLayers/Renderer/SVG.js -OpenLayers/Renderer/Canvas.js OpenLayers/Renderer/VML.js OpenLayers/Format/GeoJSON.js OpenLayers/Format/KML.js From e3cc96dbfb58ee873db457e74de7c7774a25bf45 Mon Sep 17 00:00:00 2001 From: Bart van den Eijnden Date: Wed, 29 Feb 2012 18:43:55 +0100 Subject: [PATCH 070/119] protect for in loops with hasOwnProperty --- lib/OpenLayers/BaseTypes/Class.js | 8 ++- lib/OpenLayers/Control/GetFeature.js | 16 +++-- lib/OpenLayers/Control/NavigationHistory.js | 54 ++++++++------ lib/OpenLayers/Control/SLDSelect.js | 13 ++-- lib/OpenLayers/Control/WMSGetFeatureInfo.js | 10 +-- lib/OpenLayers/Format/GML/Base.js | 14 ++-- lib/OpenLayers/Format/GeoRSS.js | 20 +++--- lib/OpenLayers/Format/OSM.js | 70 +++++++++--------- lib/OpenLayers/Format/SLD/v1.js | 32 +++++---- lib/OpenLayers/Format/SLD/v1_0_0_GeoServer.js | 10 +-- lib/OpenLayers/Format/SOSGetObservation.js | 8 ++- lib/OpenLayers/Format/WFS.js | 38 +++++----- lib/OpenLayers/Format/WFST/v1.js | 22 +++--- lib/OpenLayers/Format/WMC/v1.js | 58 ++++++++------- lib/OpenLayers/Format/WMC/v1_1_0.js | 4 +- lib/OpenLayers/Format/WMTSCapabilities.js | 6 +- lib/OpenLayers/Format/XML.js | 16 +++-- lib/OpenLayers/Layer.js | 4 +- lib/OpenLayers/Layer/HTTPRequest.js | 6 +- lib/OpenLayers/Layer/MapGuide.js | 6 +- lib/OpenLayers/Layer/MapServer.js | 6 +- lib/OpenLayers/Layer/Vector.js | 8 ++- lib/OpenLayers/Layer/WMTS.js | 6 +- lib/OpenLayers/Protocol/Script.js | 6 +- lib/OpenLayers/Request.js | 4 +- lib/OpenLayers/Rule.js | 20 +++--- lib/OpenLayers/Style.js | 32 +++++---- lib/OpenLayers/StyleMap.js | 52 ++++++++------ lib/OpenLayers/Tile/Image/IFrame.js | 14 ++-- lib/OpenLayers/Tween.js | 16 +++-- lib/OpenLayers/Util.js | 72 +++++++++++-------- 31 files changed, 385 insertions(+), 266 deletions(-) diff --git a/lib/OpenLayers/BaseTypes/Class.js b/lib/OpenLayers/BaseTypes/Class.js index 4a900b4198..1e242f55bb 100644 --- a/lib/OpenLayers/BaseTypes/Class.js +++ b/lib/OpenLayers/BaseTypes/Class.js @@ -91,9 +91,11 @@ OpenLayers.Util.extend = function(destination, source) { destination = destination || {}; if (source) { for (var property in source) { - var value = source[property]; - if (value !== undefined) { - destination[property] = value; + if (source.hasOwnProperty(property)) { + var value = source[property]; + if (value !== undefined) { + destination[property] = value; + } } } diff --git a/lib/OpenLayers/Control/GetFeature.js b/lib/OpenLayers/Control/GetFeature.js index c037f87d15..49760b03d3 100644 --- a/lib/OpenLayers/Control/GetFeature.js +++ b/lib/OpenLayers/Control/GetFeature.js @@ -258,7 +258,9 @@ OpenLayers.Control.GetFeature = OpenLayers.Class(OpenLayers.Control, { activate: function () { if (!this.active) { for(var i in this.handlers) { - this.handlers[i].activate(); + if (this.handlers.hasOwnProperty(i)) { + this.handlers[i].activate(); + } } } return OpenLayers.Control.prototype.activate.apply( @@ -276,7 +278,9 @@ OpenLayers.Control.GetFeature = OpenLayers.Class(OpenLayers.Control, { deactivate: function () { if (this.active) { for(var i in this.handlers) { - this.handlers[i].deactivate(); + if (this.handlers.hasOwnProperty(i)) { + this.handlers[i].deactivate(); + } } } return OpenLayers.Control.prototype.deactivate.apply( @@ -560,7 +564,9 @@ OpenLayers.Control.GetFeature = OpenLayers.Class(OpenLayers.Control, { unselectAll: function() { // we'll want an option to supress notification here for(var fid in this.features) { - this.unselect(this.features[fid]); + if (this.features.hasOwnProperty(fid)) { + this.unselect(this.features[fid]); + } } }, @@ -573,7 +579,9 @@ OpenLayers.Control.GetFeature = OpenLayers.Class(OpenLayers.Control, { */ setMap: function(map) { for(var i in this.handlers) { - this.handlers[i].setMap(map); + if (this.handlers.hasOwnProperty(i)) { + this.handlers[i].setMap(map); + } } OpenLayers.Control.prototype.setMap.apply(this, arguments); }, diff --git a/lib/OpenLayers/Control/NavigationHistory.js b/lib/OpenLayers/Control/NavigationHistory.js index eb46946e73..4fe47a629e 100644 --- a/lib/OpenLayers/Control/NavigationHistory.js +++ b/lib/OpenLayers/Control/NavigationHistory.js @@ -193,7 +193,9 @@ OpenLayers.Control.NavigationHistory = OpenLayers.Class(OpenLayers.Control, { this.next.destroy(); this.deactivate(); for(var prop in this) { - this[prop] = null; + if (this.hasOwnProperty(prop)) { + this[prop] = null; + } } }, @@ -334,25 +336,27 @@ OpenLayers.Control.NavigationHistory = OpenLayers.Class(OpenLayers.Control, { setListeners: function() { this.listeners = {}; for(var type in this.registry) { - 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.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); + } } - if(this.nextStack.length > 0) { - this.nextStack = []; - this.onNextChange(null, 0); - } - } - return true; - }, this); + return true; + }, this); + } } }, @@ -371,7 +375,9 @@ OpenLayers.Control.NavigationHistory = OpenLayers.Class(OpenLayers.Control, { this.setListeners(); } for(var type in this.listeners) { - this.map.events.register(type, this, this.listeners[type]); + if (this.listeners.hasOwnProperty(type)) { + this.map.events.register(type, this, this.listeners[type]); + } } activated = true; if(this.previousStack.length == 0) { @@ -405,9 +411,11 @@ OpenLayers.Control.NavigationHistory = OpenLayers.Class(OpenLayers.Control, { if(this.map) { if(OpenLayers.Control.prototype.deactivate.apply(this)) { for(var type in this.listeners) { - this.map.events.unregister( - type, this, this.listeners[type] - ); + if (this.listeners.hasOwnProperty(type)) { + this.map.events.unregister( + type, this, this.listeners[type] + ); + } } if(this.clearOnDeactivate) { this.clear(); diff --git a/lib/OpenLayers/Control/SLDSelect.js b/lib/OpenLayers/Control/SLDSelect.js index 52f0798ae9..50ac906afd 100644 --- a/lib/OpenLayers/Control/SLDSelect.js +++ b/lib/OpenLayers/Control/SLDSelect.js @@ -168,11 +168,16 @@ OpenLayers.Control.SLDSelect = OpenLayers.Class(OpenLayers.Control, { * Take care of things that are not handled in superclass. */ destroy: function() { - for (var key in this.layerCache) { - delete this.layerCache[key]; + var key; + for (key in this.layerCache) { + if (this.layerCache.hasOwnProperty(key)) { + delete this.layerCache[key]; + } } - for (var key in this.wfsCache) { - delete this.wfsCache[key]; + for (key in this.wfsCache) { + if (this.wfsCache.hasOwnProperty(key)) { + delete this.wfsCache[key]; + } } OpenLayers.Control.prototype.destroy.apply(this, arguments); }, diff --git a/lib/OpenLayers/Control/WMSGetFeatureInfo.js b/lib/OpenLayers/Control/WMSGetFeatureInfo.js index 9348a9d542..67555f1038 100644 --- a/lib/OpenLayers/Control/WMSGetFeatureInfo.js +++ b/lib/OpenLayers/Control/WMSGetFeatureInfo.js @@ -456,10 +456,12 @@ OpenLayers.Control.WMSGetFeatureInfo = OpenLayers.Class(OpenLayers.Control, { } var layers; for (var url in services) { - layers = services[url]; - var wmsOptions = this.buildWMSOptions(url, layers, - clickPosition, layers[0].params.FORMAT); - OpenLayers.Request.GET(wmsOptions); + if (services.hasOwnProperty(url)) { + layers = services[url]; + var wmsOptions = this.buildWMSOptions(url, layers, + clickPosition, layers[0].params.FORMAT); + OpenLayers.Request.GET(wmsOptions); + } } } }, diff --git a/lib/OpenLayers/Format/GML/Base.js b/lib/OpenLayers/Format/GML/Base.js index 0eceadaed6..9abbf5aa7a 100644 --- a/lib/OpenLayers/Format/GML/Base.js +++ b/lib/OpenLayers/Format/GML/Base.js @@ -564,12 +564,14 @@ OpenLayers.Format.GML.Base = OpenLayers.Class(OpenLayers.Format.XML, { this.writeNode("feature:_geometry", feature.geometry, node); } for(var name in feature.attributes) { - var value = feature.attributes[name]; - if(value != null) { - this.writeNode( - "feature:_attribute", - {name: name, value: value}, node - ); + if (feature.attributes.hasOwnProperty(name)) { + var value = feature.attributes[name]; + if(value != null) { + this.writeNode( + "feature:_attribute", + {name: name, value: value}, node + ); + } } } return node; diff --git a/lib/OpenLayers/Format/GeoRSS.js b/lib/OpenLayers/Format/GeoRSS.js index a9e117b2ec..0fc1790f6d 100644 --- a/lib/OpenLayers/Format/GeoRSS.js +++ b/lib/OpenLayers/Format/GeoRSS.js @@ -325,15 +325,17 @@ OpenLayers.Format.GeoRSS = OpenLayers.Class(OpenLayers.Format.XML, { featureNode.appendChild(linkNode); } for(var attr in feature.attributes) { - 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 (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); + } } featureNode.appendChild(geometryNode); return featureNode; diff --git a/lib/OpenLayers/Format/OSM.js b/lib/OpenLayers/Format/OSM.js index 48ef45ac91..a5de50fc35 100644 --- a/lib/OpenLayers/Format/OSM.js +++ b/lib/OpenLayers/Format/OSM.js @@ -140,33 +140,35 @@ OpenLayers.Format.OSM = OpenLayers.Class(OpenLayers.Format.XML, { feat_list[i] = feat; } for (var node_id in nodes) { - var node = nodes[node_id]; - if (!node.used || this.checkTags) { - var tags = null; + if (nodes.hasOwnProperty(node_id)) { + 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; }, @@ -273,9 +275,11 @@ OpenLayers.Format.OSM = OpenLayers.Class(OpenLayers.Format.XML, { } if (this.checkTags) { for(var key in way.tags) { - if (this.areaTags[key]) { - poly_tags = true; - break; + if (way.tags.hasOwnProperty(key)) { + if (this.areaTags[key]) { + poly_tags = true; + break; + } } } } @@ -430,10 +434,12 @@ OpenLayers.Format.OSM = OpenLayers.Class(OpenLayers.Format.XML, { */ serializeTags: function(feature, node) { for (var key in feature.attributes) { - var tag = this.createElementNS(null, "tag"); - tag.setAttribute("k", key); - tag.setAttribute("v", feature.attributes[key]); - node.appendChild(tag); + if (feature.attributes.hasOwnProperty(key)) { + var tag = this.createElementNS(null, "tag"); + tag.setAttribute("k", key); + tag.setAttribute("v", feature.attributes[key]); + node.appendChild(tag); + } } }, diff --git a/lib/OpenLayers/Format/SLD/v1.js b/lib/OpenLayers/Format/SLD/v1.js index cd32810be9..2a1c2e33af 100644 --- a/lib/OpenLayers/Format/SLD/v1.js +++ b/lib/OpenLayers/Format/SLD/v1.js @@ -541,9 +541,11 @@ 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[prop] == sym) { - css = prop; - break; + if (this.cssMap.hasOwnProperty(prop)) { + if(this.cssMap[prop] == sym) { + css = prop; + break; + } } } return css; @@ -565,12 +567,14 @@ 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[key].test(href)) { - format = key; - break; + if (this.graphicFormats.hasOwnProperty(key)) { + if(this.graphicFormats[key].test(href)) { + format = key; + break; + } } } - return format || this.defautlGraphicFormat; + return format || this.defaultGraphicFormat; }, /** @@ -676,7 +680,9 @@ OpenLayers.Format.SLD.v1 = OpenLayers.Class(OpenLayers.Format.Filter.v1_0_0, { } } else { for(var name in sld.namedLayers) { - this.writeNode("NamedLayer", sld.namedLayers[name], root); + if (sld.namedLayers.hasOwnProperty(name)) { + this.writeNode("NamedLayer", sld.namedLayers[name], root); + } } } return root; @@ -769,11 +775,13 @@ OpenLayers.Format.SLD.v1 = OpenLayers.Class(OpenLayers.Format.Filter.v1_0_0, { ruleMap[zIndex].symbolizers.push(symbolizer.clone()); } for (zIndex in ruleMap) { - if (!(zIndex in rulesByZ)) { - zValues.push(zIndex); - rulesByZ[zIndex] = []; + if (ruleMap.hasOwnProperty(zIndex)) { + if (!(zIndex in rulesByZ)) { + zValues.push(zIndex); + rulesByZ[zIndex] = []; + } + rulesByZ[zIndex].push(ruleMap[zIndex]); } - rulesByZ[zIndex].push(ruleMap[zIndex]); } } else { // no symbolizers in rule diff --git a/lib/OpenLayers/Format/SLD/v1_0_0_GeoServer.js b/lib/OpenLayers/Format/SLD/v1_0_0_GeoServer.js index bee661311b..784e42b592 100644 --- a/lib/OpenLayers/Format/SLD/v1_0_0_GeoServer.js +++ b/lib/OpenLayers/Format/SLD/v1_0_0_GeoServer.js @@ -128,10 +128,12 @@ OpenLayers.Format.SLD.v1_0_0_GeoServer = OpenLayers.Class( var options = symbolizer.vendorOptions; if (options) { for (var key in symbolizer.vendorOptions) { - this.writeNode("VendorOption", { - name: key, - value: symbolizer.vendorOptions[key] - }, node); + if (symbolizer.vendorOptions.hasOwnProperty(key)) { + this.writeNode("VendorOption", { + name: key, + value: symbolizer.vendorOptions[key] + }, node); + } } } return node; diff --git a/lib/OpenLayers/Format/SOSGetObservation.js b/lib/OpenLayers/Format/SOSGetObservation.js index a7f2c1725f..feb1e35a49 100644 --- a/lib/OpenLayers/Format/SOSGetObservation.js +++ b/lib/OpenLayers/Format/SOSGetObservation.js @@ -210,10 +210,14 @@ OpenLayers.Format.SOSGetObservation = OpenLayers.Class(OpenLayers.Format.XML, { this.writeNode("eventTime", options, node); } for (var procedure in options.procedures) { - this.writeNode("procedure", options.procedures[procedure], node); + if (options.procedures.hasOwnProperty(procedure)) { + this.writeNode("procedure", options.procedures[procedure], node); + } } for (var observedProperty in options.observedProperties) { - this.writeNode("observedProperty", options.observedProperties[observedProperty], node); + if (options.observedProperties.hasOwnProperty(observedProperty)) { + this.writeNode("observedProperty", options.observedProperties[observedProperty], node); + } } if (options.foi) { this.writeNode("featureOfInterest", options.foi, node); diff --git a/lib/OpenLayers/Format/WFS.js b/lib/OpenLayers/Format/WFS.js index 860df0aa5f..0d69566ad6 100644 --- a/lib/OpenLayers/Format/WFS.js +++ b/lib/OpenLayers/Format/WFS.js @@ -104,15 +104,17 @@ 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) { - 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); - } + 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); + } + } return featureContainer; }, @@ -166,14 +168,16 @@ OpenLayers.Format.WFS = OpenLayers.Class(OpenLayers.Format.GML, { // add in attributes for(var propName in feature.attributes) { - 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); + 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); + } } diff --git a/lib/OpenLayers/Format/WFST/v1.js b/lib/OpenLayers/Format/WFST/v1.js index e3bf963afc..5341fd17a7 100644 --- a/lib/OpenLayers/Format/WFST/v1.js +++ b/lib/OpenLayers/Format/WFST/v1.js @@ -332,12 +332,14 @@ OpenLayers.Format.WFST.v1 = OpenLayers.Class(OpenLayers.Format.XML, { // add in attributes for(var key in feature.attributes) { - 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.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 + ); + } } } @@ -410,9 +412,11 @@ OpenLayers.Format.WFST.v1 = OpenLayers.Class(OpenLayers.Format.XML, { var parts = []; var uri; for(var key in schemaLocations) { - uri = this.namespaces[key]; - if(uri) { - parts.push(uri + " " + schemaLocations[key]); + if (schemaLocations.hasOwnProperty(key)) { + uri = this.namespaces[key]; + if(uri) { + parts.push(uri + " " + schemaLocations[key]); + } } } var value = parts.join(" ") || undefined; diff --git a/lib/OpenLayers/Format/WMC/v1.js b/lib/OpenLayers/Format/WMC/v1.js index e6eed09b44..46e1947cbc 100644 --- a/lib/OpenLayers/Format/WMC/v1.js +++ b/lib/OpenLayers/Format/WMC/v1.js @@ -48,8 +48,10 @@ OpenLayers.Format.WMC.v1 = OpenLayers.Class(OpenLayers.Format.XML, { prefix = this.namespaces[this.defaultPrefix]; } else { for(prefix in this.namespaces) { - if(this.namespaces[prefix] == uri) { - break; + if (this.namespaces.hasOwnProperty(prefix)) { + if(this.namespaces[prefix] == uri) { + break; + } } } } @@ -674,12 +676,14 @@ OpenLayers.Format.WMC.v1 = OpenLayers.Class(OpenLayers.Format.XML, { setAttributes: function(node, obj) { var value; for(var name in obj) { - 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); + 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); + } } } }, @@ -1091,25 +1095,29 @@ OpenLayers.Format.WMC.v1 = OpenLayers.Class(OpenLayers.Format.XML, { userValue: true }; for (var dim in context.dimensions) { - 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]; + 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 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; }, diff --git a/lib/OpenLayers/Format/WMC/v1_1_0.js b/lib/OpenLayers/Format/WMC/v1_1_0.js index 16caf0ece4..ceed7f5fd2 100644 --- a/lib/OpenLayers/Format/WMC/v1_1_0.js +++ b/lib/OpenLayers/Format/WMC/v1_1_0.js @@ -122,7 +122,9 @@ OpenLayers.Format.WMC.v1_1_0 = OpenLayers.Class( // optional SRS element(s) if (context.srs) { for(var name in context.srs) { - node.appendChild(this.createElementDefaultNS("SRS", name)); + if (context.srs.hasOwnProperty(name)) { + node.appendChild(this.createElementDefaultNS("SRS", name)); + } } } diff --git a/lib/OpenLayers/Format/WMTSCapabilities.js b/lib/OpenLayers/Format/WMTSCapabilities.js index d69e944c5f..b142072092 100644 --- a/lib/OpenLayers/Format/WMTSCapabilities.js +++ b/lib/OpenLayers/Format/WMTSCapabilities.js @@ -84,8 +84,10 @@ OpenLayers.Format.WMTSCapabilities = OpenLayers.Class(OpenLayers.Format.XML.Vers matrixSet: true }; for (var prop in required) { - if (!(prop in config)) { - throw new Error("Missing property '" + prop + "' in layer configuration."); + if (required.hasOwnProperty(prop)) { + if (!(prop in config)) { + throw new Error("Missing property '" + prop + "' in layer configuration."); + } } } diff --git a/lib/OpenLayers/Format/XML.js b/lib/OpenLayers/Format/XML.js index e5cc118891..3d8be16ed5 100644 --- a/lib/OpenLayers/Format/XML.js +++ b/lib/OpenLayers/Format/XML.js @@ -89,7 +89,9 @@ OpenLayers.Format.XML = OpenLayers.Class(OpenLayers.Format, { this.namespaces = OpenLayers.Util.extend({}, this.namespaces); this.namespaceAlias = {}; for(var alias in this.namespaces) { - this.namespaceAlias[this.namespaces[alias]] = alias; + if (this.namespaces.hasOwnProperty(alias)) { + this.namespaceAlias[this.namespaces[alias]] = alias; + } } }, @@ -558,11 +560,13 @@ OpenLayers.Format.XML = OpenLayers.Class(OpenLayers.Format, { setAttributes: function(node, obj) { var value, uri; for(var name in obj) { - 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.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); + } } } }, diff --git a/lib/OpenLayers/Layer.js b/lib/OpenLayers/Layer.js index 788b6e7633..76f6b5d6b7 100644 --- a/lib/OpenLayers/Layer.js +++ b/lib/OpenLayers/Layer.js @@ -423,7 +423,9 @@ OpenLayers.Layer = OpenLayers.Class({ getOptions: function() { var options = {}; for(var o in this.options) { - options[o] = this[o]; + if (this.options.hasOwnProperty(o)) { + options[o] = this[o]; + } } return options; }, diff --git a/lib/OpenLayers/Layer/HTTPRequest.js b/lib/OpenLayers/Layer/HTTPRequest.js index d1e9bf2219..6cbc83dc3d 100644 --- a/lib/OpenLayers/Layer/HTTPRequest.js +++ b/lib/OpenLayers/Layer/HTTPRequest.js @@ -218,8 +218,10 @@ OpenLayers.Layer.HTTPRequest = OpenLayers.Class(OpenLayers.Layer, { var urlParams = OpenLayers.Util.upperCaseObject(OpenLayers.Util.getParameters(url)); for(var key in allParams) { - if(key.toUpperCase() in urlParams) { - delete allParams[key]; + if (allParams.hasOwnProperty(key)) { + if(key.toUpperCase() in urlParams) { + delete allParams[key]; + } } } paramsString = OpenLayers.Util.getParameterString(allParams); diff --git a/lib/OpenLayers/Layer/MapGuide.js b/lib/OpenLayers/Layer/MapGuide.js index 680b8472c2..4285fd6094 100644 --- a/lib/OpenLayers/Layer/MapGuide.js +++ b/lib/OpenLayers/Layer/MapGuide.js @@ -346,8 +346,10 @@ OpenLayers.Layer.MapGuide = OpenLayers.Class(OpenLayers.Layer.Grid, { var urlParams = OpenLayers.Util.upperCaseObject( OpenLayers.Util.getParameters(url)); for(var key in allParams) { - if(key.toUpperCase() in urlParams) { - delete allParams[key]; + if (allParams.hasOwnProperty(key)) { + if(key.toUpperCase() in urlParams) { + delete allParams[key]; + } } } var paramsString = OpenLayers.Util.getParameterString(allParams); diff --git a/lib/OpenLayers/Layer/MapServer.js b/lib/OpenLayers/Layer/MapServer.js index 61e9930ab9..2151961713 100644 --- a/lib/OpenLayers/Layer/MapServer.js +++ b/lib/OpenLayers/Layer/MapServer.js @@ -142,8 +142,10 @@ OpenLayers.Layer.MapServer = OpenLayers.Class(OpenLayers.Layer.Grid, { var urlParams = OpenLayers.Util.upperCaseObject( OpenLayers.Util.getParameters(url)); for(var key in allParams) { - if(key.toUpperCase() in urlParams) { - delete allParams[key]; + if (allParams.hasOwnProperty(key)) { + if(key.toUpperCase() in urlParams) { + delete allParams[key]; + } } } paramsString = OpenLayers.Util.getParameterString(allParams); diff --git a/lib/OpenLayers/Layer/Vector.js b/lib/OpenLayers/Layer/Vector.js index 2857a82d7b..0e771b0017 100644 --- a/lib/OpenLayers/Layer/Vector.js +++ b/lib/OpenLayers/Layer/Vector.js @@ -509,8 +509,10 @@ OpenLayers.Layer.Vector = OpenLayers.Class(OpenLayers.Layer, { if(!zoomChanged && coordSysUnchanged) { for(var i in this.unrenderedFeatures) { - var feature = this.unrenderedFeatures[i]; - this.drawFeature(feature); + if (this.unrenderedFeatures.hasOwnProperty(i)) { + var feature = this.unrenderedFeatures[i]; + this.drawFeature(feature); + } } } } @@ -1023,4 +1025,4 @@ OpenLayers.Layer.Vector = OpenLayers.Class(OpenLayers.Layer, { }, CLASS_NAME: "OpenLayers.Layer.Vector" -}); \ No newline at end of file +}); diff --git a/lib/OpenLayers/Layer/WMTS.js b/lib/OpenLayers/Layer/WMTS.js index c82beb4d18..8673502f6f 100644 --- a/lib/OpenLayers/Layer/WMTS.js +++ b/lib/OpenLayers/Layer/WMTS.js @@ -229,8 +229,10 @@ OpenLayers.Layer.WMTS = OpenLayers.Class(OpenLayers.Layer.Grid, { matrixSet: true }; for (var prop in required) { - if (!(prop in config)) { - throw new Error("Missing property '" + prop + "' in layer configuration."); + if (required.hasOwnProperty(prop)) { + if (!(prop in config)) { + throw new Error("Missing property '" + prop + "' in layer configuration."); + } } } diff --git a/lib/OpenLayers/Protocol/Script.js b/lib/OpenLayers/Protocol/Script.js index 49e332b7f0..a92a0c9360 100644 --- a/lib/OpenLayers/Protocol/Script.js +++ b/lib/OpenLayers/Protocol/Script.js @@ -135,7 +135,7 @@ OpenLayers.Protocol.Script = OpenLayers.Class(OpenLayers.Protocol, { }); this.filterToParams = function(filter, params) { return format.write(filter, params); - } + }; } }, @@ -311,7 +311,9 @@ OpenLayers.Protocol.Script = OpenLayers.Class(OpenLayers.Protocol, { this.destroyRequest(response.priv); } else { for (var key in this.pendingRequests) { - this.destroyRequest(this.pendingRequests[key]); + if (this.pendingRequests.hasOwnProperty(key)) { + this.destroyRequest(this.pendingRequests[key]); + } } } }, diff --git a/lib/OpenLayers/Request.js b/lib/OpenLayers/Request.js index a5de46fdee..f1f51467a2 100644 --- a/lib/OpenLayers/Request.js +++ b/lib/OpenLayers/Request.js @@ -181,7 +181,9 @@ OpenLayers.Request = { config.method, url, config.async, config.user, config.password ); for(var header in config.headers) { - request.setRequestHeader(header, config.headers[header]); + if (config.headers.hasOwnProperty(header)) { + request.setRequestHeader(header, config.headers[header]); + } } var events = this.events; diff --git a/lib/OpenLayers/Rule.js b/lib/OpenLayers/Rule.js index 452b3de25f..0f7db50ae2 100644 --- a/lib/OpenLayers/Rule.js +++ b/lib/OpenLayers/Rule.js @@ -128,7 +128,9 @@ OpenLayers.Rule = OpenLayers.Class({ */ destroy: function() { for (var i in this.symbolizer) { - this.symbolizer[i] = null; + if (this.symbolizer.hasOwnProperty(i)) { + this.symbolizer[i] = null; + } } this.symbolizer = null; delete this.symbolizers; @@ -216,12 +218,14 @@ OpenLayers.Rule = OpenLayers.Class({ options.symbolizer = {}; var value, type; for(var key in this.symbolizer) { - 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; + 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; + } } } } @@ -233,4 +237,4 @@ OpenLayers.Rule = OpenLayers.Class({ }, CLASS_NAME: "OpenLayers.Rule" -}); \ No newline at end of file +}); diff --git a/lib/OpenLayers/Style.js b/lib/OpenLayers/Style.js index 1af88dfba2..891af83181 100644 --- a/lib/OpenLayers/Style.js +++ b/lib/OpenLayers/Style.js @@ -273,7 +273,9 @@ OpenLayers.Style = OpenLayers.Class({ OpenLayers.Util.extend(context, this.context); for (var i in this.propertyStyles) { - style[i] = OpenLayers.Style.createLiteral(style[i], context, feature, i); + if (this.propertyStyles.hasOwnProperty(i)) { + style[i] = OpenLayers.Style.createLiteral(style[i], context, feature, i); + } } return style; }, @@ -301,14 +303,16 @@ OpenLayers.Style = OpenLayers.Class({ for (var i=0, len=rules.length; i Date: Thu, 1 Mar 2012 11:54:07 +0100 Subject: [PATCH 071/119] Use the 3 available sub-domains for OSM by default --- lib/OpenLayers/Layer/OSM.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/OpenLayers/Layer/OSM.js b/lib/OpenLayers/Layer/OSM.js index 04e7b04454..264687644f 100644 --- a/lib/OpenLayers/Layer/OSM.js +++ b/lib/OpenLayers/Layer/OSM.js @@ -34,7 +34,7 @@ OpenLayers.Layer.OSM = OpenLayers.Class(OpenLayers.Layer.XYZ, { /** * APIProperty: url * {String} The tileset URL scheme. Defaults to - * : http://tile.openstreetmap.org/${z}/${x}/${y}.png + * : http://[a|b|c].tile.openstreetmap.org/${z}/${x}/${y}.png * (the official OSM tileset) if the second argument to the constructor * is null or undefined. To use another tileset you can have something * like this: @@ -43,7 +43,11 @@ OpenLayers.Layer.OSM = OpenLayers.Class(OpenLayers.Layer.XYZ, { * "http://tah.openstreetmap.org/Tiles/tile/${z}/${x}/${y}.png"); * (end) */ - url: 'http://tile.openstreetmap.org/${z}/${x}/${y}.png', + url: [ + 'http://a.tile.openstreetmap.org/${z}/${x}/${y}.png', + 'http://b.tile.openstreetmap.org/${z}/${x}/${y}.png', + 'http://c.tile.openstreetmap.org/${z}/${x}/${y}.png' + ], /** * Property: attribution From eb47d9777485a4618e01d2469ad5bb55ab555524 Mon Sep 17 00:00:00 2001 From: Peter Robins Date: Sun, 26 Feb 2012 15:23:17 +0000 Subject: [PATCH 072/119] KML: write attributes; add option for kvp attributes --- lib/OpenLayers/Format/KML.js | 90 +++++++++++++++++++++++--- tests/Format/KML.html | 120 +++++++++++++++++++++-------------- 2 files changed, 155 insertions(+), 55 deletions(-) diff --git a/lib/OpenLayers/Format/KML.js b/lib/OpenLayers/Format/KML.js index 1754fd8eb5..f76b4ff708 100644 --- a/lib/OpenLayers/Format/KML.js +++ b/lib/OpenLayers/Format/KML.js @@ -64,9 +64,25 @@ OpenLayers.Format.KML = OpenLayers.Class(OpenLayers.Format.XML, { * APIProperty: extractAttributes * {Boolean} Extract attributes from KML. Default is true. * Extracting styleUrls requires this to be set to true + * Note that currently only Data and SimpleData + * elements are handled. */ extractAttributes: true, + /** + * APIProperty: kvpAttributes + * {Boolean} Only used if extractAttributes is true. + * If set to true, attributes will be simple + * key-value pairs, compatible with other formats, + * Any displayName elements will be ignored. + * If set to false, attributes will be objects, + * retaining any displayName elements, but not + * compatible with other formats. Any CDATA in + * displayName will be read in as a string value. + * Default is false. + */ + kvpAttributes: false, + /** * Property: extractStyles * {Boolean} Extract styles from KML. Default is false. @@ -1078,12 +1094,16 @@ OpenLayers.Format.KML = OpenLayers.Class(OpenLayers.Format.XML, { var valueNode = data.getElementsByTagName("value"); if (valueNode.length) { ed['value'] = this.getChildValue(valueNode[0]); - } - var nameNode = data.getElementsByTagName("displayName"); - if (nameNode.length) { - ed['displayName'] = this.getChildValue(nameNode[0]); } - attributes[key] = ed; + if (this.kvpAttributes) { + attributes[key] = ed['value']; + } else { + var nameNode = data.getElementsByTagName("displayName"); + if (nameNode.length) { + ed['displayName'] = this.getChildValue(nameNode[0]); + } + attributes[key] = ed; + } } var simpleDataNodes = node.getElementsByTagName("SimpleData"); for (i = 0, len = simpleDataNodes.length; i < len; i++) { @@ -1091,8 +1111,12 @@ OpenLayers.Format.KML = OpenLayers.Class(OpenLayers.Format.XML, { data = simpleDataNodes[i]; key = data.getAttribute("name"); ed['value'] = this.getChildValue(data); - ed['displayName'] = key; - attributes[key] = ed; + if (this.kvpAttributes) { + attributes[key] = ed['value']; + } else { + ed['displayName'] = key; + attributes[key] = ed; + } } return attributes; @@ -1209,7 +1233,14 @@ OpenLayers.Format.KML = OpenLayers.Class(OpenLayers.Format.XML, { var geometryNode = this.buildGeometryNode(feature.geometry); placemarkNode.appendChild(geometryNode); - // TBD - deal with remaining (non name/description) attributes. + // output attributes as extendedData + if (feature.attributes) { + var edNode = this.buildExtendedData(feature.attributes); + if (edNode) { + placemarkNode.appendChild(edNode); + } + } + return placemarkNode; }, @@ -1440,5 +1471,48 @@ OpenLayers.Format.KML = OpenLayers.Class(OpenLayers.Format.XML, { return point.x + "," + point.y; }, + /** + * Method: buildExtendedData + * + * Parameters: + * attributes - {Object} + * + * Returns + * {DOMElement} A KML ExtendedData node or {null} if no attributes. + */ + buildExtendedData: function(attributes) { + var extendedData = this.createElementNS(this.kmlns, "ExtendedData"); + for (attributeName in attributes) { + // empty, name, description, styleUrl attributes ignored + if (attributes[attributeName] && attributeName != "name" && attributeName != "description" && attributeName != "styleUrl") { + var data = this.createElementNS(this.kmlns, "Data"); + data.setAttribute("name", attributeName); + var value = this.createElementNS(this.kmlns, "value"); + if (typeof attributes[attributeName] == "object") { + // cater for object attributes with 'value' properties + // other object properties will output an empty node + if (attributes[attributeName].value) { + value.appendChild(this.createTextNode(attributes[attributeName].value)); + } + if (attributes[attributeName].displayName) { + var displayName = this.createElementNS(this.kmlns, "displayName"); + // displayName always written as CDATA + displayName.appendChild(this.getXMLDoc().createCDATASection(attributes[attributeName].displayName)); + data.appendChild(displayName); + } + } else { + value.appendChild(this.createTextNode(attributes[attributeName])); + } + data.appendChild(value); + extendedData.appendChild(data); + } + } + if (this.isSimpleContent(extendedData)) { + return null; + } else { + return extendedData; + } + }, + CLASS_NAME: "OpenLayers.Format.KML" }); diff --git a/tests/Format/KML.html b/tests/Format/KML.html index 42b6fe6e0d..a7dfd976c2 100644 --- a/tests/Format/KML.html +++ b/tests/Format/KML.html @@ -198,21 +198,35 @@ t.ok(style.t, "getStyle returns copy of style rather than reference"); } function test_Format_KML_extendedData(t) { - t.plan(2); + t.plan(6); var f = new OpenLayers.Format.KML(); var features = f.read(OpenLayers.Util.getElement("kml_extendeddata").value); - t.eq(features[0].attributes.all_bridges.value, "3030", "read value from extendeddata correctly."); - t.eq(features[0].attributes.all_bridges.displayName, "all bridges", "read displayName from extendeddata correctly."); + t.eq(features[0].attributes.holeYardage.value, "234", "read value from extendeddata correctly."); + t.eq(features[0].attributes.holeYardage.displayName, "The yardage is ", "read displayName from extendeddata correctly."); + t.eq(f.read(f.write(features[0]))[0].attributes.holeYardage.value, features[0].attributes.holeYardage.value, "attribute value written correctly"); + t.eq(f.read(f.write(features[0]))[0].attributes.holeYardage.displayName, features[0].attributes.holeYardage.displayName, "attribute displayName written correctly"); + f.kvpAttributes = true; + features = f.read(OpenLayers.Util.getElement("kml_extendeddata").value); + t.eq(features[0].attributes.holeYardage, "234", "read kvp value from extendeddata correctly."); + t.eq(f.read(f.write(features[0]))[0].attributes.holeYardage, features[0].attributes.holeYardage, "kvp attribute value written correctly"); } function test_Format_KML_extendedData_SchemaData(t) { - t.plan(4); + t.plan(10); var f = new OpenLayers.Format.KML(); var features = f.read(OpenLayers.Util.getElement("kml_extendeddata2").value); t.eq(features[0].attributes.TrailHeadName.value, "Pi in the sky", "read value from extendeddata (schema data) correctly."); t.eq(features[0].attributes.TrailHeadName.displayName, "TrailHeadName", "read displayName from extendeddata correctly"); t.eq(features[0].attributes.ElevationGain.value, "10", "read value from extendeddata (schema data) correctly."); t.eq(features[0].attributes.ElevationGain.displayName, "ElevationGain", "read displayName from extendeddata correctly"); + t.eq(f.read(f.write(features[0]))[0].attributes.TrailHeadName.value, features[0].attributes.TrailHeadName.value, "attribute value from extendeddata (schema data) written correctly"); + t.eq(f.read(f.write(features[0]))[0].attributes.ElevationGain.value, features[0].attributes.ElevationGain.value, "attribute value from extendeddata (schema data) written correctly"); + f.kvpAttributes = true; + features = f.read(OpenLayers.Util.getElement("kml_extendeddata2").value); + t.eq(features[0].attributes.TrailHeadName, "Pi in the sky", "read kvp value from extendeddata (schema data) correctly."); + t.eq(features[0].attributes.ElevationGain, "10", "read kvp value from extendeddata (schema data) correctly."); + t.eq(f.read(f.write(features[0]))[0].attributes.TrailHeadName, features[0].attributes.TrailHeadName, "kvp attribute value from extendeddata (schema data) written correctly"); + t.eq(f.read(f.write(features[0]))[0].attributes.ElevationGain, features[0].attributes.ElevationGain, "kvp attribute value from extendeddata (schema data) written correctly"); } function test_Format_KML_placemarkName(t) { @@ -287,49 +301,61 @@