[OpenLayers-Commits] r11672 - in sandbox/tschaub/click: . examples lib/OpenLayers lib/OpenLayers/Handler lib/OpenLayers/Layer lib/OpenLayers/Protocol/WFS lib/OpenLayers/Renderer lib/OpenLayers/Strategy tests tests/Protocol

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Tue Mar 8 10:23:45 EST 2011


Author: tschaub
Date: 2011-03-08 07:23:44 -0800 (Tue, 08 Mar 2011)
New Revision: 11672

Modified:
   sandbox/tschaub/click/
   sandbox/tschaub/click/examples/mobile-drawing.html
   sandbox/tschaub/click/examples/split-feature.html
   sandbox/tschaub/click/lib/OpenLayers/Handler/Drag.js
   sandbox/tschaub/click/lib/OpenLayers/Layer/Grid.js
   sandbox/tschaub/click/lib/OpenLayers/Map.js
   sandbox/tschaub/click/lib/OpenLayers/Protocol/WFS/v1.js
   sandbox/tschaub/click/lib/OpenLayers/Renderer/SVG2.js
   sandbox/tschaub/click/lib/OpenLayers/Strategy/BBOX.js
   sandbox/tschaub/click/lib/OpenLayers/Strategy/Cluster.js
   sandbox/tschaub/click/lib/OpenLayers/Strategy/Filter.js
   sandbox/tschaub/click/lib/OpenLayers/Strategy/Fixed.js
   sandbox/tschaub/click/lib/OpenLayers/Strategy/Paging.js
   sandbox/tschaub/click/lib/OpenLayers/Strategy/Refresh.js
   sandbox/tschaub/click/tests/Map.html
   sandbox/tschaub/click/tests/Protocol/WFS.html
Log:
Merge r11655:11671 from trunk.


Property changes on: sandbox/tschaub/click
___________________________________________________________________
Modified: svn:mergeinfo
   - /sandbox/roberthl/openlayers:9745-9748
/trunk/openlayers:11572-11654
   + /sandbox/roberthl/openlayers:9745-9748
/trunk/openlayers:11572-11671

Modified: sandbox/tschaub/click/examples/mobile-drawing.html
===================================================================
--- sandbox/tschaub/click/examples/mobile-drawing.html	2011-03-08 15:21:33 UTC (rev 11671)
+++ sandbox/tschaub/click/examples/mobile-drawing.html	2011-03-08 15:23:44 UTC (rev 11672)
@@ -8,10 +8,6 @@
         <link rel="stylesheet" href="../theme/default/style.css" type="text/css">
         <script src="../lib/OpenLayers.js"></script>
         <script src="mobile-drawing.js"></script>
-        <script src="http://192.168.1.122:8124/debug.js?ns=OpenLayers.Console"></script>
-        <script>
-            OpenLayers.Console.log("mobile-drawing");
-        </script>
         <style>
             html, body {
                 margin: 0;

Modified: sandbox/tschaub/click/examples/split-feature.html
===================================================================
--- sandbox/tschaub/click/examples/split-feature.html	2011-03-08 15:21:33 UTC (rev 11671)
+++ sandbox/tschaub/click/examples/split-feature.html	2011-03-08 15:23:44 UTC (rev 11672)
@@ -68,9 +68,10 @@
                     }
                 });
                 map.addControl(split);
-                split.activate();
+
                 map.zoomToMaxExtent();
 
