[Commits] r1333 - in sandbox/camptocamp/geobretagne: lib/GeoExt/data tests/lib/GeoExt/data

commits at geoext.org commits at geoext.org
Mon Aug 24 12:59:36 CEST 2009


Author: elemoine
Date: 2009-08-24 12:59:36 +0200 (Mon, 24 Aug 2009)
New Revision: 1333

Modified:
   sandbox/camptocamp/geobretagne/lib/GeoExt/data/WMSCapabilitiesReader.js
   sandbox/camptocamp/geobretagne/tests/lib/GeoExt/data/LayerReader.html
   sandbox/camptocamp/geobretagne/tests/lib/GeoExt/data/WMSCapabilitiesReader.html
   sandbox/camptocamp/geobretagne/tests/lib/GeoExt/data/WMSCapabilitiesReader.js
Log:
revert all our patches to WMSCapabilitiesReader (#152, #151, #150, #126)


Modified: sandbox/camptocamp/geobretagne/lib/GeoExt/data/WMSCapabilitiesReader.js
===================================================================
--- sandbox/camptocamp/geobretagne/lib/GeoExt/data/WMSCapabilitiesReader.js	2009-08-21 17:29:27 UTC (rev 1332)
+++ sandbox/camptocamp/geobretagne/lib/GeoExt/data/WMSCapabilitiesReader.js	2009-08-24 10:59:36 UTC (rev 1333)
@@ -40,25 +40,15 @@
                 {name: "name", type: "string"},
                 {name: "abstract", type: "string"},
                 {name: "queryable", type: "boolean"},
-                {name: "opaque", type: "boolean"},
-                {name: "noSubsets", type: "boolean"},
-                {name: "cascaded", type: "int"},
-                {name: "fixedWidth", type: "int"},
-                {name: "fixedHeight", type: "int"},
-                {name: "minScale", type: "float"},
-                {name: "maxScale", type: "float"},
-                {name: "prefix", type: "string"},
-                {name: "formats"}, // array
-                {name: "styles"}, // array
-                {name: "srs"}, // object
-                {name: "dimensions"}, // object
-                {name: "bbox"}, // object
-                {name: "llbbox"}, // array
-                {name: "attribution"}, // object
-                {name: "keywords"}, // array
-                {name: "identifiers"}, // object
-                {name: "authorityURLs"}, // object
-                {name: "metadataURLs"} // array
+                {name: "formats"},
+                {name: "styles"},
+                {name: "llbbox"},
+                {name: "minScale"},
+                {name: "maxScale"},
+                {name: "prefix"},
+                {name: "attribution"},
+                {name: "keywords"},
+                {name: "metadataURLs"}
             ]
         );
     }
@@ -90,48 +80,9 @@
         }
         return this.readRecords(data);
     },
-    
-    /** private: method[serviceExceptionFormat]
-     *  :param formats: ``Array`` An array of service exception format strings.
-     *  :return: ``String`` The (supposedly) best service exception format.
-     */
-    serviceExceptionFormat: function(formats) {
-        if (OpenLayers.Util.indexOf(formats, 
-            "application/vnd.ogc.se_inimage")>-1) {
-            return "application/vnd.ogc.se_inimage";
-        }
-        if (OpenLayers.Util.indexOf(formats, 
-            "application/vnd.ogc.se_xml")>-1) {
-            return "application/vnd.ogc.se_xml";
-        }
-        return formats[0];
-    },
-    
-    /** private: method[imageFormat]
-     *  :param formats: ``Object`` The layer's capabilities object.
-     *  :return: ``String`` The (supposedly) best mime type for requesting 
-     *      tiles.
-     */
-    imageFormat: function(layer) {
-        var formats = layer.formats;
-        if (!layer.queryable && 
-            OpenLayers.Util.indexOf(formats, "image/jpeg")>-1) {
-            return "image/jpeg";
-        }
-        if (OpenLayers.Util.indexOf(formats, "image/png")>-1) {
-            return "image/png";
-        }
-        if (OpenLayers.Util.indexOf(formats, "image/png; mode=24bit")>-1) {
-            return "image/png; mode=24bit";
-        }
-        if (OpenLayers.Util.indexOf(formats, "image/gif")>-1) {
-            return "image/gif";
-        }
-        return formats[0];
-    },
 
     /** private: method[readRecords]
-     *  :param data: ``DOMElement | String | Object`` A document element or XHR
+     *  :param data: ``DOMElement | Strint | Object`` A document element or XHR
      *      response string.  As an alternative to fetching capabilities data
      *      from a remote source, an object representing the capabilities can
      *      be provided given that the structure mirrors that returned from the
@@ -142,45 +93,28 @@
      *  Create a data block containing Ext.data.Records from an XML document.
      */
     readRecords: function(data) {
+        
         if(typeof data === "string" || data.nodeType) {
             data = this.meta.format.read(data);
         }
-        var capability = data.capability;
-        var url = capability.request.getmap.href;
+        var url = data.capability.request.getmap.href;
         var records = [], layer;        
 
-        for(var i=0, len=capability.layers.length; i<len; i++){
-            layer = capability.layers[i];
+        for(var i=0, len=data.capability.layers.length; i<len; i++){
+            layer = data.capability.layers[i];
+
             if(layer.name) {
-                var options = {
-                    queryable: layer.queryable != undefined ? 
-                        layer.queryable : undefined,
-                    minScale: layer.minScale != undefined ? 
-                        layer.minScale : undefined,
-                    maxScale: layer.maxScale != undefined ? 
-                        layer.maxScale : undefined,
-                    attribution: layer.attribution ?
-                        this.attributionMarkup(layer.attribution) :
-                        undefined
-                };
-                if (this.meta.layerOptions) {
-                    Ext.apply(options, this.meta.layerOptions);
-                }
-                var l = new OpenLayers.Layer.WMS(
-                    layer.title || layer.name,
-                    url, {
-                        layers: layer.name, 
-                        exceptions: this.serviceExceptionFormat(
-                            capability.exception.formats
-                        ),
-                        format: this.imageFormat(layer),
-                        version: data.version
-                    }, 
-                    options
-                );
                 records.push(new this.recordType(Ext.apply(layer, {
-                    layer: l
-                }), l.id));
+                    layer: new OpenLayers.Layer.WMS(
+                        layer.title || layer.name,
+                        url,
+                        {layers: layer.name}, {
+                            attribution: layer.attribution ?
+                                this.attributionMarkup(layer.attribution) :
+                                undefined
+                        }
+                    )
+                })));
             }
         }
         

