[OpenLayers-Commits] r11739 - in sandbox/cmoullet/openlayers: lib/OpenLayers/Format tests/Format

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Tue Mar 29 05:43:15 EDT 2011


Author: cmoullet
Date: 2011-03-29 02:43:14 -0700 (Tue, 29 Mar 2011)
New Revision: 11739

Modified:
   sandbox/cmoullet/openlayers/lib/OpenLayers/Format/WMSGetFeatureInfo.js
   sandbox/cmoullet/openlayers/tests/Format/WMSGetFeatureInfo.html
Log:
revert patch

Modified: sandbox/cmoullet/openlayers/lib/OpenLayers/Format/WMSGetFeatureInfo.js
===================================================================
--- sandbox/cmoullet/openlayers/lib/OpenLayers/Format/WMSGetFeatureInfo.js	2011-03-29 09:39:42 UTC (rev 11738)
+++ sandbox/cmoullet/openlayers/lib/OpenLayers/Format/WMSGetFeatureInfo.js	2011-03-29 09:43:14 UTC (rev 11739)
@@ -1,5 +1,5 @@
-/* Copyright (c) 2006-2011 by OpenLayers Contributors (see authors.txt for 
- * full list of contributors). Published under the Clear BSD license.  
+/* Copyright (c) 2006-2011 by OpenLayers Contributors (see authors.txt for
+ * full list of contributors). Published under the Clear BSD license.
  * See http://svn.openlayers.org/trunk/openlayers/license.txt for the
  * full text of the license. */
 
@@ -20,12 +20,12 @@
      * APIProperty: layerIdentifier
      * {String} All xml nodes containing this search criteria will populate an
      *     internal array of layer nodes.
-     */ 
+     */
     layerIdentifier: '_layer',
 
     /**
      * APIProperty: featureIdentifier
-     * {String} All xml nodes containing this search criteria will populate an 
+     * {String} All xml nodes containing this search criteria will populate an
      *     internal array of feature nodes for each layer node found.
      */
     featureIdentifier: '_feature',
@@ -88,8 +88,8 @@
         }
         return result;
     },
-    
-    
+
+
     /**
      * Method: read_msGMLOutput
      * Parse msGMLOutput nodes.
@@ -112,14 +112,14 @@
                     layerName = layerName.split(':')[1];
                 }
                 var layerName = layerName.replace(this.layerIdentifier, '');
-                var featureNodes = this.getSiblingNodesByTagCriteria(node, 
+                var featureNodes = this.getSiblingNodesByTagCriteria(node,
                     this.featureIdentifier);
                 if (featureNodes) {
                     for (var j = 0; j < featureNodes.length; j++) {
                         var featureNode = featureNodes[j];
                         var geomInfo = this.parseGeometry(featureNode);
                         var attributes = this.parseAttributes(featureNode);
-                        var feature = new OpenLayers.Feature.Vector(geomInfo.geometry, 
+                        var feature = new OpenLayers.Feature.Vector(geomInfo.geometry,
                             attributes, null);
                         feature.bounds = geomInfo.bounds;
                         feature.type = layerName;
@@ -130,7 +130,7 @@
         }
         return response;
     },
-    
+
     /**
      * Method: read_FeatureInfoResponse
      * Parse FeatureInfoResponse nodes.
@@ -150,25 +150,10 @@
             var featureNode = featureNodes[i];
             var geom = null;
 
-            // attributes can be actual attributes on the FIELDS tag, 
-            // or FIELD children
             var attributes = {};
-            var j;
-            var jlen = featureNode.attributes.length;
-            if (jlen > 0) {
-                for(j=0; j<jlen; j++) {
-                    var attribute = featureNode.attributes[j];
-                    attributes[attribute.nodeName] = attribute.nodeValue;
-                }
-            } else {
-                var nodes = featureNode.childNodes;
-                for (j=0, jlen=nodes.length; j<jlen; ++j) {
-                    var node = nodes[j];
-                    if (node.nodeType != 3) {
-                        attributes[node.getAttribute("name")] = 
-                            node.getAttribute("value");
-                    }
-                }
+            for(var j=0, jlen=featureNode.attributes.length; j<jlen; j++) {
+                var attribute = featureNode.attributes[j];
+                attributes[attribute.nodeName] = attribute.nodeValue;
             }
 
             response.push(
@@ -180,18 +165,18 @@
 
     /**
      * Method: getSiblingNodesByTagCriteria
-     * Recursively searches passed xml node and all it's descendant levels for 
-     *     nodes whose tagName contains the passed search string. This returns an 
-     *     array of all sibling nodes which match the criteria from the highest 
+     * Recursively searches passed xml node and all it's descendant levels for
+     *     nodes whose tagName contains the passed search string. This returns an
+     *     array of all sibling nodes which match the criteria from the highest
      *     hierarchial level from which a match is found.
-     * 
+     *
      * Parameters:
      * node - {DOMElement} An xml node
-     * criteria - {String} Search string which will match some part of a tagName 
-     *                                       
+     * criteria - {String} Search string which will match some part of a tagName
+     *
      * Returns:
      * Array({DOMElement)) An array of sibling xml nodes
-     */                
+     */
     getSiblingNodesByTagCriteria: function(node, criteria){
         var nodes = [];
         var children, tagName, n, matchNodes, child;
@@ -213,7 +198,7 @@
                         child, criteria);
 
                     if(matchNodes.length > 0){
-                        (nodes.length == 0) ? 
+                        (nodes.length == 0) ?
                             nodes = matchNodes : nodes.push(matchNodes);
                     }
                 }
