[Commits] r1973 - in sandbox/mapgears/geoext.ux/ux/WMSLayerAdder: examples lib/GeoExt.ux/widgets

commits at geoext.org commits at geoext.org
Tue Mar 16 17:05:08 CET 2010


Author: adube
Date: 2010-03-16 17:05:08 +0100 (Tue, 16 Mar 2010)
New Revision: 1973

Modified:
   sandbox/mapgears/geoext.ux/ux/WMSLayerAdder/examples/WMSLayerAdderInWindowExample.js
   sandbox/mapgears/geoext.ux/ux/WMSLayerAdder/lib/GeoExt.ux/widgets/WMSLayerAdder.js
Log:
wmslayeradder - srs compatibility checkup (new field)

Modified: sandbox/mapgears/geoext.ux/ux/WMSLayerAdder/examples/WMSLayerAdderInWindowExample.js
===================================================================
--- sandbox/mapgears/geoext.ux/ux/WMSLayerAdder/examples/WMSLayerAdderInWindowExample.js	2010-03-16 14:29:08 UTC (rev 1972)
+++ sandbox/mapgears/geoext.ux/ux/WMSLayerAdder/examples/WMSLayerAdderInWindowExample.js	2010-03-16 16:05:08 UTC (rev 1973)
@@ -59,7 +59,7 @@
 
         WMSLayerAdder = new GeoExt.ux.WMSLayerAdder({
             region: "east",
-            gridPanelOptions: {'height': 210},
+            gridPanelOptions: {'height': 260},
             serverStore: oServerStore,
             mapPanel: mapPanel
         });
@@ -69,7 +69,7 @@
             modal: true,
             closeAction: 'hide',
             width: 600,
-            height: 350,
+            height: 400,
             title: OpenLayers.i18n("WMSLayerAdder"),
             layout: 'fit',
             items: [WMSLayerAdder]

Modified: sandbox/mapgears/geoext.ux/ux/WMSLayerAdder/lib/GeoExt.ux/widgets/WMSLayerAdder.js
===================================================================
--- sandbox/mapgears/geoext.ux/ux/WMSLayerAdder/lib/GeoExt.ux/widgets/WMSLayerAdder.js	2010-03-16 14:29:08 UTC (rev 1972)
+++ sandbox/mapgears/geoext.ux/ux/WMSLayerAdder/lib/GeoExt.ux/widgets/WMSLayerAdder.js	2010-03-16 16:05:08 UTC (rev 1973)
@@ -233,17 +233,23 @@
     createWMSCapabilitiesStore: function(url) {
         this.WMSCapabilitiesStore = 
             new GeoExt.data.WMSCapabilitiesStore({'url': url});
+        this.WMSCapabilitiesStore.on(
+            'load', this.onWMSCapabilitiesStoreLoad, this);
         this.WMSCapabilitiesStore.load();
     },
 
     createGridPanel: function() {
         var columns = [
+            { header: OpenLayers.i18n('Add'),
+              dataIndex: "srsCompatible", hidden: false,
+              renderer: this.boolRenderer, width: 30},
             { header: OpenLayers.i18n('Title'), 
               dataIndex: "title", id: "title", sortable: true},
             { header: OpenLayers.i18n('Name'), 
               dataIndex: "name", sortable: true},
             { header: OpenLayers.i18n('Queryable'), 
-              dataIndex: "queryable", sortable: true, hidden: true},
+              dataIndex: "queryable", sortable: true, hidden: true, 
+              renderer: this.boolRenderer},
             { header: OpenLayers.i18n('Description'),
               dataIndex: "abstract", hidden: true}
         ];
@@ -305,13 +311,34 @@
                 fieldLabel: OpenLayers.i18n('Name'),
                 name: 'name'
             },{
+                xtype: 'radiogroup',
+                columns: 'auto',
                 fieldLabel: OpenLayers.i18n('Queryable'),
-                name: 'queryable'
+                name: 'queryable',
+                items: [{
+                    inputValue: "true",
+                    boxLabel: OpenLayers.i18n("Yes")
+                }, {
+                    inputValue: "",
+                    boxLabel: OpenLayers.i18n("No")
+                }]
             },{
+                xtype: 'radiogroup',
+                columns: 'auto',
+                fieldLabel: OpenLayers.i18n('Can add ?'),
+                name: 'srsCompatible',
+                items: [{
+                    inputValue: "true",
+                    boxLabel: OpenLayers.i18n("Yes")
+                }, {
+                    inputValue: "false",
+                    boxLabel: OpenLayers.i18n("No")
+                }]
+            },{
                 xtype: 'textarea',
                 fieldLabel: OpenLayers.i18n('Description'),
                 name: 'abstract',
-                anchor: '100% -15'
+                anchor: '100% -30'
             }]
         };
 
@@ -368,6 +395,14 @@
         var grid = Ext.getCmp('wms_capabilities_grid_panel');
         var record = grid.getSelectionModel().getSelected();
         if(record) {
+            // check the projection of the map is supported by the layer
+            if (record.get("srsCompatible") === false) {
+                var error = "This layer can't be added to the current map" + 
+                            " because it doesn't support its projection.";
+                alert(OpenLayers.i18n(error));
+                return;
+            }
+
             var copy = record.copy();
 
             // the following line gives "too much recursion".
@@ -385,6 +420,30 @@
                 OpenLayers.Bounds.fromArray(copy.get("llbbox"))
             );
         }
+    },
+
+    onWMSCapabilitiesStoreLoad: function(store, records, options) {
+        var srs = this.mapPanel.map.getProjection();
+
+        // loop through all records (layers) to see if they contain the current
+        // map projection
+        for(var i=0; i<records.length; i++) {
+            var record = records[i];
+
+            // Check if the 'srs' contains a 'key' named by the srs OR
+            // Check if the 'srs' is an array and contains the srs
+            if(record.get('srs')[srs] === true ||
+               OpenLayers.Util.indexOf(record.get('srs'), srs) >= 0) {
+                record.set("srsCompatible", true);
+            } else {
+                record.set("srsCompatible", false);
+            }
+        }
+    },
+
+    boolRenderer: function(bool) {
+        return (bool)
+            ? '<span style="color:green;">' + OpenLayers.i18n("Yes") + '</span>'
+            : '<span style="color:red;">' + OpenLayers.i18n("No") + '</span>';
     }
-
 });



More information about the Commits mailing list