[OpenLayers-Commits] r12274 - in branches/openlayers/2.11: . lib/OpenLayers lib/OpenLayers/Control lib/OpenLayers/Format lib/OpenLayers/Layer lib/OpenLayers/Protocol tests tests/BaseTypes tests/Control tests/Layer tests/Protocol tools

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Wed Aug 24 19:32:37 EDT 2011


Author: crschmidt
Date: 2011-08-24 16:32:34 -0700 (Wed, 24 Aug 2011)
New Revision: 12274

Modified:
   branches/openlayers/2.11/
   branches/openlayers/2.11/lib/OpenLayers/Control/ModifyFeature.js
   branches/openlayers/2.11/lib/OpenLayers/Format/WPSDescribeProcess.js
   branches/openlayers/2.11/lib/OpenLayers/Layer/ArcGISCache.js
   branches/openlayers/2.11/lib/OpenLayers/Layer/HTTPRequest.js
   branches/openlayers/2.11/lib/OpenLayers/Map.js
   branches/openlayers/2.11/lib/OpenLayers/Protocol/Script.js
   branches/openlayers/2.11/tests/BaseTypes/Date.html
   branches/openlayers/2.11/tests/Control/ModifyFeature.html
   branches/openlayers/2.11/tests/Layer/ArcGISCache.html
   branches/openlayers/2.11/tests/Map.html
   branches/openlayers/2.11/tests/Protocol/Script.html
   branches/openlayers/2.11/tools/closure.py
