[OpenLayers-Commits] r7511 - sandbox/topp/trimet/lib/OpenLayers/Format/GML

commits at openlayers.org commits at openlayers.org
Tue Jul 15 16:13:53 EDT 2008


Author: tschaub
Date: 2008-07-15 16:13:53 -0400 (Tue, 15 Jul 2008)
New Revision: 7511

Modified:
   sandbox/topp/trimet/lib/OpenLayers/Format/GML/Base.js
Log:
correctly parsing multilinestring

Modified: sandbox/topp/trimet/lib/OpenLayers/Format/GML/Base.js
===================================================================
--- sandbox/topp/trimet/lib/OpenLayers/Format/GML/Base.js	2008-07-15 20:04:17 UTC (rev 7510)
+++ sandbox/topp/trimet/lib/OpenLayers/Format/GML/Base.js	2008-07-15 20:13:53 UTC (rev 7511)
@@ -37,10 +37,10 @@
     schemaLocation: null,
     
     /**
-     * APIProperty: typeName
-     * {String} The feature typeName.
+     * APIProperty: featureType
+     * {String} The local (without prefix) feature typeName.
      */
-    typeName: null,
+    featureType: null,
     
     /**
      * APIProperty: featureNS
@@ -89,7 +89,7 @@
      *     this instance.
      *
      * Valid options properties:
-     * typeName - {String} Feature typeName (required).
+     * featureType - {String} Local (without prefix) feature typeName (required).
      * featureNS - {String} Feature namespace (required).
      * geometryName - {String} Geometry element name.
      */
@@ -148,10 +148,10 @@
     readers: {
         "gml": {
             "featureMember": function(node, obj) {
-                this.readChildNodes(node, feature);
+                this.readChildNodes(node, obj);
             },
             "featureMembers": function(node, obj) {
-                this.readChildNodes(node, feature);                
+                this.readChildNodes(node, obj);                
             },
             "Point": function(node, container) {
                 var obj = {};
@@ -253,12 +253,15 @@
                 obj.points = points;
             },
             "MultiLineString": function(node, container) {
-                var obj = {};
+                var obj = {components: []};
                 this.readChildNodes(node, obj);
                 container.components = [
                     new OpenLayers.Geometry.MultiLineString(obj.components)
                 ];
             },
+            "lineStringMember": function(node, obj) {
+                this.readChildNodes(node, obj);
+            },
             "Polygon": function(node, container) {
                 var obj = {outer: null, inner: []};
                 this.readChildNodes(node, obj);
@@ -294,12 +297,12 @@
         },
         "feature": {
             "*": function(node, obj) {
-                // The node can either be named like the typeName, or it
-                // can be a child of the feature:typeName.  Children can be
+                // The node can either be named like the featureType, or it
+                // can be a child of the feature:featureType.  Children can be
                 // geometry or attributes.
                 var name;
                 var local = node.nodeName.split(":").pop();
-                if(local == this.typeName) {
+                if(local == this.featureType) {
                     name = "_typeName";
                 } else {
                     // Assume attribute elements have one child node and that the child
@@ -313,23 +316,24 @@
                 this.readers.feature[name].apply(this, [node, obj]);
             },
             "_typeName": function(node, obj) {
-                var feature = new OpenLayers.Feature.Vector();
+                var container = {components: [], attributes: {}};
+                this.readChildNodes(node, container);
+                var feature = new OpenLayers.Feature.Vector(
+                    container.components[0], container.attributes
+                );
                 var fid = node.getAttribute("fid");
                 if(fid) {
                     feature.fid = fid;
                 }
-                var container = {components: []};
-                this.readChildNodes(node, container);
-                feature.geometry = container.components[0];
                 obj.features.push(feature);
             },
-            "_geometry": function(node, feature) {
-                this.readChildNodes(node, feature);
+            "_geometry": function(node, obj) {
+                this.readChildNodes(node, obj);
             },
-            "_attribute": function(node, feature) {
+            "_attribute": function(node, obj) {
                 var local = node.nodeName.split(":").pop();
                 var value = this.getChildValue(node);
-                feature.attributes[local] = value;
+                obj.attributes[local] = value;
             }
         }
     },
@@ -453,7 +457,7 @@
         },
         "feature": {
             "_typeName": function(feature) {
-                var node = this.createElementNSPlus("feature:" + this.typeName);
+                var node = this.createElementNSPlus("feature:" + this.featureType);
                 if(feature.geometry) {
                     this.writeNode(node, "feature:_geometry", feature.geometry);
                 }



More information about the Commits mailing list