[OpenLayers-Commits] r11155 - in sandbox/elemoine/draw-feature: . examples lib/OpenLayers lib/OpenLayers/Control lib/OpenLayers/Format/WMTSCapabilities lib/OpenLayers/Handler tests tests/Control tests/Format/WMTSCapabilities tests/Handler tools

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Sun Feb 20 11:56:45 EST 2011


Author: erilem
Date: 2011-02-20 08:56:45 -0800 (Sun, 20 Feb 2011)
New Revision: 11155

Added:
   sandbox/elemoine/draw-feature/tests/Handler/Box.html
   sandbox/elemoine/draw-feature/tests/OpenLayersJsFiles.html
Modified:
   sandbox/elemoine/draw-feature/
   sandbox/elemoine/draw-feature/examples/mobile.js
   sandbox/elemoine/draw-feature/lib/OpenLayers/Control/ModifyFeature.js
   sandbox/elemoine/draw-feature/lib/OpenLayers/Format/WMTSCapabilities/v1_0_0.js
   sandbox/elemoine/draw-feature/lib/OpenLayers/Handler/Box.js
   sandbox/elemoine/draw-feature/lib/OpenLayers/Map.js
   sandbox/elemoine/draw-feature/tests/Control/Measure.html
   sandbox/elemoine/draw-feature/tests/Control/ModifyFeature.html
   sandbox/elemoine/draw-feature/tests/Format/WMTSCapabilities/v1_0_0.html
   sandbox/elemoine/draw-feature/tests/list-tests.html
   sandbox/elemoine/draw-feature/tools/update_dev_dir.sh
Log:
svn merge -r 11141:HEAD http://svn.openlayers.org/trunk/openlayers/ .


Property changes on: sandbox/elemoine/draw-feature
___________________________________________________________________
Modified: svn:mergeinfo
   - /sandbox/roberthl/openlayers:9745-9748
/trunk/openlayers:11027-11037,11040-11091,11094-11140
   + /sandbox/roberthl/openlayers:9745-9748
/trunk/openlayers:11027-11037,11040-11091,11094-11140,11142-11154

Modified: sandbox/elemoine/draw-feature/examples/mobile.js
===================================================================
--- sandbox/elemoine/draw-feature/examples/mobile.js	2011-02-20 16:44:06 UTC (rev 11154)
+++ sandbox/elemoine/draw-feature/examples/mobile.js	2011-02-20 16:56:45 UTC (rev 11155)
@@ -1,9 +1,9 @@
 
 // initialize map when page ready
 var map;
