Ticket #1547: ticket1547.patch
| File ticket1547.patch, 3.2 kB (added by bartvde, 2 months ago) |
|---|
-
lib/OpenLayers/Format/GML.js
old new 72 72 * {Boolean} Extract attributes from GML. 73 73 */ 74 74 extractAttributes: true, 75 76 /** 77 * APIProperty: extractGeometry 78 * {Boolean} Extract geometry from GML. If this is false, the DOMElement 79 * will be cached on the feature for parsing later on. 80 */ 81 extractGeometry: true, 75 82 76 83 /** 77 84 * APIProperty: xy … … 140 147 var order = ["MultiPolygon", "Polygon", 141 148 "MultiLineString", "LineString", 142 149 "MultiPoint", "Point", "Envelope"]; 143 var type, nodeList, geometry, parser ;150 var type, nodeList, geometry, parser, geometryNode, geometryType; 144 151 for(var i=0; i<order.length; ++i) { 145 152 type = order[i]; 146 153 nodeList = this.getElementsByTagNameNS(node, this.gmlns, type); 147 154 if(nodeList.length > 0) { 148 // only deal with first geometry of this type 149 var parser = this.parseGeometry[type.toLowerCase()]; 150 if(parser) { 151 geometry = parser.apply(this, [nodeList[0]]); 152 if (this.internalProjection && this.externalProjection) { 153 geometry.transform(this.externalProjection, 154 this.internalProjection); 155 } 155 if (this.extractGeometry) { 156 // only deal with first geometry of this type 157 var parser = this.parseGeometry[type.toLowerCase()]; 158 if(parser) { 159 geometry = parser.apply(this, [nodeList[0]]); 160 if (this.internalProjection && this.externalProjection) { 161 geometry.transform(this.externalProjection, 162 this.internalProjection); 163 } 164 } else { 165 OpenLayers.Console.error(OpenLayers.i18n( 166 "unsupportedGeometryType", {'geomType':type})); 167 } 156 168 } else { 157 OpenLayers.Console.error(OpenLayers.i18n( 158 "unsupportedGeometryType", {'geomType':type})); 169 geometry = null; 170 geometryNode = nodeList[0]; 171 geometryType = type; 159 172 } 160 173 // stop looking for different geometry types 161 174 break; … … 168 181 attributes = this.parseAttributes(node); 169 182 } 170 183 var feature = new OpenLayers.Feature.Vector(geometry, attributes); 184 if (!this.extractGeometry) { 185 // cache the DOMElement on the feature for future reference 186 // we also need the geometryType to call the correct parser 187 feature.geometryNode = {node: geometryNode, type: geometryType}; 188 } 171 189 // assign fid - this can come from a "fid" or "id" attribute 172 190 var childNode = node.firstChild; 173 191 var fid;