Modified: sandbox/camptocamp/geobretagne/tests/lib/GeoExt/data/LayerReader.html
===================================================================
--- sandbox/camptocamp/geobretagne/tests/lib/GeoExt/data/LayerReader.html	2009-08-21 17:29:27 UTC (rev 1332)
+++ sandbox/camptocamp/geobretagne/tests/lib/GeoExt/data/LayerReader.html	2009-08-24 10:59:36 UTC (rev 1333)
@@ -33,7 +33,7 @@
     }
 
     function test_readRecords(t) {
-        t.plan(6);
+        t.plan(5);
 
         var reader, layers, data;
 
@@ -50,8 +50,6 @@
              "readRecords returns expected number of records");
         t.ok(data.records[0] instanceof GeoExt.data.LayerRecord,
              "readRecords returns records of expected type");
-        t.ok(data.records[0].id == layers[0].id,
-             "readRecords returns records with expected \"id\"");
         t.ok(data.records[0].get("layer") == layers[0],
              "readRecords returns records with expected \"layer\" field");
         t.eq(data.records[0].get("title"), layers[0].name,

Modified: sandbox/camptocamp/geobretagne/tests/lib/GeoExt/data/WMSCapabilitiesReader.html
===================================================================
--- sandbox/camptocamp/geobretagne/tests/lib/GeoExt/data/WMSCapabilitiesReader.html	2009-08-21 17:29:27 UTC (rev 1332)
+++ sandbox/camptocamp/geobretagne/tests/lib/GeoExt/data/WMSCapabilitiesReader.html	2009-08-24 10:59:36 UTC (rev 1333)
@@ -17,7 +17,7 @@
             var fields = reader.recordType.prototype.fields;
 
             // 1 test
-            t.eq(fields.items.length, 24, 'number of default items is correct');
+            t.eq(fields.items.length, 14, 'number of default items is correct');
 
 
             var reader = new GeoExt.data.WMSCapabilitiesReader({},[
@@ -33,24 +33,17 @@
                  'field values set from configuration are correct');
         }
         function test_read(t) {
-            t.plan(35);
+            t.plan(16);
 
-            var reader = new GeoExt.data.WMSCapabilitiesReader({
-                layerOptions: {
-                    singleTile: true
-                }
-            });
+            var reader = new GeoExt.data.WMSCapabilitiesReader();
 
-            var records = reader.read({responseXML: doc});
+            var records = reader.read({responseXML : doc});
 
             //1 test
             t.eq(records.totalRecords, 22, 'readRecords returns correct number of records');
             
             var record = records.records[2];
 
-            //1 test -- testing value of record id
-            t.ok(record.id == record.get("layer").id, "[2] correct record id");
-
             //8 tests -- testing the fields of a record
             t.eq(record.get("name"), "tiger:tiger_roads", "[2] correct layer name");
             t.eq(record.get("title"), "Manhattan (NY) roads", "[2] correct layer title");
@@ -72,42 +65,20 @@
                 "[2] correct legend url"
             );
             t.eq(record.get("queryable"), true, "[2] correct queryable attribute");
-            t.eq(record.get("opaque"), true, "[2] correct opaque attribute");
-            t.eq(record.get("cascaded"), 3, "[2] correct cascaded attribute");
-            t.eq(record.get("noSubsets"), true, "[2] correct noSubsets attribute");
-            t.eq(record.get("fixedWidth"), 400, "[2] correct fixedWidth attribute");
-            t.eq(record.get("fixedHeight"), 200, "[2] correct fixedHeight attribute");
-            t.eq(record.get("formats")[0], "image/png", "[2] correct image/png formats attribute");
-            t.eq(record.get("formats")[14], "image/geotiff", "[2] correct image/geotiff formats attribute");
-            t.eq(record.get("formats")[27], "rss", "[2] correct rss formats attribute");
-            t.eq(record.get("srs")[0], "EPSG:WGS84(DD)", "[2] correct srs[0] attribute");
-            t.eq(record.get("srs")[record.get("srs").length-1], "EPSG:42303", "[2] correct srs[nb_srs-1] attribute");
-            t.eq(record.get("prefix"), "tiger", "[2] correct prefix attribute");
-            t.eq(
-                record.get("bbox")["EPSG:4326"].bbox,
-                [-74.02722,40.684221,-73.907005,40.878178],
-                "[2] correct bbox"
-            );
-            t.eq(record.get("authorityURLs").gcmd, "http://www.authority.com", "[2] correct authorityURLs attribute");
-            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
 
-            //8 tests -- Testing the layer field
+            //4 tests -- Testing the layer field
             var layer = record.get("layer");
             t.eq(layer.CLASS_NAME, "OpenLayers.Layer.WMS", "[2] layer field is of type OpenLayers.Layer.WMS");
             t.eq(layer.url, "http://publicus.opengeo.org:80/geoserver/wms?SERVICE=WMS&", "[2] layer field has correct URL");
             t.eq(layer.params.LAYERS, "tiger:tiger_roads","[2] layer field has correct LAYERS parameter");
             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.queryable, true, "[2] layer field has correct queryable attribute");