+                split.activate();
             }
             
             function flashFeatures(features, index) {

Modified: sandbox/tschaub/click/lib/OpenLayers/Handler/Drag.js
===================================================================
--- sandbox/tschaub/click/lib/OpenLayers/Handler/Drag.js	2011-03-08 15:21:33 UTC (rev 11671)
+++ sandbox/tschaub/click/lib/OpenLayers/Handler/Drag.js	2011-03-08 15:23:44 UTC (rev 11672)
@@ -192,6 +192,7 @@
      * {Boolean} Let the event propagate.
      */
     dragmove: function (evt) {
+        this.lastMoveEvt = evt;
         if (this.started && !this.timeoutId && (evt.xy.x != this.last.x ||
                                                 evt.xy.y != this.last.y)) {
             if(this.documentDrag === true && this.documentEvents) {
@@ -349,7 +350,6 @@
      * {Boolean} Let the event propagate.
      */
     mousemove: function(evt) {
-        this.lastMoveEvt = evt;
         return this.dragmove(evt);
     },
 

Modified: sandbox/tschaub/click/lib/OpenLayers/Layer/Grid.js
===================================================================
--- sandbox/tschaub/click/lib/OpenLayers/Layer/Grid.js	2011-03-08 15:21:33 UTC (rev 11671)
+++ sandbox/tschaub/click/lib/OpenLayers/Layer/Grid.js	2011-03-08 15:23:44 UTC (rev 11672)
@@ -701,7 +701,7 @@
         var tlLayer = this.grid[0][0].position;
         var offsetX = parseInt(this.map.layerContainerDiv.style.left);
         var offsetY = parseInt(this.map.layerContainerDiv.style.top);
-        tlViewPort = tlLayer.add(offsetX, offsetY);
+        var tlViewPort = tlLayer.add(offsetX, offsetY);
         if (tlViewPort.x > -this.tileSize.w * (buffer - 1)) {
             this.shiftColumn(true);
         } else if (tlViewPort.x < -this.tileSize.w * buffer) {

Modified: sandbox/tschaub/click/lib/OpenLayers/Map.js
===================================================================
--- sandbox/tschaub/click/lib/OpenLayers/Map.js	2011-03-08 15:21:33 UTC (rev 11671)
+++ sandbox/tschaub/click/lib/OpenLayers/Map.js	2011-03-08 15:23:44 UTC (rev 11672)
@@ -1581,21 +1581,20 @@
                 this.moveByPx(dx, dy);
             }
         } else {
-            // if we don't have a center, we were using moveByPx previously
-            var forceSetCenter = !this.center;
-            
             // getCenter
             var centerPx = this.getViewPortPxFromLonLat(this.getCachedCenter());
 
             // adjust
             var newCenterPx = centerPx.add(dx, dy);
 
-            if (forceSetCenter || !newCenterPx.equals(centerPx)) {
+            if (this.dragging || !newCenterPx.equals(centerPx)) {
                 var newCenterLonLat = this.getLonLatFromViewPortPx(newCenterPx);
                 if (options.animate) {
                     this.panTo(newCenterLonLat);
                 } else {
-                    this.setCenter(newCenterLonLat, null, options.dragging);
+                    this.moveTo(newCenterLonLat);
+                    this.dragging = false;
+                    this.events.triggerEvent("moveend");
                 }    
             }
         }        
@@ -1618,8 +1617,7 @@
             var center = this.getCachedCenter();
 
             // center will not change, don't do nothing
-            if (lonlat.lon == center.lon &&
-                lonlat.lat == center.lat) {
+            if (lonlat.equals(center)) {
                 return;
             }
 
@@ -1630,9 +1628,6 @@
 
             this.panTween.start( { x: 0, y: 0 }, vector, this.panDuration, {
                 callbacks: {
-                    start: OpenLayers.Function.bind(function() {
-                        this.events.triggerEvent("movestart");
-                    }, this),
                     eachStep: OpenLayers.Function.bind(function(px) {
                         var x = px.x - last.x,
                             y = px.y - last.y;
@@ -1641,7 +1636,8 @@
                         last.y = Math.round(px.y);
                     }, this),
                     done: OpenLayers.Function.bind(function(px) {
-                        this.moveTo(lonlat, this.zoom, {noEvent: true});
+                        this.moveTo(lonlat);
+                        this.dragging = false;
                         this.events.triggerEvent("moveend");
                     }, this)
                 }
@@ -1666,10 +1662,10 @@
      * TBD: reconsider forceZoomChange in 3.0
      */
     setCenter: function(lonlat, zoom, dragging, forceZoomChange) {
+        this.panTween && this.panTween.stop();             
         this.moveTo(lonlat, zoom, {
             'dragging': dragging,
-            'forceZoomChange': forceZoomChange,
-            'caller': 'setCenter'
+            'forceZoomChange': forceZoomChange
         });
     },
     
@@ -1689,7 +1685,8 @@
         var x = hw + dx;
         var y = hh + dy;
         var wrapDateLine = this.baseLayer.wrapDateLine;
-        var xRestriction = yRestriction = 0;
+        var xRestriction = 0;
+        var yRestriction = 0;
         if (this.restrictedExtent) {
             xRestriction = hw;
             yRestriction = hh;
@@ -1705,6 +1702,10 @@
                     x >= this.minPx.x + xRestriction;
         }
         if (valid) {
+            if (!this.dragging) {
+                this.dragging = true;
+                this.events.triggerEvent("movestart");
+            }
             this.center = null;
             if (dx) {
                 this.layerContainerDiv.style.left =
@@ -1757,16 +1758,10 @@
             }
         }
         // dragging is false by default
-        var dragging = options.dragging;
+        var dragging = options.dragging || this.dragging;
         // forceZoomChange is false by default
         var forceZoomChange = options.forceZoomChange;
-        // noEvent is false by default
-        var noEvent = options.noEvent;
 
-        if (this.panTween && options.caller == "setCenter") {
-            this.panTween.stop();
-        }    
-             
         if (!this.getCachedCenter() && !this.isValidLonLat(lonlat)) {
             lonlat = this.maxExtent.getCenterLonLat();
         }
@@ -1812,14 +1807,10 @@
         var centerChanged = (this.isValidLonLat(lonlat)) && 
                             (!lonlat.equals(this.center));
 
-
         // if neither center nor zoom will change, no need to do anything
-        if (zoomChanged || centerChanged || !dragging) {
+        if (zoomChanged || centerChanged || dragging) {
+            dragging || this.events.triggerEvent("movestart");
 
-            if (!this.dragging && !noEvent) {
-                this.events.triggerEvent("movestart");
-            }
-
             if (centerChanged) {
                 if (!zoomChanged && this.center) { 
                     // if zoom hasnt changed, just slide layerContainer
@@ -1860,14 +1851,10 @@
             //send the move call to the baselayer and all the overlays    
 
             if(this.baseLayer.visibility) {
-                this.baseLayer.moveTo(bounds, zoomChanged, dragging);
-                if(dragging) {
-                    this.baseLayer.events.triggerEvent("move");
-                } else {
-                    this.baseLayer.events.triggerEvent("moveend",
-                        {"zoomChanged": zoomChanged}
-                    );
-                }
+                this.baseLayer.moveTo(bounds, zoomChanged, options.dragging);
+                options.dragging || this.baseLayer.events.triggerEvent(
+                    "moveend", {zoomChanged: zoomChanged}
+                );
             }
             
             bounds = this.baseLayer.getExtent();
@@ -1890,38 +1877,25 @@
                         });
                     }
                     if (inRange && layer.visibility) {
-                        layer.moveTo(bounds, zoomChanged, dragging);
-                        if(dragging) {
-                            layer.events.triggerEvent("move");
-                        } else {
-                            layer.events.triggerEvent("moveend",
-                                {"zoomChanged": zoomChanged}
-                            );
-                        }
+                        layer.moveTo(bounds, zoomChanged, options.dragging);
+                        options.dragging || layer.events.triggerEvent(
+                            "moveend", {zoomChanged: zoomChanged}
+                        );
                     }
                 }                
             }
             
+            this.events.triggerEvent("move");
+            dragging || this.events.triggerEvent("moveend");
+
             if (zoomChanged) {
                 //redraw popups
                 for (var i=0, len=this.popups.length; i<len; i++) {
                     this.popups[i].updatePosition();
                 }
-            }    
-            
-            this.events.triggerEvent("move");
-    
-            if (zoomChanged) { this.events.triggerEvent("zoomend"); }
+                this.events.triggerEvent("zoomend");
+            }
         }
-
-        // even if nothing was done, we want to notify of this
-        if (!dragging && !noEvent) {
-            this.events.triggerEvent("moveend");
-        }
-        
-        // Store the map dragging state for later use
-        this.dragging = !!dragging; 
-
     },
 
     /** 

Modified: sandbox/tschaub/click/lib/OpenLayers/Protocol/WFS/v1.js
===================================================================
--- sandbox/tschaub/click/lib/OpenLayers/Protocol/WFS/v1.js	2011-03-08 15:21:33 UTC (rev 11671)
+++ sandbox/tschaub/click/lib/OpenLayers/Protocol/WFS/v1.js	2011-03-08 15:23:44 UTC (rev 11672)
@@ -183,6 +183,30 @@
 
         return response;
     },
+
+    /**
+     * APIMethod: setFeatureType
+     * Change the feature type on the fly.
+     *
+     * Parameters:
+     * featureType - {String} Local (without prefix) feature typeName.
+     */
+    setFeatureType: function(featureType) {
+        this.featureType = featureType;
+        this.format.featureType = featureType;
+    },
+ 
+    /**
+     * APIMethod: setGeometryName
+     * Sets the geometryName option after instantiation.
+     *
+     * Parameters:
+     * geometryName - {String} Name of geometry attribute.
+     */
+    setGeometryName: function(geometryName) {
+        this.geometryName = geometryName;
+        this.format.geometryName = geometryName;
+    },
     
     /**
      * Method: handleRead

Modified: sandbox/tschaub/click/lib/OpenLayers/Renderer/SVG2.js
===================================================================
--- sandbox/tschaub/click/lib/OpenLayers/Renderer/SVG2.js	2011-03-08 15:21:33 UTC (rev 11671)
+++ sandbox/tschaub/click/lib/OpenLayers/Renderer/SVG2.js	2011-03-08 15:23:44 UTC (rev 11672)
@@ -651,9 +651,8 @@
     getComponentsString: function(components, separator) {
         var len = components.length;
         var strings = new Array(len);
-        for(var i=0; i<len; i++) {
-            component = components[i];
-            strings[i] = this.getShortString(component);
+        for (var i=0; i<len; i++) {
+            strings[i] = this.getShortString(components[i]);
         }
 
         return strings.join(separator || ",");

Modified: sandbox/tschaub/click/lib/OpenLayers/Strategy/BBOX.js
===================================================================
--- sandbox/tschaub/click/lib/OpenLayers/Strategy/BBOX.js	2011-03-08 15:21:33 UTC (rev 11671)
+++ sandbox/tschaub/click/lib/OpenLayers/Strategy/BBOX.js	2011-03-08 15:23:44 UTC (rev 11672)
@@ -61,6 +61,15 @@
     response: null,
 
     /**
+     * Constructor: OpenLayers.Strategy.BBOX
+     * Create a new BBOX strategy.
+     *
+     * Parameters:
+     * options - {Object} Optional object whose properties will be set on the
+     *     instance.
+     */
+    
+    /**
      * Method: activate
      * Set up strategy with regard to reading new batches of remote data.
      * 

Modified: sandbox/tschaub/click/lib/OpenLayers/Strategy/Cluster.js
===================================================================
--- sandbox/tschaub/click/lib/OpenLayers/Strategy/Cluster.js	2011-03-08 15:21:33 UTC (rev 11671)
+++ sandbox/tschaub/click/lib/OpenLayers/Strategy/Cluster.js	2011-03-08 15:23:44 UTC (rev 11672)
@@ -59,6 +59,15 @@
     resolution: null,
 
     /**
+     * Constructor: OpenLayers.Strategy.Cluster
+     * Create a new clustering strategy.
+     *
+     * Parameters:
+     * options - {Object} Optional object whose properties will be set on the
+     *     instance.
+     */
+    
+    /**
      * APIMethod: activate
      * Activate the strategy.  Register any listeners, do appropriate setup.
      * 

Modified: sandbox/tschaub/click/lib/OpenLayers/Strategy/Filter.js
===================================================================
--- sandbox/tschaub/click/lib/OpenLayers/Strategy/Filter.js	2011-03-08 15:21:33 UTC (rev 11671)
+++ sandbox/tschaub/click/lib/OpenLayers/Strategy/Filter.js	2011-03-08 15:23:44 UTC (rev 11672)
@@ -40,6 +40,15 @@
     caching: false,
     
     /**
+     * Constructor: OpenLayers.Strategy.Filter
+     * Create a new filter strategy.
+     *
+     * Parameters:
+     * options - {Object} Optional object whose properties will be set on the
+     *     instance.
+     */
+
+    /**
      * APIMethod: activate
      * Activate the strategy.  Register any listeners, do appropriate setup.
      *     By default, this strategy automatically activates itself when a layer

Modified: sandbox/tschaub/click/lib/OpenLayers/Strategy/Fixed.js
===================================================================
--- sandbox/tschaub/click/lib/OpenLayers/Strategy/Fixed.js	2011-03-08 15:21:33 UTC (rev 11671)
+++ sandbox/tschaub/click/lib/OpenLayers/Strategy/Fixed.js	2011-03-08 15:23:44 UTC (rev 11672)
@@ -25,6 +25,15 @@
     preload: false,
 
     /**
+     * Constructor: OpenLayers.Strategy.Fixed
+     * Create a new Fixed strategy.
+     *
+     * Parameters:
+     * options - {Object} Optional object whose properties will be set on the
+     *     instance.
+     */
+
+    /**
      * Method: activate
      * Activate the strategy: load data or add listener to load when visible
      *

Modified: sandbox/tschaub/click/lib/OpenLayers/Strategy/Paging.js
===================================================================
--- sandbox/tschaub/click/lib/OpenLayers/Strategy/Paging.js	2011-03-08 15:21:33 UTC (rev 11671)
+++ sandbox/tschaub/click/lib/OpenLayers/Strategy/Paging.js	2011-03-08 15:23:44 UTC (rev 11672)
@@ -41,6 +41,15 @@
     paging: false,
 
     /**
+     * Constructor: OpenLayers.Strategy.Paging
+     * Create a new paging strategy.
+     *
+     * Parameters:
+     * options - {Object} Optional object whose properties will be set on the
+     *     instance.
+     */
+    
+    /**
      * APIMethod: activate
      * Activate the strategy.  Register any listeners, do appropriate setup.
      * 

Modified: sandbox/tschaub/click/lib/OpenLayers/Strategy/Refresh.js
===================================================================
--- sandbox/tschaub/click/lib/OpenLayers/Strategy/Refresh.js	2011-03-08 15:21:33 UTC (rev 11671)
+++ sandbox/tschaub/click/lib/OpenLayers/Strategy/Refresh.js	2011-03-08 15:23:44 UTC (rev 11672)
@@ -38,6 +38,15 @@
     timer: null,
 
     /**
+     * Constructor: OpenLayers.Strategy.Refresh
+     * Create a new Refresh strategy.
+     *
+     * Parameters:
+     * options - {Object} Optional object whose properties will be set on the
+     *     instance.
+     */
+   
+    /**
      * APIMethod: activate
      * Activate the strategy. Register any listeners, do appropriate setup.
      * 

Modified: sandbox/tschaub/click/tests/Map.html
===================================================================
--- sandbox/tschaub/click/tests/Map.html	2011-03-08 15:21:33 UTC (rev 11671)
+++ sandbox/tschaub/click/tests/Map.html	2011-03-08 15:23:44 UTC (rev 11672)
@@ -163,8 +163,15 @@
     }
 
     function test_Map_center(t) {
-        t.plan(8);
-        map = new OpenLayers.Map('map');
+        t.plan(11);
+        var log = [];
+        map = new OpenLayers.Map('map', {
+            eventListeners: {
+                "movestart": function() {log.push("movestart");},
+                "move": function() {log.push("move");},
+                "moveend": function() {log.push("moveend");}
+            }            
+        });
         var baseLayer = new OpenLayers.Layer.WMS("Test Layer", 
             "http://octo.metacarta.com/cgi-bin/mapserv?",
             {map: "/mapdata/vmap_wms.map", layers: "basic"} );
@@ -180,7 +187,11 @@
         map.zoomOut();
         t.eq( map.getZoom(), 0, "map.zoom is correct after calling setCenter,zoom in, zoom out");
 
+        log = [];
         map.zoomTo(5);
+        t.eq(log[0], "movestart", "zoomTo fires movestart event");
+        t.eq(log[1], "move", "zoomTo fires move event");
+        t.eq(log[2], "moveend", "zoomTo fires moveend event");
         t.eq( map.getZoom(), 5, "map.zoom is correct after calling zoomTo" );
 
     /**
@@ -1527,20 +1538,60 @@
     
     function test_panTo(t) {
         
-        t.plan(2);
+        t.plan(6);
         
-        var map = new OpenLayers.Map("map");
+        var log = [];
+        var map = new OpenLayers.Map("map", {
+            eventListeners: {
+                "movestart": function() {log.push("movestart");},
+                "move": function() {log.push("move");},
+                "moveend": function() {log.push("moveend");}
+            }            
+        });
         map.addLayer(
             new OpenLayers.Layer(null, {isBaseLayer: true})
         );
         map.setCenter(new OpenLayers.LonLat(0, 0), 0);
+        t.eq(log[log.length-1], "moveend", "moveend fired when map center is set");
+        log = [];
         
         map.panTo(new OpenLayers.LonLat(1, 0));
         t.eq(map.panTween.playing, true, "the map pan tween is playing before destroy");
         
-        map.destroy();
-        t.ok(!map.panTween || !map.panTween.playing, "the map pan tween is not playing after destroy");
+        t.delay_call(2, function() {
+            t.eq(log[0], "movestart", "panTo starts with movestart event");
+            t.eq(log[1], "move", "move events fired while panning");
+            t.eq(log[log.length-1], "moveend", "panTo finishes with moveend event");
+            map.destroy();
+            t.ok(!map.panTween || !map.panTween.playing, "the map pan tween is not playing after destroy");
+        });
     }
+    
+    function test_pan(t) {
+        t.plan(4);
+        
+        var map = new OpenLayers.Map("map");
+        map.addLayer(
+            new OpenLayers.Layer(null, {isBaseLayer: true})
+        );
+        map.setCenter(new OpenLayers.LonLat(0, 0), 5);
+        var log = [];
+        map.events.on({
+            "movestart": function() {log.push("movestart");},
+            "move": function() {log.push("move");},
+            "moveend": function() {log.push("moveend");}
+        });
+        
+        // simulate the drag sequence of the DragPan control;
+        map.pan(5,5, {animate: false, dragging: true});
+        map.pan(1,1, {animate: false, dragging: false});
+        
+        t.eq(log[0], "movestart", "pan sequence starts with movestart");
+        t.eq(log[1], "move", "followed by move,");
+        t.eq(log[log.length-2], "move", "move again before we stop panning,");
+        t.eq(log[log.length-1], "moveend", "and moveend when we're done.");
+        
+    }
 
     function test_updateSize(t) {
         t.plan(2);

Modified: sandbox/tschaub/click/tests/Protocol/WFS.html
===================================================================
--- sandbox/tschaub/click/tests/Protocol/WFS.html	2011-03-08 15:21:33 UTC (rev 11671)
+++ sandbox/tschaub/click/tests/Protocol/WFS.html	2011-03-08 15:23:44 UTC (rev 11672)
@@ -24,6 +24,39 @@
              "initialize returns instance of custom versioned protocol")
     }
 
+    function test_setGeometryName(t) {
+        t.plan(4);
+        var protocol = new OpenLayers.Protocol.WFS({
+            url: "http://some.url.org",
+            featureNS: "http://namespace.org",
+            featureType: "type",
+            geometryName: "geom"
+        });
+        t.eq(protocol.geometryName, "geom", "geometryName set correctly by constructor");
+        t.eq(protocol.format.geometryName, "geom", "geometryName correctly set on format by constructor");
+        // change the geometryName on the fly
+        protocol.setGeometryName("SHAPE");
+        t.eq(protocol.geometryName, "SHAPE", "geometryName changed correctly by setGeometryName");
+        t.eq(protocol.format.geometryName, "SHAPE", "geometryName correctly changed on format by setGeometryName");
+        protocol.destroy();
+    }
+
+    function test_setFeatureType(t) {
+        t.plan(4);
+        var protocol = new OpenLayers.Protocol.WFS({
+            url: "http://some.url.org",
+            featureNS: "http://namespace.org",
+            featureType: "type"
+        });
+        t.eq(protocol.featureType, "type", "featureType set correctly by constructor");
+        t.eq(protocol.format.featureType, "type", "featureType correctly set on format by constructor");
+        // change the feature type on the fly
+        protocol.setFeatureType("foo");
+        t.eq(protocol.featureType, "foo", "featureType changed correctly by setFeatureType");
+        t.eq(protocol.format.featureType, "foo", "featureType correctly changed on format by setFeatureType");
+        protocol.destroy();
+    }
+
     function test_read(t) {
         t.plan(7);
 



More information about the Commits mailing list