[OpenLayers-Commits] r5689 - in sandbox/tschaub/fractional: examples lib/OpenLayers lib/OpenLayers/Control lib/OpenLayers/Geometry lib/OpenLayers/Handler tests tests/Control tests/Handler tests/Layer tests/data theme/default theme/default/img

commits at openlayers.org commits at openlayers.org
Tue Jan 8 13:44:42 EST 2008


Author: tschaub
Date: 2008-01-08 13:44:42 -0500 (Tue, 08 Jan 2008)
New Revision: 5689

Added:
   sandbox/tschaub/fractional/theme/default/img/blank.gif
   sandbox/tschaub/fractional/theme/default/img/overview_replacement.gif
Modified:
   sandbox/tschaub/fractional/examples/custom-control-point.html
   sandbox/tschaub/fractional/examples/custom-control.html
   sandbox/tschaub/fractional/examples/custom-style.html
   sandbox/tschaub/fractional/examples/debug.html
   sandbox/tschaub/fractional/examples/drag-feature.html
   sandbox/tschaub/fractional/examples/draw-feature.html
   sandbox/tschaub/fractional/examples/editingtoolbar-outside.html
   sandbox/tschaub/fractional/examples/editingtoolbar.html
   sandbox/tschaub/fractional/examples/example.html
   sandbox/tschaub/fractional/examples/overviewmap.html
   sandbox/tschaub/fractional/lib/OpenLayers/BaseTypes.js
   sandbox/tschaub/fractional/lib/OpenLayers/Control/OverviewMap.js
   sandbox/tschaub/fractional/lib/OpenLayers/Geometry/LinearRing.js
   sandbox/tschaub/fractional/lib/OpenLayers/Handler/Click.js
   sandbox/tschaub/fractional/lib/OpenLayers/Map.js
   sandbox/tschaub/fractional/lib/OpenLayers/Util.js
   sandbox/tschaub/fractional/tests/Control/test_Attribution.html
   sandbox/tschaub/fractional/tests/Control/test_OverviewMap.html
   sandbox/tschaub/fractional/tests/Control/test_Scale.html
   sandbox/tschaub/fractional/tests/Handler/test_Click.html
   sandbox/tschaub/fractional/tests/Layer/test_MapServer.html
   sandbox/tschaub/fractional/tests/data/geos_wkt_intersects.js
   sandbox/tschaub/fractional/tests/grid_inittiles.html
   sandbox/tschaub/fractional/tests/test_BaseTypes.html
   sandbox/tschaub/fractional/theme/default/style.css
Log:
merge r5645:HEAD from trunk

Modified: sandbox/tschaub/fractional/examples/custom-control-point.html
===================================================================
--- sandbox/tschaub/fractional/examples/custom-control-point.html	2008-01-08 18:42:03 UTC (rev 5688)
+++ sandbox/tschaub/fractional/examples/custom-control-point.html	2008-01-08 18:44:42 UTC (rev 5689)
@@ -10,7 +10,6 @@
     </style>
     <script src="../lib/OpenLayers.js"></script>
     <script type="text/javascript">
-        <!--
         var lon = 5;
         var lat = 40;
         var zoom = 5;
@@ -42,7 +41,6 @@
             map.addControl(control);
             map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
         }
-        // -->
     </script>
   </head>
   <body onload="init()">

Modified: sandbox/tschaub/fractional/examples/custom-control.html
===================================================================
--- sandbox/tschaub/fractional/examples/custom-control.html	2008-01-08 18:42:03 UTC (rev 5688)
+++ sandbox/tschaub/fractional/examples/custom-control.html	2008-01-08 18:44:42 UTC (rev 5689)
@@ -10,7 +10,6 @@
         </style>
         <script src="../lib/OpenLayers.js"></script>
         <script type="text/javascript">
-            <!--
             var lon = 5;
             var lat = 40;
             var zoom = 5;
@@ -46,7 +45,6 @@
                 map.addControl(control);
                 map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
             }
-            // -->
         </script>
     </head>
     <body onload="init()">

Modified: sandbox/tschaub/fractional/examples/custom-style.html
===================================================================
--- sandbox/tschaub/fractional/examples/custom-style.html	2008-01-08 18:42:03 UTC (rev 5688)
+++ sandbox/tschaub/fractional/examples/custom-style.html	2008-01-08 18:44:42 UTC (rev 5689)
@@ -20,7 +20,6 @@
         </style>
         <script src="../lib/OpenLayers.js"></script>
         <script type="text/javascript">
-            <!--
             var lon = 5;
             var lat = 40;
             var zoom = 5;
@@ -36,7 +35,6 @@
                 map.addLayer(layer);
                 map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
             }
-            // -->
         </script>
     </head>
     <body onload="init()">

Modified: sandbox/tschaub/fractional/examples/debug.html
===================================================================
--- sandbox/tschaub/fractional/examples/debug.html	2008-01-08 18:42:03 UTC (rev 5688)
+++ sandbox/tschaub/fractional/examples/debug.html	2008-01-08 18:44:42 UTC (rev 5689)
@@ -7,7 +7,6 @@
         <script src="../lib/Firebug/firebug.js"></script>
         <script src="../lib/OpenLayers.js"></script>
         <script type="text/javascript">
-            <!--
             function consoleLog() {
                 OpenLayers.Console.log("This is the result of an OpenLayers.Console.log() call");
             }
@@ -23,7 +22,6 @@
             function consoleDirxml() {
                 OpenLayers.Console.dirxml(document.getElementsByTagName('body')[0]);
             }
-            // -->
         </script>
     </head>
     <body>

