From cea7b3e55c1c10ed83b5d1e0ad555ae10ff037f0 Mon Sep 17 00:00:00 2001 From: fredj Date: Tue, 24 Jan 2012 09:55:32 +0100 Subject: [PATCH 01/28] Set Control.TransformFeature handle role (resize) into attributes. --- examples/transform-feature.html | 19 ++----------------- lib/OpenLayers/Control/TransformFeature.js | 7 +++++-- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/examples/transform-feature.html b/examples/transform-feature.html index d768c106a6..cfb1407b62 100644 --- a/examples/transform-feature.html +++ b/examples/transform-feature.html @@ -14,29 +14,14 @@ function init(){ map = new OpenLayers.Map('map', {allOverlays: true}); - // context for appropriate scale/resize cursors - var cursors = ["sw-resize", "s-resize", "se-resize", - "e-resize", "ne-resize", "n-resize", "nw-resize", "w-resize"]; - var context = { - getCursor: function(feature){ - var i = OpenLayers.Util.indexOf(control.handles, feature); - var cursor = "inherit"; - if(i !== -1) { - i = (i + 8 + Math.round(control.rotation / 90) * 2) % 8; - cursor = cursors[i]; - } - return cursor; - } - }; - // a nice style for the transformation box var style = new OpenLayers.Style({ - cursor: "${getCursor}", + cursor: "${role}", pointRadius: 5, fillColor: "white", fillOpacity: 1, strokeColor: "black" - }, {context: context}); + }); // allow testing of specific renderers via "?renderer=Canvas", etc var renderer = OpenLayers.Util.getParameters(window.location.href).renderer; diff --git a/lib/OpenLayers/Control/TransformFeature.js b/lib/OpenLayers/Control/TransformFeature.js index e0fa7c3b5a..d3bb90b696 100644 --- a/lib/OpenLayers/Control/TransformFeature.js +++ b/lib/OpenLayers/Control/TransformFeature.js @@ -468,10 +468,13 @@ OpenLayers.Control.TransformFeature = OpenLayers.Class(OpenLayers.Control, { var handles = new Array(8); var rotationHandles = new Array(4); var geom, handle, rotationHandle; + var resize = ["sw-resize", "s-resize", "se-resize", "e-resize", + "ne-resize", "n-resize", "nw-resize", "w-resize"]; for(var i=0; i<8; ++i) { geom = box.geometry.components[i]; - handle = new OpenLayers.Feature.Vector(geom.clone(), null, - typeof this.renderIntent == "string" ? null : + handle = new OpenLayers.Feature.Vector(geom.clone(), { + role: resize[i] + }, typeof this.renderIntent == "string" ? null : this.renderIntent); if(i % 2 == 0) { rotationHandle = new OpenLayers.Feature.Vector(geom.clone(), From eceaf1a319f2fbbfe236fb737b9213d954734f10 Mon Sep 17 00:00:00 2001 From: fredj Date: Tue, 24 Jan 2012 12:35:08 +0100 Subject: [PATCH 02/28] Add more properties to destroy in destroy() --- lib/OpenLayers/Control/TransformFeature.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/OpenLayers/Control/TransformFeature.js b/lib/OpenLayers/Control/TransformFeature.js index d3bb90b696..a4f9b245e7 100644 --- a/lib/OpenLayers/Control/TransformFeature.js +++ b/lib/OpenLayers/Control/TransformFeature.js @@ -603,10 +603,16 @@ OpenLayers.Control.TransformFeature = OpenLayers.Class(OpenLayers.Control, { geom._rotationHandle && geom._rotationHandle.destroy(); geom._rotationHandle = null; } + this.center = null; + this.feature = null; + this.handles = null; + this.rotationHandleSymbolizer = null; + this.rotationHandles = null; this.box.destroy(); this.box = null; this.layer = null; this.dragControl.destroy(); + this.dragControl = null; OpenLayers.Control.prototype.destroy.apply(this, arguments); }, From d9de788b3bc187a6a1702c51c699788f4d3403a5 Mon Sep 17 00:00:00 2001 From: fredj Date: Tue, 24 Jan 2012 12:42:01 +0100 Subject: [PATCH 03/28] Don't create unneded local variable (box) --- lib/OpenLayers/Control/TransformFeature.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/OpenLayers/Control/TransformFeature.js b/lib/OpenLayers/Control/TransformFeature.js index a4f9b245e7..0884f6d86d 100644 --- a/lib/OpenLayers/Control/TransformFeature.js +++ b/lib/OpenLayers/Control/TransformFeature.js @@ -335,7 +335,7 @@ OpenLayers.Control.TransformFeature = OpenLayers.Class(OpenLayers.Control, { var control = this; this.center = new OpenLayers.Geometry.Point(0, 0); - var box = new OpenLayers.Feature.Vector( + this.box = new OpenLayers.Feature.Vector( new OpenLayers.Geometry.LineString([ new OpenLayers.Geometry.Point(-1, -1), new OpenLayers.Geometry.Point(0, -1), @@ -351,7 +351,7 @@ OpenLayers.Control.TransformFeature = OpenLayers.Class(OpenLayers.Control, { ); // Override for box move - make sure that the center gets updated - box.geometry.move = function(x, y) { + this.box.geometry.move = function(x, y) { control._moving = true; OpenLayers.Geometry.LineString.prototype.move.apply(this, arguments); control.center.move(x, y); @@ -471,7 +471,7 @@ OpenLayers.Control.TransformFeature = OpenLayers.Class(OpenLayers.Control, { var resize = ["sw-resize", "s-resize", "se-resize", "e-resize", "ne-resize", "n-resize", "nw-resize", "w-resize"]; for(var i=0; i<8; ++i) { - geom = box.geometry.components[i]; + geom = this.box.geometry.components[i]; handle = new OpenLayers.Feature.Vector(geom.clone(), { role: resize[i] }, typeof this.renderIntent == "string" ? null : @@ -492,7 +492,6 @@ OpenLayers.Control.TransformFeature = OpenLayers.Class(OpenLayers.Control, { handles[i] = handle; } - this.box = box; this.rotationHandles = rotationHandles; this.handles = handles; }, From 1d422dbc73dcca193016812e1bcdeed3e34be53d Mon Sep 17 00:00:00 2001 From: fredj Date: Tue, 24 Jan 2012 13:59:29 +0100 Subject: [PATCH 04/28] Remove unsetFeature call in Control.TransformFeature.deactivate --- lib/OpenLayers/Control/TransformFeature.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/OpenLayers/Control/TransformFeature.js b/lib/OpenLayers/Control/TransformFeature.js index 0884f6d86d..09cc76a8a9 100644 --- a/lib/OpenLayers/Control/TransformFeature.js +++ b/lib/OpenLayers/Control/TransformFeature.js @@ -232,9 +232,6 @@ OpenLayers.Control.TransformFeature = OpenLayers.Class(OpenLayers.Control, { this.dragControl.deactivate(); deactivated = true; } - if (deactivated) { - this.unsetFeature(); - } return deactivated; }, From 7652b0e9837c8b3089ffd85f58d7f0e3240ddea5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Wed, 25 Jan 2012 10:48:54 +0100 Subject: [PATCH 05/28] change test function name in Handler/Keyboard.html, non-functional change --- tests/Handler/Keyboard.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Handler/Keyboard.html b/tests/Handler/Keyboard.html index 947cd99b09..d9d533748e 100644 --- a/tests/Handler/Keyboard.html +++ b/tests/Handler/Keyboard.html @@ -70,7 +70,7 @@ } - function test_Handler_Drag_deactivate(t) { + function test_Handler_Keyboard_deactivate(t) { t.plan(8); var map = new OpenLayers.Map('map'); var control = new OpenLayers.Control(); From 2f660316038046719b74c0a67b08931a3e3d3560 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Wed, 25 Jan 2012 10:54:39 +0100 Subject: [PATCH 06/28] remove multiple variable declarations in Control/KeyboardDefaults.js, non functional change --- lib/OpenLayers/Control/KeyboardDefaults.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/OpenLayers/Control/KeyboardDefaults.js b/lib/OpenLayers/Control/KeyboardDefaults.js index a015a9ae16..f3505353f0 100644 --- a/lib/OpenLayers/Control/KeyboardDefaults.js +++ b/lib/OpenLayers/Control/KeyboardDefaults.js @@ -62,6 +62,7 @@ OpenLayers.Control.KeyboardDefaults = OpenLayers.Class(OpenLayers.Control, { * evt - {Event} */ defaultKeyPress: function (evt) { + var size; switch(evt.keyCode) { case OpenLayers.Event.KEY_LEFT: this.map.pan(-this.slideFactor, 0); @@ -77,19 +78,19 @@ OpenLayers.Control.KeyboardDefaults = OpenLayers.Class(OpenLayers.Control, { break; case 33: // Page Up. Same in all browsers. - var size = this.map.getSize(); + size = this.map.getSize(); this.map.pan(0, -0.75*size.h); break; case 34: // Page Down. Same in all browsers. - var size = this.map.getSize(); + size = this.map.getSize(); this.map.pan(0, 0.75*size.h); break; case 35: // End. Same in all browsers. - var size = this.map.getSize(); + size = this.map.getSize(); this.map.pan(0.75*size.w, 0); break; case 36: // Home. Same in all browsers. - var size = this.map.getSize(); + size = this.map.getSize(); this.map.pan(-0.75*size.w, 0); break; From ca8a801ff0e9f65aca6009f0863cf9b5be74c6da Mon Sep 17 00:00:00 2001 From: ahocevar Date: Wed, 25 Jan 2012 11:48:18 +0100 Subject: [PATCH 07/28] Using t.eq to better show the issue (see #162) --- tests/Strategy/BBOX.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Strategy/BBOX.html b/tests/Strategy/BBOX.html index 026a13d474..c0ff4ff401 100644 --- a/tests/Strategy/BBOX.html +++ b/tests/Strategy/BBOX.html @@ -80,7 +80,7 @@ strategy.update({force: true}); var from = map.getProjectionObject(); var to = layer.projection; - t.ok(strategy.bounds.equals(map.getExtent().transform(from, to)), "[force update different proj] bounds transformed"); + t.eq(strategy.bounds.toString(), map.getExtent().transform(from, to).toString(), "[force update different proj] bounds transformed"); } From c66e5da29a44e5518ed0f6006d07481c1a3503d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Wed, 25 Jan 2012 13:07:14 +0100 Subject: [PATCH 08/28] mock map.pan, map.zoomIn and map.zoomOut in the Control.KeyboardDefaults tests, references #176 --- tests/Control/KeyboardDefaults.html | 217 +++++++++++++--------------- 1 file changed, 103 insertions(+), 114 deletions(-) diff --git a/tests/Control/KeyboardDefaults.html b/tests/Control/KeyboardDefaults.html index 225699ea84..e1901779e7 100644 --- a/tests/Control/KeyboardDefaults.html +++ b/tests/Control/KeyboardDefaults.html @@ -47,132 +47,121 @@ * http://unixpapa.com/js/key.html */ function test_Control_KeyboardDefaults_KeyDownEvent (t) { - t.plan( 16 ); + t.plan( 25 ); + + var evt = {which: 1}, pans = [], zoomIns = 0, zoomOuts = 0; - var evt = {which: 1}; map = new OpenLayers.Map('map'); + + // mock "pan", "zoomIn" and "zoomOut" + map.pan = function(dx, dy) { + pans.push({dx: dx, dy: dy}); + }; + map.zoomIn = function() { + zoomIns++; + }; + map.zoomOut = function() { + zoomOuts++; + }; + var layer = new OpenLayers.Layer.WMS("Test Layer", "http://octo.metacarta.com/cgi-bin/mapserv?", {map: "/mapdata/vmap_wms.map", layers: "basic"}); map.addLayer(layer); - control = new OpenLayers.Control.KeyboardDefaults(); + + var control = new OpenLayers.Control.KeyboardDefaults({ + slideFactor: 100 + }); map.addControl(control); - var STARTING_ZOOM_LEVEL = 4; - var DELAY = 2; - - var centerLL = new OpenLayers.LonLat(0,0); - map.setCenter(centerLL, STARTING_ZOOM_LEVEL); + map.setCenter(new OpenLayers.LonLat(0, 0), 4); // Start new test. evt.keyCode = OpenLayers.Event.KEY_LEFT; control.defaultKeyPress(evt); - t.delay_call( - DELAY, function() { - t.ok( map.getCenter().lon < centerLL.lon, "key left works correctly" ); - - // Start new test. - evt.keyCode = OpenLayers.Event.KEY_RIGHT; - control.defaultKeyPress(evt); - }, - DELAY, function() { - t.eq( map.getCenter().lon, centerLL.lon, "key right works correctly" ); - - // Start new test. - evt.keyCode = OpenLayers.Event.KEY_UP; - control.defaultKeyPress(evt); - }, - DELAY, function() { - t.ok( map.getCenter().lat > centerLL.lat, "key up works correctly" ); - - // Start new test. - evt.keyCode = OpenLayers.Event.KEY_DOWN; - control.defaultKeyPress(evt); - }, - DELAY, function() { - t.ok( map.getCenter().lat == centerLL.lat, "key down works correctly" ); - - // Start new test. - evt.keyCode = 33; //page up - control.defaultKeyPress(evt); - }, - DELAY, function() { - t.ok( map.getCenter().lat > centerLL.lat, "key page up works correctly" ); - - // Start new test. - evt.keyCode = 34; //page down - control.defaultKeyPress(evt); - }, - DELAY, function() { - t.ok( map.getCenter().lat == centerLL.lat, "key page down works correctly" ); - - // Start new test. - evt.keyCode = 35; //end - control.defaultKeyPress(evt); - }, - DELAY, function() { - t.ok( map.getCenter().lon > centerLL.lon, "key end works correctly" ); - - // Start new test. - evt.keyCode = 36; //home - control.defaultKeyPress(evt); - }, - DELAY, function() { - t.ok( map.getCenter().lon == centerLL.lon, "key home works correctly"); - - // Start new test. - evt.keyCode = 43; //+ - control.defaultKeyPress(evt); - t.eq( map.getZoom(), STARTING_ZOOM_LEVEL + 1, "key code 43 works correctly: +/= key (ASCII), keypad + (ASCII, Opera)" ); - - // Start new test. - evt.keyCode = 61; - control.defaultKeyPress(evt); - t.eq( map.getZoom(), STARTING_ZOOM_LEVEL + 2, "key code 61 works correctly: +/= key (Mozilla, Opera, some ASCII)"); - - // Start new test. - evt.keyCode = 187; - control.defaultKeyPress(evt); - t.eq( map.getZoom(), STARTING_ZOOM_LEVEL + 3, "key code 187 works correctly: +/= key (IE)"); - - // Start new test. - evt.keyCode = 107; - control.defaultKeyPress(evt); - t.eq( map.getZoom(), STARTING_ZOOM_LEVEL + 4, "key code 107 works correctly: keypad + (IE, Mozilla)"); - - // Start new test. - // set zoomanimation flag manually, - // reason: loadend event in layers.js will not achieved in unittests - map.zoomanimationActive = false; - evt.keyCode = 45; - control.defaultKeyPress(evt); - t.eq( map.getZoom(), STARTING_ZOOM_LEVEL + 3, "key code 45 works correctly: -/_ key (ASCII, Opera), keypad - (ASCII, Opera)"); - - // Start new test. - // set zoomanimation flag manually, - // reason: loadend event in layers.js will not achieved in unittests - map.zoomanimationActive = false; - evt.keyCode = 109; - control.defaultKeyPress(evt); - t.eq( map.getZoom(), STARTING_ZOOM_LEVEL + 2, "key code 109 works correctly: -/_ key (Mozilla), keypad - (Mozilla, IE)"); - - // Start new test. - // set zoomanimation flag manually, - // reason: loadend event in layers.js will not achieved in unittests - map.zoomanimationActive = false; - evt.keyCode = 189; - control.defaultKeyPress(evt); - t.eq( map.getZoom(), STARTING_ZOOM_LEVEL + 1, "key code 189 works correctly: -/_ key (IE)"); - - // Start new test. - // set zoomanimation flag manually, - // reason: loadend event in layers.js will not achieved in unittests - map.zoomanimationActive = false; - evt.keyCode = 95; - control.defaultKeyPress(evt); - t.eq( map.getZoom(), STARTING_ZOOM_LEVEL, "key code 95 works correctly: -/_ key (some ASCII)"); - } - ); + t.eq(pans.length, 1, '[KEY_LEFT] pan called once'); + t.eq(pans[0], {dx: -100, dy: 0}, + '[KEY LEFT] pan called with expected args'); + + evt.keyCode = OpenLayers.Event.KEY_RIGHT; + control.defaultKeyPress(evt); + t.eq(pans.length, 2, '[KEY_RIGHT] pan called once'); + t.eq(pans[1], {dx: 100, dy: 0}, + '[KEY RIGHT] pan called with expected args'); + + evt.keyCode = OpenLayers.Event.KEY_UP; + control.defaultKeyPress(evt); + t.eq(pans.length, 3, '[KEY_UP] pan called once'); + t.eq(pans[2], {dx: 0, dy: -100}, + '[KEY UP] pan called with expected args'); + + evt.keyCode = OpenLayers.Event.KEY_DOWN; + control.defaultKeyPress(evt); + t.eq(pans.length, 4, '[KEY_DOWN] pan called once'); + t.eq(pans[3], {dx: 0, dy: 100}, + '[KEY DOWN] pan called with expected args'); + + evt.keyCode = 33; + control.defaultKeyPress(evt); + t.eq(pans.length, 5, '[33] pan called once'); + t.eq(pans[4], {dx: 0, dy: -384}, + '[33] pan called with expected args'); + + evt.keyCode = 34; + control.defaultKeyPress(evt); + t.eq(pans.length, 6, '[34] pan called once'); + t.eq(pans[5], {dx: 0, dy: 384}, + '[34] pan called with expected args'); + + evt.keyCode = 35; + control.defaultKeyPress(evt); + t.eq(pans.length, 7, '[35] pan called once'); + t.eq(pans[6], {dx: 768, dy: 0}, + '[35] pan called with expected args'); + + evt.keyCode = 36; + control.defaultKeyPress(evt); + t.eq(pans.length, 8, '[36] pan called once'); + t.eq(pans[7], {dx: -768, dy: 0}, + '[36] pan called with expected args'); + + evt.keyCode = 43; + control.defaultKeyPress(evt); + t.eq(zoomIns, 1, '[43] zoomIn called once'); + + evt.keyCode = 61; + control.defaultKeyPress(evt); + t.eq(zoomIns, 2, '[61] zoomIn called once'); + + evt.keyCode = 187; + control.defaultKeyPress(evt); + t.eq(zoomIns, 3, '[187] zoomIn called once'); + + evt.keyCode = 107; + control.defaultKeyPress(evt); + t.eq(zoomIns, 4, '[107] zoomIn called once'); + + evt.keyCode = 107; + control.defaultKeyPress(evt); + t.eq(zoomIns, 5, '[107] zoomIn called once'); + + evt.keyCode = 45; + control.defaultKeyPress(evt); + t.eq(zoomOuts, 1, '[45] zoomOut called once'); + + evt.keyCode = 109; + control.defaultKeyPress(evt); + t.eq(zoomOuts, 2, '[109] zoomOut called once'); + + evt.keyCode = 189; + control.defaultKeyPress(evt); + t.eq(zoomOuts, 3, '[189] zoomOut called once'); + + evt.keyCode = 95; + control.defaultKeyPress(evt); + t.eq(zoomOuts, 4, '[95] zoomOut called once'); + + map.destroy(); } From 586a39ca30242f22807f53cf84df00fc9b9b9d9c Mon Sep 17 00:00:00 2001 From: fredj Date: Mon, 23 Jan 2012 16:25:12 +0100 Subject: [PATCH 09/28] Layer.Zoomify: url already defined in Layer.HTTPRequest --- lib/OpenLayers/Layer/Zoomify.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/lib/OpenLayers/Layer/Zoomify.js b/lib/OpenLayers/Layer/Zoomify.js index 2822f67fce..82e3838365 100644 --- a/lib/OpenLayers/Layer/Zoomify.js +++ b/lib/OpenLayers/Layer/Zoomify.js @@ -21,12 +21,6 @@ */ OpenLayers.Layer.Zoomify = OpenLayers.Class(OpenLayers.Layer.Grid, { - /** - * Property: url - * {String} URL for root directory with TileGroupX subdirectories. - */ - url: null, - /** * Property: size * {} The Zoomify image size in pixels. From 8062f70e1b36ea793f0d3bf29f07482915b047fc Mon Sep 17 00:00:00 2001 From: fredj Date: Mon, 23 Jan 2012 13:50:39 +0100 Subject: [PATCH 10/28] Pass unmodified arguments array to the parent class --- lib/OpenLayers/Layer/MapServer.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/OpenLayers/Layer/MapServer.js b/lib/OpenLayers/Layer/MapServer.js index 544c716a8a..61e9930ab9 100644 --- a/lib/OpenLayers/Layer/MapServer.js +++ b/lib/OpenLayers/Layer/MapServer.js @@ -39,9 +39,7 @@ OpenLayers.Layer.MapServer = OpenLayers.Class(OpenLayers.Layer.Grid, { * options - {Object} Hashtable of extra options to tag onto the layer */ initialize: function(name, url, params, options) { - var newArguments = []; - newArguments.push(name, url, params, options); - OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments); + OpenLayers.Layer.Grid.prototype.initialize.apply(this, arguments); this.params = OpenLayers.Util.applyDefaults( this.params, this.DEFAULT_PARAMS From f627071274b46b5e6d3633ff4f15acca444ec835 Mon Sep 17 00:00:00 2001 From: fredj Date: Fri, 9 Dec 2011 10:52:27 +0100 Subject: [PATCH 11/28] Remove unnecessary initialize functions (only calls the parent). --- lib/OpenLayers/Layer/Boxes.js | 3 --- lib/OpenLayers/Layer/PointTrack.js | 3 --- 2 files changed, 6 deletions(-) diff --git a/lib/OpenLayers/Layer/Boxes.js b/lib/OpenLayers/Layer/Boxes.js index 91c3d49cad..481b742542 100644 --- a/lib/OpenLayers/Layer/Boxes.js +++ b/lib/OpenLayers/Layer/Boxes.js @@ -25,9 +25,6 @@ OpenLayers.Layer.Boxes = OpenLayers.Class(OpenLayers.Layer.Markers, { * name - {String} * options - {Object} Hashtable of extra options to tag onto the layer */ - initialize: function (name, options) { - OpenLayers.Layer.Markers.prototype.initialize.apply(this, arguments); - }, /** * Method: drawMarker diff --git a/lib/OpenLayers/Layer/PointTrack.js b/lib/OpenLayers/Layer/PointTrack.js index 2350415454..5a9dbf2230 100644 --- a/lib/OpenLayers/Layer/PointTrack.js +++ b/lib/OpenLayers/Layer/PointTrack.js @@ -44,9 +44,6 @@ OpenLayers.Layer.PointTrack = OpenLayers.Class(OpenLayers.Layer.Vector, { * options - {Object} Optional object with properties to tag onto the * instance. */ - initialize: function(name, options) { - OpenLayers.Layer.Vector.prototype.initialize.apply(this, arguments); - }, /** * APIMethod: addNodes From 359d48f466d8660bef153c0fa82dbe1dc5489862 Mon Sep 17 00:00:00 2001 From: Pierre GIRAUD Date: Thu, 26 Jan 2012 15:37:13 +0100 Subject: [PATCH 12/28] Fixing typo --- lib/OpenLayers/Format/XLS/v1.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/OpenLayers/Format/XLS/v1.js b/lib/OpenLayers/Format/XLS/v1.js index 8f7c31b095..aa3fda7068 100644 --- a/lib/OpenLayers/Format/XLS/v1.js +++ b/lib/OpenLayers/Format/XLS/v1.js @@ -228,7 +228,7 @@ OpenLayers.Format.XLS.v1 = OpenLayers.Class(OpenLayers.Format.XML, { } }); if (address.freeFormAddress) { - this.writeNode("freeFormAddess", address.freeFormAddress, node); + this.writeNode("freeFormAddress", address.freeFormAddress, node); } else { if (address.street) { this.writeNode("StreetAddress", address, node); From 717e13fb44afb2d0f5e95487cfa2ae7b37c5b540 Mon Sep 17 00:00:00 2001 From: fredj Date: Thu, 26 Jan 2012 15:58:17 +0100 Subject: [PATCH 13/28] transformFeature() already call drawHandles --- lib/OpenLayers/Control/TransformFeature.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/OpenLayers/Control/TransformFeature.js b/lib/OpenLayers/Control/TransformFeature.js index 09cc76a8a9..66b441846e 100644 --- a/lib/OpenLayers/Control/TransformFeature.js +++ b/lib/OpenLayers/Control/TransformFeature.js @@ -513,7 +513,6 @@ OpenLayers.Control.TransformFeature = OpenLayers.Class(OpenLayers.Control, { onDrag: function(feature, pixel) { if(feature === control.box) { control.transformFeature({center: control.center}); - control.drawHandles(); } }, // set a new feature From 4e73df011534d4f499b31c020bffa178a932e066 Mon Sep 17 00:00:00 2001 From: fredj Date: Fri, 27 Jan 2012 11:41:45 +0100 Subject: [PATCH 14/28] Set Control.TransformFeature handle role (rotate) into attributes. --- lib/OpenLayers/Control/TransformFeature.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/OpenLayers/Control/TransformFeature.js b/lib/OpenLayers/Control/TransformFeature.js index 66b441846e..2b719a4450 100644 --- a/lib/OpenLayers/Control/TransformFeature.js +++ b/lib/OpenLayers/Control/TransformFeature.js @@ -465,17 +465,17 @@ OpenLayers.Control.TransformFeature = OpenLayers.Class(OpenLayers.Control, { var handles = new Array(8); var rotationHandles = new Array(4); var geom, handle, rotationHandle; - var resize = ["sw-resize", "s-resize", "se-resize", "e-resize", - "ne-resize", "n-resize", "nw-resize", "w-resize"]; + var positions = ["sw", "s", "se", "e", "ne", "n", "nw", "w"]; for(var i=0; i<8; ++i) { geom = this.box.geometry.components[i]; handle = new OpenLayers.Feature.Vector(geom.clone(), { - role: resize[i] + role: positions[i] + "-resize" }, typeof this.renderIntent == "string" ? null : this.renderIntent); if(i % 2 == 0) { - rotationHandle = new OpenLayers.Feature.Vector(geom.clone(), - null, typeof this.rotationHandleSymbolizer == "string" ? + rotationHandle = new OpenLayers.Feature.Vector(geom.clone(), { + role: positions[i] + "-rotate" + }, typeof this.rotationHandleSymbolizer == "string" ? null : this.rotationHandleSymbolizer); rotationHandle.geometry.move = rotationHandleMoveFn; geom._rotationHandle = rotationHandle; From becb7af745f47e32fbe02bde893560774eb689d9 Mon Sep 17 00:00:00 2001 From: fredj Date: Fri, 27 Jan 2012 12:31:18 +0100 Subject: [PATCH 15/28] Update the transform-feature example to show how the 'role' attribute can be used --- examples/transform-feature.html | 55 +++++++++++++++++++++++---------- 1 file changed, 39 insertions(+), 16 deletions(-) diff --git a/examples/transform-feature.html b/examples/transform-feature.html index cfb1407b62..a0c5645de2 100644 --- a/examples/transform-feature.html +++ b/examples/transform-feature.html @@ -14,15 +14,6 @@ function init(){ map = new OpenLayers.Map('map', {allOverlays: true}); - // a nice style for the transformation box - var style = new OpenLayers.Style({ - cursor: "${role}", - pointRadius: 5, - fillColor: "white", - fillOpacity: 1, - strokeColor: "black" - }); - // allow testing of specific renderers via "?renderer=Canvas", etc var renderer = OpenLayers.Util.getParameters(window.location.href).renderer; renderer = (renderer) ? [renderer] : OpenLayers.Layer.Vector.prototype.renderers; @@ -30,7 +21,36 @@ // the layer that we want to transform features on var vectorLayer = new OpenLayers.Layer.Vector("Simple Geometry", { styleMap: new OpenLayers.StyleMap({ - "transform": style + // a nice style for the transformation box + "transform": new OpenLayers.Style({ + display: "${getDisplay}", + cursor: "${role}", + pointRadius: 5, + fillColor: "white", + fillOpacity: 1, + strokeColor: "black" + }, { + context: { + getDisplay: function(feature) { + // hide the resize handle at the south-east corner + return feature.attributes.role === "se-resize" ? "none" : ""; + } + } + }), + "rotate": new OpenLayers.Style({ + display: "${getDisplay}", + pointRadius: 10, + fillColor: "#ddd", + fillOpacity: 1, + strokeColor: "black" + }, { + context: { + getDisplay: function(feature) { + // only display the rotate handle at the south-east corner + return feature.attributes.role === "se-rotate" ? "" : "none"; + } + } + }) }), renderers: renderer }); @@ -38,7 +58,8 @@ // create the TransformFeature control, using the renderIntent // from above control = new OpenLayers.Control.TransformFeature(vectorLayer, { - renderIntent: "transform" + renderIntent: "transform", + rotationHandleSymbolizer: "rotate" }); map.addControl(control); @@ -86,13 +107,15 @@

This example shows transformation of vector features with a tranformation box. Grab one of the handles to resize the feature. - Holding the SHIFT key will preserve the aspect ratio. Position the - mouse right outside one of the corner handles to rotate the feature, - and hold the SHIFT key to only rotate in 45° increments.

-

In this example, the transformation box has been set on the left + Holding the SHIFT key will preserve the aspect ratio. Use the gray + handle to rotate the feature and hold the SHIFT key to only rotate + in 45° increments. +

+

In this example, the transformation box has been set on the left feature, with a rotation preset of 45°. Clicking on the right feature will set it for transformation, starting with an unrotated box. - Dragging a feature or the box edges will move it around.

+ Dragging a feature or the box edges will move it around. +

From fe202cef14e1ea750d7b26ab922dacbb8b5f74e3 Mon Sep 17 00:00:00 2001 From: fredj Date: Fri, 27 Jan 2012 13:23:08 +0100 Subject: [PATCH 16/28] Change getUrlAsync parameters. Instead of giving the function a bound, a scope, a property to update and a callback, only give the bound and a callback. When the url is retrieved by getUrlAsync, simply call the callback with the url as argument and let the caller manage this. --- lib/OpenLayers/Layer/ArcIMS.js | 11 ++--------- lib/OpenLayers/Tile/Image.js | 13 ++++++------- tests/Tile/Image.html | 5 ++--- 3 files changed, 10 insertions(+), 19 deletions(-) diff --git a/lib/OpenLayers/Layer/ArcIMS.js b/lib/OpenLayers/Layer/ArcIMS.js index 860cd8d770..ddbb37d383 100644 --- a/lib/OpenLayers/Layer/ArcIMS.js +++ b/lib/OpenLayers/Layer/ArcIMS.js @@ -205,12 +205,9 @@ OpenLayers.Layer.ArcIMS = OpenLayers.Class(OpenLayers.Layer.Grid, { * Parameters: * bounds - {} A bounds representing the bbox for the * request. - * scope - {Object} The scope of the callback method. - * prop - {String} The name of the property in the scoped object to - * recieve the image url. * callback - {Function} Function to call when image url is retrieved. */ - getURLasync: function(bounds, scope, prop, callback) { + getURLasync: function(bounds, callback) { bounds = this.adjustBounds(bounds); // create an arcxml request to generate the image @@ -239,11 +236,7 @@ OpenLayers.Layer.ArcIMS = OpenLayers.Class(OpenLayers.Layer.Grid, { var axlResp = new OpenLayers.Format.ArcXML(); var arcxml = axlResp.read(doc); - scope[prop] = this.getUrlOrImage(arcxml.image.output); - - // call the callback function to recieve the updated property on the - // scoped object - callback.apply(scope); + callback(this.getUrlOrImage(arcxml.image.output)); }, scope: this }); diff --git a/lib/OpenLayers/Tile/Image.js b/lib/OpenLayers/Tile/Image.js index d863d7dece..a24242ba95 100644 --- a/lib/OpenLayers/Tile/Image.js +++ b/lib/OpenLayers/Tile/Image.js @@ -168,15 +168,14 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, { this.layer.div.appendChild(this.getTile()); if (this.layer.async) { // Asynchronous image requests call the asynchronous getURL method - // on the layer to fetch an image that covers 'this.bounds', in the scope of - // 'this', setting the 'url' property of the layer itself, and running - // the callback 'initImage' when the image request returns. - var myId = this.asyncRequestId = (this.asyncRequestId || 0) + 1; - this.layer.getURLasync(this.bounds, this, "url", function() { - if (myId == this.asyncRequestId) { + // on the layer to fetch an image that covers 'this.bounds'. + var id = this.asyncRequestId = (this.asyncRequestId || 0) + 1; + this.layer.getURLasync(this.bounds, OpenLayers.Function.bind(function(url) { + if (id == this.asyncRequestId) { + this.url = url; this.initImage(); } - }); + }, this)); } else { // synchronous image requests get the url immediately. this.url = this.layer.getURL(this.bounds); diff --git a/tests/Tile/Image.html b/tests/Tile/Image.html index 9b00113eea..0d67cf1408 100644 --- a/tests/Tile/Image.html +++ b/tests/Tile/Image.html @@ -85,9 +85,8 @@ var layer = new OpenLayers.Layer.WMS( "Name", "http://labs.metacarta.com/TESTURL?", - {layers: 'basic'}, {async: true, getURLasync: function(bounds, scope, url, callback) { - scope.url = this.getURL(bounds); - callback.call(scope); + {layers: 'basic'}, {async: true, getURLasync: function(bounds, callback) { + callback(this.getURL(bounds)); }} ); map.addLayer(layer); From 40806dbe687f4cf3c8cf3f62ce93430b3506fb74 Mon Sep 17 00:00:00 2001 From: fredj Date: Fri, 27 Jan 2012 14:50:34 +0100 Subject: [PATCH 17/28] Pass the callback scope to getURLasync --- lib/OpenLayers/Layer/ArcIMS.js | 5 +++-- lib/OpenLayers/Tile/Image.js | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/OpenLayers/Layer/ArcIMS.js b/lib/OpenLayers/Layer/ArcIMS.js index ddbb37d383..eb7dbc983c 100644 --- a/lib/OpenLayers/Layer/ArcIMS.js +++ b/lib/OpenLayers/Layer/ArcIMS.js @@ -206,8 +206,9 @@ OpenLayers.Layer.ArcIMS = OpenLayers.Class(OpenLayers.Layer.Grid, { * bounds - {} A bounds representing the bbox for the * request. * callback - {Function} Function to call when image url is retrieved. + * scope - {Object} The scope of the callback method. */ - getURLasync: function(bounds, callback) { + getURLasync: function(bounds, callback, scope) { bounds = this.adjustBounds(bounds); // create an arcxml request to generate the image @@ -236,7 +237,7 @@ OpenLayers.Layer.ArcIMS = OpenLayers.Class(OpenLayers.Layer.Grid, { var axlResp = new OpenLayers.Format.ArcXML(); var arcxml = axlResp.read(doc); - callback(this.getUrlOrImage(arcxml.image.output)); + callback.call(scope, this.getUrlOrImage(arcxml.image.output)); }, scope: this }); diff --git a/lib/OpenLayers/Tile/Image.js b/lib/OpenLayers/Tile/Image.js index a24242ba95..23a7c9668a 100644 --- a/lib/OpenLayers/Tile/Image.js +++ b/lib/OpenLayers/Tile/Image.js @@ -170,12 +170,12 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, { // Asynchronous image requests call the asynchronous getURL method // on the layer to fetch an image that covers 'this.bounds'. var id = this.asyncRequestId = (this.asyncRequestId || 0) + 1; - this.layer.getURLasync(this.bounds, OpenLayers.Function.bind(function(url) { + this.layer.getURLasync(this.bounds, function(url) { if (id == this.asyncRequestId) { this.url = url; this.initImage(); } - }, this)); + }, this); } else { // synchronous image requests get the url immediately. this.url = this.layer.getURL(this.bounds); From 1f43df33f8d25890cc4b0391b98177a579f51dce Mon Sep 17 00:00:00 2001 From: fredj Date: Mon, 30 Jan 2012 09:04:41 +0100 Subject: [PATCH 18/28] Add a note into notes/2.12.md about getURLasync changes --- notes/2.12.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/notes/2.12.md b/notes/2.12.md index ee5ae8843c..a02c465a7a 100644 --- a/notes/2.12.md +++ b/notes/2.12.md @@ -86,6 +86,10 @@ If you were previously using the `OpenLayers.Layer.SphericalMercator.forwardMerc `OpenLayers.Protocol.HTTP` no longer requires `OpenLayers.Format.QueryStringFilter`. It you need this, make sure it is included in your build config file. +## Changes in getURLasync + +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. + ## 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 8558b6ee5cfdcba2bc40fe83c507835251d81361 Mon Sep 17 00:00:00 2001 From: fredj Date: Wed, 18 Jan 2012 10:04:45 +0100 Subject: [PATCH 25/28] Update OpenLayers.Layer.Grid.calculateGridLayout inputs type. No need to clone the passed bounds (read only access). 'bounds' can be either a Bounds instance or a simple javascript object. Same for 'origin': LonLat instance or a simple javascript object. --- lib/OpenLayers/Layer/Grid.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/OpenLayers/Layer/Grid.js b/lib/OpenLayers/Layer/Grid.js index 0a1c2d8220..4722d64322 100644 --- a/lib/OpenLayers/Layer/Grid.js +++ b/lib/OpenLayers/Layer/Grid.js @@ -677,8 +677,10 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, { * Generate parameters for the grid layout. * * Parameters: - * bounds - {} - * origin - {} + * bounds - {|Object} OpenLayers.Bounds or an + * object with a 'left' and 'top' properties. + * origin - {|Object} OpenLayers.LonLat or an + * object with a 'lon' and 'lat' properties. * resolution - {Number} * * Returns: @@ -686,8 +688,6 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, { * tileoffsetlat, tileoffsetx, tileoffsety */ calculateGridLayout: function(bounds, origin, resolution) { - bounds = bounds.clone(); - var tilelon = resolution * this.tileSize.w; var tilelat = resolution * this.tileSize.h; From 657b47abb0d99a3be09c3725b1fe0e0f02c4a67b Mon Sep 17 00:00:00 2001 From: fredj Date: Mon, 16 Jan 2012 15:15:03 +0100 Subject: [PATCH 26/28] Update Control.OverviewMap.getOverviewPxFromLonLat input type 'lonlat' parameter can be either a OpenLayers.LonLat instance or a simple javascript object with a 'lon' and 'lat' properties. --- lib/OpenLayers/Control/OverviewMap.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/OpenLayers/Control/OverviewMap.js b/lib/OpenLayers/Control/OverviewMap.js index 67bba68886..29fefeb5b2 100644 --- a/lib/OpenLayers/Control/OverviewMap.js +++ b/lib/OpenLayers/Control/OverviewMap.js @@ -628,12 +628,14 @@ OpenLayers.Control.OverviewMap = OpenLayers.Class(OpenLayers.Control, { * translated into pixel bounds for the overview map */ getRectBoundsFromMapBounds: function(lonLatBounds) { - var leftBottomLonLat = new OpenLayers.LonLat(lonLatBounds.left, - lonLatBounds.bottom); - var rightTopLonLat = new OpenLayers.LonLat(lonLatBounds.right, - lonLatBounds.top); - var leftBottomPx = this.getOverviewPxFromLonLat(leftBottomLonLat); - var rightTopPx = this.getOverviewPxFromLonLat(rightTopLonLat); + var leftBottomPx = this.getOverviewPxFromLonLat({ + lon: lonLatBounds.left, + lat: lonLatBounds.bottom + }); + var rightTopPx = this.getOverviewPxFromLonLat({ + lon: lonLatBounds.right, + lat: lonLatBounds.top + }); var bounds = null; if (leftBottomPx && rightTopPx) { bounds = new OpenLayers.Bounds(leftBottomPx.x, leftBottomPx.y, @@ -699,7 +701,8 @@ OpenLayers.Control.OverviewMap = OpenLayers.Class(OpenLayers.Control, { * Get a pixel location from a map location * * Parameters: - * lonlat - {} + * lonlat - {|Object} OpenLayers.LonLat or an + * object with a 'lon' and 'lat' properties. * * Returns: * {Object} Location which is the passed-in OpenLayers.LonLat, From 3a69729074117739eeb33b7f14b914ccf1c53b2c Mon Sep 17 00:00:00 2001 From: fredj Date: Mon, 16 Jan 2012 14:25:15 +0100 Subject: [PATCH 27/28] Update OpenLayers.Bounds.containsLonLat input type 'll' parameter can now be either a OpenLayers.LonLat instance or a simple javascript object with a 'lon' and 'lat' properties. --- lib/OpenLayers/BaseTypes/Bounds.js | 12 ++++++------ lib/OpenLayers/Feature/Vector.js | 3 ++- lib/OpenLayers/Geometry.js | 3 ++- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/OpenLayers/BaseTypes/Bounds.js b/lib/OpenLayers/BaseTypes/Bounds.js index 46b992961d..5a527ca02a 100644 --- a/lib/OpenLayers/BaseTypes/Bounds.js +++ b/lib/OpenLayers/BaseTypes/Bounds.js @@ -359,7 +359,8 @@ OpenLayers.Bounds = OpenLayers.Class({ * APIMethod: containsLonLat * * Parameters: - * ll - {} + * ll - {|Object} OpenLayers.LonLat or an + * object with a 'lon' and 'lat' properties. * options - {Object} Optional parameters * * Acceptable options: @@ -382,13 +383,12 @@ OpenLayers.Bounds = OpenLayers.Class({ worldBounds = options.worldBounds; if (worldBounds && !contains) { var worldWidth = worldBounds.getWidth(); - ll = ll.clone(); var worldCenterX = (worldBounds.left + worldBounds.right) / 2; var worldsAway = Math.round((ll.lon - worldCenterX) / worldWidth); - ll.lon -= (worldsAway * worldWidth); - contains = this.containsLonLat( - ll, {inclusive: options.inclusive} - ); + contains = this.containsLonLat({ + lon: ll.lon - worldsAway * worldWidth, + lat: ll.lat + }, {inclusive: options.inclusive}); } return contains; }, diff --git a/lib/OpenLayers/Feature/Vector.js b/lib/OpenLayers/Feature/Vector.js index 75dd5ff20d..27928a2b47 100644 --- a/lib/OpenLayers/Feature/Vector.js +++ b/lib/OpenLayers/Feature/Vector.js @@ -267,7 +267,8 @@ OpenLayers.Feature.Vector = OpenLayers.Class(OpenLayers.Feature, { * Determins whether the feature intersects with the specified location. * * Parameters: - * lonlat - {} + * lonlat - {|Object} OpenLayers.LonLat or an + * object with a 'lon' and 'lat' properties. * toleranceLon - {float} Optional tolerance in Geometric Coords * toleranceLat - {float} Optional tolerance in Geographic Coords * diff --git a/lib/OpenLayers/Geometry.js b/lib/OpenLayers/Geometry.js index 888f73b83e..f199e3fa35 100644 --- a/lib/OpenLayers/Geometry.js +++ b/lib/OpenLayers/Geometry.js @@ -176,7 +176,8 @@ OpenLayers.Geometry = OpenLayers.Class({ * geometry. * * Parameters: - * lonlat - {} + * lonlat - {|Object} OpenLayers.LonLat or an + * object with a 'lon' and 'lat' properties. * toleranceLon - {float} Optional tolerance in Geometric Coords * toleranceLat - {float} Optional tolerance in Geographic Coords * From 79a64f4be6e830fd718019d118666906c910b350 Mon Sep 17 00:00:00 2001 From: fredj Date: Thu, 2 Feb 2012 17:03:35 +0100 Subject: [PATCH 28/28] Tile.Image tests: add missing scope params (see #184) --- tests/Tile/Image.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Tile/Image.html b/tests/Tile/Image.html index 0d67cf1408..0b42064265 100644 --- a/tests/Tile/Image.html +++ b/tests/Tile/Image.html @@ -85,8 +85,8 @@ var layer = new OpenLayers.Layer.WMS( "Name", "http://labs.metacarta.com/TESTURL?", - {layers: 'basic'}, {async: true, getURLasync: function(bounds, callback) { - callback(this.getURL(bounds)); + {layers: 'basic'}, {async: true, getURLasync: function(bounds, callback, scope) { + callback.call(scope, this.getURL(bounds)); }} ); map.addLayer(layer);