[Commits] r595 - apps/opengeo/geoexplorer/trunk/lib

commits at geoext.org commits at geoext.org
Tue May 5 02:09:55 CEST 2009


Author: dwins
Date: 2009-05-05 02:09:55 +0200 (Tue, 05 May 2009)
New Revision: 595

Modified:
   apps/opengeo/geoexplorer/trunk/lib/CapabilitiesGrid.js
Log:
Handle the case where no tile alignment works (ie, the layer overlaps both the eastern and western hemisphere), thereby avoiding an infinite loop.


Modified: apps/opengeo/geoexplorer/trunk/lib/CapabilitiesGrid.js
===================================================================
--- apps/opengeo/geoexplorer/trunk/lib/CapabilitiesGrid.js	2009-05-04 20:04:16 UTC (rev 594)
+++ apps/opengeo/geoexplorer/trunk/lib/CapabilitiesGrid.js	2009-05-05 00:09:55 UTC (rev 595)
@@ -115,6 +115,11 @@
         var maxTileSize = 180.0;
 
         var extentSize = Math.max(bounds.getWidth(), bounds.getHeight());
+
+        if (extentSize > maxTileSize) {
+            return new OpenLayers.Bounds(-180, -90, 180, 90);
+        }
+
         var zoomLevel = 
             Math.round((Math.log(maxTileSize / extentSize) / Math.log(2)));
         var tileSize = maxTileSize / Math.pow(2, zoomLevel);
@@ -125,7 +130,8 @@
         var rowIndex0 = Math.floor(bounds.bottom / tileSize);
         var rowIndex1 = Math.ceil(bounds.top / tileSize) - 1;
 
-        while (colIndex0 != colIndex1 || rowIndex0 != rowIndex1) {
+        while (tileSize < maxTileSize && 
+            (colIndex0 != colIndex1 || rowIndex0 != rowIndex1)) {
             tileSize = tileSize * 2;
 
             colIndex0 = Math.floor(bounds.left / tileSize);
@@ -135,6 +141,10 @@
             rowIndex1 = Math.ceil(bounds.top / tileSize) - 1;
         }
 
+        if (tileSize >= maxTileSize) {
+            return new OpenLayers.Bounds(-180, -90, 180, 90);
+        }
+
         var x0 = colIndex0 * tileSize;
         var y0 = rowIndex0 * tileSize;
         var x1 = x0 + tileSize;



More information about the Commits mailing list