Modified: sandbox/tschaub/fractional/examples/drag-feature.html
===================================================================
--- sandbox/tschaub/fractional/examples/drag-feature.html	2008-01-08 18:42:03 UTC (rev 5688)
+++ sandbox/tschaub/fractional/examples/drag-feature.html	2008-01-08 18:44:42 UTC (rev 5689)
@@ -20,7 +20,6 @@
         </style>
         <script src="../lib/OpenLayers.js"></script>
         <script type="text/javascript">
-            <!--
             var map, vectors, controls;
             function init(){
                 map = new OpenLayers.Map('map');
@@ -61,8 +60,6 @@
                     }
                 }
             }
-
-            // -->
         </script>
     </head>
     <body onload="init()">

Modified: sandbox/tschaub/fractional/examples/draw-feature.html
===================================================================
--- sandbox/tschaub/fractional/examples/draw-feature.html	2008-01-08 18:42:03 UTC (rev 5688)
+++ sandbox/tschaub/fractional/examples/draw-feature.html	2008-01-08 18:44:42 UTC (rev 5689)
@@ -17,7 +17,6 @@
         </style>
         <script src="../lib/OpenLayers.js"></script>
         <script type="text/javascript">
-            <!--
             var map, drawControls;
             OpenLayers.Util.onImageLoadErrorColor = "transparent";
             function init(){
@@ -63,7 +62,6 @@
                     }
                 }
             }
-            // -->
         </script>
     </head>
     <body onload="init()">

Modified: sandbox/tschaub/fractional/examples/editingtoolbar-outside.html
===================================================================
--- sandbox/tschaub/fractional/examples/editingtoolbar-outside.html	2008-01-08 18:42:03 UTC (rev 5688)
+++ sandbox/tschaub/fractional/examples/editingtoolbar-outside.html	2008-01-08 18:44:42 UTC (rev 5689)
@@ -18,7 +18,6 @@
     <script src="../lib/Firebug/firebug.js"></script>
     <script src="../lib/OpenLayers.js"></script>
     <script type="text/javascript">
-        <!--
         var lon = 5;
         var lat = 40;
         var zoom = 5;
@@ -43,7 +42,6 @@
             
             map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
         }
-        // -->
     </script>
   </head>
   <body onload="init()">

Modified: sandbox/tschaub/fractional/examples/editingtoolbar.html
===================================================================
--- sandbox/tschaub/fractional/examples/editingtoolbar.html	2008-01-08 18:42:03 UTC (rev 5688)
+++ sandbox/tschaub/fractional/examples/editingtoolbar.html	2008-01-08 18:44:42 UTC (rev 5689)
@@ -13,7 +13,6 @@
         <script src="../lib/OpenLayers.js"></script>
         <script src="../lib/Firebug/debug.js"></script>
         <script type="text/javascript">
-            <!--
             var lon = 5;
             var lat = 40;
             var zoom = 5;
@@ -32,7 +31,6 @@
     
                 map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
             }
-            // -->
         </script>
     </head>
     <body onload="init()">

Modified: sandbox/tschaub/fractional/examples/example.html
===================================================================
--- sandbox/tschaub/fractional/examples/example.html	2008-01-08 18:42:03 UTC (rev 5688)
+++ sandbox/tschaub/fractional/examples/example.html	2008-01-08 18:44:42 UTC (rev 5689)
@@ -14,7 +14,6 @@
         // debugging/inspecting in Firebug
         var map = null;
 
-        <!--
         function init(){
 
             //set title name to include Browser Detection
@@ -76,7 +75,6 @@
             // map.setCenter(new OpenLayers.LonLat(0, 0), 0);
             map.zoomToMaxExtent();
         }
-        // -->
     </script>
   </head>
   <body onload="init()">

Modified: sandbox/tschaub/fractional/examples/overviewmap.html
===================================================================
--- sandbox/tschaub/fractional/examples/overviewmap.html	2008-01-08 18:42:03 UTC (rev 5688)
+++ sandbox/tschaub/fractional/examples/overviewmap.html	2008-01-08 18:44:42 UTC (rev 5689)
@@ -86,7 +86,7 @@
         map2.addLayers([bos]);
         map2.addControl(new OpenLayers.Control.LayerSwitcher());
         
-        // create an overview map control with the default options
+        // create an overview map control with non-default options
         var controlOptions = {
             mapOptions: mapOptions
         }