@@ -231,11 +216,11 @@
      *
      * Returns:
      * {Object} An attributes object.
-     * 
+     *
      * Notes:
      * Assumes that attributes are direct child xml nodes of the passed node
-     * and contain only a single text node. 
-     */    
+     * and contain only a single text node.
+     */
     parseAttributes: function(node){
         var attributes = {};
         if (node.nodeType == 1) {
@@ -266,7 +251,7 @@
 
     /**
      * Method: parseGeometry
-     * Parse the geometry and the feature bounds out of the node using 
+     * Parse the geometry and the feature bounds out of the node using
      *     Format.GML
      *
      * Parameters:
@@ -276,7 +261,7 @@
      * {Object} An object containing the geometry and the feature bounds
     */
     parseGeometry: function(node) {
-        // we need to use the old Format.GML parser since we do not know the 
+        // we need to use the old Format.GML parser since we do not know the
         // geometry name
         if (!this.gmlFormat) {
             this.gmlFormat = new OpenLayers.Format.GML();
@@ -292,5 +277,5 @@
     },
 
     CLASS_NAME: "OpenLayers.Format.WMSGetFeatureInfo"
-    
+
 });

Modified: sandbox/cmoullet/openlayers/tests/Format/WMSGetFeatureInfo.html
===================================================================
--- sandbox/cmoullet/openlayers/tests/Format/WMSGetFeatureInfo.html	2011-03-29 09:39:42 UTC (rev 11738)
+++ sandbox/cmoullet/openlayers/tests/Format/WMSGetFeatureInfo.html	2011-03-29 09:43:14 UTC (rev 11739)
@@ -1,15 +1,15 @@
-<html> 
-<head> 
+<html>
+<head>
     <script src="../OLLoader.js"></script>
     <script type="text/javascript">
-    
+
     function test_read_FeatureInfoResponse(t) {
-        t.plan(7);
-        
+        t.plan(5);
+
         var parser = new OpenLayers.Format.WMSGetFeatureInfo();
 
         // read empty response
-        var text = 
+        var text =
             '<?xml version="1.0" encoding="UTF-8" ?>' +
             '<FeatureInfoResponse>' +
             '</FeatureInfoResponse>';
@@ -19,7 +19,7 @@
              "Parsing empty FeatureInfoResponse response succesfull");
 
         // read 1 feature
-        text = 
+        text =
             '<?xml version="1.0" encoding="UTF-8" ?>' +
             '<FeatureInfoResponse>' +
             '  <FIELDS OBJECTID="1188" HECTARES="1819.734" ZONENR="5854" NULZONES=" " AREA="18197340.1426" PERIMETER="19177.4073627" SHAPE="NULL" SE_ANNO_CAD_DATA="NULL" SHAPE.AREA="0" SHAPE.LEN="0"/>' +
@@ -33,7 +33,7 @@
              "Attribute OBJECTID contains the right value");
 
         // read multiple features