-            t.eq(layer.singleTile, true, "[2] layer field has correct singleTile attribute (from WMSCapabilitiesReader constructor)");
             
             // 3 tests -- attribution markup
             var attribution = layer.attribution;
             t.ok(attribution.indexOf("http://foo/logo.png") !== -1, "attribution markup has a logo");
             t.ok(attribution.indexOf("Foo Authority") !== -1, "attribution markup has a title");
             t.ok(attribution.indexOf("http://foo/about/") !== -1, "attribution has a link");
+
         }
     </script>
   <body>

Modified: sandbox/camptocamp/geobretagne/tests/lib/GeoExt/data/WMSCapabilitiesReader.js
===================================================================
--- sandbox/camptocamp/geobretagne/tests/lib/GeoExt/data/WMSCapabilitiesReader.js	2009-08-21 17:29:27 UTC (rev 1332)
+++ sandbox/camptocamp/geobretagne/tests/lib/GeoExt/data/WMSCapabilitiesReader.js	2009-08-24 10:59:36 UTC (rev 1333)
@@ -4110,12 +4110,10 @@
               '</LegendURL>' +
             '</Style>' +
           '</Layer>' +
-          '<Layer queryable="1" opaque="1" cascaded="3" noSubsets="1" fixedWidth="400" fixedHeight="200">' +
+          '<Layer queryable="1">' +
             '<Name>tiger:tiger_roads</Name>' +
             '<Title>Manhattan (NY) roads</Title>' +
             '<Abstract>Highly simplified road layout of Manhattan in New York..</Abstract>' +
-            '<AuthorityURL name="gcmd"><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="http://www.authority.com" /></AuthorityURL>' +
-            '<Identifier authority="gcmd">id_value</Identifier>' +
             '<KeywordList>' +
               '<Keyword>DS_tiger_roads</Keyword>' +
               '<Keyword>tiger_roads</Keyword>' +
@@ -4151,7 +4149,6 @@
                 '<OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="http://publicus.opengeo.org:80/geoserver/wms/GetLegendGraphic?VERSION=1.0.0&amp;FORMAT=image/png&amp;WIDTH=20&amp;HEIGHT=20&amp;LAYER=tiger:tiger_roads"/>' +
               '</LegendURL>' +
             '</Style>' +
-            '<ScaleHint min="37.4177136322228" max="299.341709057782" />' +
           '</Layer>' +
           '<Layer queryable="1">' +
             '<Name>sf:archsites</Name>' +



More information about the Commits mailing list