+var gg = new OpenLayers.Projection("EPSG:4326");
+var sm = new OpenLayers.Projection("EPSG:900913");
 function init() {
-    var gg = new OpenLayers.Projection("EPSG:4326");
-    var sm = new OpenLayers.Projection("EPSG:900913");
     
     // layer for drawn features
     var vector = new OpenLayers.Layer.Vector();
@@ -42,7 +42,7 @@
         navigator.geolocation.getCurrentPosition(
             updatePosition,
             function failure(error) {
-                updateLog(error.message);
+                OpenLayers.Console.log(error.message);
             },
             {
                 enableHighAccuracy: true
@@ -58,25 +58,14 @@
     position = pos;
     var lon =  position.coords.longitude;
     var lat = position.coords.latitude;
-    updateLog("position: lon " + lon + ", lat " + lat);
+    OpenLayers.Console.log("position: lon " + lon + ", lat " + lat);
     map.setCenter(
         new OpenLayers.LonLat(lon, lat).transform(gg, sm)
     );
 }
 
-// allow simple logging
-var log = [];
-function updateLog(message) {
-    log.push(message);
-    if (window.console) {
-        console.log(message);
-    }
-}
-function clearLog() {
-    log.length = 0;
-}    
-
 function pan(fx, fy) {
     var size = map.getSize();
     map.pan(size.w * fx, size.h * fy);
 }
+

Modified: sandbox/elemoine/draw-feature/lib/OpenLayers/Control/ModifyFeature.js
===================================================================
--- sandbox/elemoine/draw-feature/lib/OpenLayers/Control/ModifyFeature.js	2011-02-20 16:44:06 UTC (rev 11154)
+++ sandbox/elemoine/draw-feature/lib/OpenLayers/Control/ModifyFeature.js	2011-02-20 16:56:45 UTC (rev 11155)
@@ -351,18 +351,23 @@
     },
 
     /**
-     * Method: selectFeature
-     * Called when the select feature control selects a feature.
+     * APIMethod: selectFeature
+     * Select a feature for modification in standalone mode. In non-standalone
+     * mode, this method is called when the select feature control selects a
+     * feature. Register a listener to the beforefeaturemodified event and
+     * return false to prevent feature modification.
      *
      * Parameters:
      * feature - {<OpenLayers.Feature.Vector>} the selected feature.
      */
     selectFeature: function(feature) {
-        this.feature = feature;
-        this.modified = false;
-        this.resetVertices();
-        this.dragControl.activate();
-        this.onModificationStart(this.feature);
+        if (!this.standalone || this.beforeSelectFeature(feature) !== false) {
+            this.feature = feature;
+            this.modified = false;
+            this.resetVertices();
+            this.dragControl.activate();
+            this.onModificationStart(this.feature);
+        }
     },
 
     /**

Modified: sandbox/elemoine/draw-feature/lib/OpenLayers/Format/WMTSCapabilities/v1_0_0.js
===================================================================
--- sandbox/elemoine/draw-feature/lib/OpenLayers/Format/WMTSCapabilities/v1_0_0.js	2011-02-20 16:44:06 UTC (rev 11154)
+++ sandbox/elemoine/draw-feature/lib/OpenLayers/Format/WMTSCapabilities/v1_0_0.js	2011-02-20 16:56:45 UTC (rev 11155)
@@ -191,7 +191,14 @@
             },
             "MatrixHeight": function(node, obj) {
                 obj.matrixHeight = parseInt(this.getChildValue(node)); 
-            },        
+            },
+            "ResourceURL": function(node, obj) {
+                obj.resourceUrl = obj.resourceUrl || {};
+                obj.resourceUrl[node.getAttribute("resourceType")] = {
+                    format: node.getAttribute("format"),
+                    template: node.getAttribute("template")
+                };
+            },
             // not used for now, can be added in the future though
             /*"Themes": function(node, obj) {
                 obj.themes = [];

Modified: sandbox/elemoine/draw-feature/lib/OpenLayers/Handler/Box.js
===================================================================
--- sandbox/elemoine/draw-feature/lib/OpenLayers/Handler/Box.js	2011-02-20 16:44:06 UTC (rev 11154)
+++ sandbox/elemoine/draw-feature/lib/OpenLayers/Handler/Box.js	2011-02-20 16:56:45 UTC (rev 11155)
@@ -68,11 +68,11 @@
      * Method: destroy
      */
     destroy: function() {
+        OpenLayers.Handler.prototype.destroy.apply(this, arguments);
         if (this.dragHandler) {
             this.dragHandler.destroy();
             this.dragHandler = null;
         }            
-        OpenLayers.Handler.prototype.destroy.apply(this, arguments);
     },
 
     /**

Modified: sandbox/elemoine/draw-feature/lib/OpenLayers/Map.js
===================================================================
--- sandbox/elemoine/draw-feature/lib/OpenLayers/Map.js	2011-02-20 16:44:06 UTC (rev 11154)
+++ sandbox/elemoine/draw-feature/lib/OpenLayers/Map.js	2011-02-20 16:56:45 UTC (rev 11155)
@@ -943,7 +943,7 @@
         }
 
         this.events.triggerEvent("addlayer", {layer: layer});
-		layer.events.triggerEvent("added", {map: this, layer: layer});
+        layer.events.triggerEvent("added", {map: this, layer: layer});
         layer.afterAdd();
     },
 
@@ -1018,7 +1018,7 @@
         this.resetLayersZIndex();
 
         this.events.triggerEvent("removelayer", {layer: layer});
-		layer.events.triggerEvent("removed", {map: this, layer: layer})
+        layer.events.triggerEvent("removed", {map: this, layer: layer})
     },
 
     /**

Modified: sandbox/elemoine/draw-feature/tests/Control/Measure.html
===================================================================
--- sandbox/elemoine/draw-feature/tests/Control/Measure.html	2011-02-20 16:44:06 UTC (rev 11154)
+++ sandbox/elemoine/draw-feature/tests/Control/Measure.html	2011-02-20 16:56:45 UTC (rev 11155)
@@ -131,8 +131,8 @@
             // wait for delay then confirm event was logged
             delay, function() {
                 t.eq(log.length, 1, "a) event logged")
-                t.eq(log[0].type, "measurepartial", "a) event logged");
-                t.eq(log[0].measure, 10, "a) correct measure");
+                t.ok(log[0] && log[0].type == "measurepartial", "a) event logged");
+                t.ok(log[0] && log[0].measure == 10, "a) correct measure");
                 
                 // b) move 10 pixels and click
                 trigger("mousemove", 0, 20);
@@ -145,8 +145,8 @@
             },
             delay, function() {
                 t.eq(log.length, 2, "b) event logged");
-                t.eq(log[1].type, "measurepartial", "b) correct type");
-                t.eq(log[1].measure, 20, "b) correct measure");
+                t.ok(log[1] && log[1].type == "measurepartial", "b) correct type");
+                t.ok(log[1] && log[1].measure == 20, "b) correct measure");
 
                 // c) move 10 pixels and click
                 trigger("mousemove", 0, 30);
@@ -161,8 +161,8 @@
             // wait for rest of delay and confirm event logged
             delay / 2, function() {
                 t.eq(log.length, 3, "c) event logged");
-                t.eq(log[2].type, "measurepartial", "c) correct type");
-                t.eq(log[2].measure, 30, "c) correct measure");
+                t.ok(log[2] && log[2].type == "measurepartial", "c) correct type");
+                t.ok(log[2] && log[2].measure == 30, "c) correct measure");
                 
                 // d) move 10 pixels and click
                 trigger("mousemove", 0, 40);
@@ -176,8 +176,8 @@
                 trigger("dblclick", 0, 40);
 
                 t.eq(log.length, 4, "e) event logged");
-                t.eq(log[3].type, "measure", "e) correct type");
-                t.eq(log[3].measure, 40, "e) correct measure");                
+                t.ok(log[3] && log[3].type == "measure", "e) correct type");
+                t.ok(log[3] && log[3].measure == 40, "e) correct measure");                
             },
             // wait for rest of delay and confirm no measurepartial logged
             delay, function() {
@@ -198,22 +198,22 @@
                 trigger("mousemove", 10, 0);
 
                 t.eq(log.length, 1, "g) event logged");
-                t.eq(log[0].type, "measurepartial", "g) correct type");
-                t.eq(log[0].measure, 10, "g) correct measure");
+                t.ok(log[0] && log[0].type == "measurepartial", "g) correct type");
+                t.ok(log[0] && log[0].measure == 10, "g) correct measure");
                 
                 // h) move 10 pixels
                 trigger("mousemove", 20, 0);
 
                 t.eq(log.length, 2, "h) event logged");
-                t.eq(log[1].type, "measurepartial", "h) correct type");
-                t.eq(log[1].measure, 20, "h) correct measure");
+                t.ok(log[1] && log[1].type == "measurepartial", "h) correct type");
+                t.ok(log[1] && log[1].measure == 20, "h) correct measure");
 
                 // i) mouse up to finish
                 trigger("mouseup", 20, 0);
 
                 t.eq(log.length, 3, "i) event logged");
-                t.eq(log[2].type, "measure", "i) correct type");
-                t.eq(log[2].measure, 20, "i) correct measure");
+                t.ok(log[2] && log[2].type == "measure", "i) correct type");
+                t.ok(log[2] && log[2].measure == 20, "i) correct measure");
 
                 // j) clean up
                 log = [];
@@ -284,10 +284,10 @@
             delay, function() {
                 // confirm measurepartial is fired
                 t.eq(log.length, 1, "a) event logged");
-                t.eq(log[0].type, "measurepartial", "a) correct type");
+                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.eq(log[0].measure, 0, "a) correct measure");
+                t.ok(log[0] && log[0].measure == 0, "a) correct measure");
 
                 // b) move 10 pixels
                 trigger("mousemove", 0, 20);
@@ -296,10 +296,10 @@
 
                 // confirm measurepartial is fired 2 times
                 t.eq(log.length, 3, "b) event logged");
-                t.eq(log[1].type, "measurepartial", "b) correct type");
-                t.eq(log[1].measure, 20, "b) correct measure");
-                t.eq(log[2].type, "measurepartial", "c) correct type");
-                t.eq(log[2].measure, 30, "c) correct measure");
+                t.ok(log[1] && log[1].type == "measurepartial", "b) correct type");
+                t.ok(log[1] && log[1].measure == 20, "b) correct measure");
+                t.ok(log[2] && log[2].type == "measurepartial", "c) correct type");
+                t.ok(log[2] && log[2].measure == 30, "c) correct measure");
 
                 // d) switch immediate measurement off
                 control.setImmediate(false);
@@ -315,8 +315,8 @@
             // wait for delay then confirm event was logged
             delay, function() {
                 t.eq(log.length, 4, "e) event logged")
-                t.eq(log[3].type, "measurepartial", "e) correct type");
-                t.eq(log[3].measure, 40, "e) correct measure");
+                t.ok(log[3] && log[3].type == "measurepartial", "e) correct type");
+                t.ok(log[3] && log[3].measure == 40, "e) correct measure");
 
                 // f) switch immediate measurement on
                 control.setImmediate(true);
@@ -327,33 +327,33 @@
             },
             delay, function() {
                 t.eq(log.length, 5, "g) event logged");
-                t.eq(log[4].type, "measurepartial", "g) correct type");
-                t.eq(log[4].measure, 50, "g) correct measure");
+                t.ok(log[4] && log[4].type == "measurepartial", "g) correct type");
+                t.ok(log[4] && log[4].measure == 50, "g) correct measure");
 
                 // h) move 10 pixels
                 trigger("mousemove", 0, 60);
 
                 t.eq(log.length, 6, "h) event logged");
-                t.eq(log[5].type, "measurepartial", "h) correct type");
-                t.eq(log[5].measure, 60, "h) correct measure");
+                t.ok(log[5] && log[5].type == "measurepartial", "h) correct type");
+                t.ok(log[5] && log[5].measure == 60, "h) correct measure");
 
                 // i) double click to finish
                 trigger("mousedown", 0, 60);
                 t.eq(log.length, 7, "i) event logged");
-                t.eq(log[6].type, "measurepartial", "i) correct type");
-                t.eq(log[6].measure, 60, "i) correct measure");
+                t.eq(log[6] && log[6].type, "measurepartial", "i) correct type");
+                t.eq(log[6] && log[6].measure, 60, "i) correct measure");
                 trigger("mouseup", 0, 60);
                 t.eq(log.length, 7, "i) no event fired yet");
             },
             delay, function() {
                 t.eq(log.length, 8, "i) event logged");
-                t.eq(log[7].type, "measurepartial", "i) correct type");
-                t.eq(log[7].measure, 60, "i) correct measure");
+                t.eq(log[7] && log[7].type, "measurepartial", "i) correct type");
+                t.eq(log[7] && log[7].measure, 60, "i) correct measure");
 
                 trigger("dblclick", 0, 60);
                 t.eq(log.length, 9, "i) event logged");
-                t.eq(log[8].type, "measure", "i) correct type");
-                t.eq(log[8].measure, 60, "i) correct measure");
+                t.eq(log[8] && log[8].type, "measure", "i) correct type");
+                t.eq(log[8] && log[8].measure, 60, "i) correct measure");
                 // clear log
                 log = [];
 

Modified: sandbox/elemoine/draw-feature/tests/Control/ModifyFeature.html
===================================================================
--- sandbox/elemoine/draw-feature/tests/Control/ModifyFeature.html	2011-02-20 16:44:06 UTC (rev 11154)
+++ sandbox/elemoine/draw-feature/tests/Control/ModifyFeature.html	2011-02-20 16:56:45 UTC (rev 11155)
@@ -648,7 +648,7 @@
     
     function test_standalone(t) {
         
-        t.plan(17);
+        t.plan(18);
         var map = new OpenLayers.Map("map");
         var layer = new OpenLayers.Layer.Vector();
         
@@ -673,6 +673,7 @@
         var log = [];
         layer.events.on({
             beforefeaturemodified: function(evt) {
+                layer.events.unregister("beforefeaturemodified", this, arguments.callee);
                 log.push(evt);
             },
             featuremodified: function(evt) {
@@ -690,7 +691,9 @@
         
         // manually select feature for editing
         control.selectFeature(f1);
+        t.eq(log.length, 1, "[select f1] beforefeaturemodified triggered");
         t.ok(control.feature === f1, "[select f1] control.feature set to f1");
+        log = []
         
         // manually unselect feature for editing
         control.unselectFeature(f1);

Modified: sandbox/elemoine/draw-feature/tests/Format/WMTSCapabilities/v1_0_0.html
===================================================================
--- sandbox/elemoine/draw-feature/tests/Format/WMTSCapabilities/v1_0_0.html	2011-02-20 16:44:06 UTC (rev 11154)
+++ sandbox/elemoine/draw-feature/tests/Format/WMTSCapabilities/v1_0_0.html	2011-02-20 16:56:45 UTC (rev 11155)
@@ -36,7 +36,7 @@
         }
     
         function test_layers(t) {
-            t.plan(21);
+            t.plan(25);
             var xml = document.getElementById("ogcsample").firstChild.nodeValue;
             var doc = new OpenLayers.Format.XML().read(xml);
     
@@ -75,7 +75,14 @@
             t.eq(wgs84Bbox.right, 180.0, "wgs84BoudingBox right is correct");
             t.eq(wgs84Bbox.bottom, -90.0, "wgs84BoudingBox bottom is correct");
             t.eq(wgs84Bbox.top, 90.0, "wgs84BoudingBox top is correct");
-            
+
+            t.eq(layer.resourceUrl.tile.format, "image/png", "resourceUrl.tile.format is correct");
+            t.eq(layer.resourceUrl.tile.template, "http://www.example.com/wmts/coastlines/{TileMatrix}/{TileRow}/{TileCol}.png", 
+                 "resourceUrl.tile.template is correct");
+
+            t.eq(layer.resourceUrl.FeatureInfo.format, "application/gml+xml; version=3.1", "resourceUrl.FeatureInfo.format is correct");
+            t.eq(layer.resourceUrl.FeatureInfo.template, "http://www.example.com/wmts/coastlines/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}/{J}/{I}.xml", 
+                 "resourceUrl.FeatureInfo.template is correct");
         }
 
         function test_tileMatrixSets(t) {
@@ -240,6 +247,10 @@
                 <ows:UpperCorner>180 90</ows:UpperCorner>
             </ows:WGS84BoundingBox>
             <ows:Identifier>coastlines</ows:Identifier>
+            <ResourceURL format="image/png" resourceType="tile"
+                         template="http://www.example.com/wmts/coastlines/{TileMatrix}/{TileRow}/{TileCol}.png" />
+            <ResourceURL format="application/gml+xml; version=3.1" resourceType="FeatureInfo"
+                         template="http://www.example.com/wmts/coastlines/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}/{J}/{I}.xml" />
             <Style isDefault="true">
                 <ows:Title>Dark Blue</ows:Title>
                 <ows:Identifier>DarkBlue</ows:Identifier>

Copied: sandbox/elemoine/draw-feature/tests/Handler/Box.html (from rev 11154, trunk/openlayers/tests/Handler/Box.html)
===================================================================
--- sandbox/elemoine/draw-feature/tests/Handler/Box.html	                        (rev 0)
+++ sandbox/elemoine/draw-feature/tests/Handler/Box.html	2011-02-20 16:56:45 UTC (rev 11155)
@@ -0,0 +1,26 @@
+<html>
+<head>
+  <script src="../../lib/OpenLayers.js"></script>
+  <script type="text/javascript">
+    function test_Handler_Box_destroy(t) {
+        t.plan(1);
+        var map = new OpenLayers.Map('map');
+        var control = new OpenLayers.Control();
+        map.addControl(control);
+        var handler = new OpenLayers.Handler.Box(control);
+        handler.activate();
+        try {
+            handler.destroy();
+            t.ok(true, "destroying the box handler should not raise any error");
+        } catch(err) {
+            t.fail("destroying the box handler causes trouble: " + err);
+        }
+        map.destroy();
+    }
+
+  </script>
+</head>
+<body>
+    <div id="map" style="width: 300px; height: 150px;"/>
+</body>
+</html>

Copied: sandbox/elemoine/draw-feature/tests/OpenLayersJsFiles.html (from rev 11154, trunk/openlayers/tests/OpenLayersJsFiles.html)
===================================================================
--- sandbox/elemoine/draw-feature/tests/OpenLayersJsFiles.html	                        (rev 0)
+++ sandbox/elemoine/draw-feature/tests/OpenLayersJsFiles.html	2011-02-20 16:56:45 UTC (rev 11155)
@@ -0,0 +1,27 @@
+<html>
+<head>
+    <script type="text/javascript">
+        window.OpenLayers = new Array(
+            "OpenLayers/Util.js",
+            "OpenLayers/BaseTypes.js"
+        );
+    </script>
+    <script src="../lib/OpenLayers.js"></script>
+    <script type="text/javascript">
+        function test_OpenLayers(t) {
+            t.plan(1);
+            var s = document.getElementsByTagName("script");
+            var src, count = 0;
+            for(var i=0, len=s.length; i<len; i++) {
+                src = s[i].getAttribute('src');
+                if(src) {
+                    count++;
+                }
+            }
+            t.eq(count, 3, "Three OpenLayers scripts loaded.");
+        }
+    </script>
+</head>
+<body>
+</body>
+</html>

Modified: sandbox/elemoine/draw-feature/tests/list-tests.html
===================================================================
--- sandbox/elemoine/draw-feature/tests/list-tests.html	2011-02-20 16:44:06 UTC (rev 11154)
+++ sandbox/elemoine/draw-feature/tests/list-tests.html	2011-02-20 16:56:45 UTC (rev 11155)
@@ -112,6 +112,7 @@
     <li>Geometry/Rectangle.html</li>
     <li>Geometry/Surface.html</li>
     <li>Handler.html</li>
+    <li>Handler/Box.html</li>
     <li>Handler/Click.html</li>
     <li>Handler/Drag.html</li>
     <li>Handler/Feature.html</li>

Modified: sandbox/elemoine/draw-feature/tools/update_dev_dir.sh
===================================================================
--- sandbox/elemoine/draw-feature/tools/update_dev_dir.sh	2011-02-20 16:44:06 UTC (rev 11154)
+++ sandbox/elemoine/draw-feature/tools/update_dev_dir.sh	2011-02-20 16:56:45 UTC (rev 11155)
@@ -2,7 +2,8 @@
 
 # Used to update http://openlayers.org/dev/ 
 
-svn up /osgeo/openlayers/docs/dev; 
+svn revert -R /osgeo/openlayers/docs/dev
+svn up /osgeo/openlayers/docs/dev
 
 # Get current 'Last Changed Rev'
 REV=`svn info /osgeo/openlayers/docs/dev/ | grep 'Revision' | awk '{print $2}'`



More information about the Commits mailing list