OpenLayers OpenLayers

Changeset 7139

Show
Ignore:
Timestamp:
05/12/08 14:17:47 (6 months ago)
Author:
sbenthall
Message:

- Envelope parameters now checked automatically and added as appropriate to the envelope.
- outputFormat now depends on Format

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sandbox/vector-behavior/lib/OpenLayers/Protocol/WFS/v1_0_0.js

    r7117 r7139  
    1616     
    1717    /** 
     18     * Array of parameters that should be set in a WFS request's outer envelope. 
     19     */ 
     20     
     21    ENVELOPE_PARAMS : ['service','version','maxFeatures', 'outputFormat'], 
     22     
     23    /** 
     24     * A mapping from Format classnames to the proper value for the outputFormat parameter of a WFS request. 
     25     */ 
     26    outputFormats : { 
     27        "OpenLayers.Format.GML" : "GML2"     
     28    }, 
     29     
     30     
     31    /** 
    1832     * Property: namespaces 
    1933     * {Object} Namespace dictionary keyed by namespace alias. 
     
    3246     */ 
    3347    DEFAULT_PARAMS: { service: "WFS", 
    34                       version: "1.0.0", 
     48                      version: "1.0.0" 
    3549                    }, 
    3650 
     
    99113        OpenLayers.Util.applyDefaults( 
    100114                       this.params,  
    101                        OpenLayers.Util.upperCaseObject(this.DEFAULT_PARAMS) 
     115                       this.DEFAULT_PARAMS 
    102116                       ); 
    103117         
     
    137151         
    138152         
    139         var root = this.createEnvelope("wfs:GetFeature"); 
     153        var root = this.createEnvelope("wfs:GetFeature", params); 
    140154         
    141155        var query = this.format.createElementNSPlus("wfs:Query", { 
     
    196210     
    197211    // name e.g. 'wfs:Transaction' 
    198     createEnvelope: function(name) { 
     212    createEnvelope: function(name, params) { 
    199213        var envelope = this.format.createElementNSPlus(name);  
    200214 
    201         // should handle params here gracefully 
    202         // should check for e.g. maxFeatures 
    203         envelope.setAttribute('version', this.params.VERSION); 
    204         envelope.setAttribute('service', this.params.SERVICE); 
     215 
     216        if(!params){ 
     217            params = {}; 
     218        } 
     219        var param; 
     220        for(var i = 0; i < this.ENVELOPE_PARAMS.length; i++){ 
     221            param = this.ENVELOPE_PARAMS[i]; 
     222            if(params[param]){ 
     223                envelope.setAttribute(param, params[param]); 
     224            } 
     225        } 
    205226         
    206227        envelope.setAttribute("xmlns:" + this.format.featurePrefix, this.format.featureNS); 
    207228        
    208         // This should depend on the layer's format. 
    209         envelope.setAttribute("outputFormat","GML2"); 
     229        if(this.outputFormats[this.format.CLASS_NAME] && !params.outputFormat){ 
     230            OpenLayers.Console.log("Setting outputFormat according to Format class name " + this.format.CLASS_NAME); 
     231            envelope.setAttribute("outputFormat", this.outputFormats[this.format.CLASS_NAME]);     
     232        } 
    210233         
    211234        envelope.setAttribute("xmlns:" + this.format.featurePrefix, this.format.featureNS);