[Commits] r892 - in apps/opengeo/geoexplorer/trunk: . lib script

commits at geoext.org commits at geoext.org
Thu May 28 23:30:25 CEST 2009


Author: tcoulter
Date: 2009-05-28 23:30:25 +0200 (Thu, 28 May 2009)
New Revision: 892

Modified:
   apps/opengeo/geoexplorer/trunk/debug.html
   apps/opengeo/geoexplorer/trunk/embed-debug.html
   apps/opengeo/geoexplorer/trunk/lib/GeoExplorer.js
   apps/opengeo/geoexplorer/trunk/script/GeoExplorer-debug.js
Log:
Multiple WMS's. This will break the layer window entirely until #206 can be finished.

Modified: apps/opengeo/geoexplorer/trunk/debug.html
===================================================================
--- apps/opengeo/geoexplorer/trunk/debug.html	2009-05-28 21:28:46 UTC (rev 891)
+++ apps/opengeo/geoexplorer/trunk/debug.html	2009-05-28 21:30:25 UTC (rev 892)
@@ -29,15 +29,23 @@
         <script>
             Ext.BLANK_IMAGE_URL = "theme/img/blank.gif";
             var app = new GeoExplorer.Full({
-                ows: "/geoserver/ows",
+                proxy: "/cgi-bin/proxy.cgi?url=",
+                ows: {
+                    "sigma": "http://sigma.openplans.org/geoserver/ows",
+                    "geo": "http://geo.openplans.org/geoserver/ows",
+                    "demo": "http://demo.opengeo.org/geoserver/ows"
+                },
                 map: {
                     layers: [{
-                        name: "topp:states"
-                    },
-                    {
-                        name: "topp:bluemarble",
-                        isBaseLayer: true
-                     
+                        name: "openstreetmap",
+                        ows: "demo",
+                        isBaseLayer: true  
+                    },{
+                        name: "nurc:Img_Sample",
+                        ows: "geo"
+                    },{
+                        name: "topp:states",
+                        ows: "sigma"
                     }],
                     center: [-96.7, 37.6],
                     zoom: 4

Modified: apps/opengeo/geoexplorer/trunk/embed-debug.html
===================================================================
--- apps/opengeo/geoexplorer/trunk/embed-debug.html	2009-05-28 21:28:46 UTC (rev 891)
+++ apps/opengeo/geoexplorer/trunk/embed-debug.html	2009-05-28 21:30:25 UTC (rev 892)
@@ -4,6 +4,7 @@
         <title>GeoExplorer Embedded (debug)</title>
         
         <!-- This file is expected to go into an iframe. -->
+        <script type="text/javascript" src="externals/openlayers/lib/Firebug/firebug.js"></script>
         
         <!-- Ext resources -->
         <link rel="stylesheet" type="text/css" href="externals/ext/resources/css/ext-all.css" />
@@ -31,8 +32,11 @@
             Ext.BLANK_IMAGE_URL = "theme/img/blank.gif";
             var app = new GeoExplorer.Embed({
                 ows: "/geoserver/ows",
-                map: {
-                    layers: [{
+                 map: {
+                    layers: [
+                    {
+                        name: "nurc:Img_Sample"
+                    },{
                         name: "topp:states"
                     }],
                     center: [-96.7, 37.6],

Modified: apps/opengeo/geoexplorer/trunk/lib/GeoExplorer.js
===================================================================
--- apps/opengeo/geoexplorer/trunk/lib/GeoExplorer.js	2009-05-28 21:28:46 UTC (rev 891)
+++ apps/opengeo/geoexplorer/trunk/lib/GeoExplorer.js	2009-05-28 21:30:25 UTC (rev 892)
@@ -77,6 +77,8 @@
      *     we can insert responses from multiple requests.
      */
     popupCache: {},
+    
+    layerSources: null,
 
     /**
      * Method: load
@@ -84,51 +86,82 @@
      *     prepares the application for use.
      */
     load: function() {
+        
+        this.layerSources = new Ext.data.SimpleStore({
+            fields: ["id", "name", "store"],
+            data: []
+        });
+        
+        var dispatchQueue = [
+            // create layout as soon as Ext says ready
+            function(done) {
+                Ext.onReady(function() {
+                    this.createLayout();
+                    done();
+                }, this);
+            }
+        ];
+        
+        for (var id in this.ows) {
+            
+            // Load capabilities for each ows passed in.
+            dispatchQueue.push(
+                (function(id) {
+                    // Create a new scope for 'id'.
+                    return function(done){
+                        var store = new GeoExt.data.WMSCapabilitiesStore();
+                        var url = this.createWMSCapabilitiesURL(this.ows[id])
+                        
+                        OpenLayers.Request.GET({
+                            proxy: this.proxy, 
+                            url: url,
+                            success: function(request){
+                                var data = request.responseXML || request.responseText
+                                store.loadData(data);
+                                
+                                var record = new this.layerSources.recordType({
+                                    store: store,
+                                    id: id
+                                });
+                                
+                                this.layerSources.add(record);
+                                done();
+                            },
+                            failure: function(){
+                                OpenLayers.Console.error("Couldn't get capabilities document for ows '" + id + "'.");
+                                done();
+                            },
+                            scope: this
+                        });
+                    } 
+                })(id)
+            );
+        }
+        
         this.dispatch(
-            [
-                // create layout as soon as Ext says ready
-                function(done) {
-                    Ext.onReady(function() {
-                        this.createLayout();
-                        done();
-                    }, this);
-                },
-                // load capabilities immediately
-                function(done) {
-                    this.initCapabilities();
-                    this.capabilities.load({
-                        callback: done
-                    });
-                }
-            ],
+            dispatchQueue,
+            
             // activate app when the above are both done
             this.activate
         );
     },
     
-    /**
-     * Method: initCapabilities
-     */
-    initCapabilities: function() {        
-        var url;
+    createWMSCapabilitiesURL: function(url) {
         var args = {
             SERVICE: "WMS",
             REQUEST: "GetCapabilities"
         };
-        var argIndex = this.ows.indexOf("?");
+        var argIndex = url.indexOf("?");
         if(argIndex > -1) {
-            var search = this.ows.substring(this.ows.indexOf("?")+1);
-            var url = this.ows.replace(search, Ext.urlEncode(Ext.apply(
+            var search = url.substring(url.indexOf("?")+1);
+            url = url.replace(search, Ext.urlEncode(Ext.apply(
                 Ext.urlDecode(search), args
             )));
         } else {
-            url = this.ows + "?" + Ext.urlEncode(args);
+            url = url + "?" + Ext.urlEncode(args);
         }
-        if(this.proxy) {
-            url = this.proxy + encodeURIComponent(url);
-        }
-        
-        this.capabilities = new GeoExt.data.WMSCapabilitiesStore({url: url});
+
+        return url;
     },
     
     /**
@@ -140,7 +173,7 @@
         // create the map
         // TODO: check this.initialConfig.map for any map options
         this.map = new OpenLayers.Map({
-//          allOverlays: true,
+            allOverlays: true,
             controls: [new OpenLayers.Control.PanPanel(),
                        new OpenLayers.Control.ZoomPanel()]
         });
@@ -376,30 +409,40 @@
         var mapConfig = this.initialConfig.map;
 
         if(mapConfig && mapConfig.layers) {
-            var conf, id, record, layer, records = [];
-            for(var i=0; i<mapConfig.layers.length; ++i) {
-                conf = mapConfig.layers[i];
-                id = this.capabilities.find("name", conf.name);
-                if(id >= 0) {
-                    record = this.capabilities.getAt(id).copy();
-                    layer = record.get("layer");
+            var records = [];
+            
+            for(var i = 0; i < mapConfig.layers.length; ++i) {
+                var conf = mapConfig.layers[i];
+                var index = this.layerSources.find("id", conf.ows);
+                
+                if (index == -1) {
+                    continue;
+                }
+                
+                var record = this.layerSources.getAt(index);
+                var store = record.data.store;
 
+                var id = store.find("name", conf.name);
+                
+                if (id >= 0) {
+                    var record = store.getAt(id).copy();
+                    var layer = record.get("layer");
+                    
                     // set layer max extent from capabilities
                     // TODO: make this SRS independent
                     layer.restrictedExtent = OpenLayers.Bounds.fromArray(record.get("llbbox"));
-
+                    
                     if (this.alignToGrid) {
                         layer.maxExtent = new OpenLayers.Bounds(-180, -90, 180, 90);
                     } else {
                         layer.maxExtent = layer.restrictedExtent;
                     }
-
+                    
                     // set layer visibility from config
-                    layer.visibility = ("visibility" in conf) ?
-                        conf.visibility : true;
+                    layer.visibility = ("visibility" in conf) ? conf.visibility : true;
                     
                     // set layer title from config
-                    if(conf.title) {
+                    if (conf.title) {
                         layer.name = conf.title;
                     }
                     
@@ -409,7 +452,9 @@
                     // set any other layer configuration
                     records.push(record);
                 }
+                
             }
+            
             this.layers.add(records);
             
             // set map center
@@ -465,14 +510,6 @@
                     scope : this
                 }),
                 new Ext.Button({
-                    text: "Add Base Layers",
-                    iconCls: "icon-addlayers",
-                    handler: function(){
-                        capGridPanel.addLayers(true);
-                    },
-                    scope : this
-                }),
-                new Ext.Button({
                     text: "Done",
                     handler: function() {
                         this.capGrid.hide();
@@ -957,7 +994,7 @@
      * Returns an object that represents the app's current configuration.
      *
      * Returns:
-     * {Object} An object that represents the app's current configuration.
+     *{Object} An object that represents the app's current configuration.
      */ 
     extractConfiguration: function(){
         var config = {};
@@ -974,27 +1011,19 @@
         //Layers configuration
         config.map.layers = [];
 
-        // If there is a visible baselayer, it needs to be added last to avoid 
-        // issues with deferred rendering.
-        var activeBaseMap = null; 
+        this.layers.each(function(layerRecord){
 
-        this.layers.each(function(layerRecord){
             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
+                visibility: layerRecord.get("layer").getVisibility()
             };
 
-            if (!activeBaseMap && c.visibility && c.isBaseLayer) 
-                activeBaseMap = c;
-            else 
-                config.map.layers.push(c);
+            config.map.layers.push(c);
         });
 
-        if (activeBaseMap) config.map.layers.push(activeBaseMap);
-
         return config;
     },
 
@@ -1009,3 +1038,4 @@
         win.show();
     }
 });
+

Modified: apps/opengeo/geoexplorer/trunk/script/GeoExplorer-debug.js
===================================================================
--- apps/opengeo/geoexplorer/trunk/script/GeoExplorer-debug.js	2009-05-28 21:28:46 UTC (rev 891)
+++ apps/opengeo/geoexplorer/trunk/script/GeoExplorer-debug.js	2009-05-28 21:30:25 UTC (rev 892)
@@ -13,7 +13,8 @@
         "lib/GeoExplorer/LayerMenuItem.js",
         "lib/GeoExplorer/CapabilitiesGrid.js",
         "lib/GeoExplorer/Full/Full.js",
-        "lib/GeoExplorer/Embed/Embed.js"
+        "lib/GeoExplorer/Embed/Embed.js",
+        "lib/GeoExplorer/EventfulWMSCapabilitiesReader.js"
     );
 
     var appendable = !(/MSIE/.test(navigator.userAgent) ||



More information about the Commits mailing list