OpenLayers OpenLayers

Ticket #1547: ticket1547.patch

File ticket1547.patch, 3.2 kB (added by bartvde, 2 months ago)

fixed a bug in the patch

  • lib/OpenLayers/Format/GML.js

    old new  
    7272     * {Boolean} Extract attributes from GML. 
    7373     */ 
    7474    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, 
    7582     
    7683    /** 
    7784     * APIProperty: xy 
     
    140147        var order = ["MultiPolygon", "Polygon", 
    141148                     "MultiLineString", "LineString", 
    142149                     "MultiPoint", "Point", "Envelope"]; 
    143         var type, nodeList, geometry, parser
     150        var type, nodeList, geometry, parser, geometryNode, geometryType
    144151        for(var i=0; i<order.length; ++i) { 
    145152            type = order[i]; 
    146153            nodeList = this.getElementsByTagNameNS(node, this.gmlns, type); 
    147154            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                    } 
    156168                } else { 
    157                     OpenLayers.Console.error(OpenLayers.i18n( 
    158                                 "unsupportedGeometryType", {'geomType':type})); 
     169                    geometry = null; 
     170                    geometryNode = nodeList[0]; 
     171                    geometryType = type; 
    159172                } 
    160173                // stop looking for different geometry types 
    161174                break; 
     
    168181            attributes = this.parseAttributes(node); 
    169182        } 
    170183        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        } 
    171189        // assign fid - this can come from a "fid" or "id" attribute 
    172190        var childNode = node.firstChild; 
    173191        var fid;