[Commits] r1400 - in core/trunk/geoext: lib/GeoExt/data tests/lib/GeoExt/data

commits at geoext.org commits at geoext.org
Fri Oct 9 08:25:51 CEST 2009


Author: bbinet
Date: 2009-10-09 08:25:50 +0200 (Fri, 09 Oct 2009)
New Revision: 1400

Modified:
   core/trunk/geoext/lib/GeoExt/data/WMSCapabilitiesReader.js
   core/trunk/geoext/tests/lib/GeoExt/data/WMSCapabilitiesReader.html
Log:
Add support for giving default layer options to WMSCapabilitiesReader. r=elemoine,ahocevar,tschaub (closes #152)

Modified: core/trunk/geoext/lib/GeoExt/data/WMSCapabilitiesReader.js
===================================================================
--- core/trunk/geoext/lib/GeoExt/data/WMSCapabilitiesReader.js	2009-10-08 20:16:40 UTC (rev 1399)
+++ core/trunk/geoext/lib/GeoExt/data/WMSCapabilitiesReader.js	2009-10-09 06:25:50 UTC (rev 1400)
@@ -20,7 +20,9 @@
 /** api: constructor
  *  .. class:: WMSCapabilitiesReader(meta, recordType)
  *  
- *      :param meta: ``Object`` Reader configuration.
+ *      :param meta: ``Object`` Reader configuration from which 
+ *          ``layerOptions`` is an optional object passed as default options
+ *          to the ``OpenLayers.Layer.WMS`` constructor.
  *      :param recordType: ``Array | Ext.data.Record`` An array of field
  *          configuration objects or a record object.  Default is
  *          :class:`GeoExt.data.LayerRecord` with the following additional
@@ -170,6 +172,16 @@
         for(var i=0, len=capability.layers.length; i<len; i++){
             layer = layers[i];
             if(layer.name) {
+                var options = {
+                    attribution: layer.attribution ?
+                        this.attributionMarkup(layer.attribution) :
+                        undefined,
+                    minScale: layer.minScale,
+                    maxScale: layer.maxScale
+                };
+                if(this.meta.layerOptions) {
+                    Ext.apply(options, this.meta.layerOptions);
+                }
                 var l = new OpenLayers.Layer.WMS(
                     layer.title || layer.name,
                     url,
@@ -179,13 +191,8 @@
                         format: this.imageFormat(layer),
                         transparent: this.imageTransparent(layer),
                         version: version
-                    }, {
-                        attribution: layer.attribution ?
-                            this.attributionMarkup(layer.attribution) :
-                            undefined,
-                        minScale: layer.minScale,
-                        maxScale: layer.maxScale
-                    }
+                    }, 
+                    options
                 );
                 records.push(new this.recordType(Ext.apply(layer, {
                     layer: l

Modified: core/trunk/geoext/tests/lib/GeoExt/data/WMSCapabilitiesReader.html
===================================================================
--- core/trunk/geoext/tests/lib/GeoExt/data/WMSCapabilitiesReader.html	2009-10-08 20:16:40 UTC (rev 1399)
+++ core/trunk/geoext/tests/lib/GeoExt/data/WMSCapabilitiesReader.html	2009-10-09 06:25:50 UTC (rev 1400)
@@ -33,9 +33,13 @@
                  'field values set from configuration are correct');
         }
         function test_read(t) {
-            t.plan(35);
+            t.plan(36);
 
-            var reader = new GeoExt.data.WMSCapabilitiesReader();
+            var reader = new GeoExt.data.WMSCapabilitiesReader({
+                layerOptions: {
+                    singleTile: true
+                }
+            });
 
             var records = reader.read({responseXML: doc});
 
@@ -97,7 +101,7 @@
             t.eq(record.get("identifiers").gcmd, "id_value", "[2] correct identifiers attribute");
             // cannot test "dimensions" until we have nested layers: see http://trac.openlayers.org/ticket/2144
 
-            //6 tests -- Testing the layer field
+            //7 tests -- Testing the layer field
             record = records.records[2];
             layer = record.get("layer");
             t.eq(layer.CLASS_NAME, "OpenLayers.Layer.WMS", "[2] layer field is of type OpenLayers.Layer.WMS");
@@ -106,6 +110,7 @@
             t.eq(layer.name, "Manhattan (NY) roads","[2] layer field has correct name");
             t.eq(typeof(layer.minScale), "number","[2] layer minScale has been set");
             t.eq(typeof(layer.maxScale), "number","[2] layer maxScale has been set");
+            t.eq(layer.singleTile, true, "[2] layer field has correct singleTile attribute (from WMSCapabilitiesReader constructor)");
             
             // 3 tests -- attribution markup
             record = records.records[2];



More information about the Commits mailing list