[OpenLayers-Commits] r11715 - in sandbox/cmoullet/openlayers: . examples lib lib/OpenLayers lib/OpenLayers/Control lib/OpenLayers/Filter lib/OpenLayers/Format/Filter lib/OpenLayers/Handler lib/OpenLayers/Layer lib/OpenLayers/Protocol lib/OpenLayers/Protocol/WFS lib/OpenLayers/Renderer tests tests/Control tests/Format/Filter tests/Handler tests/Layer tests/Protocol theme/default

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Thu Mar 17 14:28:21 EDT 2011


Author: cmoullet
Date: 2011-03-17 11:28:20 -0700 (Thu, 17 Mar 2011)
New Revision: 11715

Added:
   sandbox/cmoullet/openlayers/examples/arcgiscache_ags.html
   sandbox/cmoullet/openlayers/examples/arcgiscache_direct.html
   sandbox/cmoullet/openlayers/examples/arcgiscache_jsonp.html
   sandbox/cmoullet/openlayers/examples/cross-origin.html
   sandbox/cmoullet/openlayers/examples/cross-origin.js
   sandbox/cmoullet/openlayers/lib/OpenLayers/Filter/Function.js
   sandbox/cmoullet/openlayers/lib/OpenLayers/Layer/ArcGISCache.js
   sandbox/cmoullet/openlayers/lib/OpenLayers/Protocol/Script.js
   sandbox/cmoullet/openlayers/tests/Layer/ArcGISCache.html
   sandbox/cmoullet/openlayers/tests/Layer/ArcGISCache.json
   sandbox/cmoullet/openlayers/tests/Protocol/Script.html
Modified:
   sandbox/cmoullet/openlayers/
   sandbox/cmoullet/openlayers/examples/dynamic-text-layer.html
   sandbox/cmoullet/openlayers/examples/example-list.html
   sandbox/cmoullet/openlayers/lib/OpenLayers.js
   sandbox/cmoullet/openlayers/lib/OpenLayers/Control/PinchZoom.js
   sandbox/cmoullet/openlayers/lib/OpenLayers/Control/TouchNavigation.js
   sandbox/cmoullet/openlayers/lib/OpenLayers/Events.js
   sandbox/cmoullet/openlayers/lib/OpenLayers/Format/Filter/v1.js
   sandbox/cmoullet/openlayers/lib/OpenLayers/Format/Filter/v1_0_0.js
   sandbox/cmoullet/openlayers/lib/OpenLayers/Format/Filter/v1_1_0.js
   sandbox/cmoullet/openlayers/lib/OpenLayers/Handler/Click.js
   sandbox/cmoullet/openlayers/lib/OpenLayers/Handler/Pinch.js
   sandbox/cmoullet/openlayers/lib/OpenLayers/Handler/Point.js
   sandbox/cmoullet/openlayers/lib/OpenLayers/Layer.js
   sandbox/cmoullet/openlayers/lib/OpenLayers/Map.js
   sandbox/cmoullet/openlayers/lib/OpenLayers/Protocol/WFS/v1.js
   sandbox/cmoullet/openlayers/lib/OpenLayers/Renderer/SVG.js
   sandbox/cmoullet/openlayers/lib/OpenLayers/Renderer/SVG2.js
   sandbox/cmoullet/openlayers/lib/OpenLayers/Request.js
   sandbox/cmoullet/openlayers/tests/Control/TouchNavigation.html
   sandbox/cmoullet/openlayers/tests/Format/Filter/v1_0_0.html
   sandbox/cmoullet/openlayers/tests/Format/Filter/v1_1_0.html
   sandbox/cmoullet/openlayers/tests/Handler/Click.html
   sandbox/cmoullet/openlayers/tests/Handler/Point.html
   sandbox/cmoullet/openlayers/tests/list-tests.html
   sandbox/cmoullet/openlayers/theme/default/style.css
Log:
merge with trunk


Property changes on: sandbox/cmoullet/openlayers
___________________________________________________________________
Modified: svn:mergeinfo
   - /sandbox/roberthl/openlayers:9745-9748
/trunk/openlayers:11161-11688
   + /sandbox/roberthl/openlayers:9745-9748
/trunk/openlayers:11161-11688,11690-11714

Copied: sandbox/cmoullet/openlayers/examples/arcgiscache_ags.html (from rev 11714, trunk/openlayers/examples/arcgiscache_ags.html)
===================================================================
--- sandbox/cmoullet/openlayers/examples/arcgiscache_ags.html	                        (rev 0)
+++ sandbox/cmoullet/openlayers/examples/arcgiscache_ags.html	2011-03-17 18:28:20 UTC (rev 11715)
@@ -0,0 +1,219 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+  <head>
+    <title>OpenLayers ArcGIS Cache Example (MapServer Access)</title>
+    <link rel="stylesheet" href="../theme/default/style.css" type="text/css" />
+    <link rel="stylesheet" href="style.css" type="text/css" />
+    <script src='http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAjpkAC9ePGem0lIq5XcMiuhR_wWLPFku8Ix9i2SXYRVK3e45q1BQUd_beF8dtzKET_EteAjPdGDwqpQ'></script>
+    <script src="../lib/OpenLayers.js"></script>
+    <script src="../lib/OpenLayers/Layer/ArcGISCache.js" type="text/javascript"></script>
+    <script type="text/javascript">
+        var map, 
+            cacheLayer,
+            testLayer,
+            //This layer requires meta data about the ArcGIS service.  Typically you should use a 
+            //JSONP call to get this dynamically.  For this example, we are just going to hard-code
+            //an example that we got from here (yes, it's very big):
+            //    http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer?f=json&pretty=true
+            layerInfo = {
+                  "currentVersion" : 10.01, 
+                  "serviceDescription" : "This worldwide street map presents highway-level data for the world and street-level data for the United States, Canada, Japan, Southern Africa, and a number of countries in Europe and elsewhere. This comprehensive street map includes highways, major roads, minor roads, railways, water features, administrative boundaries, cities, parks, and landmarks, overlaid on shaded relief imagery for added context. The street map was developed by ESRI using ESRI basemap data, AND road data, USGS elevation data, and UNEP-WCMC parks and protected areas for the world, and Tele Atlas Dynamap® and Multinet® street data for North America and Europe. Coverage for street-level data in Europe includes Andorra, Austria, Belgium, Czech Republic, Denmark, France, Germany, Great Britain, Greece, Hungary, Ireland, Italy, Luxembourg, Netherlands, Northern Ireland (Belfast only), Norway, Poland, Portugal, San Marino, Slovakia, Spain, Sweden, and Switzerland. Co
 verage for street-level data elsewhere in the world includes China (Hong Kong only), Colombia, Egypt (Cairo only), Indonesia (Jakarta only), Japan, Mexico (Mexico City only), Russia (Moscow and St. Petersburg only), South Africa, Thailand, and Turkey (Istanbul and Ankara only). For more information on this map, visit us \u003ca href=\"http://goto.arcgisonline.com/maps/World_Street_Map \" target=\"_new\"\u003eonline\u003c/a\u003e.", 
+                  "mapName" : "Layers", 
+                  "description" : "This worldwide street map presents highway-level data for the world and street-level data for the United States, Canada, Japan, Southern Africa, most countries in Europe, and several other countries. This comprehensive street map includes highways, major roads, minor roads, one-way arrow indicators, railways, water features, administrative boundaries, cities, parks, and landmarks, overlaid on shaded relief imagery for added context. The map also includes building footprints for selected areas in the United States and Europe and parcel boundaries for much of the lower 48 states.\n\nThe street map was developed by ESRI using ESRI basemap data, DeLorme base map layers, AND road data, USGS elevation data, UNEP-WCMC parks and protected areas for the world, Tele Atlas Dynamap® and Multinet® street data for North America and Europe, and First American parcel data for the United States. Coverage for street-level data in Europe includes Andorra, Aus
 tria, Belgium, Czech Republic, Denmark, France, Germany, Great Britain, Greece, Hungary, Ireland, Italy, Luxembourg, Netherlands, Norway, Poland, Portugal, San Marino, Slovakia, Spain, Sweden, and Switzerland. Coverage for street-level data elsewhere in the world includes China (Hong Kong only), Colombia, Egypt (Cairo only), Indonesia (Jakarta only), Japan, Mexico, Russia, South Africa, Thailand, and Turkey (Istanbul and Ankara only). For more information on this map, visit us online at http://goto.arcgisonline.com/maps/World_Street_Map\n", 
+                  "copyrightText" : "Sources: ESRI, DeLorme, AND, Tele Atlas, First American, ESRI Japan, UNEP-WCMC, USGS, METI, ESRI Hong Kong, ESRI Thailand, Procalculo Prosis", 
+                  "layers" : [
+                    {
+                      "id" : 0, 
+                      "name" : "World Street Map", 
+                      "parentLayerId" : -1, 
+                      "defaultVisibility" : true, 
+                      "subLayerIds" : null, 
+                      "minScale" : 0, 
+                      "maxScale" : 0
+                    }
+                  ], 
+                  "tables" : [
+                    
+                  ], 
+                  "spatialReference" : {
+                    "wkid" : 102100
+                  }, 
+                  "singleFusedMapCache" : true, 
+                  "tileInfo" : {
+                    "rows" : 256, 
+                    "cols" : 256, 
+                    "dpi" : 96, 
+                    "format" : "JPEG", 
+                    "compressionQuality" : 90, 
+                    "origin" : {
+                      "x" : -20037508.342787, 
+                      "y" : 20037508.342787
+                    }, 
+                    "spatialReference" : {
+                      "wkid" : 102100
+                    }, 
+                    "lods" : [
+                      {"level" : 0, "resolution" : 156543.033928, "scale" : 591657527.591555}, 
+                      {"level" : 1, "resolution" : 78271.5169639999, "scale" : 295828763.795777}, 
+                      {"level" : 2, "resolution" : 39135.7584820001, "scale" : 147914381.897889}, 
+                      {"level" : 3, "resolution" : 19567.8792409999, "scale" : 73957190.948944}, 
+                      {"level" : 4, "resolution" : 9783.93962049996, "scale" : 36978595.474472}, 
+                      {"level" : 5, "resolution" : 4891.96981024998, "scale" : 18489297.737236}, 
+                      {"level" : 6, "resolution" : 2445.98490512499, "scale" : 9244648.868618}, 
+                      {"level" : 7, "resolution" : 1222.99245256249, "scale" : 4622324.434309}, 
+                      {"level" : 8, "resolution" : 611.49622628138, "scale" : 2311162.217155}, 
+                      {"level" : 9, "resolution" : 305.748113140558, "scale" : 1155581.108577}, 
+                      {"level" : 10, "resolution" : 152.874056570411, "scale" : 577790.554289}, 
+                      {"level" : 11, "resolution" : 76.4370282850732, "scale" : 288895.277144}, 
+                      {"level" : 12, "resolution" : 38.2185141425366, "scale" : 144447.638572}, 
+                      {"level" : 13, "resolution" : 19.1092570712683, "scale" : 72223.819286}, 
+                      {"level" : 14, "resolution" : 9.55462853563415, "scale" : 36111.909643}, 
+                      {"level" : 15, "resolution" : 4.77731426794937, "scale" : 18055.954822}, 
+                      {"level" : 16, "resolution" : 2.38865713397468, "scale" : 9027.977411}, 
+                      {"level" : 17, "resolution" : 1.19432856685505, "scale" : 4513.988705}
+                    ]
+                  }, 
+                  "initialExtent" : {
+                    "xmin" : -20037507.0671618, 
+                    "ymin" : -20037507.0671618, 
+                    "xmax" : 20037507.0671618, 
+                    "ymax" : 20037507.0671619, 
+                    "spatialReference" : {
+                      "wkid" : 102100
+                    }
+                  }, 
+                  "fullExtent" : {
+                    "xmin" : -20037507.0671618, 
+                    "ymin" : -19971868.8804086, 
+                    "xmax" : 20037507.0671618, 
+                    "ymax" : 19971868.8804086, 
+                    "spatialReference" : {
+                      "wkid" : 102100
+                    }
+                  }, 
+                  "units" : "esriMeters", 
+                  "supportedImageFormatTypes" : "PNG24,PNG,JPG,DIB,TIFF,EMF,PS,PDF,GIF,SVG,SVGZ,AI,BMP", 
+                  "documentInfo" : {
+                    "Title" : "World Street Map", 
+                    "Author" : "ESRI", 
+                    "Comments" : "", 
+                    "Subject" : "streets, highways, major roads, railways, water features, administrative boundaries, cities, parks, protected areas, landmarks ", 
+                    "Category" : "transportation(Transportation Networks) ", 
+                    "Keywords" : "World, Global, 2009, Japan, UNEP-WCMC", 
+                    "Credits" : ""
+                  }, 
+                  "capabilities" : "Map"
+                };
+
+        function init(){
+            //The max extent for spherical mercator
+            var maxExtent = new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34);
+            
+            //Max extent from layerInfo above            
+            var layerMaxExtent = new OpenLayers.Bounds(
+                layerInfo.fullExtent.xmin, 
+                layerInfo.fullExtent.ymin, 
+                layerInfo.fullExtent.xmax, 
+                layerInfo.fullExtent.ymax  
+            );
+            
+            var resolutions = [];
+            for (var i=0; i<layerInfo.tileInfo.lods.length; i++) {
+                resolutions.push(layerInfo.tileInfo.lods[i].resolution);
+            }
+            
+            map = new OpenLayers.Map('map', {
+                maxExtent: maxExtent,
+                StartBounds: layerMaxExtent,
+                units: (layerInfo.units == "esriFeet") ? 'ft' : 'm',
+                resolutions: resolutions,
+                tileSize: new OpenLayers.Size(layerInfo.tileInfo.width, layerInfo.tileInfo.height),                
+                projection: 'EPSG:' + layerInfo.spatialReference.wkid
+            });
+            
+            
+            
+            cacheLayer = new OpenLayers.Layer.ArcGISCache( "AGSCache",
+                    "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer", {
+                        isBaseLayer: true,
+
+                        //From layerInfo above                        
+                        resolutions: resolutions,                        
+                        tileSize: new OpenLayers.Size(layerInfo.tileInfo.cols, layerInfo.tileInfo.rows),                        
+                        tileOrigin: new OpenLayers.LonLat(layerInfo.tileInfo.origin.x , layerInfo.tileInfo.origin.y),                        
+                        maxExtent: layerMaxExtent,                        
+                        projection: 'EPSG:' + layerInfo.spatialReference.wkid,
+                    });
+
+            
+            // create Google Mercator layers
+            testLayer = new OpenLayers.Layer.Google(
+                "Google Streets",
+                {'sphericalMercator': true}
+            );
+            
+            map.addLayers([testLayer, cacheLayer]);
+            
+            map.addControl(new OpenLayers.Control.LayerSwitcher());
+            map.addControl( new OpenLayers.Control.MousePosition() );
+            
+            map.zoomToExtent(new OpenLayers.Bounds(-8341644, 4711236, -8339198, 4712459));
+        }
+    </script>
+  </head>
+  <body onload="init()">
+      <h1 id="title">OpenLayers ArcGIS Cache Example (MapServer Access)</h1>
+
+    <div id="tags">
+        arcgis, arcgiscache, cache, tms
+    </div>
+
+    <p id="shortdesc">
+        Demonstrates the basic initialization of the ArcGIS Cache layer using a prebuilt configuration, and standard tile access.
+    </p>
+
+    <div id="map" class="smallmap"></div>
+
+    <div id="docs">
+        <p>This example demonstrates using the ArcGISCache layer for 
+        accessing ESRI's ArcGIS Server (AGS) Map Cache tiles through 
+        an AGS MapServer.  Toggle the visibility of the AGS layer to
+        demonstrate how the two maps are lined up correctly.</p>
+        
+         <h2>Notes on this layer</h2>
+        <p>A few attempts have been made at this kind of layer before. See 
+        <a href="http://trac.osgeo.org/openlayers/ticket/1967">here</a> and 
+        <a href="http://trac.osgeo.org/openlayers/browser/sandbox/tschaub/arcgiscache/lib/OpenLayers/Layer/ArcGISCache.js">here</a>.
+        A problem the users encounter is that the tiles seem to "jump around".
+        This is due to the fact that the max extent for the cached layer actually
+        changes at each zoom level due to the way these caches are constructed.
+        We have attempted to use the resolutions, tile size, and tile origin
+        from the cache meta data to make the appropriate changes to the max extent
+        of the tile to compensate for this behavior.</p>
+        You will need to know:
+        <ul>
+            <li>Max Extent: The max extent of the layer</li>
+            <li>Resolutions: An array of resolutions, one for each zoom level</li>
+            <li>Tile Origin: The location of the tile origin for the cache in the upper left.</li>
+            <li>Tile Size: The size of each tile in the cache. Commonly 256 x 256</li>
+        </ul>
+        <p>It's important that you set the correct values in your layer, and these
+        values will differ from layer to layer. You can find these values for your 
+        layer in a metadata page in ArcGIS Server. 
+        (ie. <a href="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer">http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer</a>)</p>
+        <ul>
+            <li>Max Extent: Full Extent</li>
+            <li>Resolutions: Tile Info -> Levels of Detail -> Resolution</li>
+            <li>Tile Origin: Origin -> X,Y</li>
+            <li>Tile Size: Tile Info -> Height,Width</li>
+        </ul>
+        
+        <h2> Other Examples </h2>
+        <p>This is one of three examples for this layer.  You can also configure this
+        layer to use <a href="arcgiscache_direct.html">prebuilt tiles in a file store
+         (not a live server).</a> It is also  possible to let this
+          <a href="arcgiscache_jsonp.html">layer 'auto-configure' itself using the
+          capabilities json object from the server itself when using a live ArcGIS server.</a>
+        </p>
+    </div>
+  </body>
+</html>

