[Commits] r945 - apps/opengeo/geoexplorer/trunk/lib
commits at geoext.org
commits at geoext.org
Tue Jun 2 18:58:11 CEST 2009
Author: tcoulter
Date: 2009-06-02 18:58:11 +0200 (Tue, 02 Jun 2009)
New Revision: 945
Modified:
apps/opengeo/geoexplorer/trunk/lib/GeoExplorer.js
Log:
extractConfiguration now produces the right server list, and attributes layers with the identier of the servers they come from.
Modified: apps/opengeo/geoexplorer/trunk/lib/GeoExplorer.js
===================================================================
--- apps/opengeo/geoexplorer/trunk/lib/GeoExplorer.js 2009-06-02 13:03:47 UTC (rev 944)
+++ apps/opengeo/geoexplorer/trunk/lib/GeoExplorer.js 2009-06-02 16:58:11 UTC (rev 945)
@@ -1155,7 +1155,9 @@
* :return: an :class:`Object` representing the app's current configuration.
*/
extractConfiguration: function() {
- var config = {};
+ var config = {
+ ows: {}
+ };
// Map configuration
@@ -1166,24 +1168,48 @@
zoom: this.map.zoom
};
+ var sourcesUsed = {};
+
//Layers configuration
config.map.layers = [];
+
+ this.layers.each(function(layerRecord){
+ var layer = layerRecord.get('layer');
+ if (layer.displayInLayerSwitcher) {
+
+ // BIG DIRTY HACK!
+ // There's no direct link between layers and their source.
+ // Let's muddle the url a bit and see if we can come up
+ // with something meaningful.
+ var url = layer.url.replace(/wms.*/, "ows").replace(/:80\//, "/")
+ var index = this.layerSources.find("url", url);
+ var source = this.layerSources.getAt(index);
+
+ if (source == null) {
+ OpenLayers.Console.error("Could not find source for layer '" + layerRecord.get("name") + "'");
+
+ // Return; error gracefully. (This is debatable.)
+ return;
+ }
- this.layers.each(function(layerRecord){
- if (layerRecord.get('layer').displayInLayerSwitcher) {
+ sourcesUsed[source.data.identifier] = url;
+
var c = {
- title: layerRecord.get("title"),
- name: (layerRecord.get("layer").params &&
- layerRecord.get("layer").params.LAYERS) ||
- layerRecord.get("name"),
- visibility: layerRecord.get("layer").getVisibility(),
- isBaseLayer: layerRecord.get("layer").isBaseLayer
+ name: layerRecord.get("name"),
+ visibility: layer.getVisibility(),
+ isBaseLayer: layer.isBaseLayer,
+ ows: source.data.identifier
};
config.map.layers.push(c);
}
- });
-
+ }, this);
+
+ // Source configuration
+ for (identifier in sourcesUsed) {
+ config.ows[identifier] = sourcesUsed[identifier];
+ }
+
return config;
},
More information about the Commits
mailing list