Modified: sandbox/tschaub/fractional/lib/OpenLayers/BaseTypes.js
===================================================================
--- sandbox/tschaub/fractional/lib/OpenLayers/BaseTypes.js	2008-01-08 18:42:03 UTC (rev 5688)
+++ sandbox/tschaub/fractional/lib/OpenLayers/BaseTypes.js	2008-01-08 18:44:42 UTC (rev 5689)
@@ -213,7 +213,20 @@
  *********************/
 
 OpenLayers.Number = {
+
     /**
+     * Property: OpenLayers.Number.decimalSeparator
+     * Decimal separator to use when formatting numbers.
+     */
+    decimalSeparator: ".",
+    
+    /**
+     * Property: OpenLayers.Number.thousandsSeparator
+     * Thousands separator to use when formatting numbers.
+     */
+    thousandsSeparator: ",",
+    
+    /**
      * APIFunction: OpenLayers.Number.limitSigDigs
      * Limit the number of significant digits on a float.
      * 
@@ -231,6 +244,60 @@
             fig = parseFloat(num.toPrecision(sig));
         }
         return fig;
+    },
+    
+    /**
+     * APIFunction: OpenLayers.Number.format
+     * Formats a number for output.
+     * 
+     * Parameters:
+     * num  - {Float}
+     * dec  - {Integer} Number of decimal places to round to.
+     *        Defaults to 0. Set to null to leave decimal places unchanged.
+     * tsep - {String} Thousands separator.
+     *        Default is ",".
+     * dsep - {String} Decimal separator.
+     *        Default is ".".
+     *
+     * Returns:
+     * {String} A string representing the formatted number.
+     */
+    format: function(num, dec, tsep, dsep) {
+        dec = (typeof dec != "undefined") ? dec : 0; 
+        tsep = (typeof tsep != "undefined") ? tsep :
+            OpenLayers.Number.thousandsSeparator; 
+        dsep = (typeof dsep != "undefined") ? dsep :
+            OpenLayers.Number.decimalSeparator;
+
+        if (dec != null) {
+            num = parseFloat(num.toFixed(dec));
+        }
+
+        var parts = num.toString().split(".");
+        if (parts.length == 1 && dec == null) {
+            // integer where we do not want to touch the decimals
+            dec = 0;
+        }
+        
+        var integer = parts[0];
+        if (tsep) {
+            var thousands = /(-?[0-9]+)([0-9]{3})/; 
+            while(thousands.test(integer)) { 
+                integer = integer.replace(thousands, "$1" + tsep + "$2"); 
+            }
+        }
+        
+        var str;
+        if (dec == 0) {
+            str = integer;
+        } else {
+            var rem = parts.length > 1 ? parts[1] : "0";
+            if (dec != null) {
+                rem = rem + new Array(dec - rem.length + 1).join("0");
+            }
+            str = integer + dsep + rem;
+        }
+        return str;
     }
 };
 