Copied: sandbox/cmoullet/openlayers/examples/arcgiscache_direct.html (from rev 11714, trunk/openlayers/examples/arcgiscache_direct.html)
===================================================================
--- sandbox/cmoullet/openlayers/examples/arcgiscache_direct.html	                        (rev 0)
+++ sandbox/cmoullet/openlayers/examples/arcgiscache_direct.html	2011-03-17 18:28:20 UTC (rev 11715)
@@ -0,0 +1,106 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+    <head>
+        <title>ArcGIS Server Map Cache Example (Direct Access)</title>
+        <link rel="stylesheet" href="../theme/default/style.css" type="text/css" />
+        <link rel="stylesheet" href="style.css" type="text/css" />
+        <script src="../lib/OpenLayers.js" type="text/javascript"></script>
+        <script src="../lib/OpenLayers/Layer/ArcGISCache.js" type="text/javascript"></script>
+        <script type="text/javascript">
+        /* First 4 variables extracted from conf.xml file */
+        
+            /* Tile layers & map MUST have same projection */
+            var proj='EPSG:26915';
+        
+        
+            /* Layer can also accept serverResolutions array
+             * to deal with situation in which layer resolution array & map resolution
+             * array are out of sync*/
+            var mapResolutions = [33.0729828126323,16.9333672000677,8.46668360003387,4.23334180001693,2.11667090000847,1.05833545000423];
+
+            /* For this example this next line is not really needed, 256x256 is default.
+             * However, you would need to change this if your layer had different tile sizes */
+            var tileSize = new OpenLayers.Size(256,256);
+            
+            /* Tile Origin is required unless it is the same as the implicit map origin
+             * which can be affected by several variables including maxExtent for map or base layer */
+            var agsTileOrigin = new OpenLayers.LonLat(-5120900,9998100);
+            
+            /* This can really be any valid bounds that the map would reasonably be within */
+            /*  var mapExtent = new OpenLayers.Bounds(293449.454286,4307691.661132,314827.830376,4323381.484178); */
+            var mapExtent = new OpenLayers.Bounds(289310.8204,4300021.937,314710.8712,4325421.988);
+            
+            var aerialsUrl = 'http://serverx.esri.com/arcgiscache/dgaerials/Layers/_alllayers';
+            var roadsUrl = 'http://serverx.esri.com/arcgiscache/DG_County_roads_yesA_backgroundDark/Layers/_alllayers';
+            
+            var map;
+            function init(){
+                map = new OpenLayers.Map('map', {
+                    maxExtent:mapExtent,
+                    controls: [
+                        new OpenLayers.Control.Navigation(),
+                        new OpenLayers.Control.LayerSwitcher(), 
+                        new OpenLayers.Control.PanZoomBar(),
+                        new OpenLayers.Control.MousePosition()]
+                });
+                
+                var baseLayer = new OpenLayers.Layer.ArcGISCache('Aerials', aerialsUrl, {
+                    tileOrigin: agsTileOrigin,
+                    resolutions: mapResolutions,
+                    sphericalMercator: true,
+                    maxExtent: mapExtent,
+                    useArcGISServer: false,
+                    isBaseLayer: true,
+                    type: 'jpg',
+                    projection: proj
+                });
+                var overlayLayer = new OpenLayers.Layer.ArcGISCache('Roads', roadsUrl, {
+                    tileOrigin: agsTileOrigin,
+                    resolutions: mapResolutions,
+                    sphericalMercator: true,
+                    maxExtent: mapExtent,
+                    useArcGISServer: false,
+                    isBaseLayer: false,
+                    projection: proj
+                });
+                map.addLayers([baseLayer, overlayLayer]);
+                
+                //map.zoomToExtent(new OpenLayers.Bounds(295892.34, 4308521.69, 312825.71, 4316988.37));
+                map.zoomToExtent(new OpenLayers.Bounds(-8341644, 4711236, -8339198, 4712459));
+            }
+        </script>
+    </head>
+    <body onload="init()">
+        <h1 id="title">ArcGIS Server Map Cache Example (Direct Access)</h1>
+
+        <div id="tags">
+        </div>
+
+        <p id="shortdesc">
+            Demonstrates the basic initialization of the ArcGIS Cache layer using a prebuilt configuration, and direct tile access from a file store.
+        </p>
+
+        <div id="map" class="smallmap"></div>
+        
+        <div id="docs">
+            <p>This example demonstrates using the ArcGISCache layer for 
+            accessing ESRI's ArcGIS Server (AGS) Map Cache tiles directly 
+            via the folder structure and HTTP.  Toggle the visibility of the AGS layer to
+            demonstrate how the two maps are lined up correctly.</p>
+
+            <h2>Notes on this Layer</h2>
+            <p>It's important that you set the correct values in your layer, and these
+            values will differ between tile sets. You can find these values for your 
+            layer in conf.xml at the root of your cache. 
+            (ie. <a href="http://serverx.esri.com/arcgiscache/dgaerials/Layers/conf.xml">http://serverx.esri.com/arcgiscache/dgaerials/Layers/conf.xml</a>)</p>
+
+            <p>For fused map caches this is often http:<i>ServerName</i>/arcgiscache/<i>MapServiceName</i>/Layers <br />
+            For individual layer caches this is often  http:<i>ServerName</i>/arcgiscache/<i>LayerName</i>/Layers </p>
+            
+            <h2> Other Examples </h2>
+            <p>This is one of three examples for this layer.  You can also configure this
+            layer to use <a href="arcgiscache_ags.html">prebuilt tiles from a live server.</a> It is also
+            possible to let this <a href="arcgiscache_jsonp.html">layer 'auto-configure' itself using the capabilities json object from the server itself when using a live ArcGIS server.</a>
+            </p>
+        </div>
+    </body>
+</html>

Copied: sandbox/cmoullet/openlayers/examples/arcgiscache_jsonp.html (from rev 11714, trunk/openlayers/examples/arcgiscache_jsonp.html)
===================================================================
--- sandbox/cmoullet/openlayers/examples/arcgiscache_jsonp.html	                        (rev 0)
+++ sandbox/cmoullet/openlayers/examples/arcgiscache_jsonp.html	2011-03-17 18:28:20 UTC (rev 11715)
@@ -0,0 +1,108 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+  <head>
+    <title>OpenLayers ArcGIS Cache Example (Autoconfigure with JSONP)</title>
+    <link rel="stylesheet" href="../theme/default/style.css" type="text/css" />
+    <link rel="stylesheet" href="style.css" type="text/css" />
+
+    <script src="../lib/OpenLayers.js"></script>
+    <script src="../lib/OpenLayers/Layer/ArcGISCache.js" type="text/javascript"></script>
+    
+    <!-- This is to simplify making the JSONP request for this example -->
+    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
+    
+    <script type="text/javascript">
+        var map,
+            layerURL = "http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer";
+        
+        function init() {
+            var jsonp_url = layerURL + '?f=json&pretty=true&callback=?';
+            $.getJSON(jsonp_url, function(data) {                
+                initMap(data);
+            });
+        }
+
+        function initMap(layerInfo){
+            /*
+             * The initialize function in this layer has the ability to automatically configure
+             * itself if given the JSON capabilities object from the ArcGIS map server.
+             * This hugely simplifies setting up a new layer, and switching basemaps when using this technique.
+             *
+             * see the 'initialize' function in ArcGISCache.js, or 
+             * see the other two ArcGISCache.js examples for direct manual configuration options
+             *
+             */
+            var baseLayer = new OpenLayers.Layer.ArcGISCache("AGSCache", layerURL, {
+                layerInfo: layerInfo
+            });
+            
+            /*
+             * Make sure our baselayer and our map are synced up
+             */
+            map = new OpenLayers.Map('map', { 
+                maxExtent: baseLayer.maxExtent,
+                units: baseLayer.units,
+                resolutions: baseLayer.resolutions,
+                numZoomLevels: baseLayer.numZoomLevels,
+                tileSize: baseLayer.tileSize,
+                displayProjection: baseLayer.displayProjection,
+                StartBounds: baseLayer.initialExtent                
+            });
+            map.addLayers([baseLayer]);
+            
+            
+            //overlay test layer
+            //http://openlayers.org/dev/examples/web-mercator.html
+            var wms = new OpenLayers.Layer.WMS("Highways",
+                "http://sampleserver1.arcgisonline.com/arcgis/services/Specialty/ESRI_StateCityHighway_USA/MapServer/WMSServer", 
+                {layers: "2", format: "image/gif", transparent: "true"}, 
+                { isBaseLayer: false, wrapDateLine: false } 
+            );
+            map.addLayers([wms]);
+
+            
+            
+            map.addControl(new OpenLayers.Control.LayerSwitcher());
+            map.addControl(new OpenLayers.Control.MousePosition() );            
+            //map.zoomToExtent(new OpenLayers.Bounds(-8341644, 4711236, -8339198, 4712459));
+            map.zoomToExtent(new OpenLayers.Bounds(-8725663.6225564, 4683718.6735907, -8099491.4868444, 4996804.7414467));
+        }
+    </script>
+  </head>
+  <body onload="init()">
+      <h1 id="title">OpenLayers ArcGIS Cache Example (Autoconfigure with JSONP)</h1>
+
+    <div id="tags">
+        arcgis, arcgiscache, cache, tms, jsonp
+    </div>
+
+    <p id="shortdesc">
+        Demonstrates the basic initialization of the ArcGIS Cache layer by using the server capabilities object.
+    </p>
+
+    <div id="map" class="smallmap"></div>
+
+    <div id="docs">
+        <p>This example demonstrates using the ArcGISCache layer for 
+        accessing ESRI's ArcGIS Server (AGS) Map Cache tiles normally through 
+        a live AGS MapServer.  Toggle the visibility of the overlay to
+        demonstrate how the two layers are lined up correctly.</p>
+        
+        <h2>Notes on this Layer</h2>
+        <p>
+        This method automatically configures the layer using the capabilities object 
+        generated by the server itself.  This page shows how to construct the url for the server capabilities object,
+        retrieve it using JSONP (and jQuery), and pass it in during construction.  Note that in this case, 
+        the layer is constructed before the map.  This approach greatly simplifies the
+        configuration of your map, and works best when all your tiles / overlays are similarly laid out.
+        If you are using a live AGS map server for your layer, it can be helpful to check your
+        server configuration using this technique before trying one of the other examples for this layer.  
+        </p>
+        
+        <h2> Other Examples </h2>
+        <p>This is one of three examples for this layer.  You can also configure this
+        layer to use <a href="arcgiscache_direct.html">prebuilt tiles in a file store (not a live server).</a>  
+        As well a retrieve <a href="arcgiscache_ags.html">tiles from a live server.</a> 
+        </p>
+    </div>
+  </body>
+</html>

Copied: sandbox/cmoullet/openlayers/examples/cross-origin.html (from rev 11714, trunk/openlayers/examples/cross-origin.html)
===================================================================
--- sandbox/cmoullet/openlayers/examples/cross-origin.html	                        (rev 0)
+++ sandbox/cmoullet/openlayers/examples/cross-origin.html	2011-03-17 18:28:20 UTC (rev 11715)
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <title>OpenLayers Script Protocol Example</title>
+        <link rel="stylesheet" href="../theme/default/style.css" type="text/css">
+        <link rel="stylesheet" href="style.css" type="text/css">
+        <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" />
+        <meta name="apple-mobile-web-app-capable" content="yes" />
+        <script src="../lib/OpenLayers.js"></script>
+    </head>
+    <body>
+        <h1 id="title">Script Protocol</h1>
+        <div id="tags">
+            protocol, script, cross origin, advanced
+        </div>
+        <p id="shortdesc">
+            Demonstrates the use of a script protocol for making feature requests 
+            cross origin.
+        </p>
+        <div id="map" class="smallmap"></div>
+        <div id="docs">
+            <p>
+                In cases where a service returns serialized features and accepts
+                a named callback (e.g. http://example.com/features.json?callback=foo),
+                the script protocol can be used to read features without being
+                restricted by the same origin policy.
+            </p>
+            <p>
+                View the <a href="cross-origin.js" target="_blank">cross-origin.js</a>
+                source to see how this is done
+            </p>
+        </div>
+        <script src="cross-origin.js"></script>
+    </body>
+</html>

Copied: sandbox/cmoullet/openlayers/examples/cross-origin.js (from rev 11714, trunk/openlayers/examples/cross-origin.js)
===================================================================
--- sandbox/cmoullet/openlayers/examples/cross-origin.js	                        (rev 0)
+++ sandbox/cmoullet/openlayers/examples/cross-origin.js	2011-03-17 18:28:20 UTC (rev 11715)
@@ -0,0 +1,39 @@
+var map = new OpenLayers.Map({
+    div: "map",
+    layers: [
+        new OpenLayers.Layer.WMS(
+            "World Map",
+            "http://maps.opengeo.org/geowebcache/service/wms",
+            {layers: "bluemarble"}
+        ),
+        new OpenLayers.Layer.Vector("States", {
+            strategies: [new OpenLayers.Strategy.BBOX()],
+            protocol: new OpenLayers.Protocol.Script({
+                url: "http://suite.opengeo.org/geoserver/wfs",
+                callbackKey: "format_options",
+                callbackPrefix: "callback:",
+                params: {
+                    service: "WFS",
+                    version: "1.1.0",
+                    srsName: "EPSG:4326",
+                    request: "GetFeature",
+                    typeName: "world:cities",
+                    outputFormat: "json"
+                },
+                filterToParams: function(filter, params) {
+                    // example to demonstrate BBOX serialization
+                    if (filter.type === OpenLayers.Filter.Spatial.BBOX) {
+                        params.bbox = filter.value.toArray();
+                        if (filter.projection) {
+                            params.bbox.push(filter.projection.getCode());
+                        }
+                    }
+                    return params;
+                }
+            })
+        })
+    ],
+    center: new OpenLayers.LonLat(0, 0),
+    zoom: 1
+});
+

Modified: sandbox/cmoullet/openlayers/examples/dynamic-text-layer.html
===================================================================
--- sandbox/cmoullet/openlayers/examples/dynamic-text-layer.html	2011-03-17 16:33:12 UTC (rev 11714)
+++ sandbox/cmoullet/openlayers/examples/dynamic-text-layer.html	2011-03-17 18:28:20 UTC (rev 11715)
@@ -41,7 +41,13 @@
             // Needed only for interaction, not for the display.
             function onPopupClose(evt) {
                 // 'this' is the popup.
-                selectControl.unselect(this.feature);
+                var feature = this.feature;
+                if (feature.layer) { // The feature is not destroyed
+                    selectControl.unselect(feature);
+                } else { // After "moveend" or "refresh" events on POIs layer all 
+                         //     features have been destroyed by the Strategy.BBOX
+                    this.destroy();
+                }
             }
             function onFeatureSelect(evt) {
                 feature = evt.feature;
@@ -53,7 +59,7 @@
                                          null, true, onPopupClose);
                 feature.popup = popup;
                 popup.feature = feature;
-                map.addPopup(popup);
+                map.addPopup(popup, true);
             }
             function onFeatureUnselect(evt) {
                 feature = evt.feature;

Modified: sandbox/cmoullet/openlayers/examples/example-list.html
===================================================================
--- sandbox/cmoullet/openlayers/examples/example-list.html	2011-03-17 16:33:12 UTC (rev 11714)
+++ sandbox/cmoullet/openlayers/examples/example-list.html	2011-03-17 18:28:20 UTC (rev 11715)
@@ -101,7 +101,7 @@
             }
             #examples .mainlink {
                 height: 8em;
-                overflow: hidden;
+                overflow: auto;
             }
             #exwin {
                 position: absolute;

Modified: sandbox/cmoullet/openlayers/lib/OpenLayers/Control/PinchZoom.js
===================================================================
--- sandbox/cmoullet/openlayers/lib/OpenLayers/Control/PinchZoom.js	2011-03-17 16:33:12 UTC (rev 11714)
+++ sandbox/cmoullet/openlayers/lib/OpenLayers/Control/PinchZoom.js	2011-03-17 18:28:20 UTC (rev 11715)
@@ -124,6 +124,7 @@
      */
     pinchStart: function(evt, pinchData) {
         this.pinchOrigin = evt.xy;
+        this.currentCenter = evt.xy;
     },
     
     /**
@@ -170,21 +171,20 @@
      *     of the pinch gesture. This give us the final scale of the pinch.
      */
     pinchDone: function(evt, start, last) {
+        this.applyTransform("");
         var zoom = this.map.getZoomForResolution(this.map.getResolution() / last.scale, true);
-        var resolution = this.map.getResolutionForZoom(zoom);
+        if (zoom !== this.map.getZoom() || !this.currentCenter.equals(this.pinchOrigin)) {
+            var resolution = this.map.getResolutionForZoom(zoom);
 
-        var location = this.map.getLonLatFromPixel(this.pinchOrigin);
-        var zoomPixel = this.currentCenter;        
-        var size = this.map.getSize();
-        
-        location.lon += resolution * ((size.w / 2) - zoomPixel.x);
-        location.lat -= resolution * ((size.h / 2) - zoomPixel.y);
+            var location = this.map.getLonLatFromPixel(this.pinchOrigin);
+            var zoomPixel = this.currentCenter;        
+            var size = this.map.getSize();
 
-        this.map.setCenter(location, zoom);
+            location.lon += resolution * ((size.w / 2) - zoomPixel.x);
+            location.lat -= resolution * ((size.h / 2) - zoomPixel.y);
 
-        var style = this.map.layerContainerDiv.style;
-        style['-webkit-transform'] = "";
-        style['-moz-transform'] = "";
+            this.map.setCenter(location, zoom);
+        }
     },
 
     CLASS_NAME: "OpenLayers.Control.PinchZoom"

Modified: sandbox/cmoullet/openlayers/lib/OpenLayers/Control/TouchNavigation.js
===================================================================
--- sandbox/cmoullet/openlayers/lib/OpenLayers/Control/TouchNavigation.js	2011-03-17 16:33:12 UTC (rev 11714)
+++ sandbox/cmoullet/openlayers/lib/OpenLayers/Control/TouchNavigation.js	2011-03-17 18:28:20 UTC (rev 11715)
@@ -45,6 +45,12 @@
     pinchZoomOptions: null,
 
     /**
+     * APIProperty: clickHandlerOptions
+     * {Object} Options passed to the Click handler.
+     */
+    clickHandlerOptions: null,
+
+    /**
      * APIProperty: documentDrag
      * {Boolean} Allow panning of the map by dragging outside map viewport.
      *     Default is false.
@@ -121,13 +127,14 @@
      */
     draw: function() {
         var clickCallbacks = {
-            'click': this.defaultClick,
-            'dblclick': this.defaultDblClick
+            click: this.defaultClick,
+            dblclick: this.defaultDblClick
         };
-        var clickOptions = {
-            'double': true,
-            'stopDouble': true
-        };
+        var clickOptions = OpenLayers.Util.extend({
+            "double": true,
+            stopDouble: true,
+            pixelTolerance: 2
+        }, this.clickHandlerOptions);
         this.handlers.click = new OpenLayers.Handler.Click(
             this, clickCallbacks, clickOptions
         );

Modified: sandbox/cmoullet/openlayers/lib/OpenLayers/Events.js
===================================================================
--- sandbox/cmoullet/openlayers/lib/OpenLayers/Events.js	2011-03-17 16:33:12 UTC (rev 11714)
+++ sandbox/cmoullet/openlayers/lib/OpenLayers/Events.js	2011-03-17 18:28:20 UTC (rev 11715)
@@ -854,7 +854,18 @@
     clearMouseCache: function() { 
         this.element.scrolls = null;
         this.element.lefttop = null;
-        this.element.offsets = null;
+        // OpenLayers.Util.pagePosition needs to use
+        // element.getBoundingClientRect to correctly calculate the offsets
+        // for the iPhone, but once the page is scrolled, getBoundingClientRect
+        // returns incorrect offsets. So our best bet is to not invalidate the
+        // offsets once we have them, and hope that the page was not scrolled
+        // when we did the initial calculation.
+        if (!((document.body.scrollTop != 0 ||
+                                document.body.scrollLeft != 0) &&
+                                navigator.userAgent.match(/iPhone/i))) {
+            OpenLayers.Console.log("clear");
+            this.element.offsets = null;
+        }
     },      
 
     /**

Copied: sandbox/cmoullet/openlayers/lib/OpenLayers/Filter/Function.js (from rev 11714, trunk/openlayers/lib/OpenLayers/Filter/Function.js)
===================================================================
--- sandbox/cmoullet/openlayers/lib/OpenLayers/Filter/Function.js	                        (rev 0)
+++ sandbox/cmoullet/openlayers/lib/OpenLayers/Filter/Function.js	2011-03-17 18:28:20 UTC (rev 11715)
@@ -0,0 +1,52 @@
+/* Copyright (c) 2006-2011 by OpenLayers Contributors (see authors.txt for 
+ * full list of contributors). Published under the Clear BSD license.  
+ * See http://svn.openlayers.org/trunk/openlayers/license.txt for the
+ * full text of the license. */
+
+/**
+ * @requires OpenLayers/Filter.js
+ */
+
+/**
+ * Class: OpenLayers.Filter.Function
+ * This class represents a filter function.
+ * We are using this class for creation of complex 
+ * filters that can contain filter functions as values.
+ * Nesting function as other functions parameter is supported.
+ * 
+ * Inherits from
+ * - <OpenLayers.Filter>
+ */
+OpenLayers.Filter.Function = OpenLayers.Class(OpenLayers.Filter, {
+
+    /**
+     * APIProperty: name
+     * {String} Name of the function.
+     */
+    name: null,
+    
+    /**
+     * APIProperty: params
+     * {Array(<OpenLayers.Filter.Function> || String || Number)} Function parameters
+     * For now support only other Functions, String or Number
+     */
+    params: null,  
+    
+    /** 
+     * Constructor: OpenLayers.Filter.Function
+     * Creates a filter function.
+     *
+     * Parameters:
+     * options - {Object} An optional object with properties to set on the
+     *     function.
+     * 
+     * Returns:
+     * {<OpenLayers.Filter.Function>}
+     */
+    initialize: function(options) {
+        OpenLayers.Filter.prototype.initialize.apply(this, [options]);
+    },
+
+    CLASS_NAME: "OpenLayers.Filter.Function"
+});
+

Modified: sandbox/cmoullet/openlayers/lib/OpenLayers/Format/Filter/v1.js
===================================================================
--- sandbox/cmoullet/openlayers/lib/OpenLayers/Format/Filter/v1.js	2011-03-17 16:33:12 UTC (rev 11714)
+++ sandbox/cmoullet/openlayers/lib/OpenLayers/Format/Filter/v1.js	2011-03-17 18:28:20 UTC (rev 11715)
@@ -186,6 +186,10 @@
             "Distance": function(node, obj) {
                 obj.distance = parseInt(this.getChildValue(node));
                 obj.distanceUnits = node.getAttribute("units");
+            },
+            "Function": function(node, obj) {
+                //TODO write decoder for it
+                return;
             }
         }
     },