-        text = 
+        text =
             '<?xml version="1.0" encoding="UTF-8" ?>' +
             '<FeatureInfoResponse>' +
             '  <FIELDS OBJECTID="551" Shape="NULL" NAME="Carbon" STATE_NAME="Wyoming" AREA="7999.91062" POP2000="15639" POP00_SQMI="2" Shape_Length="6.61737274334215" Shape_Area="2.23938983524154"/>' +
@@ -49,34 +49,15 @@
         t.eq(features[1].attributes.STATE_NAME, 'Wyoming',
              "Attribute STATE_NAME contains the right value");
 
-        text = '<FeatureInfoResponse>' +
-            '<FIELDS>' +
-            '<FIELD name="ID" value="B31A0154"/>' +
-            '<FIELD name="FID" value="31AL0011"/>' +
-            '</FIELDS>' +
-            '<FIELDS>' +
-            '<FIELD name="ID" value="B31A0153"/>' +
-            '<FIELD name="FID" value="31AL0011"/>' +
-            '</FIELDS>' +
-            '</FeatureInfoResponse>';
-
-        features = parser.read(text);
-
-        t.eq(features.length, 2,
-             "Parsed 2 features in total");
-
-        t.eq(features[1].attributes.FID, '31AL0011',
-             "Attribute FID contains the right value");
-
     }
 
     function test_read_msGMLOutput(t) {
         t.plan(13);
-        
+
         var parser = new OpenLayers.Format.WMSGetFeatureInfo();
 
         // read empty response
-        var text = 
+        var text =
             '<?xml version="1.0" encoding="ISO-8859-1"?>' +
             '<msGMLOutput ' +
             '	 xmlns:gml="http://www.opengis.net/gml"' +
@@ -111,7 +92,7 @@
         t.eq((features[0].attributes.EMPTY === null), true, "Empty attribute is parsed as null");
 
         // read 1 feature from 1 layer
-        text = 
+        text =
             '<?xml version="1.0" encoding="ISO-8859-1"?>' +
             '<msGMLOutput ' +
             '	 xmlns:gml="http://www.opengis.net/gml"' +
@@ -155,7 +136,7 @@
         t.eq(bounds.top.toFixed(3), "480609.250", "Bounds top parsed correctly");
 
         // read 2 features from 2 layers
-        text = 
+        text =
             '<?xml version="1.0" encoding="ISO-8859-1"?>' +
             '<msGMLOutput ' +
             '	 xmlns:gml="http://www.opengis.net/gml"' +
@@ -248,14 +229,14 @@
 
     function test_read_GMLFeatureInfoResponse(t) {
         t.plan(4);
-        
+
         var parser = new OpenLayers.Format.WMSGetFeatureInfo();
 
         // read Ionic response, see if parser falls back to GML format
         // url used:
         /* http://webservices.ionicsoft.com/ionicweb/wfs/BOSTON_ORA?service=WMS&request=GetFeatureInfo&layers=roads&version=1.1.1&bbox=-71.1,42.25,-71.05,42.3&width=500&height=500&format=image/png&SRS=EPSG:4326&styles=&x=174&y=252&query_layers=roads&info_format=application/vnd.ogc.gml */
-        var text = 
-            "<?xml version='1.0' encoding='utf-8' ?>" + 
+        var text =
+            "<?xml version='1.0' encoding='utf-8' ?>" +
             '  <ogcwfs:FeatureCollection xsi:schemaLocation="http://www.ionicsoft.com/wfs http://webservices.ionicsoft.com/ionicweb/wfs/BOSTON_ORA?REQUEST=DescribeAllFeatureType&amp;SERVICE=WFS http://www.opengis.net/wfs http://webservices.ionicsoft.com/ionicweb/wfs/BOSTON_ORA/REQUEST/get/DATA/LPR/wfs/1.0.0/WFS-basic.xsd" xmlns:wfs="http://www.ionicsoft.com/wfs" xmlns:gml="http://www.opengis.net/gml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ogcwfs="http://www.opengis.net/wfs">' +
             '    <gml:boundedBy>' +
             '      <gml:Box srsName="EPSG:4326">' +
@@ -311,9 +292,9 @@
              "Attribute cat contains the right value");
 
     }
-    
-    </script> 
-</head> 
+
+    </script>
+</head>
 <body>
-</body> 
-</html> 
+</body>
+</html>



More information about the Commits mailing list