Modified: sandbox/tschaub/fractional/lib/OpenLayers/Control/OverviewMap.js
===================================================================
--- sandbox/tschaub/fractional/lib/OpenLayers/Control/OverviewMap.js	2008-01-08 18:42:03 UTC (rev 5688)
+++ sandbox/tschaub/fractional/lib/OpenLayers/Control/OverviewMap.js	2008-01-08 18:44:42 UTC (rev 5689)
@@ -20,12 +20,6 @@
 OpenLayers.Control.OverviewMap = OpenLayers.Class(OpenLayers.Control, {
 
     /**
-     * Property: id
-     * {String} For div.id
-     */
-    id:  "OverviewMap",
-
-    /**
      * Property: element
      * {DOMElement} The DOM element that contains the overview map
      */
@@ -36,7 +30,7 @@
      * {<OpenLayers.Map>} A reference to the overvew map itself.
      */
     ovmap: null,
-        
+
     /**
      * APIProperty: size
      * {<OpenLayers.Size>} The overvew map size in pixels.  Note that this is
@@ -52,6 +46,34 @@
      * If none are sent at construction, the base layer for the main map is used.
      */
     layers: null,
+    
+    /**
+     * APIProperty: minRectSize
+     * {Integer} The minimum width or height (in pixels) of the extent
+     *     rectangle on the overview map.  When the extent rectangle reaches
+     *     this size, it will be replaced depending on the value of the
+     *     <minRectDisplayClass> property.  Default is 15 pixels.
+     */
+    minRectSize: 15,
+    
+    /**
+     * APIProperty: minRectDisplayClass
+     * {String} Replacement style class name for the extent rectangle when
+     *     <minRectSize> is reached.  This string will be suffixed on to the
+     *     displayClass.  Default is "RectReplacement".
+     *
+     * Example CSS declaration:
+     * (code)
+     * .olControlOverviewMapRectReplacement {
+     *     overflow: hidden;
+     *     cursor: move;
+     *     background-image: url("img/overview_replacement.gif");
+     *     background-repeat: no-repeat;
+     *     background-position: center;
+     * }
+     * (end)
+     */
+    minRectDisplayClass: "RectReplacement",
 
     /**
      * APIProperty: minRatio
@@ -74,6 +96,12 @@
      * options that the main map was constructed with.
      */
     mapOptions: null,
+    
+    /**
+     * Property: dragHandler
+     * {<OpenLayers.Handler.Drag>} A handler for dragging the extent rectangle.
+     */
+    dragHandler: null,
 
     /**
      * Constructor: OpenLayers.Control.OverviewMap
@@ -97,6 +125,9 @@
         if (!this.mapDiv) { // we've already been destroyed
             return;
         }
+        this.dragHandler.destroy();
+        this.clickHandler.destroy();
+
         this.mapDiv.removeChild(this.extentRectangle);
         this.extentRectangle = null;
         this.rectEvents.destroy();
@@ -107,13 +138,9 @@
         
         this.element.removeChild(this.mapDiv);
         this.mapDiv = null;
-        this.mapDivEvents.destroy(); 
-        this.mapDivEvents = null;
 
         this.div.removeChild(this.element);
         this.element = null;
-        this.elementEvents.destroy();
-        this.elementEvents = null;
 
         if (this.maximizeDiv) {
             OpenLayers.Event.stopObservingElement(this.maximizeDiv);
@@ -165,45 +192,14 @@
         this.extentRectangle = document.createElement('div');
         this.extentRectangle.style.position = 'absolute';
         this.extentRectangle.style.zIndex = 1000;  //HACK
-        this.extentRectangle.style.overflow = 'hidden';
-        this.extentRectangle.style.backgroundImage = 'url(' +
-                                        OpenLayers.Util.getImagesLocation() +
-                                        'blank.gif)';
         this.extentRectangle.className = this.displayClass+'ExtentRectangle';
         this.mapDiv.appendChild(this.extentRectangle);
-                
+
         this.element.appendChild(this.mapDiv);  
 
         this.div.appendChild(this.element);
 
         this.map.events.register('moveend', this, this.update);
-        
-        // Set up events.  The image div recenters the map on click.
-        // The extent rectangle can be dragged to recenter the map.
-        // If the mousedown happened elsewhere, then mousemove and mouseup
-        // should slip through.
-        this.elementEvents = new OpenLayers.Events(this, this.element);
-        this.elementEvents.register('mousedown', this, function(e) {
-            OpenLayers.Event.stop(e);
-        });
-        this.elementEvents.register('click', this, function(e) {
-            OpenLayers.Event.stop(e);
-        });
-        this.elementEvents.register('dblclick', this, function(e) {
-            OpenLayers.Event.stop(e);
-        });
-        this.rectEvents = new OpenLayers.Events(this, this.extentRectangle,
-                                                null, true);
-        this.rectEvents.register('mouseout', this, this.rectMouseOut);
-        this.rectEvents.register('mousedown', this, this.rectMouseDown);
-        this.rectEvents.register('mousemove', this, this.rectMouseMove);
-        this.rectEvents.register('mouseup', this, this.rectMouseUp);
-        this.rectEvents.register('click', this, function(e) {
-            OpenLayers.Event.stop(e);
-        });
-        this.rectEvents.register('dblclick', this, this.rectDblClick );
-        this.mapDivEvents = new OpenLayers.Events(this, this.mapDiv);
-        this.mapDivEvents.register('click', this, this.mapDivClick);
 
         // Optionally add min/max buttons if the control will go in the
         // map viewport.
@@ -276,64 +272,20 @@
     },
 
     /**
-     * Method: rectMouseOut
-     * Handle browser events
+     * Method: rectDrag
+     * Handle extent rectangle drag
      *
      * Parameters:
-     * evt - {<OpenLayers.Event>} evt
+     * px - {<OpenLayers.Pixel>} The pixel location of the drag.
      */
-    rectMouseOut: function (evt) {
-        if(this.rectDragStart != null) {
-            if(this.performedRectDrag) {
-                this.rectMouseMove(evt);
-                var rectPxBounds = this.getRectPxBounds(); 
-                // if we're off of the overview map, update the main map
-                // otherwise, keep moving the rect
-                if((rectPxBounds.top <= 0) || (rectPxBounds.left <= 0) || 
-                   (rectPxBounds.bottom >= this.size.h - this.hComp) || 
-                   (rectPxBounds.right >= this.size.w - this.wComp)) {
-                    this.updateMapToRect();
-                } else {
-                    return; 
-                }
-            }
-            document.onselectstart = null;
-            this.rectDragStart = null;
-        }
-    },
-
-    /**
-     * Method: rectMouseDown
-     * Handle browser events
-     *
-     * Parameters:
-     * evt - {<OpenLayers.Event>} evt
-     */
-    rectMouseDown: function (evt) {
-        if(!OpenLayers.Event.isLeftClick(evt)) {
-            return;
-        }
-        this.rectDragStart = evt.xy.clone();
-        this.performedRectDrag = false;
-        OpenLayers.Event.stop(evt);
-    },
-
-    /**
-     * Method: rectMouseMove
-     * Handle browser events
-     *
-     * Parameters:
-     * evt - {<OpenLayers.Event>} evt
-     */
-    rectMouseMove: function(evt) {
-        if(this.rectDragStart != null) {
-            var deltaX = this.rectDragStart.x - evt.xy.x;
-            var deltaY = this.rectDragStart.y - evt.xy.y;
-            var rectPxBounds = this.getRectPxBounds();
-            var rectTop = rectPxBounds.top;
-            var rectLeft = rectPxBounds.left;
-            var rectHeight = Math.abs(rectPxBounds.getHeight());
-            var rectWidth = rectPxBounds.getWidth();
+    rectDrag: function(px) {
+        var deltaX = this.dragHandler.last.x - px.x;
+        var deltaY = this.dragHandler.last.y - px.y;
+        if(deltaX != 0 || deltaY != 0) {
+            var rectTop = this.rectPxBounds.top;
+            var rectLeft = this.rectPxBounds.left;
+            var rectHeight = Math.abs(this.rectPxBounds.getHeight());
+            var rectWidth = this.rectPxBounds.getWidth();
             // don't allow dragging off of parent element
             var newTop = Math.max(0, (rectTop - deltaY));
             newTop = Math.min(newTop,
@@ -345,45 +297,10 @@
                                                        newTop + rectHeight,
                                                        newLeft + rectWidth,
                                                        newTop));
-            this.rectDragStart = evt.xy.clone();
-            this.performedRectDrag = true;
-            OpenLayers.Event.stop(evt);
         }
     },
-
-    /**
-     * Method: rectMouseUp
-     * Handle browser events
-     *
-     * Parameters:
-     * evt - {<OpenLayers.Event>} evt
-     */
-    rectMouseUp: function(evt) {
-        if(!OpenLayers.Event.isLeftClick(evt)) {
-            return;
-        }
-        if(this.performedRectDrag) {
-            this.updateMapToRect();
-            OpenLayers.Event.stop(evt);
-        }        
-        document.onselectstart = null;
-        this.rectDragStart = null;
-    },
     
     /**
-     * Method: rectDblClick
-     * Handle browser events
-     *
-     * Parameters:
-     * evt - {<OpenLayers.Event>} evt
-     */
-    rectDblClick: function(evt) {
-        this.performedRectDrag = false;
-        OpenLayers.Event.stop(evt);
-        this.updateOverview();
-    },
-
-    /**
      * Method: mapDivClick
      * Handle browser events
      *
@@ -391,14 +308,13 @@
      * evt - {<OpenLayers.Event>} evt
      */
     mapDivClick: function(evt) {
-        var pxBounds = this.getRectPxBounds();
-        var pxCenter = pxBounds.getCenterPixel();
+        var pxCenter = this.rectPxBounds.getCenterPixel();
         var deltaX = evt.xy.x - pxCenter.x;
         var deltaY = evt.xy.y - pxCenter.y;
-        var top = pxBounds.top;
-        var left = pxBounds.left;
-        var height = Math.abs(pxBounds.getHeight());
-        var width = pxBounds.getWidth();
+        var top = this.rectPxBounds.top;
+        var left = this.rectPxBounds.left;
+        var height = Math.abs(this.rectPxBounds.getHeight());
+        var width = this.rectPxBounds.getWidth();
         var newTop = Math.max(0, (top + deltaY));
         newTop = Math.min(newTop, this.ovmap.size.h - height);
         var newLeft = Math.max(0, (left + deltaX));
@@ -532,6 +448,40 @@
                      parseInt(OpenLayers.Element.getStyle(this.extentRectangle,
                                                'border-bottom-width'));
         this.hComp = (this.hComp) ? this.hComp : 2;
+
+        this.dragHandler = new OpenLayers.Handler.Drag(
+            this, {move: this.rectDrag, done: this.updateMapToRect},
+            {map: this.ovmap}
+        );
+        this.clickHandler = new OpenLayers.Handler.Click(
+            this, {
+                "click": this.mapDivClick
+            },{
+                "single": true, "double": false,
+                "stopSingle": true, "stopDouble": true,
+                "pixelTolerance": 1,
+                map: this.ovmap
+            }
+        );
+        this.clickHandler.activate();
+        
+        this.rectEvents = new OpenLayers.Events(this, this.extentRectangle,
+                                                null, true);
+        this.rectEvents.register("mouseover", this, function(e) {
+            if(!this.dragHandler.active && !this.map.dragging) {
+                // this click handler de/activation can be removed when
+                // ticket #1247 is addressed
+                this.clickHandler.deactivate();
+                this.dragHandler.activate();
+                this.clickHandler.activate();
+            }
+        });
+        this.rectEvents.register("mouseout", this, function(e) {
+            if(!this.dragHandler.dragging) {
+                this.dragHandler.deactivate();
+            }
+        });
+
     },
         
     /**
@@ -548,7 +498,7 @@
         }
         var pxBounds = this.getRectBoundsFromMapBounds(this.map.getExtent());
         if (pxBounds) {
-          this.setRectPxBounds(pxBounds);
+            this.setRectPxBounds(pxBounds);
         }
     },
     
@@ -557,26 +507,9 @@
      * Updates the map extent to match the extent rectangle position and size
      */
     updateMapToRect: function() {
-        var pxBounds = this.getRectPxBounds();
-        var lonLatBounds = this.getMapBoundsFromRectBounds(pxBounds);
+        var lonLatBounds = this.getMapBoundsFromRectBounds(this.rectPxBounds);
         this.map.setCenter(lonLatBounds.getCenterLonLat(), this.map.zoom);
     },
-    
-    /**
-     * Method: getRectPxBounds
-     * Get extent rectangle pixel bounds
-     *
-     * Returns:
-     * {<OpenLayers.Bounds>} A bounds which is the extent rectangle's pixel
-     * bounds (relative to the parent element)
-     */
-    getRectPxBounds: function() {
-        var top = parseInt(this.extentRectangle.style.top);
-        var left = parseInt(this.extentRectangle.style.left);
-        var height = parseInt(this.extentRectangle.style.height);
-        var width = parseInt(this.extentRectangle.style.width);
-        return new OpenLayers.Bounds(left, top + height, left + width, top);
-    },
 
     /**
      * Method: setRectPxBounds
@@ -592,10 +525,29 @@
                               this.ovmap.size.h - this.hComp);
         var right = Math.min(pxBounds.left + pxBounds.getWidth(),
                              this.ovmap.size.w - this.wComp);
-        this.extentRectangle.style.top = parseInt(top) + 'px';
-        this.extentRectangle.style.left = parseInt(left) + 'px';
-        this.extentRectangle.style.height = parseInt(Math.max(bottom - top, 0))+ 'px';
-        this.extentRectangle.style.width = parseInt(Math.max(right - left, 0)) + 'px';
+        var width = Math.max(right - left, 0);
+        var height = Math.max(bottom - top, 0);
+        if(width < this.minRectSize || height < this.minRectSize) {
+            this.extentRectangle.className = this.displayClass +
+                                             this.minRectDisplayClass;
+            var rLeft = left + (width / 2) - (this.minRectSize / 2);
+            var rTop = top + (height / 2) - (this.minRectSize / 2);
+            this.extentRectangle.style.top = Math.round(rTop) + 'px';
+            this.extentRectangle.style.left = Math.round(rLeft) + 'px';
+            this.extentRectangle.style.height = this.minRectSize + 'px';
+            this.extentRectangle.style.width = this.minRectSize + 'px';
+        } else {
+            this.extentRectangle.className = this.displayClass +
+                                             'ExtentRectangle';
+            this.extentRectangle.style.top = Math.round(top) + 'px';
+            this.extentRectangle.style.left = Math.round(left) + 'px';
+            this.extentRectangle.style.height = Math.round(height) + 'px';
+            this.extentRectangle.style.width = Math.round(width) + 'px';
+        }
+        this.rectPxBounds = new OpenLayers.Bounds(
+            Math.round(left), Math.round(bottom),
+            Math.round(right), Math.round(top)
+        );
     },
 
     /**

Modified: sandbox/tschaub/fractional/lib/OpenLayers/Geometry/LinearRing.js
===================================================================
--- sandbox/tschaub/fractional/lib/OpenLayers/Geometry/LinearRing.js	2008-01-08 18:42:03 UTC (rev 5688)
+++ sandbox/tschaub/fractional/lib/OpenLayers/Geometry/LinearRing.js	2008-01-08 18:44:42 UTC (rev 5689)
@@ -212,8 +212,10 @@
      *     the point is coincident with an edge.  Returns boolean otherwise.
      */
     containsPoint: function(point) {
-        var px = point.x;
-        var py = point.y;
+        var approx = OpenLayers.Number.limitSigDigs;
+        var digs = 14;
+        var px = approx(point.x, digs);
+        var py = approx(point.y, digs);
         function getX(y, x1, y1, x2, y2) {
             return (((x1 - x2) * y) + ((x2 * y1) - (x1 * y2))) / (y1 - y2);
         }
@@ -222,11 +224,11 @@
         var crosses = 0;
         for(var i=0; i<numSeg; ++i) {
             start = this.components[i];
-            x1 = start.x;
-            y1 = start.y;
+            x1 = approx(start.x, digs);
+            y1 = approx(start.y, digs);
             end = this.components[i + 1];
-            x2 = end.x;
-            y2 = end.y;
+            x2 = approx(end.x, digs);
+            y2 = approx(end.y, digs);
             
             /**
              * The following conditions enforce five edge-crossing rules:
@@ -253,7 +255,7 @@
                 // ignore other horizontal edges
                 continue;
             }
-            cx = getX(py, x1, y1, x2, y2);
+            cx = approx(getX(py, x1, y1, x2, y2), digs);
             if(cx == px) {
                 // point on line
                 if(y1 < y2 && (py >= y1 && py <= y2) || // upward
@@ -267,7 +269,7 @@
                 // no crossing to the right
                 continue;
             }
-            if(cx < Math.min(x1, x2) || cx > Math.max(x1, x2)) {
+            if(x1 != x2 && (cx < Math.min(x1, x2) || cx > Math.max(x1, x2))) {
                 // no crossing
                 continue;
             }

Modified: sandbox/tschaub/fractional/lib/OpenLayers/Handler/Click.js
===================================================================
--- sandbox/tschaub/fractional/lib/OpenLayers/Handler/Click.js	2008-01-08 18:42:03 UTC (rev 5688)
+++ sandbox/tschaub/fractional/lib/OpenLayers/Handler/Click.js	2008-01-08 18:44:42 UTC (rev 5689)
@@ -90,13 +90,6 @@
     down: null,
     
     /**
-     * Property: cachedEvent
-     * {Event} Since IE doesn't let us call window.setTimeout with extra
-     *     arguments, we cache the last click event here.
-     */
-    cachedEvent: null,
-    
-    /**
      * Constructor: OpenLayers.Handler.Click
      * Create a new click handler.
      * 
@@ -211,7 +204,7 @@
     /**
      * Method: delayedCall
      * Sets <timerId> to null.  And optionally triggers the click callback if
-     *     <cachedEvent> is set.
+     *     evt is set.
      */
     delayedCall: function(evt) {
         this.timerId = null;

Modified: sandbox/tschaub/fractional/lib/OpenLayers/Map.js
===================================================================
--- sandbox/tschaub/fractional/lib/OpenLayers/Map.js	2008-01-08 18:42:03 UTC (rev 5688)
+++ sandbox/tschaub/fractional/lib/OpenLayers/Map.js	2008-01-08 18:44:42 UTC (rev 5689)
@@ -61,6 +61,12 @@
      * {DOMElement} The element that contains the map
      */
     div: null,
+    
+    /**
+     * Property: dragging
+     * {Boolean} The map is currently being dragged.
+     */
+    dragging: false,
 
     /**
      * Property: size
@@ -1229,7 +1235,8 @@
      * TBD: reconsider forceZoomChange in 3.0
      */
     setCenter: function (lonlat, zoom, dragging, forceZoomChange) {
-
+        this.dragging = !!dragging;
+        
         if (!this.center && !this.isValidLonLat(lonlat)) {
             lonlat = this.maxExtent.getCenterLonLat();
         }

Modified: sandbox/tschaub/fractional/lib/OpenLayers/Util.js
===================================================================
--- sandbox/tschaub/fractional/lib/OpenLayers/Util.js	2008-01-08 18:42:03 UTC (rev 5688)
+++ sandbox/tschaub/fractional/lib/OpenLayers/Util.js	2008-01-08 18:44:42 UTC (rev 5689)
@@ -51,7 +51,7 @@
 OpenLayers.Util.extend = function(destination, source) {
     if(destination && source) {
         for(var property in source) {
-            value = source[property];
+            var value = source[property];
             if(value !== undefined) {
                 destination[property] = value;
             }

Modified: sandbox/tschaub/fractional/tests/Control/test_Attribution.html
===================================================================
--- sandbox/tschaub/fractional/tests/Control/test_Attribution.html	2008-01-08 18:42:03 UTC (rev 5688)
+++ sandbox/tschaub/fractional/tests/Control/test_Attribution.html	2008-01-08 18:44:42 UTC (rev 5689)
@@ -1,7 +1,7 @@
 <html>
 <head>
   <script src="../../lib/OpenLayers.js"></script>
-  <script type="text/javascript"><!--
+  <script type="text/javascript">
     var map; 
     function test_01_Control_Attribution_constructor (t) {
         t.plan( 2 );
@@ -35,7 +35,6 @@
 
 
     }    
-  // -->
   </script>
 </head>
 <body>

Modified: sandbox/tschaub/fractional/tests/Control/test_OverviewMap.html
===================================================================
--- sandbox/tschaub/fractional/tests/Control/test_OverviewMap.html	2008-01-08 18:42:03 UTC (rev 5688)
+++ sandbox/tschaub/fractional/tests/Control/test_OverviewMap.html	2008-01-08 18:44:42 UTC (rev 5689)
@@ -51,9 +51,12 @@
         t.eq(cent.lon, -71.3515625, "Clicking on the Overview Map has the correct effect on map lon");
         t.eq(cent.lat, 42.17578125, "Clicking on the Overview Map has the correct effect on map lat");
 
-        control.rectMouseDown({'xy':new OpenLayers.Pixel(5,5), 'which':1});
-        control.rectMouseMove({'xy':new OpenLayers.Pixel(15,15), 'which':1});
-        control.rectMouseUp({'xy':new OpenLayers.Pixel(15,15), 'which':1});
+        control.dragHandler = {
+            last: new OpenLayers.Pixel(5,5),
+            destroy: function() {}
+        };
+        control.rectDrag(new OpenLayers.Pixel(15, 15));
+        control.updateMapToRect();
         
         var cent = map.getCenter();
         t.eq(cent.lon, -71.2734375, "Dragging on the Overview Map has the correct effect on map lon");

Modified: sandbox/tschaub/fractional/tests/Control/test_Scale.html
===================================================================
--- sandbox/tschaub/fractional/tests/Control/test_Scale.html	2008-01-08 18:42:03 UTC (rev 5688)
+++ sandbox/tschaub/fractional/tests/Control/test_Scale.html	2008-01-08 18:44:42 UTC (rev 5689)
@@ -1,7 +1,7 @@
 <html>
 <head>
   <script src="../../lib/OpenLayers.js"></script>
-  <script type="text/javascript"><!--
+  <script type="text/javascript">
     var map; 
     function test_01_Control_Scale_constructor (t) {
         t.plan( 2 );
@@ -44,7 +44,6 @@
         map.addControl(control);
         t.eq(control.div.firstChild.innerHTML, "Scale = 1 : 443M", "Internal scale displayed properly.");
     }    
-  // -->
   </script>
 </head>
 <body>

Modified: sandbox/tschaub/fractional/tests/Handler/test_Click.html
===================================================================
--- sandbox/tschaub/fractional/tests/Handler/test_Click.html	2008-01-08 18:42:03 UTC (rev 5688)
+++ sandbox/tschaub/fractional/tests/Handler/test_Click.html	2008-01-08 18:44:42 UTC (rev 5689)
@@ -229,63 +229,6 @@
 
     }
 
-    function test_Handler_Drag_submethods(t) {
-        t.plan(4);
-        
-        var map = new OpenLayers.Map('map', {controls: []});
-
-        var control = new OpenLayers.Control();
-        map.addControl(control);
-        
-
-        var handler = new OpenLayers.Handler.Drag(control, {});
-        // set test events
-        var events = ["down", "move", "up", "out"];
-        var testEvents = {};
-        var type, px;
-        for(var i=0; i<events.length; ++i) {
-            type = events[i];
-            px = new OpenLayers.Pixel(Math.random(), Math.random());
-            testEvents[type] = {xy: px};
-            setMethod(type);
-        }
-        function setMethod(type) {
-            handler[type] = function(evt) {
-                t.ok(evt.xy.x == testEvents[type].xy.x &&
-                     evt.xy.y == testEvents[type].xy.y,
-                     "handler." + type + " called with the right event");
-            }
-        }
-        handler.activate();
-        
-        // test mousedown
-        handler.checkModifiers = function(evt) {
-            return true;
-        }
-        var oldIsLeftClick = OpenLayers.Event.isLeftClick;
-        OpenLayers.Event.isLeftClick = function(evt) {
-            return true;
-        }
-        map.events.triggerEvent("mousedown", testEvents.down);
-        OpenLayers.Event.isLeftClick = oldIsLeftClick;
-
-        // test mousemove
-        map.events.triggerEvent("mousemove", testEvents.move);
-        
-        // test mouseup
-        map.events.triggerEvent("mouseup", testEvents.up);
-        
-        // test mouseout
-        var oldMouseLeft = OpenLayers.Util.mouseLeft;
-        OpenLayers.Util.mouseLeft = function() {
-            return true;
-        };
-        handler.started = true;
-        map.events.triggerEvent("mouseout", testEvents.out);
-        OpenLayers.Util.mouseLeft = oldMouseLeft;
-        
-    }
-
     function test_Handler_Click_deactivate(t) {
         t.plan(4);
         var control = {

Modified: sandbox/tschaub/fractional/tests/Layer/test_MapServer.html
===================================================================
--- sandbox/tschaub/fractional/tests/Layer/test_MapServer.html	2008-01-08 18:42:03 UTC (rev 5688)
+++ sandbox/tschaub/fractional/tests/Layer/test_MapServer.html	2008-01-08 18:44:42 UTC (rev 5689)
@@ -464,7 +464,6 @@
         map.destroy();
     }
     
-  // -->
   </script>
 </head>
 <body>

Modified: sandbox/tschaub/fractional/tests/data/geos_wkt_intersects.js
===================================================================
--- sandbox/tschaub/fractional/tests/data/geos_wkt_intersects.js	2008-01-08 18:42:03 UTC (rev 5688)
+++ sandbox/tschaub/fractional/tests/data/geos_wkt_intersects.js	2008-01-08 18:44:42 UTC (rev 5689)
@@ -488,5 +488,8 @@
 {'wkt1':'MULTIPOINT (20 20,80 70,140 120,200 170)', 'wkt2':'MULTIPOINT (80 70,140 120)', result:true},
 {'wkt1':'MULTIPOINT (80 70,20 20,200 170,140 120)', 'wkt2':'MULTIPOINT (140 120,80 70)', result:true},
 {'wkt1':'MULTIPOINT (80 70,20 20,200 170,140 120)', 'wkt2':'MULTIPOINT (80 170,140 120,200 80)', result:true},
-{'wkt1':'MULTIPOINT (80 70,20 20,200 170,140 120)', 'wkt2':'MULTIPOINT (80 170,140 120,200 80,80 70)', result:true}
+{'wkt1':'MULTIPOINT (80 70,20 20,200 170,140 120)', 'wkt2':'MULTIPOINT (80 170,140 120,200 80,80 70)', result:true},
+{'wkt1':'POLYGON((-8239529.462853361 4980952.065110421,-8224242.057199065 4980952.065110421,-8224242.057199064 4988844.188279452,-8239529.462853361 4988844.188279452,-8239529.462853361 4980952.065110421))', 'wkt2':'POINT(-8225445.94039435  4982695.78481786)', result:true},
+{'wkt1':'POLYGON((-8239529.462853361 4980952.065110421,-8224242.057199065 4980952.065110421,-8224242.057199064 4988844.188279452,-8239529.462853361 4988844.188279452,-8239529.462853361 4980952.065110421))', 'wkt2':'POINT(-8224242.0571985  4982695.78481786)', result:false},
+{'wkt1':'POLYGON((-8239529.462853361 4980952.065110421,-8224242.057199065 4980952.065110421,-8224242.057199064 4988844.188279452,-8239529.462853361 4988844.188279452,-8239529.462853361 4980952.065110421))', 'wkt2':'POINT(-8224242.0571995  4982695.78481786)', result:true}
 ];

Modified: sandbox/tschaub/fractional/tests/grid_inittiles.html
===================================================================
--- sandbox/tschaub/fractional/tests/grid_inittiles.html	2008-01-08 18:42:03 UTC (rev 5688)
+++ sandbox/tschaub/fractional/tests/grid_inittiles.html	2008-01-08 18:44:42 UTC (rev 5689)
@@ -9,7 +9,6 @@
     </style>
     <script src="../lib/OpenLayers.js"></script>
     <script type="text/javascript">
-        <!--
         function init(){
             var map = new OpenLayers.Map('map', {'maxResolution': 1.40625/2, tileSize: new OpenLayers.Size(256,256)});
             ww = new OpenLayers.Layer.WMS( "Basic", 
@@ -21,7 +20,6 @@
             map.zoomOut();
             map.zoomOut();
         }
-        // -->
     </script>
   </head>
   <body onload="init()">

Modified: sandbox/tschaub/fractional/tests/test_BaseTypes.html
===================================================================
--- sandbox/tschaub/fractional/tests/test_BaseTypes.html	2008-01-08 18:42:03 UTC (rev 5688)
+++ sandbox/tschaub/fractional/tests/test_BaseTypes.html	2008-01-08 18:44:42 UTC (rev 5689)
@@ -137,7 +137,25 @@
         t.eq(OpenLayers.Number.limitSigDigs(num, 5), 1234.6, "running limSigDig() on a floating point number works fine");
         
     }
+    
+    function test_Number_format(t) {
+        t.plan(9);
+        var format = OpenLayers.Number.format;
+        t.eq(format(12345), "12,345", "formatting an integer number works");
+        t.eq(format(12345, 3), "12,345.000", "zero padding an integer works");
+        t.eq(format(12345, null, ","), "12,345", "adding thousands separator to an integer works");
+        t.eq(format(12345, 0, ","), "12,345", "adding thousands separator to an integer with defined 0 decimal places works");
 
+        var num = 12345.6789
+        t.eq(format(num, null, "", ","), "12345,6789", "only changing decimal separator and leaving everything else untouched works");
+        t.eq(format(num, 5), "12,345.67890", "filling up decimals with trailing zeroes works");
+        t.eq(format(num, 3, ".", ","), "12.345,679", "rounding and changing decimal/thousands separator in function call works");
+        t.eq(format(num, 0, ""), "12346", "empty thousands separator in function call works");
+        OpenLayers.Number.thousandsSeparator = ".";
+        OpenLayers.Number.decimalSeparator = ",";
+        t.eq(format(num, 3), "12.345,679", "changing thousands/decimal separator globally works");
+    }
+
     function test_07_Function_bind(t) {
         t.plan(12);
 

Copied: sandbox/tschaub/fractional/theme/default/img/blank.gif (from rev 5687, trunk/openlayers/theme/default/img/blank.gif)
===================================================================
(Binary files differ)

Copied: sandbox/tschaub/fractional/theme/default/img/overview_replacement.gif (from rev 5687, trunk/openlayers/theme/default/img/overview_replacement.gif)
===================================================================
(Binary files differ)

Modified: sandbox/tschaub/fractional/theme/default/style.css
===================================================================
--- sandbox/tschaub/fractional/theme/default/style.css	2008-01-08 18:42:03 UTC (rev 5688)
+++ sandbox/tschaub/fractional/theme/default/style.css	2008-01-08 18:44:42 UTC (rev 5689)
@@ -64,9 +64,19 @@
 }
 
 .olControlOverviewMapExtentRectangle {
-   cursor: move;
+    overflow: hidden;
+    background-image: url("img/blank.gif");
+    cursor: move;
     border: 2px dotted red;
 }
+.olControlOverviewMapRectReplacement {
+    overflow: hidden;
+    cursor: move;
+    background-image: url("img/overview_replacement.gif");
+    background-repeat: no-repeat;
+    background-position: center;
+}
+
 .olLayerGeoRSSDescription {
     float:left;
     width:100%;



More information about the Commits mailing list