@@ -234,6 +238,28 @@
     },
 
     /**
+     * Method: writeOgcExpression
+     * Limited support for writing OGC expressions. Currently it supports
+     * (<OpenLayers.Filter.Function> || String || Number)
+     *
+     * Parameters:
+     * value - (<OpenLayers.Filter.Function> || String || Number)
+     * node - {DOMElement} A parent DOM element 
+     *
+     * Returns:
+     * {DOMElement} Updated node element.
+     */
+    writeOgcExpression: function(value, node) {
+        if(value instanceof OpenLayers.Filter.Function){
+            var child = this.writeNode("Function", value, node);
+            node.appendChild(child);
+        } else {
+            this.writeNode("Literal", value, node);
+        }
+        return node;
+    },    
+    
+    /**
      * Method: write
      *
      * Parameters:
@@ -303,35 +329,39 @@
             },
             "PropertyIsLessThan": function(filter) {
                 var node = this.createElementNSPlus("ogc:PropertyIsLessThan");
-                // no ogc:expression handling for now
+                // no ogc:expression handling for PropertyName for now
                 this.writeNode("PropertyName", filter, node);
-                this.writeNode("Literal", filter.value, node);                
+                // handle Literals or Functions for now
+                this.writeOgcExpression(filter.value, node);
                 return node;
             },
             "PropertyIsGreaterThan": function(filter) {
                 var node = this.createElementNSPlus("ogc:PropertyIsGreaterThan");
-                // no ogc:expression handling for now
+                // no ogc:expression handling for PropertyName for now
                 this.writeNode("PropertyName", filter, node);
-                this.writeNode("Literal", filter.value, node);
+                // handle Literals or Functions for now
+                this.writeOgcExpression(filter.value, node);
                 return node;
             },
             "PropertyIsLessThanOrEqualTo": function(filter) {
                 var node = this.createElementNSPlus("ogc:PropertyIsLessThanOrEqualTo");
-                // no ogc:expression handling for now
+                // no ogc:expression handling for PropertyName for now
                 this.writeNode("PropertyName", filter, node);
-                this.writeNode("Literal", filter.value, node);
+                // handle Literals or Functions for now
+                this.writeOgcExpression(filter.value, node);
                 return node;
             },
             "PropertyIsGreaterThanOrEqualTo": function(filter) {
                 var node = this.createElementNSPlus("ogc:PropertyIsGreaterThanOrEqualTo");
-                // no ogc:expression handling for now
+                // no ogc:expression handling for PropertyName for now
                 this.writeNode("PropertyName", filter, node);
-                this.writeNode("Literal", filter.value, node);
+                // handle Literals or Functions for now
+                this.writeOgcExpression(filter.value, node);
                 return node;
             },
             "PropertyIsBetween": function(filter) {
                 var node = this.createElementNSPlus("ogc:PropertyIsBetween");
-                // no ogc:expression handling for now
+                // no ogc:expression handling for PropertyName for now
                 this.writeNode("PropertyName", filter, node);
                 this.writeNode("LowerBoundary", filter, node);
                 this.writeNode("UpperBoundary", filter, node);
@@ -350,13 +380,13 @@
                 });
             },
             "LowerBoundary": function(filter) {
-                // no ogc:expression handling for now
+                // handle Literals or Functions for now
                 var node = this.createElementNSPlus("ogc:LowerBoundary");
-                this.writeNode("Literal", filter.lowerBoundary, node);
+                this.writeOgcExpression(filter.lowerBoundary, node);
                 return node;
             },
             "UpperBoundary": function(filter) {
-                // no ogc:expression handling for now
+                // handle Literals or Functions for now
                 var node = this.createElementNSPlus("ogc:UpperBoundary");
                 this.writeNode("Literal", filter.upperBoundary, node);
                 return node;
@@ -382,6 +412,18 @@
                     },
                     value: filter.distance
                 });
+            },
+            "Function": function(filter) {
+                var node = this.createElementNSPlus("ogc:Function", {
+                    attributes: {
+                        name: filter.name
+                    }
+                });
+                var params = filter.params;
+                for(var i=0, len=params.length; i<len; i++){
+                    this.writeOgcExpression(params[i], node);
+                }
+                return node;
             }
         }
     },

Modified: sandbox/cmoullet/openlayers/lib/OpenLayers/Format/Filter/v1_0_0.js
===================================================================
--- sandbox/cmoullet/openlayers/lib/OpenLayers/Format/Filter/v1_0_0.js	2011-03-17 16:33:12 UTC (rev 11714)
+++ sandbox/cmoullet/openlayers/lib/OpenLayers/Format/Filter/v1_0_0.js	2011-03-17 18:28:20 UTC (rev 11715)
@@ -96,16 +96,18 @@
         "ogc": OpenLayers.Util.applyDefaults({
             "PropertyIsEqualTo": function(filter) {
                 var node = this.createElementNSPlus("ogc:PropertyIsEqualTo");
-                // no ogc:expression handling for now
+                // no ogc:expression handling for PropertyName for now
                 this.writeNode("PropertyName", filter, node);
-                this.writeNode("Literal", filter.value, node);
+                // handle Literals or Functions for now
+                this.writeOgcExpression(filter.value, node);
                 return node;
             },
             "PropertyIsNotEqualTo": function(filter) {
                 var node = this.createElementNSPlus("ogc:PropertyIsNotEqualTo");
-                // no ogc:expression handling for now
+                // no ogc:expression handling for PropertyName for now
                 this.writeNode("PropertyName", filter, node);
-                this.writeNode("Literal", filter.value, node);
+                // handle Literals or Functions for now
+                this.writeOgcExpression(filter.value, node);
                 return node;
             },
             "PropertyIsLike": function(filter) {
@@ -150,6 +152,9 @@
     writeSpatial: function(filter, name) {
         var node = this.createElementNSPlus("ogc:"+name);
         this.writeNode("PropertyName", filter, node);
+        if(filter.value instanceof OpenLayers.Filter.Function) {
+            this.writeNode("Function", filter.value, node);
+        } else {
         var child;
         if(filter.value instanceof OpenLayers.Geometry) {
             child = this.writeNode("feature:_geometry", filter.value).firstChild;
@@ -160,6 +165,7 @@
             child.setAttribute("srsName", filter.projection);
         }
         node.appendChild(child);
+        }
         return node;
     },
 

Modified: sandbox/cmoullet/openlayers/lib/OpenLayers/Format/Filter/v1_1_0.js
===================================================================
--- sandbox/cmoullet/openlayers/lib/OpenLayers/Format/Filter/v1_1_0.js	2011-03-17 16:33:12 UTC (rev 11714)
+++ sandbox/cmoullet/openlayers/lib/OpenLayers/Format/Filter/v1_1_0.js	2011-03-17 18:28:20 UTC (rev 11715)
@@ -108,18 +108,20 @@
                 var node = this.createElementNSPlus("ogc:PropertyIsEqualTo", {
                     attributes: {matchCase: filter.matchCase}
                 });
-                // no ogc:expression handling for now
+                // no ogc:expression handling for PropertyName for now
                 this.writeNode("PropertyName", filter, node);
-                this.writeNode("Literal", filter.value, node);
+                // handle Literals or Functions for now
+                this.writeOgcExpression(filter.value, node);
                 return node;
             },
             "PropertyIsNotEqualTo": function(filter) {
                 var node = this.createElementNSPlus("ogc:PropertyIsNotEqualTo", {
                     attributes: {matchCase: filter.matchCase}
                 });
-                // no ogc:expression handling for now
+                // no ogc:expression handling for PropertyName for now
                 this.writeNode("PropertyName", filter, node);
-                this.writeNode("Literal", filter.value, node);
+                // handle Literals or Functions for now
+                this.writeOgcExpression(filter.value, node);
                 return node;
             },
             "PropertyIsLike": function(filter) {
@@ -164,6 +166,9 @@
     writeSpatial: function(filter, name) {
         var node = this.createElementNSPlus("ogc:"+name);
         this.writeNode("PropertyName", filter, node);
+        if(filter.value instanceof OpenLayers.Filter.Function) {
+            this.writeNode("Function", filter.value, node);
+        } else {
         var child;
         if(filter.value instanceof OpenLayers.Geometry) {
             child = this.writeNode("feature:_geometry", filter.value).firstChild;
@@ -174,6 +179,7 @@
             child.setAttribute("srsName", filter.projection);
         }
         node.appendChild(child);
+        }
         return node;
     },
 

Modified: sandbox/cmoullet/openlayers/lib/OpenLayers/Handler/Click.js
===================================================================
--- sandbox/cmoullet/openlayers/lib/OpenLayers/Handler/Click.js	2011-03-17 16:33:12 UTC (rev 11714)
+++ sandbox/cmoullet/openlayers/lib/OpenLayers/Handler/Click.js	2011-03-17 18:28:20 UTC (rev 11715)
@@ -51,13 +51,21 @@
      *     constructed.
      */
     pixelTolerance: 0,
-    
+        
     /**
+     * APIProperty: dblclickTolerance
+     * {Number} Maximum distance in pixels between clicks for a sequence of 
+     *     events to be considered a double click.  Default is 13.  If the
+     *     distance between two clicks is greater than this value, a double-
+     *     click will not be fired.
+     */
+    dblclickTolerance: 13,
+        
+    /**
      * APIProperty: stopSingle
      * {Boolean} Stop other listeners from being notified of clicks.  Default
-     *     is false.  If true, any click listeners registered before this one
-     *     will not be notified of *any* click event (associated with double
-     *     or single clicks).
+     *     is false.  If true, any listeners registered before this one for 
+     *     click or rightclick events will not be notified.
      */
     stopSingle: false,
     
@@ -82,6 +90,13 @@
      * {Number} The id of the timeout waiting to clear the <delayedCall>.
      */
     timerId: null,
+
+    /**
+     * Property: touch
+     * {Boolean} When a touchstart event is fired, touch will be true and all
+     *     mouse related listeners will do nothing.
+     */
+    touch: false,
     
     /**
      * Property: down
@@ -92,15 +107,22 @@
      */
     down: null,
 
-    /** 
+    /**
      * Property: last
      * {Object} Object that store relevant information about the last
-     *     touchmove. Its 'xy' OpenLayers.Pixel property gives
+     *     mousemove or touchmove. Its 'xy' OpenLayers.Pixel property gives
      *     the average location of the mouse/touch event. Its 'touches'
      *     property records clientX/clientY of each touches.
      */
     last: null,
 
