[Commits] r594 - apps/opengeo/geoexplorer/trunk/lib
commits at geoext.org
commits at geoext.org
Mon May 4 22:04:16 CEST 2009
Author: dwins
Date: 2009-05-04 22:04:16 +0200 (Mon, 04 May 2009)
New Revision: 594
Modified:
apps/opengeo/geoexplorer/trunk/lib/CapabilitiesGrid.js
apps/opengeo/geoexplorer/trunk/lib/GeoExplorer.js
Log:
Add support for TMS-friendly mode and have the getfeatureinfo control look at the layer url instead of just the capabilities url, fixing #187 and #188
Modified: apps/opengeo/geoexplorer/trunk/lib/CapabilitiesGrid.js
===================================================================
--- apps/opengeo/geoexplorer/trunk/lib/CapabilitiesGrid.js 2009-05-04 18:44:24 UTC (rev 593)
+++ apps/opengeo/geoexplorer/trunk/lib/CapabilitiesGrid.js 2009-05-04 20:04:16 UTC (rev 594)
@@ -101,9 +101,45 @@
*/
layer = record.get("layer");
layer.maxExtent = OpenLayers.Bounds.fromArray(record.get("llbbox"));
+
+ if (this.alignToGrid) {
+ layer.maxExtent = this.mungeBounds(layer.maxExtent);
+ }
+
this.mapPanel.layers.add(record);
}
+ },
+
+ mungeBounds: function(bounds) {
+ var maxTileSize = 180.0;
+
+ var extentSize = Math.max(bounds.getWidth(), bounds.getHeight());
+ var zoomLevel =
+ Math.round((Math.log(maxTileSize / extentSize) / Math.log(2)));
+ var tileSize = maxTileSize / Math.pow(2, zoomLevel);
+
+ var colIndex0 = Math.floor(bounds.left / tileSize);
+ var colIndex1 = Math.ceil(bounds.right / tileSize) - 1;
+
+ var rowIndex0 = Math.floor(bounds.bottom / tileSize);
+ var rowIndex1 = Math.ceil(bounds.top / tileSize) - 1;
+
+ while (colIndex0 != colIndex1 || rowIndex0 != rowIndex1) {
+ tileSize = tileSize * 2;
+
+ colIndex0 = Math.floor(bounds.left / tileSize);
+ colIndex1 = Math.ceil(bounds.right / tileSize) - 1;
+
+ rowIndex0 = Math.floor(bounds.bottom / tileSize);
+ rowIndex1 = Math.ceil(bounds.top / tileSize) - 1;
+ }
+
+ var x0 = colIndex0 * tileSize;
+ var y0 = rowIndex0 * tileSize;
+ var x1 = x0 + tileSize;
+ var y1 = y0 + tileSize;
+
+ return new OpenLayers.Bounds(x0, y0, x1, y1);
}
-
-});
\ No newline at end of file
+});
Modified: apps/opengeo/geoexplorer/trunk/lib/GeoExplorer.js
===================================================================
--- apps/opengeo/geoexplorer/trunk/lib/GeoExplorer.js 2009-05-04 18:44:24 UTC (rev 593)
+++ apps/opengeo/geoexplorer/trunk/lib/GeoExplorer.js 2009-05-04 20:04:16 UTC (rev 594)
@@ -14,6 +14,8 @@
* Valid config properties:
* map - {Object} Map configuration object.
* ows - {String} OWS URL
+ * alignToGrid - {boolean} if true, align tile requests to the grid enforced by
+ * tile caches such as GeoWebCache or Tilecache
*
* Valid map config properties:
* layers - {Array} A list of layer configuration objects.
@@ -56,6 +58,12 @@
mapPanel: null,
/**
+ * Property: alignToGrid
+ * whether or not to restrict tile request to tiled mapping service recommendation
+ */
+ alignToGrid: false,
+
+ /**
* Property: capGrid
* {<Ext.Window>} A window which includes a CapabilitiesGrid panel.
*/
@@ -347,10 +355,13 @@
// set layer max extent from capabilities
// TODO: make this SRS independent
- layer.maxExtent = OpenLayers.Bounds.fromArray(
- record.get("llbbox")
- );
+ layer.maxExtent = OpenLayers.Bounds.fromArray(record.get("llbbox"));
+ if (this.alignToGrid) {
+ layer.maxExtent =
+ CapabilitiesGrid.prototype.mungeBounds(layer.maxExtent);
+ }
+
// set layer visibility from config
layer.visibility = ("visibility" in conf) ?
conf.visibility : true;
@@ -392,6 +403,7 @@
layout: 'fit',
region: 'center',
autoScroll: true,
+ alignToGrid: this.alignToGrid,
listeners: {
rowdblclick: function(panel, index, evt) {
panel.addLayers();
@@ -583,6 +595,11 @@
//alert(queryableLayers.items.length);
var layerObjects = [];
queryableLayers.each(function(x){layerObjects.push(x.data.layer);});
+
+ if (queryableLayers.length > 0) {
+ infoControl.url = queryableLayers[0];
+ }
+
infoControl.layers = layerObjects;
};
More information about the Commits
mailing list