Log:
Pulling in patches for OL 2.11 RC3:

 * ArcGISCache resolutions get compromised by some JS frameworks. (Closes #3474)
 * OpenLayers.Layer.HTTPRequest initialize simplification (Closes #3470)
 * missing requires (Closes #3467)
 * deleting a vertex does not update feature.modified (Closes #3463)
 * fixing test failure in some browsers (Closes #3461)
 * a grid layer may be moved while its grid hasn't been initialized yet (Closes #3458) -- this one is the actual release blocker
 * Change the callback function of Protocol.Script (JSONP) (Closes #3417)
 * "build.py -c closure" does not work on Windows systems. (Closes #3158)



Property changes on: branches/openlayers/2.11
___________________________________________________________________
Modified: svn:mergeinfo
   - /sandbox/roberthl/openlayers:9745-9748
   + /sandbox/roberthl/openlayers:9745-9748
/trunk/openlayers:12236,12248,12250,12252,12254,12267-12270

Modified: branches/openlayers/2.11/lib/OpenLayers/Control/ModifyFeature.js
===================================================================
--- branches/openlayers/2.11/lib/OpenLayers/Control/ModifyFeature.js	2011-08-24 14:35:35 UTC (rev 12273)
+++ branches/openlayers/2.11/lib/OpenLayers/Control/ModifyFeature.js	2011-08-24 23:32:34 UTC (rev 12274)
@@ -633,6 +633,7 @@
                 this.layer.drawFeature(this.feature, this.standalone ?
                                        undefined :
                                        this.selectControl.renderIntent);
+                this.modified = true;
                 this.resetVertices();
                 this.setFeatureState();
                 this.onModification(this.feature);

Modified: branches/openlayers/2.11/lib/OpenLayers/Format/WPSDescribeProcess.js
===================================================================
--- branches/openlayers/2.11/lib/OpenLayers/Format/WPSDescribeProcess.js	2011-08-24 14:35:35 UTC (rev 12273)
+++ branches/openlayers/2.11/lib/OpenLayers/Format/WPSDescribeProcess.js	2011-08-24 23:32:34 UTC (rev 12274)
@@ -5,6 +5,7 @@
  
 /**
  * @requires OpenLayers/Format/XML.js
+ * @requires OpenLayers/Format/OWSCommon/v1_1_0.js
  */
 
 /**

Modified: branches/openlayers/2.11/lib/OpenLayers/Layer/ArcGISCache.js
===================================================================
--- branches/openlayers/2.11/lib/OpenLayers/Layer/ArcGISCache.js	2011-08-24 14:35:35 UTC (rev 12273)
+++ branches/openlayers/2.11/lib/OpenLayers/Layer/ArcGISCache.js	2011-08-24 23:32:34 UTC (rev 12274)
@@ -172,21 +172,23 @@
                 
                 this.lods = [];
                 for(var key in info.tileInfo.lods) {
-                    var lod = info.tileInfo.lods[key];
-                    if (this.useScales) {
-                        this.scales.push(lod.scale);
-                    } else {
-                        this.resolutions.push(lod.resolution);
-                    }
+                    if (info.tileInfo.lods.hasOwnProperty(key)) {
+                        var lod = info.tileInfo.lods[key];
+                        if (this.useScales) {
+                            this.scales.push(lod.scale);
+                        } else {
+                            this.resolutions.push(lod.resolution);
+                        }
                     
-                    var start = this.getContainingTileCoords(upperLeft, lod.resolution);
-                    lod.startTileCol = start.x;
-                    lod.startTileRow = start.y;
+                        var start = this.getContainingTileCoords(upperLeft, lod.resolution);
+                        lod.startTileCol = start.x;
+                        lod.startTileRow = start.y;
                     
-                    var end = this.getContainingTileCoords(bottomRight, lod.resolution);
-                    lod.endTileCol = end.x;
-                    lod.endTileRow = end.y;    
-                    this.lods.push(lod);
+                        var end = this.getContainingTileCoords(bottomRight, lod.resolution);
+                        lod.endTileCol = end.x;
+                        lod.endTileRow = end.y;    
+                        this.lods.push(lod);
+                    }
                 }
 
                 this.maxExtent = this.calculateMaxExtentWithLOD(this.lods[0]);

Modified: branches/openlayers/2.11/lib/OpenLayers/Layer/HTTPRequest.js
===================================================================
--- branches/openlayers/2.11/lib/OpenLayers/Layer/HTTPRequest.js	2011-08-24 14:35:35 UTC (rev 12273)
+++ branches/openlayers/2.11/lib/OpenLayers/Layer/HTTPRequest.js	2011-08-24 23:32:34 UTC (rev 12274)
@@ -58,9 +58,7 @@
      * options - {Object} Hashtable of extra options to tag onto the layer
      */
     initialize: function(name, url, params, options) {
-        var newArguments = arguments;
-        newArguments = [name, options];
-        OpenLayers.Layer.prototype.initialize.apply(this, newArguments);
+        OpenLayers.Layer.prototype.initialize.apply(this, [name, options]);
         this.url = url;
         this.params = OpenLayers.Util.extend( {}, params);
     },

Modified: branches/openlayers/2.11/lib/OpenLayers/Map.js
===================================================================
--- branches/openlayers/2.11/lib/OpenLayers/Map.js	2011-08-24 14:35:35 UTC (rev 12273)
+++ branches/openlayers/2.11/lib/OpenLayers/Map.js	2011-08-24 23:32:34 UTC (rev 12274)
@@ -1722,7 +1722,8 @@
             var layer, i, len;
             for (i=0, len=this.layers.length; i<len; ++i) {
                 layer = this.layers[i];
-                if (layer.visibility) {
+                if (layer.visibility &&
+                    (layer === this.baseLayer || layer.inRange)) {
                     layer.moveByPx(dx, dy);
                     layer.events.triggerEvent("move");
                 }

Modified: branches/openlayers/2.11/lib/OpenLayers/Protocol/Script.js
===================================================================
--- branches/openlayers/2.11/lib/OpenLayers/Protocol/Script.js	2011-08-24 14:35:35 UTC (rev 12273)
+++ branches/openlayers/2.11/lib/OpenLayers/Protocol/Script.js	2011-08-24 23:32:34 UTC (rev 12274)
@@ -207,7 +207,7 @@
      */
     createRequest: function(url, params, callback) {
         var id = OpenLayers.Protocol.Script.register(callback);
-        var name = "OpenLayers.Protocol.Script.getCallback(" + id + ")";
+        var name = "OpenLayers.Protocol.Script.registry[" + id + "]";
         params = OpenLayers.Util.extend({}, params);
         params[this.callbackKey] = this.callbackPrefix + name;
         url = OpenLayers.Util.urlAppend(
@@ -328,7 +328,7 @@
 (function() {
     var o = OpenLayers.Protocol.Script;
     var counter = 0;
-    var registry = {};
+    o.registry = [];
     
     /**
      * Function: OpenLayers.Protocol.Script.register
@@ -344,7 +344,10 @@
      */
     o.register = function(callback) {
         var id = ++counter;
-        registry[id] = callback;
+        o.registry[id] = function() {
+            o.unregister(id);
+            callback.apply(this, arguments);
+        };
         return id;
     };
     
@@ -356,22 +359,6 @@
      * id: {Number} The identifer returned by the register function.
      */
     o.unregister = function(id) {
-        delete registry[id];
+        delete o.registry[id];
     };
-    
-    /**
-     * Function: OpenLayers.Protocol.Script.getCallback
-     * Retreive and unregister a callback.  A call to this function is the "P" 
-     * in JSONP.  For example, a script may be added with a src attribute 
-     * http://example.com/features.json?callback=OpenLayers.Protocol.Script.getCallback(1)
-     *
-     * Parameters:
-     * id: {Number} The identifer returned by the register function.
-     */
-    o.getCallback = function(id) {
-        var callback = registry[id];
-        o.unregister(id);
-        return callback;
-    };
 })();
-

Modified: branches/openlayers/2.11/tests/BaseTypes/Date.html
===================================================================
--- branches/openlayers/2.11/tests/BaseTypes/Date.html	2011-08-24 14:35:35 UTC (rev 12273)
+++ branches/openlayers/2.11/tests/BaseTypes/Date.html	2011-08-24 23:32:34 UTC (rev 12274)
@@ -20,7 +20,15 @@
         
         // check invalid date
         date = new Date("foo");
-        str = OpenLayers.Date.toISOString(date);
+        try {
+            str = OpenLayers.Date.toISOString(date);
+        } catch (err) {
+            // some implementations throw RangeError
+            // see https://bugzilla.mozilla.org/show_bug.cgi?id=649575
+            if (err instanceof RangeError) {
+                str = "Invalid Date";
+            }
+        }
         t.eq(str, "Invalid Date", "invalid date");
 
     }

Modified: branches/openlayers/2.11/tests/Control/ModifyFeature.html
===================================================================
--- branches/openlayers/2.11/tests/Control/ModifyFeature.html	2011-08-24 14:35:35 UTC (rev 12273)
+++ branches/openlayers/2.11/tests/Control/ModifyFeature.html	2011-08-24 23:32:34 UTC (rev 12274)
@@ -74,7 +74,7 @@
     }
     
     function test_handleKeypress(t) {
-        t.plan(14);
+        t.plan(16);
 
         /**
          * There are two things that we want to test here
@@ -101,6 +101,8 @@
         // mock up vertex deletion
         control.dragControl.feature = point;
         control.feature = poly;
+        // we cannot use selectFeature since the control is not part of a map
+        control._originalGeometry = poly.geometry.clone();
         control.vertices = [point];
         point.geometry.parent = {
             removeComponent: function(geometry) {
@@ -110,6 +112,7 @@
         };
         layer.events.on({
             "featuremodified": function(event) {
+                t.ok(event.feature.modified !== null, "modified property of feature should have been set");
                 t.eq(event.feature.id, poly.id, "vertex deletion: featuremodifed triggered");
             },
             "vertexremoved": function(evt) {

Modified: branches/openlayers/2.11/tests/Layer/ArcGISCache.html
===================================================================
--- branches/openlayers/2.11/tests/Layer/ArcGISCache.html	2011-08-24 14:35:35 UTC (rev 12273)
+++ branches/openlayers/2.11/tests/Layer/ArcGISCache.html	2011-08-24 23:32:34 UTC (rev 12274)
@@ -219,6 +219,32 @@
         t.ok((tile.x >= 0 && tile.y >= 0), 'layer should not generate negative tile ranges for level of detail');
     }
 
+   /*  
+    * Test that messing up the Array.prototype does not mess up the lods of the layer. 
+    * This messes up zooming when resolutions are very small/scales are very large/zoomed way in. 
+    */ 
+    function test_Layer_ARCGISCACHE_lods (t) { 
+        t.plan( 2 ); 
+        var layerInfo = capabilitiesObject; 
+
+        lods = layerInfo.tileInfo.lods.length; 
+
+        // mess up the Array prototype
+        Array.prototype.foo = function() { };
+
+        t.ok( lods == layerInfo.tileInfo.lods.length, 'proper number of "Levels of Detail" before initialization' ); 
+
+        // initialize the layer using the JSON object from an arcgis server 
+        // see: ArcGISCache.json 
+        var layer = new OpenLayers.Layer.ArcGISCache(name, url, { 
+            layerInfo: layerInfo 
+        }); 
+
+        t.ok( lods == layer.lods.length, 'proper number of "Levels of Detail" after initialization.' );         
+        // restore the Array prototype
+        delete Array.prototype.foo;
+    } 
+
   </script>
 </head>
 <body>

Modified: branches/openlayers/2.11/tests/Map.html
===================================================================
--- branches/openlayers/2.11/tests/Map.html	2011-08-24 14:35:35 UTC (rev 12273)
+++ branches/openlayers/2.11/tests/Map.html	2011-08-24 23:32:34 UTC (rev 12274)
@@ -1790,37 +1790,77 @@
     }    
 
     function test_moveByPx(t) {
-        t.plan(8);
+        t.plan(16);
 
+        var moved;
+        var Layer = OpenLayers.Class(OpenLayers.Layer, {
+            moveByPx: function(dx, dy) {
+                moved[this.name] = true;
+            }
+        });
+
         var map = new OpenLayers.Map({
             div: 'map',
             maxExtent: new OpenLayers.Bounds(-50, -50, 50, 50),
             restrictedExtent: new OpenLayers.Bounds(-10, -10, 10, 10),
             layers: [
-                new OpenLayers.Layer('name', {isBaseLayer: true})
+                new Layer('base',
+                    {isBaseLayer: true}),
+                new Layer('outofrange',
+                    {isBaseLayer: false, minResolution:2})
             ]
         });
+
+        moved = {};
         map.zoomToExtent(new OpenLayers.Bounds(-1, -1, 1, 1));
 
         // check initial state
-        t.eq(map.layerContainerDiv.style.left, '0px', 'layer container left correct');
-        t.eq(map.layerContainerDiv.style.top, '0px', 'layer container top correct');
+        t.eq(map.layerContainerDiv.style.left, '0px',
+             '[initial state] layer container left correct');
+        t.eq(map.layerContainerDiv.style.top, '0px',
+             '[initial state] layer container top correct');
+        t.eq(moved['base'], undefined,
+             '[initial state] base layer not moved');
+        t.eq(moved['outofrange'], undefined,
+             '[initial state] out-of-range layer not moved');
 
         // move to a valid position
+        moved = {};
         map.moveByPx(-455, 455);
-        t.eq(map.layerContainerDiv.style.left, '455px', 'layer container left correct');
-        t.eq(map.layerContainerDiv.style.top, '-455px', 'layer container top correct');
+        t.eq(map.layerContainerDiv.style.left, '455px',
+             '[valid position] layer container left correct');
+        t.eq(map.layerContainerDiv.style.top, '-455px',
+             '[valid position] layer container top correct');
+        t.eq(moved['base'], true,
+             '[valid position] base layer moved');
+        t.eq(moved['outofrange'], undefined,
+             '[valid position] out-of-range layer not moved');
 
         // move outside the max extent
+        moved = {};
         map.moveByPx(-4500, 4500);
-        t.eq(map.layerContainerDiv.style.left, '455px', 'layer container left correct');
-        t.eq(map.layerContainerDiv.style.top, '-455px', 'layer container top correct');
+        t.eq(map.layerContainerDiv.style.left, '455px',
+             '[outside max extent] layer container left correct');
+        t.eq(map.layerContainerDiv.style.top, '-455px',
+             '[outside max extent] layer container top correct');
+        t.eq(moved['base'], undefined,
+             '[outside max extent] base layer not moved');
+        t.eq(moved['outofrange'], undefined,
+             '[outside max extent] out-of-range layer not moved');
 
         // move outside the restricted extent
+        moved = {};
         map.moveByPx(-500, 500);
-        t.eq(map.layerContainerDiv.style.left, '455px', 'layer container left correct');
-        t.eq(map.layerContainerDiv.style.top, '-455px', 'layer container top correct');
+        t.eq(map.layerContainerDiv.style.left, '455px',
+             '[outside restricted extent] layer container left correct');
+        t.eq(map.layerContainerDiv.style.top, '-455px',
+             '[outside restricted extent] layer container top correct');
+        t.eq(moved['base'], undefined,
+             '[outside restricted extent] base layer not moved');
+        t.eq(moved['outofrange'], undefined,
+             '[outside restricted extent] out-of-range layer not moved');
 
+
         map.destroy();
     }
 

Modified: branches/openlayers/2.11/tests/Protocol/Script.html
===================================================================
--- branches/openlayers/2.11/tests/Protocol/Script.html	2011-08-24 14:35:35 UTC (rev 12273)
+++ branches/openlayers/2.11/tests/Protocol/Script.html	2011-08-24 23:32:34 UTC (rev 12274)
@@ -150,7 +150,7 @@
 
         t.eq(script.type, 'text/javascript',
             'created script has a correct type');
-        t.eq(script.src, 'http://bar_url/?k=bar_param&cb_key=cb_prefix%3AOpenLayers.Protocol.Script.getCallback(bar)',
+        t.eq(script.src, 'http://bar_url/?k=bar_param&cb_key=cb_prefix%3AOpenLayers.Protocol.Script.registry%5Bbar%5D',
             'created script has a correct url');
         t.eq(script.id, 'OpenLayers_Protocol_Script_bar',
             'created script has a correct id');

Modified: branches/openlayers/2.11/tools/closure.py
===================================================================
--- branches/openlayers/2.11/tools/closure.py	2011-08-24 14:35:35 UTC (rev 12273)
+++ branches/openlayers/2.11/tools/closure.py	2011-08-24 23:32:34 UTC (rev 12274)
@@ -2,20 +2,21 @@
 import os
 import tempfile
 
-path = os.path.abspath(os.path.join(os.path.dirname(__file__), "closure-compiler.jar"))
+path = "../tools/closure-compiler.jar"
 if not os.path.exists(path):
     raise Exception("No closure-compiler.jar at %s; read README.txt!" % path)
 
 def minimize(code):
-    ntf = tempfile.NamedTemporaryFile()
+    ntf = tempfile.NamedTemporaryFile(delete=False)
     ntf.write(code)
     ntf.flush()
 
-    ntf2 = tempfile.NamedTemporaryFile()
+    ntf2 = tempfile.NamedTemporaryFile(delete=False)
+    ntf.close()
+    ntf2.close()
 
     os.system("java -jar %s --js %s --js_output_file %s" % (path, ntf.name, ntf2.name))
-    ntf2.seek(0)
-    data = ntf2.read()
-    ntf.close()
-    ntf2.close()
+    data = open(ntf2.name).read()
+    os.unlink(ntf.name)
+    os.unlink(ntf2.name)
     return data



More information about the Commits mailing list