+    /** 
+     * Property: first
+     * {Object} When waiting for double clicks, this object will store 
+     *     information about the first click in a two click sequence.
+     */
+    first: null,
+
     /**
      * Property: rightclickTimerId
      * {Number} The id of the right mouse timeout waiting to clear the 
@@ -126,35 +148,77 @@
      */
     initialize: function(control, callbacks, options) {
         OpenLayers.Handler.prototype.initialize.apply(this, arguments);
-        // optionally register for mousedown
-        if(this.pixelTolerance != null) {
-            this.mousedown = function(evt) {
-                this.down = this.getEventInfo(evt);
-                return true;
-            };
+    },
+    
+    /**
+     * Method: touchstart
+     * Handle touchstart.
+     *
+     * Returns:
+     * {Boolean} Continue propagating this event.
+     */
+    touchstart: function(evt) {
+        if (!this.touch) {
+            this.unregisterMouseListeners();
+            this.touch = true;
         }
+        this.down = this.getEventInfo(evt);
+        this.last = this.getEventInfo(evt);
+        return true;
     },
     
     /**
-     * Method: mousedown
-     * Handle mousedown.  Only registered as a listener if pixelTolerance is
-     *     a non-zero value at construction.
+     * Method: touchmove
+     *    Store position of last move, because touchend event can have
+     *    an empty "touches" property.
      *
      * Returns:
      * {Boolean} Continue propagating this event.
      */
-    mousedown: null,
+    touchmove: function(evt) {
+        this.last = this.getEventInfo(evt);
+        return true;
+    },
 
     /**
-     * Method: touchstart
-     * Handle touchstart.
+     * Method: touchend
+     *   Correctly set event xy property, and add lastTouches to have
+     *   touches property from last touchstart or touchmove
+     */
+    touchend: function(evt) {
+        // touchstart may not have been allowed to propagate
+        if (this.down) {
+            evt.xy = this.last.xy;
+            evt.lastTouches = this.last.touches;
+            this.handleSingle(evt);
+        }
+        return true;
+    },
+    
+    /**
+     * Method: unregisterMouseListeners
+     * In a touch environment, we don't want to handle mouse events.
+     */
+    unregisterMouseListeners: function() {
+        this.map.events.un({
+            mousedown: this.mousedown,
+            mouseup: this.mouseup,
+            click: this.click,
+            dblclick: this.dblclick,
+            scope: this
+        });
+    },
+
+    /**
+     * Method: mousedown
+     * Handle mousedown.
      *
      * Returns:
      * {Boolean} Continue propagating this event.
      */
-    touchstart: function(evt) {
+    mousedown: function(evt) {
         this.down = this.getEventInfo(evt);
-        this.last = null;
+        this.last = this.getEventInfo(evt);
         return true;
     },
 
@@ -171,8 +235,7 @@
         // Collect right mouse clicks from the mouseup
         //  IE - ignores the second right click in mousedown so using
         //  mouseup instead
-        if(this.checkModifiers(evt) &&
-           this.control.handleRightClicks &&
+        if (this.checkModifiers(evt) && this.control.handleRightClicks &&
            OpenLayers.Event.isRightClick(evt)) {
             propagate = this.rightclick(evt);
         }
@@ -194,7 +257,7 @@
            if(this.rightclickTimerId != null) {
                 //Second click received before timeout this must be 
                 // a double click
-                this.clearTimer();      
+                this.clearTimer();
                 this.callback('dblrightclick', [evt]);
                 return !this.stopDouble;
             } else { 
@@ -227,93 +290,93 @@
         if (evt) {
            this.callback('rightclick', [evt]);
         }
-        return !this.stopSingle;
     },
     
     /**
+     * Method: click
+     * Handle click events from the browser.  This is registered as a listener
+     *     for click events and should not be called from other events in this
+     *     handler.
+     *
+     * Returns:
+     * {Boolean} Continue propagating this event.
+     */
+    click: function(evt) {
+        if (!this.last) {
+            this.last = this.getEventInfo(evt);
+        }
+        this.handleSingle(evt);
+        return !this.stopSingle;
+    },
+
+    /**
      * Method: dblclick
      * Handle dblclick.  For a dblclick, we get two clicks in some browsers
      *     (FF) and one in others (IE).  So we need to always register for
-     *     dblclick to properly handle single clicks.
+     *     dblclick to properly handle single clicks.  This method is registered
+     *     as a listener for the dblclick browser event.  It should *not* be
+     *     called by other methods in this handler.
      *     
      * Returns:
      * {Boolean} Continue propagating this event.
      */
     dblclick: function(evt) {
-        // for touch devices trigger dblclick only for
-        // "one finger" touch
-        var last = this.down || this.last;
-        if (this.passesTolerance(evt) &&
-            (!last || !last.touches || last.touches.length == 1)) {
-            if(this["double"]) {
-                this.callback('dblclick', [evt]);
-            }
-            this.clearTimer();
-        }
+        this.handleDouble(evt);
         return !this.stopDouble;
     },
     
-    /**
-     * Method: touchmove
-     *    Store position of last move, because touchend event can have
-     *    an empty "touches" property.
+    /** 
+     * Method: handleDouble
+     * Handle double-click sequence.
      */
-    touchmove: function(evt) {
-        this.last = this.getEventInfo(evt);
-    },
-
-    /**
-     * Method: touchend
-     *   Correctly set event xy property, and add lastTouches to have
-     *   touches property from last touchstart or touchmove
-     */
-    touchend: function(evt) {
-        var last = this.last || this.down;
-        if (!evt || !last) {
-            return false;
+    handleDouble: function(evt) {
+        if (this["double"] && this.passesDblclickTolerance(evt)) {
+            this.callback("dblclick", [evt]);
         }
-        evt.xy = last.xy;
-        evt.lastTouches = last.touches;
-        return evt.xy ? this.click(evt) : false;
     },
-
-    /**
-     * Method: click
-     * Handle click.
-     *
-     * Returns:
-     * {Boolean} Continue propagating this event.
+    
+    /** 
+     * Method: handleSingle
+     * Handle single click sequence.
      */
-    click: function(evt) {
-        // Sencha Touch emulates click events, see ticket 3079 for more info
-        if (this.down && this.down.touches && evt.type === "click") {
-            return !this.stopSingle;
-        }
-        if(this.passesTolerance(evt)) {
-            if(this.timerId != null) {
+    handleSingle: function(evt) {
+        if (this.passesTolerance(evt)) {
+            if (this.timerId != null) {
                 // already received a click
-                var last = this.down || this.last;
-                if (last && last.touches && last.touches.length > 0) {
-                    // touch device - we may trigger dblclick
-                    this.dblclick(evt);
-                } else {
+                if (this.last.touches && this.last.touches.length === 1) {
+                    // touch device, no dblclick event - this may be a double
+                    this.handleDouble(evt);
+                }
+                // if we're not in a touch environment we clear the click timer
+                // if we've got a second touch, we'll get two touchend events
+                if (!this.last.touches || this.last.touches.length !== 2) {
                     this.clearTimer();
                 }
             } else {
+                // remember the first click info so we can compare to the second
+                this.first = this.getEventInfo(evt);
                 // set the timer, send evt only if single is true
                 //use a clone of the event object because it will no longer 
                 //be a valid event object in IE in the timer callback
                 var clickEvent = this.single ?
                     OpenLayers.Util.extend({}, evt) : null;
-                this.timerId = window.setTimeout(
-                    OpenLayers.Function.bind(this.delayedCall, this, clickEvent),
-                    this.delay
-               );
+                this.queuePotentialClick(clickEvent);
             }
         }
-        return !this.stopSingle;
     },
     
+    /** 
+     * Method: queuePotentialClick
+     * This method is separated out largely to make testing easier (so we
+     *     don't have to override window.setTimeout)
+     */
+    queuePotentialClick: function(evt) {
+        this.timerId = window.setTimeout(
+            OpenLayers.Function.bind(this.delayedCall, this, evt),
+            this.delay
+        );
+    },
+
     /**
      * Method: passesTolerance
      * Determine whether the event is within the optional pixel tolerance.  Note
@@ -327,28 +390,67 @@
      */
     passesTolerance: function(evt) {
         var passes = true;
-        if(this.pixelTolerance != null && this.down && this.down.xy) {
-            var dpx = Math.sqrt(
-                Math.pow(this.down.xy.x - evt.xy.x, 2) +
-                Math.pow(this.down.xy.y - evt.xy.y, 2)
-            );
-            if(dpx > this.pixelTolerance) {
-                passes = false;
+        if (this.pixelTolerance != null && this.down && this.down.xy) {
+            passes = this.pixelTolerance >= this.down.xy.distanceTo(evt.xy);
+            // for touch environments, we also enforce that all touches
+            // start and end within the given tolerance to be considered a click
+            if (passes && this.touch && 
+                this.down.touches.length === this.last.touches.length) {
+                // the touchend event doesn't come with touches, so we check
+                // down and last
+                for (var i=0, ii=this.down.touches.length; i<ii; ++i) {
+                    if (this.getTouchDistance(
+                            this.down.touches[i], 
+                            this.last.touches[i]
+                        ) > this.pixelTolerance) {
+                        passes = false;
+                        break;
+                    }
+                }
             }
         }
         return passes;
     },
+    
+    /** 
+     * Method: getTouchDistance
+     *
+     * Returns:
+     * {Boolean} The pixel displacement between two touches.
+     */
+    getTouchDistance: function(from, to) {
+        return Math.sqrt(
+            Math.pow(from.clientX - to.clientX, 2) +
+            Math.pow(from.clientY - to.clientY, 2)
+        );
+    },
+    
+    /**
+     * Method: passesDblclickTolerance
+     * Determine whether the event is within the optional double-cick pixel 
+     *     tolerance.
+     *
+     * Returns:
+     * {Boolean} The click is within the double-click pixel tolerance.
+     */
+    passesDblclickTolerance: function(evt) {
+        var passes = true;
+        if (this.down && this.first) {
+            passes = this.down.xy.distanceTo(this.first.xy) <= this.dblclickTolerance;
+        }
+        return passes;
+    },
 
     /**
      * Method: clearTimer
      * Clear the timer and set <timerId> to null.
      */
     clearTimer: function() {
-        if(this.timerId != null) {
+        if (this.timerId != null) {
             window.clearTimeout(this.timerId);
             this.timerId = null;
         }
-        if(this.rightclickTimerId != null) {
+        if (this.rightclickTimerId != null) {
             window.clearTimeout(this.rightclickTimerId);
             this.rightclickTimerId = null;
         }
@@ -361,8 +463,8 @@
      */
     delayedCall: function(evt) {
         this.timerId = null;
-        if(evt) {
-            this.callback('click', [evt]);
+        if (evt) {
+            this.callback("click", [evt]);
         }
     },
 
@@ -407,7 +509,7 @@
         if(OpenLayers.Handler.prototype.deactivate.apply(this, arguments)) {
             this.clearTimer();
             this.down = null;
-            this.last = null;
+            this.first = null;
             deactivated = true;
         }
         return deactivated;

Modified: sandbox/cmoullet/openlayers/lib/OpenLayers/Handler/Pinch.js
===================================================================
--- sandbox/cmoullet/openlayers/lib/OpenLayers/Handler/Pinch.js	2011-03-17 16:33:12 UTC (rev 11714)
+++ sandbox/cmoullet/openlayers/lib/OpenLayers/Handler/Pinch.js	2011-03-17 18:28:20 UTC (rev 11715)
@@ -37,9 +37,9 @@
     /**
      * Property: stopDown
      * {Boolean} Stop propagation of touchstart events from getting to
-     *     listeners on the same element. Default is true.
+     *     listeners on the same element. Default is false.
      */
-    stopDown: true,
+    stopDown: false,
 
     /**
      * Property: pinching
@@ -105,6 +105,7 @@
             this.start = null;
             this.last = null;
         }
+        // prevent document dragging
         OpenLayers.Event.stop(evt);
         return propagate;
     },
@@ -120,15 +121,15 @@
      * {Boolean} Let the event propagate.
      */
     touchmove: function(evt) {
-        var propagate = true;
         if (this.started && OpenLayers.Event.isMultiTouch(evt)) {
             this.pinching = true;
             var current = this.getPinchData(evt);
             this.callback("move", [evt, current]);
             this.last = current;
-            propagate = false;
+            // prevent document dragging
+            OpenLayers.Event.stop(evt);
         }
-        return propagate;
+        return true;
     },
 
     /**
@@ -142,16 +143,14 @@
      * {Boolean} Let the event propagate.
      */
     touchend: function(evt) {
-        var propagate = true;
         if (this.started) {
             this.started = false;
             this.pinching = false;
             this.callback("done", [evt, this.start, this.last]);
             this.start = null;
             this.last = null;
-            propagate = false;
         }
-        return propagate;
+        return true;
     },
 
     /**

Modified: sandbox/cmoullet/openlayers/lib/OpenLayers/Handler/Point.js
===================================================================
--- sandbox/cmoullet/openlayers/lib/OpenLayers/Handler/Point.js	2011-03-17 16:33:12 UTC (rev 11714)
+++ sandbox/cmoullet/openlayers/lib/OpenLayers/Handler/Point.js	2011-03-17 18:28:20 UTC (rev 11715)
@@ -284,7 +284,7 @@
         if(cancel || !this.persist) {
             this.destroyFeature();
         }
-        if(!noNew) {
+        if(!noNew && this.active) {
             this.createFeature();
         }
     },

Copied: sandbox/cmoullet/openlayers/lib/OpenLayers/Layer/ArcGISCache.js (from rev 11714, trunk/openlayers/lib/OpenLayers/Layer/ArcGISCache.js)
===================================================================
--- sandbox/cmoullet/openlayers/lib/OpenLayers/Layer/ArcGISCache.js	                        (rev 0)
+++ sandbox/cmoullet/openlayers/lib/OpenLayers/Layer/ArcGISCache.js	2011-03-17 18:28:20 UTC (rev 11715)
@@ -0,0 +1,475 @@
+/** 
+ * @requires OpenLayers/Layer/XYZ.js 
+ */ 
+
+/** 
+ * Class: OpenLayers.Layer.ArcGISCache   
+ * Layer for accessing cached map tiles from an ArcGIS Server style mapcache. 
+ * Tile must already be cached for this layer to access it. This does not require 
+ * ArcGIS Server itself.
+ * 
+ * A few attempts have been made at this kind of layer before. See 
+ * http://trac.osgeo.org/openlayers/ticket/1967 
+ * and 
+ * http://trac.osgeo.org/openlayers/browser/sandbox/tschaub/arcgiscache/lib/OpenLayers/Layer/ArcGISCache.js
+ *
+ * Typically the problem encountered is that the tiles seem to "jump around".
+ * This is due to the fact that the actual max extent for the tiles on AGS layers
+ * changes at each zoom level due to the way these caches are constructed.
+ * We have attempted to use the resolutions, tile size, and tile origin
+ * from the cache meta data to make the appropriate changes to the max extent
+ * of the tile to compensate for this behavior.  This must be done as zoom levels change
+ * and before tiles are requested, which is why methods from base classes are overridden.
+ *
+ * For reference, you can access mapcache meta data in two ways. For accessing a 
+ * mapcache through ArcGIS Server, you can simply go to the landing page for the
+ * layer. (ie. http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer)
+ * For accessing it directly through HTTP, there should always be a conf.xml file
+ * in the root directory. 
+ * (ie. http://serverx.esri.com/arcgiscache/DG_County_roads_yesA_backgroundDark/Layers/conf.xml)
+ *  
+ *Inherits from: 
+ *  - <OpenLayers.Layer.XYZ>             
+ */    
+OpenLayers.Layer.ArcGISCache = OpenLayers.Class(OpenLayers.Layer.XYZ, {  
+
+    /**
+     * APIProperty: url
+     * {String | Array} The base URL for the layer cache.  You can also
+     *     provide a list of URL strings for the layer if your cache is
+     *     available from multiple origins.  This must be set before the layer
+     *     is drawn.
+     */
+    url: null,
+    
+   /**
+    * APIProperty: tileOrigin
+    * {<OpenLayers.LonLat>} The location of the tile origin for the cache.
+    *     An ArcGIS cache has it's origin at the upper-left (lowest x value
+    *     and highest y value of the coordinate system).  The units for the
+    *     tile origin should be the same as the units for the cached data.
+    */
+    tileOrigin: null, 
+   
+   /**
+    * APIProperty: tileSize
+    * {<OpenLayers.Size>} This size of each tile. Defaults to 256 by 256 pixels.
+    */
+    tileSize: new OpenLayers.Size(256, 256),
+    
+   /**
+    * APIProperty: useAGS
+    * {Boolean} Indicates if we are going to be accessing the ArcGIS Server (AGS)
+    *     cache via an AGS MapServer or directly through HTTP. When accessing via
+    *     AGS the path structure uses a standard z/y/x structure. But AGS actually
+    *     stores the tile images on disk using a hex based folder structure that looks
+    *     like "http://example.com/mylayer/L00/R00000000/C00000000.png".  Learn more
+    *     about this here:
+    *     http://blogs.esri.com/Support/blogs/mappingcenter/archive/2010/08/20/Checking-Your-Local-Cache-Folders.aspx
+    *     Defaults to true;
+    */    
+    useArcGISServer: true,
+
+   /**
+    * APIProperty: type
+    * {String} Image type for the layer.  This becomes the filename extension
+    *     in tile requests.  Default is "png" (generating a url like
+    *     "http://example.com/mylayer/L00/R00000000/C00000000.png").
+    */
+    type: 'png',
+    
+    /**
+    * APIProperty: useScales
+    * {Boolean} Optional override to indicate that the layer should use 'scale' information
+    *     returned from the server capabilities object instead of 'resolution' information.
+    *     This can be important if your tile server uses an unusual DPI for the tiles.
+    */
+    useScales: false,
+    
+   /**
+    * APIProperty: overrideDPI
+    * {Boolean} Optional override to change the OpenLayers.DOTS_PER_INCH setting based 
+    *     on the tile information in the server capabilities object.  This can be useful 
+    *     if your server has a non-standard DPI setting on its tiles, and you're only using 
+    *     tiles with that DPI.  This value is used while OpenLayers is calculating resolution
+    *     using scales, and is not necessary if you have resolution information. (This is
+    *     typically the case)  Regardless, this setting can be useful, but is dangerous
+    *     because it will impact other layers while calculating resolution.  Only use this
+    *     if you know what you are doing.  (See OpenLayers.Util.getResolutionFromScale)
+    */
+    overrideDPI: false,
+    
+   /**
+    * Constructor: OpenLayers.Layer.ArcGISCache 
+    * Creates a new instance of this class 
+    * 
+    * Parameters: 
+    * name - {String} 
+    * url - {String} 
+    * options - {Object} extra layer options
+    */ 
+    initialize: function(name, url, options) { 
+        OpenLayers.Layer.XYZ.prototype.initialize.apply(this, arguments);
+
+        if (this.resolutions) {        
+            this.serverResolutions = this.resolutions;
+            this.maxExtent = this.getMaxExtentForResolution(this.resolutions[0]);
+        }
+
+        // this block steps through translating the values from the server layer JSON 
+        // capabilities object into values that we can use.  This is also a helpful
+        // reference when configuring this layer directly.
+        if (this.layerInfo) {
+            // alias the object
+            var info = this.layerInfo;
+            
+            // build our extents
+            var startingTileExtent = new OpenLayers.Bounds(
+                info.fullExtent.xmin, 
+                info.fullExtent.ymin, 
+                info.fullExtent.xmax, 
+                info.fullExtent.ymax  
+            );
+
+            // set our projection based on the given spatial reference.
+            // esri uses slightly different IDs, so this may not be comprehensive
+            this.projection = 'EPSG:' + info.spatialReference.wkid;
+            this.sphericalMercator = (info.spatialReference.wkid == 102100);
+            
+            // convert esri units into openlayers units (basic feet or meters only)
+            this.units = (info.units == "esriFeet") ? 'ft' : 'm';
+
+            // optional extended section based on whether or not the server returned
+            // specific tile information
+            if (!!info.tileInfo) {            
+                // either set the tiles based on rows/columns, or specific width/height
+                this.tileSize = new OpenLayers.Size(
+                    info.tileInfo.width || info.tileInfo.cols, 
+                    info.tileInfo.height || info.tileInfo.rows
+                );
+                
+                // this must be set when manually configuring this layer
+                this.tileOrigin = new OpenLayers.LonLat(
+                    info.tileInfo.origin.x, 
+                    info.tileInfo.origin.y
+                );
+
+                var upperLeft = new OpenLayers.Geometry.Point(
+                    startingTileExtent.left, 
+                    startingTileExtent.top
+                );
+                
+                var bottomRight = new OpenLayers.Geometry.Point(
+                    startingTileExtent.right, 
+                    startingTileExtent.bottom
+                );            
+                
+                if (this.useScales) {
+                    this.scales = [];
+                } else {
+                    this.resolutions = [];
+                }
+                
+                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);
+                    }
+                    
+                    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);
+                }
+
+                this.maxExtent = this.calculateMaxExtentWithLOD(this.lods[0]);
+                this.serverResolutions = this.resolutions;
+                if (this.overrideDPI && info.tileInfo.dpi) {
+                    // see comment above for 'overrideDPI'
+                    OpenLayers.DOTS_PER_INCH = info.tileInfo.dpi;
+                }
+            } 
+       }
+    }, 
+
+   /** 
+    * Method: getContainingTileCoords
+    * Calculates the x/y pixel corresponding to the position of the tile
+    *     that contains the given point and for the for the given resolution.
+    * 
+    * Parameters:
+    * point - {<OpenLayers.Geometry.Point>} 
+    * res - {Float} The resolution for which to compute the extent.
+    * 
+    * Returns: 
+    * {<OpenLayers.Pixel>} The x/y pixel corresponding to the position 
+    * of the upper left tile for the given resolution.
+    */
+    getContainingTileCoords: function(point, res) {
+        return new OpenLayers.Pixel(
+           Math.max(Math.floor((point.x - this.tileOrigin.lon) / (this.tileSize.w * res)),0),
+           Math.max(Math.floor((this.tileOrigin.lat - point.y) / (this.tileSize.h * res)),0)
+        );
+    },
+    
+   /** 
+    * Method: calculateMaxExtentWithLOD
+    * Given a Level of Detail object from the server, this function
+    *     calculates the actual max extent
+    * 
+    * Parameters: 
+    * lod - {Object} a Level of Detail Object from the server capabilities object 
+            representing a particular zoom level
+    * 
+    * Returns: 
+    * {<OpenLayers.Bounds>} The actual extent of the tiles for the given zoom level
+    */
+   calculateMaxExtentWithLOD: function(lod) {
+        // the max extent we're provided with just overlaps some tiles
+        // our real extent is the bounds of all the tiles we touch
+
+        var numTileCols = (lod.endTileCol - lod.startTileCol) + 1;
+        var numTileRows = (lod.endTileRow - lod.startTileRow) + 1;        
+
+        var minX = this.tileOrigin.lon + (lod.startTileCol * this.tileSize.w * lod.resolution);
+        var maxX = minX + (numTileCols * this.tileSize.w * lod.resolution);
+
+        var maxY = this.tileOrigin.lat - (lod.startTileRow * this.tileSize.h * lod.resolution);
+        var minY = maxY - (numTileRows * this.tileSize.h * lod.resolution);
+        return new OpenLayers.Bounds(minX, minY, maxX, maxY);
+   },
+    
+   /** 
+    * Method: calculateMaxExtentWithExtent
+    * Given a 'suggested' max extent from the server, this function uses
+    *     information about the actual tile sizes to determine the actual
+    *     extent of the layer.
+    * 
+    * Parameters: 
+    * extent - {<OpenLayers.Bounds>} The 'suggested' extent for the layer
+    * res - {Float} The resolution for which to compute the extent.
+    * 
+    * Returns: 
+    * {<OpenLayers.Bounds>} The actual extent of the tiles for the given zoom level
+    */
+   calculateMaxExtentWithExtent: function(extent, res) {
+        var upperLeft = new OpenLayers.Geometry.Point(extent.left, extent.top);
+        var bottomRight = new OpenLayers.Geometry.Point(extent.right, extent.bottom);
+        var start = this.getContainingTileCoords(upperLeft, res);
+        var end = this.getContainingTileCoords(bottomRight, res);
+        var lod = {
+            resolution: res,
+            startTileCol: start.x,
+            startTileRow: start.y,
+            endTileCol: end.x,
+            endTileRow: end.y
+        };
+        return this.calculateMaxExtentWithLOD(lod);
+   },
+    
+    /** 
+    * Method: getUpperLeftTileCoord
+    * Calculates the x/y pixel corresponding to the position 
+    *     of the upper left tile for the given resolution.
+    * 
+    * Parameters: 
+    * res - {Float} The resolution for which to compute the extent.
+    * 
+    * Returns: 
+    * {<OpenLayers.Pixel>} The x/y pixel corresponding to the position 
+    * of the upper left tile for the given resolution.
+    */
+    getUpperLeftTileCoord: function(res) {
+        var upperLeft = new OpenLayers.Geometry.Point(
+            this.maxExtent.left,
+            this.maxExtent.top);
+        return this.getContainingTileCoords(upperLeft, res);
+    },
+
+    /** 
+    * Method: getLowerRightTileCoord
+    * Calculates the x/y pixel corresponding to the position 
+    *     of the lower right tile for the given resolution.
+    *  
+    * Parameters: 
+    * res - {Float} The resolution for which to compute the extent.
+    * 
+    * Returns: 
+    * {<OpenLayers.Pixel>} The x/y pixel corresponding to the position
+    * of the lower right tile for the given resolution.
+    */
+    getLowerRightTileCoord: function(res) {
+        var bottomRight = new OpenLayers.Geometry.Point(
+            this.maxExtent.right,
+            this.maxExtent.bottom);
+        return this.getContainingTileCoords(bottomRight, res);
+    },
+    
+   /** 
+    * Method: getMaxExtentForResolution
+    * Since the max extent of a set of tiles can change from zoom level
+    *     to zoom level, we need to be able to calculate that max extent 
+    *     for a given resolution.
+    *
+    * Parameters: 
+    * res - {Float} The resolution for which to compute the extent.
+    * 
+    * Returns: 
+    * {<OpenLayers.Bounds>} The extent for this resolution
+    */ 
+    getMaxExtentForResolution: function(res) {
+        var start = this.getUpperLeftTileCoord(res);
+        var end = this.getLowerRightTileCoord(res);
+
+        var numTileCols = (end.x - start.x) + 1;
+        var numTileRows = (end.y - start.y) + 1;
+
+        var minX = this.tileOrigin.lon + (start.x * this.tileSize.w * res);
+        var maxX = minX + (numTileCols * this.tileSize.w * res);
+        
+        var maxY = this.tileOrigin.lat - (start.y * this.tileSize.h * res);
+        var minY = maxY - (numTileRows * this.tileSize.h * res);
+        return new OpenLayers.Bounds(minX, minY, maxX, maxY);
+    },
+    
+   /** 
+    * APIMethod: clone 
+    * Returns an exact clone of this OpenLayers.Layer.ArcGISCache
+    * 
+    * Parameters: 
+    * [obj] - {Object} optional object to assign the cloned instance to.
+    *  
+    * Returns: 
+    * {<OpenLayers.Layer.ArcGISCache>} clone of this instance 
+    */ 
+    clone: function (obj) { 
+        if (obj == null) { 
+            obj = new OpenLayers.Layer.ArcGISCache(this.name, this.url, this.options);
+        }
+        return OpenLayers.Layer.XYZ.prototype.clone.apply(this, [obj]);
+    },
+
+    /**
+     * Method: getMaxExtent
+     * Get this layer's maximum extent.
+     *
+     * Returns:
+     * {OpenLayers.Bounds}
+     */
+    getMaxExtent: function() {
+        var resolution = this.map.getResolution();
+        return this.maxExtent = this.getMaxExtentForResolution(resolution);
+    },
+
+    /**
+     * Method: getTileOrigin
+     * Determine the origin for aligning the grid of tiles.  
+     *     The origin will be derived from the layer's <maxExtent> property. 
+     *
+     * Returns:
+     * {<OpenLayers.LonLat>} The tile origin.
+     */
+    getTileOrigin: function() {
+        var extent = this.getMaxExtent();
+        return new OpenLayers.LonLat(extent.left, extent.bottom);
+    },
+
+   /**
+    * Method: getURL
+    * Determine the URL for a tile given the tile bounds.  This is should support
+    *     urls that access tiles through an ArcGIS Server MapServer or directly through
+    *     the hex folder structure using HTTP.  Just be sure to set the useArcGISServer
+    *     property appropriately!  This is basically the same as 
+    *     'OpenLayers.Layer.TMS.getURL',  but with the addition of hex addressing,
+    *     and tile rounding.
+    *
+    * Parameters:
+    * bounds - {<OpenLayers.Bounds>}
+    *
+    * Returns:
+    * {String} The URL for a tile based on given bounds.
+    */
+    getURL: function (bounds) {
+        var res = this.getResolution(); 
+
+        // tile center
+        var originTileX = (this.tileOrigin.lon + (res * this.tileSize.w/2)); 
+        var originTileY = (this.tileOrigin.lat - (res * this.tileSize.h/2));
+
+        var center = bounds.getCenterLonLat();
+        var point = { x: center.lon, y: center.lat };
+        var x = (Math.round(Math.abs((center.lon - originTileX) / (res * this.tileSize.w)))); 
+        var y = (Math.round(Math.abs((originTileY - center.lat) / (res * this.tileSize.h)))); 
+        var z = this.map.getZoom();
+
+        // this prevents us from getting pink tiles (non-existant tiles)
+        if (this.lods) {        
+            var lod = this.lods[this.map.getZoom()];
+            if ((x < lod.startTileCol || x > lod.endTileCol) 
+                || (y < lod.startTileRow || y > lod.endTileRow)) {
+                    return null;
+            }
+        }
+        else {
+            var start = this.getUpperLeftTileCoord(res);
+            var end = this.getLowerRightTileCoord(res);
+            if ((x < start.x || x >= end.x)
+                || (y < start.y || y >= end.y)) {
+                    return null;
+            }        
+        }
+
+        // Construct the url string
+        var url = this.url;
+        var s = '' + x + y + z;
+
+        if (url instanceof Array) {
+            url = this.selectUrl(s, url);
+        }
+
+        // Accessing tiles through ArcGIS Server uses a different path
+        // structure than direct access via the folder structure.
+        if (this.useArcGISServer) {
+            // AGS MapServers have pretty url access to tiles
+            url = url + '/tile/${z}/${y}/${x}';
+        } else {
+            // The tile images are stored using hex values on disk.
+            x = 'C' + this.zeroPad(x, 8, 16);
+            y = 'R' + this.zeroPad(y, 8, 16);
+            z = 'L' + this.zeroPad(z, 2, 16);
+            url = url + '/${z}/${y}/${x}.' + this.type;
+        }
+
+        // Write the values into our formatted url
+        url = OpenLayers.String.format(url, {'x': x, 'y': y, 'z': z});
+
+        return url;
+    },
+
+    /**
+     * Method: zeroPad
+     * Create a zero padded string optionally with a radix for casting numbers.
+     *
+     * Parameters:
+     * num - {Number} The number to be zero padded.
+     * len - {Number} The length of the string to be returned.
+     * radix - {Number} An integer between 2 and 36 specifying the base to use
+     *     for representing numeric values.
+     */
+    zeroPad: function(num, len, radix) {
+        var str = num.toString(radix || 10);
+        while (str.length < len) {
+            str = "0" + str;
+        }
+        return str;
+    },
+
+    CLASS_NAME: 'OpenLayers.Layer.ArcGISCache' 
+}); 

Modified: sandbox/cmoullet/openlayers/lib/OpenLayers/Layer.js
===================================================================
--- sandbox/cmoullet/openlayers/lib/OpenLayers/Layer.js	2011-03-17 16:33:12 UTC (rev 11714)
+++ sandbox/cmoullet/openlayers/lib/OpenLayers/Layer.js	2011-03-17 18:28:20 UTC (rev 11715)
@@ -1322,7 +1322,8 @@
         if (this.wrapDateLine) {
             // wrap around the date line, within the limits of rounding error
             var wrappingOptions = { 
-                'rightTolerance':this.getResolution()
+                'rightTolerance':this.getResolution(),
+                'leftTolerance':this.getResolution()
             };    
             bounds = bounds.wrapDateLine(this.maxExtent, wrappingOptions);
                               

Modified: sandbox/cmoullet/openlayers/lib/OpenLayers/Map.js
===================================================================
--- sandbox/cmoullet/openlayers/lib/OpenLayers/Map.js	2011-03-17 16:33:12 UTC (rev 11714)
+++ sandbox/cmoullet/openlayers/lib/OpenLayers/Map.js	2011-03-17 18:28:20 UTC (rev 11715)
@@ -510,12 +510,6 @@
             this.div = document.createElement("div");
             this.div.style.height = "1px";
             this.div.style.width = "1px";
-            
-            // Adding this to the DOM is a fix for Safari SVG rendering bugs;
-            // See #2392. On initial render(), it is removed from the dom,
-            // and a new div is added.
-            this.div.style.display = "none";
-            document.body.appendChild(this.div);
         }
         
         OpenLayers.Element.addClass(this.div, 'olMap');
@@ -650,11 +644,6 @@
      *     will be moved from the current to the new container.
      */
     render: function(div) {
-        // Fix for Safari SVG rendering bugs; See #2392
-        if(this.div && this.div.parentNode) {
-            this.div.parentNode.removeChild(this.div);
-        }
-
         this.div = OpenLayers.Util.getElement(div);
         OpenLayers.Element.addClass(this.div, 'olMap');
         this.viewPortDiv.parentNode.removeChild(this.viewPortDiv);
@@ -1764,6 +1753,7 @@
 
         if (!this.getCachedCenter() && !this.isValidLonLat(lonlat)) {
             lonlat = this.maxExtent.getCenterLonLat();
+            this.center = lonlat.clone();
         }
 
         if(this.restrictedExtent != null) {

Copied: sandbox/cmoullet/openlayers/lib/OpenLayers/Protocol/Script.js (from rev 11714, trunk/openlayers/lib/OpenLayers/Protocol/Script.js)
===================================================================
--- sandbox/cmoullet/openlayers/lib/OpenLayers/Protocol/Script.js	                        (rev 0)
+++ sandbox/cmoullet/openlayers/lib/OpenLayers/Protocol/Script.js	2011-03-17 18:28:20 UTC (rev 11715)
@@ -0,0 +1,363 @@
+/* Copyright (c) 2006-2011 by OpenLayers Contributors (see authors.txt for 
+ * full list of contributors). Published under the Clear BSD license.  
+ * See http://svn.openlayers.org/trunk/openlayers/license.txt for the
+ * full text of the license. */
+
+/**
+ * @requires OpenLayers/Protocol.js
+ * @requires OpenLayers/Feature/Vector.js
+ * @requires OpenLayers/Format/GeoJSON.js
+ */
+
+/**
+ * Class: OpenLayers.Protocol.Script
+ * A basic Script protocol for vector layers.  Create a new instance with the
+ *     <OpenLayers.Protocol.Script> constructor.  A script protocol is used to
+ *     get around the same origin policy.  It works with services that return
+ *     JSONP - that is, JSON wrapped in a client-specified callback.  The
+ *     protocol handles fetching and parsing of feature data and sends parsed
+ *     features to the <callback> configured with the protocol.  The protocol
+ *     expects features serialized as GeoJSON by default, but can be configured
+ *     to work with other formats by setting the <format> property.
+ *
+ * Inherits from:
+ *  - <OpenLayers.Protocol>
+ */
+OpenLayers.Protocol.Script = OpenLayers.Class(OpenLayers.Protocol, {
+
+    /**
+     * APIProperty: url
+     * {String} Service URL.  The service is expected to return serialized 
+     *     features wrapped in a named callback (where the callback name is
+     *     generated by this protocol).
+     *     Read-only, set through the options passed to the constructor.
+     */
+    url: null,
+
+    /**
+     * APIProperty: params
+     * {Object} Query string parameters to be appended to the URL.
+     *     Read-only, set through the options passed to the constructor.
+     *     Example: {maxFeatures: 50}
+     */
+    params: null,
+    
+    /**
+     * APIProperty: callback
+     * {Object} Function to be called when the <read> operation completes.
+     */
+    callback: null,
+
+    /**
+     * APIProperty: scope
+     * {Object} Optional ``this`` object for the callback. Read-only, set 
+     *     through the options passed to the constructor.
+     */
+    scope: null,
+
+    /**
+     * APIProperty: format
+     * {<OpenLayers.Format>} Format for parsing features.  Default is an 
+     *     <OpenLayers.Format.GeoJSON> format.  If an alternative is provided,
+     *     the format's read method must take an object and return an array
+     *     of features.
+     */
+    format: null,
+
+    /**
+     * APIProperty: callbackKey
+     * {String} The name of the query string parameter that the service 
+     *     recognizes as the callback identifier.  Default is "callback".
+     *     This key is used to generate the URL for the script.  For example
+     *     setting <callbackKey> to "myCallback" would result in a URL like 
+     *     http://example.com/?myCallback=...
+     */
+    callbackKey: "callback",
+
+    /**
+     * APIProperty: callbackPrefix
+     * {String} Where a service requires that the callback query string 
+     *     parameter value is prefixed by some string, this value may be set.
+     *     For example, setting <callbackPrefix> to "foo:" would result in a
+     *     URL like http://example.com/?callback=foo:...  Default is "".
+     */
+    callbackPrefix: "",
+
+    /**
+     * Property: pendingRequests
+     * {Object} References all pending requests.  Property names are script 
+     *     identifiers and property values are script elements.
+     */
+    pendingRequests: null,
+
+    /**
+     * Constructor: OpenLayers.Protocol.Script
+     * A class for giving layers generic Script protocol.
+     *
+     * Parameters:
+     * options - {Object} Optional object whose properties will be set on the
+     *     instance.
+     *
+     * Valid options include:
+     * url - {String}
+     * params - {Object}
+     * callback - {Function}
+     * scope - {Object}
+     */
+    initialize: function(options) {
+        options = options || {};
+        this.params = {};
+        this.pendingRequests = {};
+        OpenLayers.Protocol.prototype.initialize.apply(this, arguments);
+        if (!this.format) {
+            this.format = new OpenLayers.Format.GeoJSON();
+        }
+
+        if (!this.filterToParams && OpenLayers.Protocol.simpleFilterSerializer) {
+            this.filterToParams = OpenLayers.Function.bind(
+                OpenLayers.Protocol.simpleFilterSerializer, this
+            );
+        }
+    },
+    
+    /**
+     * APIMethod: read
+     * Construct a request for reading new features.
+     *
+     * Parameters:
+     * options - {Object} Optional object for configuring the request.
+     *     This object is modified and should not be reused.
+     *
+     * Valid options:
+     * url - {String} Url for the request.
+     * params - {Object} Parameters to get serialized as a query string.
+     * filter - {<OpenLayers.Filter>} Filter to get serialized as a
+     *     query string.
+     *
+     * Returns:
+     * {<OpenLayers.Protocol.Response>} A response object, whose "priv" property
+     *     references the injected script.  This object is also passed to the
+     *     callback function when the request completes, its "features" property
+     *     is then populated with the features received from the server.
+     */
+    read: function(options) {
+        OpenLayers.Protocol.prototype.read.apply(this, arguments);
+        options = OpenLayers.Util.applyDefaults(options, this.options);
+        options.params = OpenLayers.Util.applyDefaults(
+            options.params, this.options.params
+        );
+        if (options.filter && this.filterToParams) {
+            options.params = this.filterToParams(
+                options.filter, options.params
+            );
+        }
+        var response = new OpenLayers.Protocol.Response({requestType: "read"});
+        var request = this.createRequest(
+            options.url, 
+            options.params, 
+            OpenLayers.Function.bind(function(data) {
+                response.data = data;
+                this.handleRead(response, options);
+            }, this)
+        );
+        response.priv = request;
+        return response;
+    },
+
+    /** 
+     * APIMethod: filterToParams 
+     * Optional method to translate an <OpenLayers.Filter> object into an object 
+     *     that can be serialized as request query string provided.  If a custom 
+     *     method is not provided, any filter will not be serialized. 
+     * 
+     * Parameters: 
+     * filter - {<OpenLayers.Filter>} filter to convert. 
+     * params - {Object} The parameters object. 
+     * 
+     * Returns: 
+     * {Object} The resulting parameters object. 
+     */
+
+    /** 
+     * Method: createRequest
+     * Issues a request for features by creating injecting a script in the 
+     *     document head.
+     *
+     * Parameters:
+     * url - {String} Service URL.
+     * params - {Object} Query string parameters.
+     * callback - {Function} Callback to be called with resulting data.
+     *
+     * Returns:
+     * {HTMLScriptElement} The script pending execution.
+     */
+    createRequest: function(url, params, callback) {
+        var id = OpenLayers.Protocol.Script.register(callback);
+        var name = "OpenLayers.Protocol.Script.getCallback(" + id + ")";
+        params = OpenLayers.Util.extend({}, params);
+        params[this.callbackKey] = this.callbackPrefix + name;
+        url = OpenLayers.Util.urlAppend(
+            url, OpenLayers.Util.getParameterString(params)
+        );
+        var script = document.createElement("script");
+        script.type = "text/javascript";
+        script.src = url;
+        script.id = "OpenLayers_Protocol_Script_" + id;
+        this.pendingRequests[script.id] = script;
+        var head = document.getElementsByTagName("head")[0];
+        head.appendChild(script);
+        return script;
+    },
+    
+    /** 
+     * Method: destroyRequest
+     * Remove a script node associated with a response from the document.  Also
+     *     unregisters the callback and removes the script from the 
+     *     <pendingRequests> object.
+     *
+     * Parameters:
+     * script - {HTMLScriptElement}
+     */
+    destroyRequest: function(script) {
+        OpenLayers.Protocol.Script.unregister(script.id.split("_").pop());
+        delete this.pendingRequests[script.id];
+        if (script.parentNode) {
+            script.parentNode.removeChild(script);
+        }
+    },
+
+    /**
+     * Method: handleRead
+     * Individual callbacks are created for read, create and update, should
+     *     a subclass need to override each one separately.
+     *
+     * Parameters:
+     * response - {<OpenLayers.Protocol.Response>} The response object to pass to
+     *     the user callback.
+     * options - {Object} The user options passed to the read call.
+     */
+    handleRead: function(response, options) {
+        this.handleResponse(response, options);
+    },
+
+    /**
+     * Method: handleResponse
+     * Called by CRUD specific handlers.
+     *
+     * Parameters:
+     * response - {<OpenLayers.Protocol.Response>} The response object to pass to
+     *     any user callback.
+     * options - {Object} The user options passed to the create, read, update,
+     *     or delete call.
+     */
+    handleResponse: function(response, options) {
+        if (options.callback) {
+            if (response.data) {
+                response.features = this.parseFeatures(response.data);
+                response.code = OpenLayers.Protocol.Response.SUCCESS;
+            } else {
+                response.code = OpenLayers.Protocol.Response.FAILURE;
+            }
+            this.destroyRequest(response.priv);
+            options.callback.call(options.scope, response);
+        }
+    },
+
+    /**
+     * Method: parseFeatures
+     * Read Script response body and return features.
+     *
+     * Parameters:
+     * data - {Object} The data sent to the callback function by the server.
+     *
+     * Returns:
+     * {Array({<OpenLayers.Feature.Vector>})} or
+     *     {<OpenLayers.Feature.Vector>} Array of features or a single feature.
+     */
+    parseFeatures: function(data) {
+        return this.format.read(data);
+    },
+
+    /**
+     * APIMethod: abort
+     * Abort an ongoing request.  If no response is provided, all pending 
+     *     requests will be aborted.
+     *
+     * Parameters:
+     * response - {<OpenLayers.Protocol.Response>} The response object returned
+     *     from a <read> request.
+     */
+    abort: function(response) {
+        if (response) {
+            this.destroyRequest(response.priv);
+        } else {
+            for (var key in this.pendingRequests) {
+                this.destroyRequest(this.pendingRequests[key]);
+            }
+        }
+    },
+    
+    /**
+     * APIMethod: destroy
+     * Clean up the protocol.
+     */
+    destroy: function() {
+        this.abort();
+        delete this.params;
+        delete this.format;
+        OpenLayers.Protocol.prototype.destroy.apply(this);
+    },
+
+    CLASS_NAME: "OpenLayers.Protocol.Script" 
+});
+
+(function() {
+    var o = OpenLayers.Protocol.Script;
+    var counter = 0;
+    var registry = {};
+    
+    /**
+     * Function: OpenLayers.Protocol.Script.register
+     * Register a callback for a newly created script.
+     *
+     * Parameters:
+     * callback: {Function} The callback to be executed when the newly added
+     *     script loads.  This callback will be called with a single argument
+     *     that is the JSON returned by the service.
+     *
+     * Returns:
+     * {Number} An identifier for retreiving the registered callback.
+     */
+    o.register = function(callback) {
+        var id = ++counter;
+        registry[id] = callback;
+        return id;
+    };
+    
+    /**
+     * Function: OpenLayers.Protocol.Script.unregister
+     * Unregister a callback previously registered with the register function.
+     *
+     * Parameters:
+     * id: {Number} The identifer returned by the register function.
+     */
+    o.unregister = function(id) {
+        delete 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: sandbox/cmoullet/openlayers/lib/OpenLayers/Protocol/WFS/v1.js
===================================================================
--- sandbox/cmoullet/openlayers/lib/OpenLayers/Protocol/WFS/v1.js	2011-03-17 16:33:12 UTC (rev 11714)
+++ sandbox/cmoullet/openlayers/lib/OpenLayers/Protocol/WFS/v1.js	2011-03-17 18:28:20 UTC (rev 11715)
@@ -149,6 +149,10 @@
      *     format's read method (that is only about reading transaction
      *     responses).
      *
+     * Parameters:
+     * options - {Object} Options for the read operation, in addition to the
+     *     options set on the instance (options set here will take precedence).
+     *
      * To use a configured protocol to get e.g. a WFS hit count, applications
      * could do the following:
      *
@@ -162,6 +166,16 @@
      *     }
      * });
      * (end)
+     *
+     * To limit the attributes returned by the GetFeature request, applications
+     * can use the propertyNames option to specify the properties to include in
+     * the response:
+     *
+     * (code)
+     * protocol.read({
+     *     propertyNames: ["DURATION", "INTENSITY"]
+     * });
+     * (end)
      */
     read: function(options) {
         OpenLayers.Protocol.prototype.read.apply(this, arguments);

Modified: sandbox/cmoullet/openlayers/lib/OpenLayers/Renderer/SVG.js
===================================================================
--- sandbox/cmoullet/openlayers/lib/OpenLayers/Renderer/SVG.js	2011-03-17 16:33:12 UTC (rev 11714)
+++ sandbox/cmoullet/openlayers/lib/OpenLayers/Renderer/SVG.js	2011-03-17 18:28:20 UTC (rev 11715)
@@ -290,9 +290,9 @@
                 // the symbol viewBox is three times as large as the symbol
                 var offset = style.pointRadius * 3;
                 var size = offset * 2;
-                var id = this.importSymbol(style.graphicName);
+                var src = this.importSymbol(style.graphicName);
                 pos = this.getPosition(node);
-                widthFactor = this.symbolMetrics[id][0] * 3 / size;
+                widthFactor = this.symbolMetrics[src.id][0] * 3 / size;
                 
                 // remove the node from the dom before we modify it. This
                 // prevents various rendering issues in Safari and FF
@@ -308,7 +308,6 @@
                 // See e.g. ticket http://trac.osgeo.org/openlayers/ticket/2985 
                 // and this email thread
                 // http://osgeo-org.1803224.n2.nabble.com/Select-Control-Ctrl-click-on-Feature-with-a-graphicName-opens-new-browser-window-tc5846039.html
-                var src = document.getElementById(id);
                 node.firstChild && node.removeChild(node.firstChild);
                 node.appendChild(src.firstChild.cloneNode(true));
                 node.setAttributeNS(null, "viewBox", src.getAttributeNS(null, "viewBox"));
@@ -339,7 +338,7 @@
                         "rotate(" + rotation + " " + pos.x + " " + 
                         pos.y + ")"); 
                 } else {
-                    var metrics = this.symbolMetrics[id];
+                    var metrics = this.symbolMetrics[src.id];
                     node.firstChild.setAttributeNS(null, "transform", "rotate(" 
                         + rotation + " " 
                         + metrics[1] + " "
@@ -881,7 +880,7 @@
      * graphicName - {String} name of the symbol to import
      * 
      * Returns:
-     * {String} - id of the imported symbol
+     * {DOMElement} - the imported symbol
      */      
     importSymbol: function (graphicName)  {
         if (!this.defs) {
@@ -891,8 +890,9 @@
         var id = this.container.id + "-" + graphicName;
         
         // check if symbol already exists in the defs
-        if (document.getElementById(id) != null) {
-            return id;
+        var existing = document.getElementById(id)
+        if (existing != null) {
+            return existing;
         }
         
         var symbol = OpenLayers.Renderer.symbol[graphicName];
@@ -934,7 +934,7 @@
         ];
         
         this.defs.appendChild(symbolNode);
-        return symbolNode.id;
+        return symbolNode;
     },
     
     /**

Modified: sandbox/cmoullet/openlayers/lib/OpenLayers/Renderer/SVG2.js
===================================================================
--- sandbox/cmoullet/openlayers/lib/OpenLayers/Renderer/SVG2.js	2011-03-17 16:33:12 UTC (rev 11714)
+++ sandbox/cmoullet/openlayers/lib/OpenLayers/Renderer/SVG2.js	2011-03-17 18:28:20 UTC (rev 11715)
@@ -42,7 +42,7 @@
     labelNodeType: "g",
 
     /**
-     * Constructor: OpenLayers.Renderer.SVG
+     * Constructor: OpenLayers.Renderer.SVG2
      * 
      * Parameters:
      * containerID - {String}
@@ -217,8 +217,8 @@
                 // the symbol viewBox is three times as large as the symbol
                 var offset = style.pointRadius * 3 * resolution;
                 var size = offset * 2;
-                var id = this.importSymbol(style.graphicName);
-                widthFactor = this.symbolMetrics[id].size * 3 / size * resolution;
+                var src = this.importSymbol(style.graphicName);
+                widthFactor = this.symbolMetrics[src.id].size * 3 / size * resolution;
                 
                 // remove the node from the dom before we modify it. This
                 // prevents various rendering issues in Safari and FF
@@ -234,7 +234,6 @@
                 // See e.g. ticket http://trac.osgeo.org/openlayers/ticket/2985  
                 // and this email thread 
                 // http://osgeo-org.1803224.n2.nabble.com/Select-Control-Ctrl-click-on-Feature-with-a-graphicName-opens-new-browser-window-tc5846039.html 
-                var src = document.getElementById(id); 
                 node.firstChild && node.removeChild(node.firstChild); 
                 node.appendChild(src.firstChild.cloneNode(true)); 
                 node.setAttributeNS(null, "viewBox", src.getAttributeNS(null, "viewBox")); 
@@ -264,7 +263,7 @@
                         ["rotate(", rotation, node._x, node._y, ")"].join(" ")
                     ); 
                 } else {
-                    var metrics = this.symbolMetrics[id]; 
+                    var metrics = this.symbolMetrics[src.id]; 
                     node.firstChild.setAttributeNS(null, "transform",
                         ["rotate(", rotation, metrics.x, metrics.y, ")"].join(" ")
                     );
@@ -616,14 +615,14 @@
         }
         var align = style.labelAlign || "cm";
         text.setAttributeNS(null, "text-anchor",
-            OpenLayers.Renderer.SVG.LABEL_ALIGN[align[0]] || "middle");
+            OpenLayers.Renderer.SVG2.LABEL_ALIGN[align[0]] || "middle");
 
         if (OpenLayers.IS_GECKO === true) {
             text.setAttributeNS(null, "dominant-baseline",
-                OpenLayers.Renderer.SVG.LABEL_ALIGN[align[1]] || "central");
+                OpenLayers.Renderer.SVG2.LABEL_ALIGN[align[1]] || "central");
         } else {
             tspan.setAttributeNS(null, "baseline-shift",
-                OpenLayers.Renderer.SVG.LABEL_VSHIFT[align[1]] || "-35%");
+                OpenLayers.Renderer.SVG2.LABEL_VSHIFT[align[1]] || "-35%");
         }
 
         tspan.textContent = style.label;
@@ -679,7 +678,7 @@
      * graphicName - {String} name of the symbol to import
      * 
      * Returns:
-     * {String} - id of the imported symbol
+     * {DOMElement} - the imported symbol
      */      
     importSymbol: function (graphicName)  {
         if (!this.defs) {
@@ -689,8 +688,9 @@
         var id = this.container.id + "-" + graphicName;
         
         // check if symbol already exists in the defs
-        if (document.getElementById(id) != null) {
-            return id;
+        var existing = document.getElementById(id);
+        if (existing != null) {
+            return existing;
         }
         
         var symbol = OpenLayers.Renderer.symbol[graphicName];
@@ -732,7 +732,7 @@
         };
         
         this.defs.appendChild(symbolNode);
-        return symbolNode.id;
+        return symbolNode;
     },
     
     /**
@@ -758,6 +758,31 @@
     CLASS_NAME: "OpenLayers.Renderer.SVG2"
 });
 
+/**
+ * Constant: OpenLayers.Renderer.SVG2.LABEL_ALIGN
+ * {Object}
+ */
+OpenLayers.Renderer.SVG2.LABEL_ALIGN = {
+    "l": "start",
+    "r": "end",
+    "b": "bottom",
+    "t": "hanging"
+};
+
+/**
+ * Constant: OpenLayers.Renderer.SVG2.LABEL_VSHIFT
+ * {Object}
+ */
+OpenLayers.Renderer.SVG2.LABEL_VSHIFT = {
+    // according to
+    // http://www.w3.org/Graphics/SVG/Test/20061213/htmlObjectHarness/full-text-align-02-b.html
+    // a baseline-shift of -70% shifts the text exactly from the
+    // bottom to the top of the baseline, so -35% moves the text to
+    // the center of the baseline.
+    "t": "-70%",
+    "b": "0"    
+};
+
 /** 
  * Function: OpenLayers.Renderer.SVG2.preventDefault 
  * Used to prevent default events (especially opening images in a new tab on 

Modified: sandbox/cmoullet/openlayers/lib/OpenLayers/Request.js
===================================================================
--- sandbox/cmoullet/openlayers/lib/OpenLayers/Request.js	2011-03-17 16:33:12 UTC (rev 11714)
+++ sandbox/cmoullet/openlayers/lib/OpenLayers/Request.js	2011-03-17 18:28:20 UTC (rev 11715)
@@ -229,6 +229,10 @@
                 config.failure;
         }
 
+        if (OpenLayers.Util.createUrlObject(config.url).protocol == "file:" &&
+                                                        request.responseText) {
+            request.status = 200;
+        }
         complete(request);
 
         if (!request.status || (request.status >= 200 && request.status < 300)) {

Modified: sandbox/cmoullet/openlayers/lib/OpenLayers.js
===================================================================
--- sandbox/cmoullet/openlayers/lib/OpenLayers.js	2011-03-17 16:33:12 UTC (rev 11714)
+++ sandbox/cmoullet/openlayers/lib/OpenLayers.js	2011-03-17 18:28:20 UTC (rev 11715)
@@ -155,6 +155,7 @@
                 "OpenLayers/Layer/TMS.js",
                 "OpenLayers/Layer/TileCache.js",
                 "OpenLayers/Layer/Zoomify.js",
+                "OpenLayers/Layer/ArcGISCache.js",
                 "OpenLayers/Popup/Anchored.js",
                 "OpenLayers/Popup/AnchoredBubble.js",
                 "OpenLayers/Popup/Framed.js",
@@ -243,6 +244,7 @@
                 "OpenLayers/Filter/Logical.js",
                 "OpenLayers/Filter/Comparison.js",
                 "OpenLayers/Filter/Spatial.js",
+                "OpenLayers/Filter/Function.js",                
                 "OpenLayers/Protocol.js",
                 "OpenLayers/Protocol/HTTP.js",
                 "OpenLayers/Protocol/SimpleFilterSerializer.js",
@@ -252,6 +254,7 @@
                 "OpenLayers/Protocol/WFS/v1.js",
                 "OpenLayers/Protocol/WFS/v1_0_0.js",
                 "OpenLayers/Protocol/WFS/v1_1_0.js",
+                "OpenLayers/Protocol/Script.js",
                 "OpenLayers/Protocol/SOS.js",
                 "OpenLayers/Protocol/SOS/v1_0_0.js",
                 "OpenLayers/Layer/PointTrack.js",

Modified: sandbox/cmoullet/openlayers/tests/Control/TouchNavigation.html
===================================================================
--- sandbox/cmoullet/openlayers/tests/Control/TouchNavigation.html	2011-03-17 16:33:12 UTC (rev 11714)
+++ sandbox/cmoullet/openlayers/tests/Control/TouchNavigation.html	2011-03-17 18:28:20 UTC (rev 11715)
@@ -102,6 +102,29 @@
 
     }
 
+    function test_clickHandlerOptions(t) {
+
+        t.plan(3);
+
+         var nav = new OpenLayers.Control.TouchNavigation();
+         t.eq(nav.clickHandlerOptions, null, "clickHandlerOptions null by default");
+
+         var map = new OpenLayers.Map({
+             div: document.body,
+             controls: [
+                 new OpenLayers.Control.TouchNavigation({
+                     clickHandlerOptions: {foo: "bar"}
+                 })
+             ]
+         });
+         nav = map.controls[0];
+
+         t.eq(nav.handlers.click.foo, "bar", "foo property is set on the click handler");
+         t.eq(nav.handlers.click.pixelTolerance, 2, "pixelTolerance is 2 by default");
+         map.destroy();
+
+    }
+
     function test_zoomOut(t) {
         t.plan(1);
 
@@ -114,7 +137,7 @@
         var control = new OpenLayers.Control.TouchNavigation();
         map.addControl(control);
         var handler = control.handlers.click;
-        handler.touchstart({xy: {x: 1, y: 1}, touches: ["foo", "bar"]});
+        handler.touchstart({xy: new OpenLayers.Pixel(1 ,1), touches: ["foo", "bar"]});
         handler.touchend({});
         t.delay_call(1, function() {
             t.eq(map.getZoom(), 4, "Did we zoom out?");

Modified: sandbox/cmoullet/openlayers/tests/Format/Filter/v1_0_0.html
===================================================================
--- sandbox/cmoullet/openlayers/tests/Format/Filter/v1_0_0.html	2011-03-17 16:33:12 UTC (rev 11714)
+++ sandbox/cmoullet/openlayers/tests/Format/Filter/v1_0_0.html	2011-03-17 18:28:20 UTC (rev 11715)
@@ -152,7 +152,117 @@
 
     }
 
+    function test_FilterFunctions(t) {
+        t.plan(2);
 
+        var parser = new OpenLayers.Format.Filter.v1_0_0();
+
+        //test spatial intersects with filter function
+        var filter = new OpenLayers.Filter.Spatial({
+            property: 'the_geom',
+            type: OpenLayers.Filter.Spatial.INTERSECTS,
+            value: new OpenLayers.Filter.Function({
+                name  : 'querySingle',
+                params: ['sf:restricted', 'the_geom', 'cat=3']
+            })
+        });
+
+        var out =
+            '<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">' +
+                '<ogc:Intersects>' +
+                    '<ogc:PropertyName>the_geom</ogc:PropertyName>' +
+                    '<ogc:Function name="querySingle">' +
+                        '<ogc:Literal>sf:restricted</ogc:Literal>' +
+                        '<ogc:Literal>the_geom</ogc:Literal>' +
+                        '<ogc:Literal>cat=3</ogc:Literal>' +
+                    '</ogc:Function>' +
+                '</ogc:Intersects>' +
+            '</ogc:Filter>';
+
+
+        var node = parser.write(filter);
+
+        //test writer
+        t.xml_eq(node, out, "spatial intersect filter with functions correctly written");
+
+        //test logical filter with custom function
+        filter = new OpenLayers.Filter.Logical({
+            type: OpenLayers.Filter.Logical.AND,
+            filters: [
+                new OpenLayers.Filter.Comparison({
+                    type: OpenLayers.Filter.Comparison.NOT_EQUAL_TO,
+                    property: "FOO",
+                    value: new OpenLayers.Filter.Function({
+                        name : 'customFunction',
+                        params : ['param1', 'param2']
+                    })
+                })
+            ]
+        });
+
+        out =
+            '<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">' +
+                '<ogc:And>' +
+                    '<ogc:PropertyIsNotEqualTo>' +
+                        '<ogc:PropertyName>FOO</ogc:PropertyName>' +
+                        '<ogc:Function name="customFunction">' +
+                            '<ogc:Literal>param1</ogc:Literal>' +
+                            '<ogc:Literal>param2</ogc:Literal>' +
+                        '</ogc:Function>' +
+                    '</ogc:PropertyIsNotEqualTo>' +
+                '</ogc:And>' +
+            '</ogc:Filter>';
+
+        node = parser.write(filter);
+
+        //test writer
+        t.xml_eq(node, out, "comparison filter with filter functions correctly written");
+
+    }
+
+    function test_NestedFilterFunctions(t) {
+        t.plan(1);
+
+        //test spatial dwithin with nested filter function
+        var filter = new OpenLayers.Filter.Spatial({
+           property: 'the_geom',
+           type: OpenLayers.Filter.Spatial.DWITHIN,
+           value: new OpenLayers.Filter.Function({
+               name : 'collectGeometries',
+               params: [
+                    new OpenLayers.Filter.Function({
+                        name  : 'queryCollection',
+                        params: ['sf:roads', 'the_geom', 'INCLUDE']
+                    })
+               ]
+           }),
+           distanceUnits: "meters",
+           distance: 200
+        });
+
+        var out =
+            '<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">' +
+                '<ogc:DWithin>' +
+                    '<ogc:PropertyName>the_geom</ogc:PropertyName>' +
+                    '<ogc:Function name="collectGeometries">' +
+                        '<ogc:Function name="queryCollection">' +
+                            '<ogc:Literal>sf:roads</ogc:Literal>' +
+                            '<ogc:Literal>the_geom</ogc:Literal>' +
+                            '<ogc:Literal>INCLUDE</ogc:Literal>' +
+                        '</ogc:Function>' +
+                    '</ogc:Function>' +
+                    '<ogc:Distance units="meters">200</ogc:Distance>' +
+                '</ogc:DWithin>' +
+            '</ogc:Filter>';
+
+        var parser = new OpenLayers.Format.Filter.v1_0_0();
+        var node = parser.write(filter);
+
+        //test writer
+        t.xml_eq(node, out, "spatial dwithin filter with nested functions correctly written");
+    }
+
+
     </script> 
 </head> 
 <body>

Modified: sandbox/cmoullet/openlayers/tests/Format/Filter/v1_1_0.html
===================================================================
--- sandbox/cmoullet/openlayers/tests/Format/Filter/v1_1_0.html	2011-03-17 16:33:12 UTC (rev 11714)
+++ sandbox/cmoullet/openlayers/tests/Format/Filter/v1_1_0.html	2011-03-17 18:28:20 UTC (rev 11715)
@@ -203,6 +203,118 @@
 
     }
 
+    function test_FilterFunctions(t) {
+        t.plan(2);
+
+        var parser = new OpenLayers.Format.Filter.v1_1_0();
+
+        //test spatial intersects with filter function
+        var filter = new OpenLayers.Filter.Spatial({
+            property: 'the_geom',
+            type: OpenLayers.Filter.Spatial.INTERSECTS,
+            value: new OpenLayers.Filter.Function({
+                name  : 'querySingle',
+                params: ['sf:restricted', 'the_geom', 'cat=3']
+            })
+        });
+
+        var out =
+            '<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">' +
+                '<ogc:Intersects>' +
+                    '<ogc:PropertyName>the_geom</ogc:PropertyName>' +
+                    '<ogc:Function name="querySingle">' +
+                        '<ogc:Literal>sf:restricted</ogc:Literal>' +
+                        '<ogc:Literal>the_geom</ogc:Literal>' +
+                        '<ogc:Literal>cat=3</ogc:Literal>' +
+                    '</ogc:Function>' +
+                '</ogc:Intersects>' +
+            '</ogc:Filter>';
+
+
+        var node = parser.write(filter);
+
+        //test writer
+        t.xml_eq(node, out, "spatial intersect filter with functions correctly written");
+
+        //test logical filter with custom function
+        filter = new OpenLayers.Filter.Logical({
+            type: OpenLayers.Filter.Logical.AND,
+            filters: [
+                new OpenLayers.Filter.Comparison({
+                    type: OpenLayers.Filter.Comparison.NOT_EQUAL_TO,
+                    matchCase: false,
+                    property: "FOO",
+                    value: new OpenLayers.Filter.Function({
+                        name : 'customFunction',
+                        params : ['param1', 'param2']
+                    })
+                })
+            ]
+        });
+
+        out =
+            '<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">' +
+                '<ogc:And>' +
+                    '<ogc:PropertyIsNotEqualTo matchCase="false">' +
+                        '<ogc:PropertyName>FOO</ogc:PropertyName>' +
+                        '<ogc:Function name="customFunction">' +
+                            '<ogc:Literal>param1</ogc:Literal>' +
+                            '<ogc:Literal>param2</ogc:Literal>' +
+                        '</ogc:Function>' +
+                    '</ogc:PropertyIsNotEqualTo>' +
+                '</ogc:And>' +
+            '</ogc:Filter>';
+
+        node = parser.write(filter);
+
+        //test writer
+        t.xml_eq(node, out, "comparison filter with filter functions correctly written");
+
+    }
+
+    function test_NestedFilterFunctions(t) {
+        t.plan(1);
+
+        //test spatial dwithin with nested filter function
+        var filter = new OpenLayers.Filter.Spatial({
+           property: 'the_geom',
+           type: OpenLayers.Filter.Spatial.DWITHIN,
+           value: new OpenLayers.Filter.Function({
+               name : 'collectGeometries',
+               params: [
+                    new OpenLayers.Filter.Function({
+                        name  : 'queryCollection',
+                        params: ['sf:roads', 'the_geom', 'INCLUDE']
+                    })
+               ]
+           }),
+           distanceUnits: "meters",
+           distance: 200
+        });
+
+        var out =
+            '<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">' +
+                '<ogc:DWithin>' +
+                    '<ogc:PropertyName>the_geom</ogc:PropertyName>' +
+                    '<ogc:Function name="collectGeometries">' +
+                        '<ogc:Function name="queryCollection">' +
+                            '<ogc:Literal>sf:roads</ogc:Literal>' +
+                            '<ogc:Literal>the_geom</ogc:Literal>' +
+                            '<ogc:Literal>INCLUDE</ogc:Literal>' +
+                        '</ogc:Function>' +
+                    '</ogc:Function>' +
+                    '<ogc:Distance units="meters">200</ogc:Distance>' +
+                '</ogc:DWithin>' +
+            '</ogc:Filter>';
+
+        var parser = new OpenLayers.Format.Filter.v1_1_0();
+        var node = parser.write(filter);
+
+        //test writer
+        t.xml_eq(node, out, "spatial dwithin filter with nested functions correctly written");
+    }
+
+
     </script> 
 </head> 
 <body>

Modified: sandbox/cmoullet/openlayers/tests/Handler/Click.html
===================================================================
--- sandbox/cmoullet/openlayers/tests/Handler/Click.html	2011-03-17 16:33:12 UTC (rev 11714)
+++ sandbox/cmoullet/openlayers/tests/Handler/Click.html	2011-03-17 18:28:20 UTC (rev 11715)
@@ -102,12 +102,16 @@
     
     var callbackMap;
     function callbackSetup(log, options) {
-        callbackMap = new OpenLayers.Map('map', {controls: []});
+        callbackMap = new OpenLayers.Map({
+            div: "map",
+            controls: [], // no controls here because these tests use a custom setTimeout and we only want setTimeout calls from a single handler 
+            layers: [new OpenLayers.Layer(null, {isBaseLayer: true})],
+            center: new OpenLayers.LonLat(0, 0),
+            zoom: 1
+        });
+        var control = new OpenLayers.Control();
+        callbackMap.addControl(control);
 
-        var control = {
-            map: callbackMap
-        };
-
         var callbacks = {
             "click": function(evt) {
                 log.push({callback: "click", evt: evt});
@@ -119,6 +123,7 @@
         var handler = new OpenLayers.Handler.Click(control, callbacks, options);
         handler.activate();
         
+        
         var timers = {};
         window._setTimeout = window.setTimeout;
         window.setTimeout = function(func, delay) {
@@ -270,13 +275,140 @@
 
         handler.map.events.triggerEvent("mouseup", up);
         handler.map.events.triggerEvent("click", up);
-        
         t.eq(log.length, 0, "nothing logged - event outside tolerance");
         
         callbackTeardown();
         
     }
 
+    function test_callbacks_within_dblclickTolerance(t) {
+        t.plan(6);
+
+        var log = [];
+        var handler = callbackSetup(log, {single: false, "double": true, dblclickTolerance: 8});
+
+        var first = {
+            xy: px(0, 0)
+        };
+        var second = {
+            xy: px(0, 5)
+        };
+
+        handler.map.events.triggerEvent("mousedown", first);
+        handler.map.events.triggerEvent("mouseup", first);
+        handler.map.events.triggerEvent("click", first);
+        t.eq(log.length, 1, "one item logged");
+        t.eq(log[0] && log[0].method, "setTimeout", "setTimeout called");
+        
+        handler.map.events.triggerEvent("mousedown", second);
+        handler.map.events.triggerEvent("mouseup", second);
+        handler.map.events.triggerEvent("click", second);
+        t.eq(log.length, 2, "two events logged");
+        t.eq(log[1] && log[1].method, "clearTimeout", "clearTimeout called");
+        
+        handler.map.events.triggerEvent("dblclick", second);
+        t.eq(log.length, 3, "three items logged");
+        t.eq(log[2] && log[2].callback, "dblclick", "dblclick callback called");
+        
+        callbackTeardown();        
+    }
+
+    function test_callbacks_outside_dblclickTolerance(t) {
+        t.plan(5);
+
+        var log = [];
+        // default dblclickTolerance is 13
+        var handler = callbackSetup(log, {single: false, "double": true});
+
+        var first = {
+            xy: px(0, 0)
+        };
+        var second = {
+            xy: px(13.5, 0)
+        };
+
+        handler.map.events.triggerEvent("mousedown", first);
+        handler.map.events.triggerEvent("mouseup", first);
+        handler.map.events.triggerEvent("click", first);
+        t.eq(log.length, 1, "one item logged");
+        t.eq(log[0] && log[0].method, "setTimeout", "setTimeout called");
+
+        handler.map.events.triggerEvent("mousedown", second);
+        handler.map.events.triggerEvent("mouseup", second);
+        handler.map.events.triggerEvent("click", second);
+        t.eq(log.length, 2, "two items logged");
+        t.eq(log[1] && log[1].method, "clearTimeout", "clearTimeout called");
+
+        handler.map.events.triggerEvent("dblclick", second);
+        t.eq(log.length, 2, "still two items logged - dblclick callback is not called");
+        
+        callbackTeardown();
+    }
+
+    function test_callbacks_multitouch_single(t) {
+
+        t.plan(2);
+
+        var log = [];
+
+        var callbacks = {
+            click: function(evt) {
+                log.push({callback: "click", type: evt.type});
+            },
+            dblclick: function(evt) {
+                log.push({callback: "dblclick", type: evt.type});
+            }
+        };
+
+        var map = new OpenLayers.Map("map");
+        var layer = new OpenLayers.Layer(null, {isBaseLayer: true});
+        map.addLayer(layer);
+        map.setCenter(new OpenLayers.LonLat(0, 0), 1);
+        var control = new OpenLayers.Control();
+        map.addControl(control);
+        var handler = new OpenLayers.Handler.Click(
+            control, callbacks,
+            {"double": true, single: true, pixelTolerance: 2}
+        );
+
+        // we override here so we don't have to wait for the timeout
+        handler.queuePotentialClick = function(evt) {
+            log.push({potential: true, evt: evt});
+            OpenLayers.Handler.Click.prototype.queuePotentialClick.call(this, evt);
+        }
+        
+        handler.activate();
+        
+        function handle(o) {
+            var touches = [];
+            if (("x0" in o) && ("y0" in o)) {
+                touches.push({
+                    clientX: o.x0, clientY: o.y0
+                });
+            }
+            if (("x1" in o) && ("y1" in o)) {
+                touches.push({
+                    clientX: o.x1, clientY: o.y1
+                });
+            }
+            handler.map.events.handleBrowserEvent({
+                type: o.type, touches: touches
+            });
+        }
+
+        // a typical multitouch sequence goes like this:
+        // touchstart, touchstart, touchend, touchend
+        handle({type: "touchstart", x0: 10, y0: 10});
+        handle({type: "touchstart", x0: 10, y0: 10, x1: 30, y1: 15});
+        handle({type: "touchend"});
+        handle({type: "touchend"});
+        
+        t.eq(log.length, 1, "one item logged");
+        t.eq(log[0] && log[0].potential, true, "click in queue - no dblclick called");
+        
+        map.destroy();
+    }
+
     function test_Handler_Click_deactivate(t) {
         t.plan(4);
         var control = {
@@ -395,84 +527,125 @@
         });
     }
 
-    function test_touch_ignoresimulatedclick(t) {
-        t.plan(2);
+    function test_touch_within_dblclickTolerance(t) {
+        t.plan(4);
 
-        // set up
-
         var log;
 
-        var map = new OpenLayers.Map('map');
-        var control = {map: map};
-
         var callbacks = {
-            'dblclick': function(e) {
-                log.dblclick = {x: e.xy.x, y: e.xy.y,
-                   lastTouches: e.lastTouches};
+            click: function(evt) {
+                log.push({callback: "click", type: evt.type});
+            },
+            dblclick: function(evt) {
+                log.push({callback: "dblclick", type: evt.type});
             }
         };
 
+        var map = new OpenLayers.Map("map");
+        var layer = new OpenLayers.Layer(null, {isBaseLayer: true});
+        map.addLayer(layer);
+        map.setCenter(new OpenLayers.LonLat(0, 0), 1);
+        var control = new OpenLayers.Control();
+        map.addControl(control);
         var handler = new OpenLayers.Handler.Click(
-                control, callbacks,
-                {'double': true, pixelTolerance: null});
+            control, callbacks,
+            {"double": true, single: true, pixelTolerance: 2}
+        );
+        handler.activate();
+        
+        function handle(type, x, y) {
+            map.events.handleBrowserEvent({
+                type: type,
+                touches: [
+                    {clientX: x, clientY: y}
+                ]
+            });
+        }
 
         // test
+        log = [];
+        // sequence of two clicks on a touch device
+        // click 1
+        handle("touchstart", 10, 10);
+        handle("touchend", 11, 10);
+        handle("mousemove", 11, 10);
+        handle("mousedown", 10, 10);
+        handle("mouseup", 11, 10);
+        handle("click", 11, 10);
+        // click 2
+        handle("touchstart", 12, 10);
+        handle("touchend", 12, 10);
+        handle("mousedown", 12, 10);
+        handle("mouseup", 12, 10);
+        handle("click", 12, 10);
 
-        log = {};
-        handler.touchstart({xy: px(1, 1), touches: ["foo"]});
-        handler.touchend({});
-        handler.touchstart({xy: px(1, 1), touches: ["foo"]});
-        handler.touchend({type: "click"});
+        t.eq(log.length, 1, "one callback called");
+        t.eq(log[0] && log[0].callback, "dblclick", "click callback called");
+        t.eq(log[0] && log[0].type, "touchend", "click callback called with touchend event");
+        t.ok(!handler.timerId, "handler doesn't have a timerId waiting for click")
 
-        t.eq(!!handler.down.touches, true, "Handler down touches property should be truthy");
-        
-        t.ok(log.dblclick == undefined, "dblclick callback not called with simulated click");
-
         // tear down
         map.destroy();
     }
 
-    function test_touch_dblclick(t) {
-        t.plan(5);
+    function test_touch_outside_dblclickTolerance(t) {
+        t.plan(2);
 
-        // set up
-
         var log;
 
-        var map = new OpenLayers.Map('map');
-        var control = {map: map};
-
         var callbacks = {
-            'click': function(e) {
-                log.click = {x: e.xy.x, y: e.xy.y,
-                   lastTouches: e.lastTouches};
+            click: function(evt) {
+                log.push({callback: "click", type: evt.type});
             },
-            'dblclick': function(e) {
-                log.dblclick = {x: e.xy.x, y: e.xy.y,
-                   lastTouches: e.lastTouches};
+            dblclick: function(evt) {
+                log.push({callback: "dblclick", type: evt.type});
             }
         };
 
+        var map = new OpenLayers.Map("map");
+        var layer = new OpenLayers.Layer(null, {isBaseLayer: true});
+        map.addLayer(layer);
+        map.setCenter(new OpenLayers.LonLat(0, 0), 1);
+        var control = new OpenLayers.Control();
+        map.addControl(control);
         var handler = new OpenLayers.Handler.Click(
-                control, callbacks,
-                {'double': true, pixelTolerance: null});
+            control, callbacks,
+            {"double": true, single: true, pixelTolerance: 2, dblclickTolerance: 8}
+        );
+        handler.activate();
+        
+        function handle(type, x, y) {
+            var touches = [];
+            if (x !== undefined && y !== undefined) {
+                touches.push({
+                    clientX: x, clientY: y
+                });
+            }
+            map.events.handleBrowserEvent({
+                type: type, touches: touches
+            });
+        }
 
         // test
+        log = [];
+        // sequence of two clicks on a touch device
+        // click 1
+        handle("touchstart", 10, 10);
+        handle("touchend");
+        handle("mousemove", 11, 10);
+        handle("mousedown", 10, 10);
+        handle("mouseup", 11, 10);
+        handle("click", 11, 10);
+        // click 2
+        handle("touchstart", 20, 10);
+        handle("touchend");
+        handle("mousedown", 20, 10);
+        handle("mouseup", 20, 10);
+        handle("click", 20, 10);
 
-        log = {};
-        handler.touchstart({xy: px(1, 1), touches: [{clientX:0, clientY:10}]});
-        handler.touchend({});
-        handler.touchstart({xy: px(1, 1), touches: [{clientX:0, clientY:10}]});
-        handler.touchend({});
+        t.eq(log.length, 0, "no callbacks called");
+        t.ok(!handler.timerId, "handler doesn't have a timerId waiting for click")
 
-        t.eq(log.click, undefined, "click callback not called");
-        t.ok(log.dblclick != undefined, "dblclick callback called");
-        if(log.dblclick != undefined) {
-            t.eq(log.dblclick.x, 1, "evt.xy.x as expected");
-            t.eq(log.dblclick.y, 1, "evt.xy.y as expected");
-            t.ok(log.dblclick.lastTouches, "evt.lastTouches on evt");
-        }
-
         // tear down
         map.destroy();
     }

Modified: sandbox/cmoullet/openlayers/tests/Handler/Point.html
===================================================================
--- sandbox/cmoullet/openlayers/tests/Handler/Point.html	2011-03-17 16:33:12 UTC (rev 11714)
+++ sandbox/cmoullet/openlayers/tests/Handler/Point.html	2011-03-17 18:28:20 UTC (rev 11715)
@@ -25,7 +25,7 @@
     }
 
     function test_Handler_Point_activation(t) {
-        t.plan(10);
+        t.plan(11);
         var log = [];
         var map = new OpenLayers.Map("map", {
             resolutions: [1]
@@ -70,7 +70,15 @@
         activated = handler.deactivate();
         t.ok(activated,
              "deactivate returns true if the handler was active already");
-
+        var failed = false;
+        try {
+            handler.finalize();
+            msg = "finalizing after deactivation does not throw an error";
+        } catch (err) {
+            failed = true;
+            msg = "finalizing after deactivation throws an error";
+        }
+        t.ok(!failed, msg);
         map.destroy();
     }
 

Copied: sandbox/cmoullet/openlayers/tests/Layer/ArcGISCache.html (from rev 11714, trunk/openlayers/tests/Layer/ArcGISCache.html)
===================================================================
--- sandbox/cmoullet/openlayers/tests/Layer/ArcGISCache.html	                        (rev 0)
+++ sandbox/cmoullet/openlayers/tests/Layer/ArcGISCache.html	2011-03-17 18:28:20 UTC (rev 11715)
@@ -0,0 +1,227 @@
+<html>
+<head>
+  <script src="../../lib/OpenLayers.js"></script>
+  <script src="../../lib/OpenLayers/Layer/ArcGISCache.js" type="text/javascript"></script>
+  <script src="ArcGISCache.json" type="text/javascript"></script>
+  <script type="text/javascript">
+    var isMozilla = (navigator.userAgent.indexOf("compatible") == -1);
+    var layer; 
+
+    var name = 'Test Layer';
+    var url = "http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer";
+    var options = { }; 
+
+    function test_Layer_ARCGISCACHE_constructor (t) {
+        t.plan( 1 );
+                       
+        var layer = new OpenLayers.Layer.ArcGISCache(name, url, options);
+        t.ok( layer instanceof OpenLayers.Layer.ArcGISCache, "returns OpenLayers.Layer.ArcGISCache object" );
+    }
+    
+    function test_Layer_ARCGISCACHE_autoConfigure (t) {
+        t.plan( 5 );
+        var layerInfo = capabilitiesObject;
+        
+        //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( layer instanceof OpenLayers.Layer.ArcGISCache, "returns OpenLayers.Layer.ArcGISCache object" );        
+        t.ok( layer.projection = 'EPSG:' + layerInfo.spatialReference.wkid, "projection is set correctly");
+        t.ok( layer.units = 'm', "map units are set correctly");
+        t.ok( layer.resolutions && layer.resolutions.length == 20, "resolutions are initialized from LOD objects properly");
+        
+        if (layerInfo.tileInfo) {
+            if (layerInfo.tileInfo.width && layerInfo.tileInfo.height) {
+                var tileSize = new OpenLayers.Size(layerInfo.tileInfo.width, layerInfo.tileInfo.height);
+                t.ok((layer.tileSize.width == tileSize.width) && (layer.tileSize.height == tileSize.height), "tile size is set properly");
+            }
+            else {
+                var tileSize = new OpenLayers.Size(layerInfo.tileInfo.cols, layerInfo.tileInfo.rows);
+                t.ok((layer.tileSize.width == tileSize.width) && (layer.tileSize.height == tileSize.height), "tile size is set properly");
+            }
+        }        
+    }
+    
+    /**
+     * lets make sure we're getting the correct urls back with a basic auto-configure setup 
+     */
+    function test_Layer_ARCGISCACHE_autoConfigure_URLS(t) {
+        var layerInfo = capabilitiesObject;
+        
+        //initialize the layer using the JSON object from an arcgis server
+        //SEE: ArcGISCache.json
+        var layer = new OpenLayers.Layer.ArcGISCache(name, url, {
+            layerInfo: layerInfo
+        });
+        var map = new OpenLayers.Map('map', { 
+            maxExtent: layer.maxExtent,
+            units: layer.units,
+            resolutions: layer.resolutions,
+            numZoomLevels: layer.numZoomLevels,
+            tileSize: layer.tileSize,
+            projection: layer.displayProjection,
+            StartBounds: layer.initialExtent    
+        });
+        map.addLayers([layer]);
+    
+        //this set represents a few edge cases, and some more specific cases, it is by no means exhaustive,
+        var urlSets = [
+            { 
+                bounds: new OpenLayers.Bounds(-36787612.973083,-22463925.368666, 43362420.398053,17611091.316902),
+                url: "http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/0/0/0" 
+            },            
+            { 
+                bounds: new OpenLayers.Bounds(-31793889.951914,4589319.785415, 8281126.733654,24626828.128199),
+                url: "http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/1/0/0"
+            },            
+            { 
+                bounds: new OpenLayers.Bounds(-24639873.181971,12676071.933457, -4602364.839187,22694826.104849),
+                url: "http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/2/0/0" 
+            },
+            { 
+                bounds: new OpenLayers.Bounds(-15521241.455665,11580270.695961, 4516266.887119,21599024.867353),
+                url: "http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/2/0/1" 
+            },                    
+            { 
+                bounds: new OpenLayers.Bounds(-9265879.5435993,2870892.9335638, -8639707.4078873,3183979.0014198) ,
+                url: "http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/7/54/35" 
+            },
+            { 
+                bounds: new OpenLayers.Bounds(-10741909.131798,4684560.1640365, -10585366.09787,4762831.6810005),
+                url: "http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/9/195/119" 
+            },
+            { 
+                bounds: new OpenLayers.Bounds(-13668958.106938,4456961.2611504, -13512415.07301,4535232.7781144),
+                url: "http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/9/198/82" 
+            }
+        ];
+        
+        t.plan( urlSets.length );        
+        for(var i=0;i<urlSets.length;i++) 
+        {
+            var o = urlSets[i];            
+            map.zoomToExtent(o.bounds, true);
+            
+            var resultUrl = layer.getURL(o.bounds);            
+            t.ok( resultUrl == o.url, "correct tile returned for " + o.bounds);        
+        }
+    }    
+    
+    /**
+     * Test the formatting for the 'direct' urls, especially when not auto-configuring the layer
+     */
+    function test_Layer_ARCGISCACHE_direct(t) {
+        var roadsUrl = 'http://serverx.esri.com/arcgiscache/DG_County_roads_yesA_backgroundDark/Layers/_alllayers';
+        var urlSets = [
+            { 
+                bounds: new OpenLayers.Bounds(289244.67443386,4317153.7421985, 306178.04163392,4325620.4257985),
+                url: roadsUrl + "/L00/R0000029e/C0000027f.png" 
+            },            
+            { 
+                bounds: new OpenLayers.Bounds(308658.51534463,4303230.0164352, 325591.88254469,4311696.7000352),
+                url: roadsUrl + "/L00/R000002a0/C00000282.png"
+            },            
+            { 
+                bounds: new OpenLayers.Bounds(311136.39626998,4318933.8711555, 311678.26402038,4319204.8050307) ,
+                url: roadsUrl + "/L05/R000051e0/C00004e52.png" 
+            }
+        ];
+        t.plan( urlSets.length );
+    
+    
+        //perform the exact setup from the arcgiscache_direct example
+            
+        // First 4 variables extracted from conf.xml file        
+        // Tile layers & map MUST have same projection 
+        var proj='EPSG:26915';
+            
+        // Layer can also accept serverResolutions array
+        // to deal with situation in which layer resolution array & map resolution
+        // array are out of sync
+        var mapResolutions = [33.0729828126323,16.9333672000677,8.46668360003387,4.23334180001693,2.11667090000847,1.05833545000423];
+
+        // For this example this next line is not really needed, 256x256 is default.
+        // However, you would need to change this if your layer had different tile sizes 
+        var tileSize = new OpenLayers.Size(256,256);
+        
+        // Tile Origin is required unless it is the same as the implicit map origin
+        // which can be effected by several variables including maxExtent for map or base layer 
+        var agsTileOrigin = new OpenLayers.LonLat(-5120900,9998100);
+        
+        // This can really be any valid bounds that the map would reasonably be within 
+        var mapExtent = new OpenLayers.Bounds(289310.8204,4300021.937,314710.8712,4325421.988);
+        
+
+        var map = new OpenLayers.Map('map', {
+            maxExtent:mapExtent,
+            controls: [
+                new OpenLayers.Control.Navigation(),
+                new OpenLayers.Control.LayerSwitcher(), 
+                new OpenLayers.Control.PanZoomBar(),
+                new OpenLayers.Control.MousePosition()]
+        });
+
+        var layer = new OpenLayers.Layer.ArcGISCache('Roads', roadsUrl, {
+            tileOrigin: agsTileOrigin,
+            resolutions: mapResolutions,
+            sphericalMercator: true,
+            maxExtent: mapExtent,
+            useArcGISServer: false,
+            isBaseLayer: true,
+            projection: proj
+        });
+        
+        map.addLayers([layer]);
+        map.zoomToExtent(new OpenLayers.Bounds(-8341644, 4711236, -8339198, 4712459));
+
+        for(var i=0;i<urlSets.length;i++) 
+        {
+            var o = urlSets[i];            
+            map.zoomToExtent(o.bounds, true);
+            var resultUrl = layer.getURL(o.bounds);
+            t.ok( resultUrl == o.url, "correct tile returned for " + o.bounds);        
+        }
+    }
+        
+    /**
+     * Check our utility function for generating tile indexes against a file cache
+     */
+    function test_Layer_ARCGISCACHE_zeroPad(t) {
+        t.plan(4);
+    
+        var layer = new OpenLayers.Layer.ArcGISCache('test', null, { });
+
+        //some tile examples
+        t.ok('00000001' == layer.zeroPad(1, 8, 16), 'zeroPad should generate tile indexes properly ');
+        t.ok('00000020' == layer.zeroPad(32, 8, 16), 'zeroPad should generate tile indexes properly ');
+        t.ok('00000100' == layer.zeroPad(256, 8, 16), 'zeroPad should generate tile indexes properly ');
+        t.ok('00001000' == layer.zeroPad(4096, 8, 16), 'zeroPad should generate tile indexes properly ');        
+    }
+    
+    /**
+     * Check to ensure our LOD calculation will correctly avoid returning tile indexes less than zero
+     * (see http://trac.osgeo.org/openlayers/ticket/3169)
+     */
+    function test_Layer_ARCGISCACHE_tileBounds(t) {
+        t.plan(1);
+    
+        var layer = new OpenLayers.Layer.ArcGISCache('test', null, { });
+        var res = 264.583862501058;
+        layer.tileOrigin = new OpenLayers.LonLat(0.0, 650000.0);
+        layer.tileSize = new OpenLayers.Size(512, 512);
+        
+        // pick a point off the left of our tile origin  (would be a negative tile index)
+        var point = new OpenLayers.Geometry.Point(-123308.94829, 393128.85817);
+        
+        var tile = layer.getContainingTileCoords(point, res);
+        t.ok((tile.x >= 0 && tile.y >= 0), 'layer should not generate negative tile ranges for level of detail');
+    }
+
+  </script>
+</head>
+<body>
+<div id="map" style="width:500px;height:550px;"></div>
+</body>
+</html>

Copied: sandbox/cmoullet/openlayers/tests/Layer/ArcGISCache.json (from rev 11714, trunk/openlayers/tests/Layer/ArcGISCache.json)
===================================================================
--- sandbox/cmoullet/openlayers/tests/Layer/ArcGISCache.json	                        (rev 0)
+++ sandbox/cmoullet/openlayers/tests/Layer/ArcGISCache.json	2011-03-17 18:28:20 UTC (rev 11715)
@@ -0,0 +1,334 @@
+var capabilitiesObject = {
+  "currentVersion" : 10.01, 
+  "serviceDescription" : "This map is designed to be used as a base map by GIS professionals and as a reference map by anyone.  The base map includes administrative boundaries, cities, water features, physiographic features, parks, landmarks, highways, roads, railways, airports, and buildings overlaid on land cover and shaded relief imagery for added context. The map was compiled from a variety of best available sources from several data providers, including the U.S. Geological Survey, Food and Agriculture Organization of the United Nations, National Park Service, Tele Atlas, AND, and ESRI. The base map currently provides coverage for the world down to a scale of ~1:1m and coverage for the continental United States and Hawaii to a scale of ~1:20k.  The base map also includes detailed maps for selected cities in the United States including Portland, Oregon and Philadephia, Pennsylvania. The base map was designed and developed by ESRI based on the topographic map templates tha
 t are available through the ArcGIS Resource Centers. For more information on this map, visit us \u003ca href=\"http://goto.arcgisonline.com/maps/World_Topo_Map \" target=\"_new\"\u003eonline\u003c/a\u003e.", 
+  "mapName" : "Layers", 
+  "description" : "This map is designed to be used as a base map by GIS professionals and as a reference map by anyone.  The base map includes administrative boundaries, cities, water features, physiographic features, parks, landmarks, highways, roads, railways, airports, and buildings overlaid on land cover and shaded relief imagery for added context. The map was compiled from a variety of best available sources from several data providers, including the U.S. Geological Survey, Food and Agriculture Organization of the United Nations, National Park Service, Tele Atlas, AND, and ESRI. The base map currently provides coverage for the world down to a scale of ~1:1m and coverage for the continental United States and Hawaii to a scale of ~1:20k.  The base map also includes detailed maps for selected cities in the United States including Portland, Oregon and Philadephia, Pennsylvania. The base map was designed and developed by ESRI based on the topographic map templates that are a
 vailable through the ArcGIS Resource Centers. For more information on this map, visit us online at http://goto.arcgisonline.com/maps/World_Topo_Map", 
+  "copyrightText" : "Sources: USGS, FAO, NPS, EPA, ESRI, DeLorme, TANA, other suppliers", 
+  "layers" : [
+    {
+      "id" : 0, 
+      "name" : "Topographic Info", 
+      "parentLayerId" : -1, 
+      "defaultVisibility" : true, 
+      "subLayerIds" : [1, 2, 3, 4], 
+      "minScale" : 0, 
+      "maxScale" : 0
+    }, 
+    {
+      "id" : 1, 
+      "name" : "Elevation (m)", 
+      "parentLayerId" : 0, 
+      "defaultVisibility" : true, 
+      "subLayerIds" : null, 
+      "minScale" : 0, 
+      "maxScale" : 0
+    }, 
+    {
+      "id" : 2, 
+      "name" : "Elevation (ft)", 
+      "parentLayerId" : 0, 
+      "defaultVisibility" : true, 
+      "subLayerIds" : null, 
+      "minScale" : 0, 
+      "maxScale" : 0
+    }, 
+    {
+      "id" : 3, 
+      "name" : "Slope", 
+      "parentLayerId" : 0, 
+      "defaultVisibility" : true, 
+      "subLayerIds" : null, 
+      "minScale" : 0, 
+      "maxScale" : 0
+    }, 
+    {
+      "id" : 4, 
+      "name" : "Aspect", 
+      "parentLayerId" : 0, 
+      "defaultVisibility" : true, 
+      "subLayerIds" : null, 
+      "minScale" : 0, 
+      "maxScale" : 0
+    }, 
+    {
+      "id" : 5, 
+      "name" : "Places Info", 
+      "parentLayerId" : -1, 
+      "defaultVisibility" : true, 
+      "subLayerIds" : [6, 7, 8, 9], 
+      "minScale" : 0, 
+      "maxScale" : 0
+    }, 
+    {
+      "id" : 6, 
+      "name" : "Place Names (Country Level)", 
+      "parentLayerId" : 5, 
+      "defaultVisibility" : true, 
+      "subLayerIds" : null, 
+      "minScale" : 0, 
+      "maxScale" : 80000000
+    }, 
+    {
+      "id" : 7, 
+      "name" : "Place Names (State Level)", 
+      "parentLayerId" : 5, 
+      "defaultVisibility" : true, 
+      "subLayerIds" : null, 
+      "minScale" : 80000001, 
+      "maxScale" : 1500000
+    }, 
+    {
+      "id" : 8, 
+      "name" : "Place Names (County Level)", 
+      "parentLayerId" : 5, 
+      "defaultVisibility" : true, 
+      "subLayerIds" : null, 
+      "minScale" : 1500001, 
+      "maxScale" : 400000
+    }, 
+    {
+      "id" : 9, 
+      "name" : "Place Names (City Level)", 
+      "parentLayerId" : 5, 
+      "defaultVisibility" : true, 
+      "subLayerIds" : null, 
+      "minScale" : 399999, 
+      "maxScale" : 0
+    }, 
+    {
+      "id" : 10, 
+      "name" : "Scale Descriptions", 
+      "parentLayerId" : -1, 
+      "defaultVisibility" : true, 
+      "subLayerIds" : [11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26], 
+      "minScale" : 0, 
+      "maxScale" : 0
+    }, 
+    {
+      "id" : 11, 
+      "name" : "Level 15  ~1:18K", 
+      "parentLayerId" : 10, 
+      "defaultVisibility" : true, 
+      "subLayerIds" : null, 
+      "minScale" : 25000, 
+      "maxScale" : 15001
+    }, 
+    {
+      "id" : 12, 
+      "name" : "Level 14  ~1:36K", 
+      "parentLayerId" : 10, 
+      "defaultVisibility" : true, 
+      "subLayerIds" : null, 
+      "minScale" : 50000, 
+      "maxScale" : 25001
+    }, 
+    {
+      "id" : 13, 
+      "name" : "Level 13  ~1:72K", 
+      "parentLayerId" : 10, 
+      "defaultVisibility" : true, 
+      "subLayerIds" : null, 
+      "minScale" : 100000, 
+      "maxScale" : 50001
+    }, 
+    {
+      "id" : 14, 
+      "name" : "Level 12  ~1:144K", 
+      "parentLayerId" : 10, 
+      "defaultVisibility" : true, 
+      "subLayerIds" : null, 
+      "minScale" : 288000, 
+      "maxScale" : 100000
+    }, 
+    {
+      "id" : 15, 
+      "name" : "Level 11  ~1:288K", 
+      "parentLayerId" : 10, 
+      "defaultVisibility" : true, 
+      "subLayerIds" : null, 
+      "minScale" : 575000, 
+      "maxScale" : 288000
+    }, 
+    {
+      "id" : 16, 
+      "name" : "Level 10  ~1:577K", 
+      "parentLayerId" : 10, 
+      "defaultVisibility" : true, 
+      "subLayerIds" : null, 
+      "minScale" : 1150000, 
+      "maxScale" : 575000
+    }, 
+    {
+      "id" : 17, 
+      "name" : "Level 9    ~1:1.15M", 
+      "parentLayerId" : 10, 
+      "defaultVisibility" : true, 
+      "subLayerIds" : null, 
+      "minScale" : 2200000, 
+      "maxScale" : 1150000
+    }, 
+    {
+      "id" : 18, 
+      "name" : "Level 8    ~1:2.3M", 
+      "parentLayerId" : 10, 
+      "defaultVisibility" : true, 
+      "subLayerIds" : null, 
+      "minScale" : 4500000, 
+      "maxScale" : 2200000
+    }, 
+    {
+      "id" : 19, 
+      "name" : "Level 7    ~1:4.5M", 
+      "parentLayerId" : 10, 
+      "defaultVisibility" : true, 
+      "subLayerIds" : null, 
+      "minScale" : 9000000, 
+      "maxScale" : 4500000
+    }, 
+    {
+      "id" : 20, 
+      "name" : "Level 6    ~1:9.2M", 
+      "parentLayerId" : 10, 
+      "defaultVisibility" : true, 
+      "subLayerIds" : null, 
+      "minScale" : 18000000, 
+      "maxScale" : 9000000
+    }, 
+    {
+      "id" : 21, 
+      "name" : "Level 5    ~1:18M ", 
+      "parentLayerId" : 10, 
+      "defaultVisibility" : true, 
+      "subLayerIds" : null, 
+      "minScale" : 36000000, 
+      "maxScale" : 18000000
+    }, 
+    {
+      "id" : 22, 
+      "name" : "Level 4    ~1:36M", 
+      "parentLayerId" : 10, 
+      "defaultVisibility" : true, 
+      "subLayerIds" : null, 
+      "minScale" : 72000000, 
+      "maxScale" : 36000000
+    }, 
+    {
+      "id" : 23, 
+      "name" : "Level 3    ~1:72M", 
+      "parentLayerId" : 10, 
+      "defaultVisibility" : true, 
+      "subLayerIds" : null, 
+      "minScale" : 75500000, 
+      "maxScale" : 70000000
+    }, 
+    {
+      "id" : 24, 
+      "name" : "Level 2    ~1:147M", 
+      "parentLayerId" : 10, 
+      "defaultVisibility" : true, 
+      "subLayerIds" : null, 
+      "minScale" : 290000000, 
+      "maxScale" : 147000000
+    }, 
+    {
+      "id" : 25, 
+      "name" : "Level 1    ~1:292M", 
+      "parentLayerId" : 10, 
+      "defaultVisibility" : true, 
+      "subLayerIds" : null, 
+      "minScale" : 295000000, 
+      "maxScale" : 150000000
+    }, 
+    {
+      "id" : 26, 
+      "name" : "Level 0     ~1:584M", 
+      "parentLayerId" : 10, 
+      "defaultVisibility" : true, 
+      "subLayerIds" : null, 
+      "minScale" : 0, 
+      "maxScale" : 295000000
+    }, 
+    {
+      "id" : 27, 
+      "name" : "Citations", 
+      "parentLayerId" : -1, 
+      "defaultVisibility" : true, 
+      "subLayerIds" : null, 
+      "minScale" : 0, 
+      "maxScale" : 0
+    }
+  ], 
+  "tables" : [
+    
+  ], 
+  "spatialReference" : {
+    "wkid" : 102100
+  }, 
+  "singleFusedMapCache" : true, 
+  "tileInfo" : {
+    "rows" : 256, 
+    "cols" : 256, 
+    "dpi" : 96, 
+    "format" : "JPEG", 
+    "compressionQuality" : 90, 
+    "origin" : {
+      "x" : -20037508.342787, 
+      "y" : 20037508.342787
+    }, 
+    "spatialReference" : {
+      "wkid" : 102100
+    }, 
+    "lods" : [
+      {"level" : 0, "resolution" : 156543.033928, "scale" : 591657527.591555}, 
+      {"level" : 1, "resolution" : 78271.5169639999, "scale" : 295828763.795777}, 
+      {"level" : 2, "resolution" : 39135.7584820001, "scale" : 147914381.897889}, 
+      {"level" : 3, "resolution" : 19567.8792409999, "scale" : 73957190.948944}, 
+      {"level" : 4, "resolution" : 9783.93962049996, "scale" : 36978595.474472}, 
+      {"level" : 5, "resolution" : 4891.96981024998, "scale" : 18489297.737236}, 
+      {"level" : 6, "resolution" : 2445.98490512499, "scale" : 9244648.868618}, 
+      {"level" : 7, "resolution" : 1222.99245256249, "scale" : 4622324.434309}, 
+      {"level" : 8, "resolution" : 611.49622628138, "scale" : 2311162.217155}, 
+      {"level" : 9, "resolution" : 305.748113140558, "scale" : 1155581.108577}, 
+      {"level" : 10, "resolution" : 152.874056570411, "scale" : 577790.554289}, 
+      {"level" : 11, "resolution" : 76.4370282850732, "scale" : 288895.277144}, 
+      {"level" : 12, "resolution" : 38.2185141425366, "scale" : 144447.638572}, 
+      {"level" : 13, "resolution" : 19.1092570712683, "scale" : 72223.819286}, 
+      {"level" : 14, "resolution" : 9.55462853563415, "scale" : 36111.909643}, 
+      {"level" : 15, "resolution" : 4.77731426794937, "scale" : 18055.954822}, 
+      {"level" : 16, "resolution" : 2.38865713397468, "scale" : 9027.977411}, 
+      {"level" : 17, "resolution" : 1.19432856685505, "scale" : 4513.988705}, 
+      {"level" : 18, "resolution" : 0.597164283559817, "scale" : 2256.994353}, 
+      {"level" : 19, "resolution" : 0.298582141647617, "scale" : 1128.497176}
+    ]
+  }, 
+  "initialExtent" : {
+    "xmin" : -45223792.233066, 
+    "ymin" : -22882589.2065154, 
+    "xmax" : 45223792.233066, 
+    "ymax" : 22882589.2065155, 
+    "spatialReference" : {
+      "wkid" : 102100
+    }
+  }, 
+  "fullExtent" : {
+    "xmin" : -20037507.0671618, 
+    "ymin" : -19971868.8804086, 
+    "xmax" : 20037507.0671618, 
+    "ymax" : 19971868.8804086, 
+    "spatialReference" : {
+      "wkid" : 102100
+    }
+  }, 
+  "units" : "esriMeters", 
+  "supportedImageFormatTypes" : "PNG24,PNG,JPG,DIB,TIFF,EMF,PS,PDF,GIF,SVG,SVGZ,AI,BMP", 
+  "documentInfo" : {
+    "Title" : "World Topo Map", 
+    "Author" : "ESRI", 
+    "Comments" : "", 
+    "Subject" : "", 
+    "Category" : "", 
+    "Keywords" : "", 
+    "Credits" : ""
+  }, 
+  "capabilities" : "Map,Query,Data"
+};
\ No newline at end of file

Copied: sandbox/cmoullet/openlayers/tests/Protocol/Script.html (from rev 11714, trunk/openlayers/tests/Protocol/Script.html)
===================================================================
--- sandbox/cmoullet/openlayers/tests/Protocol/Script.html	                        (rev 0)
+++ sandbox/cmoullet/openlayers/tests/Protocol/Script.html	2011-03-17 18:28:20 UTC (rev 11715)
@@ -0,0 +1,271 @@
+<html>
+<head>
+  <script src="../../lib/OpenLayers.js"></script>
+  <script type="text/javascript">
+
+    function test_constructor(t) {
+        t.plan(11);
+        var a = new OpenLayers.Protocol.Script({
+            url: "foo"
+        });
+
+        // 7 tests
+        t.eq(a.url, "foo", "constructor sets url");
+        t.eq(a.options.url, a.url, "constructor copies url to options.url");
+        t.eq(a.params, {}, "constructor sets params");
+        t.eq(a.options.params, undefined, "constructor does not copy params to options.params");
+        t.ok(a.format instanceof OpenLayers.Format.GeoJSON,
+                "constructor sets a GeoJSON format by default");
+        t.eq(a.callbackKey, 'callback',
+                "callbackKey is set to 'callback' by default");
+        t.eq(a.callbackPrefix, '',
+                "callbackPrefix is set to '' by default");
+
+        var params = {hello: "world"};
+        var b = new OpenLayers.Protocol.Script({
+            url: "bar",
+            params: params,
+            callbackKey: 'cb_key',
+            callbackPrefix: 'cb_prefix'
+        });
+
+        // 6 tests
+        t.eq(b.params, params, "constructor sets params");
+        t.eq(b.options.params, b.params, "constructor copies params to options.params");
+        t.eq(b.callbackKey, 'cb_key',
+                "callbackKey is set to 'cb_key'");
+        t.eq(b.callbackPrefix, 'cb_prefix',
+                "callbackPrefix is set to 'cb_prefix'");
+    }
+
+    function test_destroy(t) {
+        t.plan(3);
+        var aborted = false;
+        var protocol = new OpenLayers.Protocol.Script({
+            url: "bar",
+            params: {hello: "world"},
+            abort: function() {
+                aborted = true;
+            }
+        });
+        protocol.destroy();
+        t.ok(aborted, "destroy aborts request");
+        t.eq(protocol.params, null, "destroy nullifies params");
+        t.eq(protocol.format, null, "destroy nullifies format");
+    }
+
+    function test_read(t) {
+        t.plan(5);
+        var protocol = new OpenLayers.Protocol.Script({
+            'url': 'foo_url',
+            'params': {'k': 'foo_param'}
+        });
+
+        // fake XHR request object
+        var request = {'status': 200};
+
+        // options to pass to read
+        var readOptions = {
+            'url': 'bar_url',
+            'params': {'k': 'bar_param'}
+        };
+
+        var response;
+
+        protocol.createRequest = function(url, params, callback) {
+            // 4 tests
+            t.ok(this == protocol,
+                'createRequest called with correct scope');
+            t.ok(url == readOptions.url,
+                'createRequest called with correct url');
+            t.ok(params == readOptions.params,
+                'createRequest called with correct params');
+            t.ok(callback instanceof Function,
+                'createRequest called with a function as callback');
+
+            return 'foo_request';
+       };
+
+        var resp = protocol.read(readOptions);
+
+        t.eq(resp.priv, 'foo_request',
+            'response priv property set to what the createRequest method returns');
+    }
+
+    function test_read_bbox(t) {
+        t.plan(6);
+
+        var _createRequest = OpenLayers.Protocol.Script.prototype.createRequest;
+
+        var bounds = new OpenLayers.Bounds(1, 2, 3, 4);
+        var filter = new OpenLayers.Filter.Spatial({
+            type: OpenLayers.Filter.Spatial.BBOX,
+            value: bounds,
+            projection: new OpenLayers.Projection("foo")
+        });
+
+        // log requests
+        var log, exp;
+        OpenLayers.Protocol.Script.prototype.createRequest = function(url, params,
+                                                               callback) {
+            log.push(params.bbox);
+            return null;
+        };
+
+        // 1) issue request with default protocol
+        log = [];
+        new OpenLayers.Protocol.Script().read({filter: filter});
+
+        t.eq(log.length, 1, "1) createRequest called once");
+        t.ok(log[0] instanceof Array, "1) bbox param is array");
+        exp = bounds.toArray();
+        t.eq(log[0], exp, "1) bbox param doesn't include SRS id by default");
+
+        // 2) issue request with default protocol
+        log = [];
+        new OpenLayers.Protocol.Script({srsInBBOX: true}).read({filter: filter});
+
+        t.eq(log.length, 1, "2) createRequest called once");
+        t.ok(log[0] instanceof Array, "2) bbox param is array");
+        exp = bounds.toArray();
+        exp.push("foo");
+        t.eq(log[0], exp, "2) bbox param includes SRS id if srsInBBOX is true");
+
+        OpenLayers.Protocol.Script.prototype.createRequest = _createRequest;
+    }
+
+    function test_createRequest(t) {
+        t.plan(3);
+        var protocol = new OpenLayers.Protocol.Script({
+            callbackKey: 'cb_key',
+            callbackPrefix: 'cb_prefix:'
+        });
+
+        var _register = OpenLayers.Protocol.Script.register;
+        OpenLayers.Protocol.Script.register = function() {
+            return 'bar';
+        };
+
+        var script = protocol.createRequest('http://bar_url/', {'k': 'bar_param'}, 'bar_callback');
+
+        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)',
+            'created script has a correct url');
+        t.eq(script.id, 'OpenLayers_Protocol_Script_bar',
+            'created script has a correct id');
+
+        OpenLayers.Protocol.Script.register = _register;
+    }
+
+    function test_destroyRequest(t) {
+        t.plan(2);
+
+        var protocol = new OpenLayers.Protocol.Script({});
+
+        var _unregister = OpenLayers.Protocol.Script.unregister;
+        OpenLayers.Protocol.Script.unregister = function(id) {
+            t.eq(id, 'foo', "destroyRequest calls unregister with correct id");
+        };
+        var script = {
+            id: 'script_foo'
+        };
+        protocol.destroyRequest(script);
+        t.eq(protocol.pendingRequests[script.id], null, 
+            "destroyRequest nullifies the pending request");
+
+        OpenLayers.Protocol.Script.unregister = _unregister;
+    }
+
+    function test_handleResponse(t) {
+        t.plan(8);
+
+        var protocol = new OpenLayers.Protocol.Script();
+
+        // 2 tests (should be called only twive)
+        protocol.destroyRequest = function(priv) {
+            t.eq(priv, 'foo_priv', 'destroyRequest called with correct argument');
+        }
+
+        // 1 test (should be called only once)
+        protocol.parseFeatures = function(data) {
+            t.eq(data, 'foo_data', 'parseFeatures called with correct argument');
+            return 'foo_features';
+        }
+
+        var response = {
+            priv: 'foo_priv',
+            data: 'foo_data'
+        }
+        var options = {
+            // 2 tests (should be called twice)
+            scope: 'foo_scope',
+            callback: function(resp) {
+                t.eq(this, 'foo_scope', 'callback called with correct scope');
+            }
+        }
+        protocol.handleResponse(response, options);
+        // 2 tests
+        t.eq(response.code, OpenLayers.Protocol.Response.SUCCESS,
+                'response code correctly set');
+        t.eq(response.features, 'foo_features', 
+                'response features takes a correct value');
+
+        response = {
+            priv: 'foo_priv'
+        }
+        protocol.handleResponse(response, options);
+        // 1 test
+        t.eq(response.code, OpenLayers.Protocol.Response.FAILURE,
+                'response code correctly set');
+    }
+
+    function test_parseFeatures(t) {
+        t.plan(1);
+
+        var protocol = new OpenLayers.Protocol.Script();
+
+        protocol.format = {
+            'read': function(data) {
+                t.ok(true, 'format.read called');
+            }
+        };
+
+        var ret = protocol.parseFeatures({foo: 'bar'});
+    }
+
+    function test_abort(t) {
+        t.plan(2);
+
+        var protocol = new OpenLayers.Protocol.Script();
+
+        // 1 test
+        protocol.destroyRequest = function(priv) {
+            t.eq(priv, 'foo_priv', 'destroyRequest called with correct argument');
+        }
+
+        var response = {
+            priv: 'foo_priv'
+        }
+
+        protocol.abort(response);
+
+        var calls = [];
+        protocol.pendingRequests = {
+            'foo': 'foo_request',
+            'bar': 'bar_request'
+        }
+        protocol.destroyRequest = function(priv) {
+            calls.push(priv);
+        }
+        protocol.abort();
+        // 1 test
+        t.eq(calls, ['foo_request', 'bar_request'],
+                'destroyRequest called for each pending requests');
+    }
+
+  </script>
+</head>
+<body>
+</body>
+</html>

Modified: sandbox/cmoullet/openlayers/tests/list-tests.html
===================================================================
--- sandbox/cmoullet/openlayers/tests/list-tests.html	2011-03-17 16:33:12 UTC (rev 11714)
+++ sandbox/cmoullet/openlayers/tests/list-tests.html	2011-03-17 18:28:20 UTC (rev 11715)
@@ -133,6 +133,7 @@
     <li>Layer.html</li>
     <li>Layer/ArcIMS.html</li> 
     <li>Layer/ArcGIS93Rest.html</li>
+    <li>Layer/ArcGISCache.html</li>
     <li>Layer/Bing.html</li>
     <li>Layer/EventPane.html</li>
     <li>Layer/FixedZoomLevels.html</li>
@@ -177,6 +178,7 @@
     <li>Projection.html</li>
     <li>Protocol.html</li>
     <li>Protocol/HTTP.html</li>
+    <li>Protocol/Script.html</li>
     <li>Protocol/SimpleFilterSerializer.html</li>
     <li>Protocol/SQL.html</li>
     <li>Protocol/SQL/Gears.html</li>

Modified: sandbox/cmoullet/openlayers/theme/default/style.css
===================================================================
--- sandbox/cmoullet/openlayers/theme/default/style.css	2011-03-17 16:33:12 UTC (rev 11714)
+++ sandbox/cmoullet/openlayers/theme/default/style.css	2011-03-17 18:28:20 UTC (rev 11715)
@@ -188,7 +188,7 @@
   background-repeat: no-repeat;
 }
 .olControlEditingToolbar  {
-    float:right;
+    top: 0px;
     right: 0px;
     height: 30px; 
     width: 200px;
@@ -319,6 +319,14 @@
     background-position: 0px 18px;
 }
 
+/* 
+ * When a potential text is bigger than the image it move the image
+ * with some headers (closes #3154) 
+ */
+.olControlPanZoomBar div {
+    font-size: 1px;
+}
+
 .olPopupCloseBox {
   background: url("img/close.gif") no-repeat;
   cursor: pointer;



More information about the Commits mailing list