Changeset 7117
- Timestamp:
- 05/08/08 17:22:32 (8 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
sandbox/vector-behavior/lib/OpenLayers/Protocol/WFS/v1_0_0.js
r7108 r7117 33 33 DEFAULT_PARAMS: { service: "WFS", 34 34 version: "1.0.0", 35 request: "GetFeature"36 35 }, 37 36 … … 73 72 */ 74 73 parser: null, 74 75 /** 76 * Property: filterFormat 77 * {<OpenLayers.Format.Filter>} Parser for reading and writing transactions. 78 */ 79 filterFormat: null, 75 80 76 81 /** … … 89 94 //}); 90 95 96 this.filterFormat = new OpenLayers.Format.Filter(); 97 91 98 this.params = this.params || {}; 92 99 OpenLayers.Util.applyDefaults( … … 128 135 OpenLayers.Util.extend(params, mergedOptions.params); 129 136 OpenLayers.Util.applyDefaults(params, this.params); 137 138 139 var root = this.createEnvelope("wfs:GetFeature"); 140 141 var query = this.format.createElementNSPlus("wfs:Query", { 142 attributes: {typeName: this.params.typename} 143 }); 144 145 if(params.filter){ 146 var filterNode = this.filterFormat.write(params.filter); 147 query.appendChild(filterNode); 148 } 149 150 root.appendChild(query); 151 152 if(params.bbox){ 153 var bounds = params.bbox; 154 OpenLayers.Console.log(bounds); 155 156 var bboxFilter = new OpenLayers.Filter.Spatial({ 157 type: OpenLayers.Filter.Spatial.BBOX, 158 property: this.geometryName, 159 value: new OpenLayers.Geometry.Rectangle(bounds[0], bounds[1], bounds[0] - bounds[2], bounds[1] - bounds[3]) 160 }); 161 162 var node = this.filterFormat.write(bboxFilter); 163 164 root.appendChild(node); 165 166 167 } 130 168 131 169 var callback = function(request) { … … 145 183 ); 146 184 }; 147 148 return OpenLayers.Request.GET({ 185 186 var data = this.format.write(root); 187 188 return OpenLayers.Request.POST({ 149 189 url: url, 150 190 callback: callback, 151 params: params,191 data: data, 152 192 headers: mergedOptions.headers, 153 193 scope: this 154 }); 155 }, 194 }); 195 }, 196 197 // name e.g. 'wfs:Transaction' 198 createEnvelope: function(name) { 199 var envelope = this.format.createElementNSPlus(name); 200 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); 205 206 envelope.setAttribute("xmlns:" + this.format.featurePrefix, this.format.featureNS); 207 208 // This should depend on the layer's format. 209 envelope.setAttribute("outputFormat","GML2"); 210 211 envelope.setAttribute("xmlns:" + this.format.featurePrefix, this.format.featureNS); 212 213 envelope.setAttribute("xmlns:ogc","http://www.opengis.net/ogc"); 214 215 return envelope; 216 }, 217 218 156 219 157 220 /** … … 192 255 } 193 256 194 var root = this.format.createElementNSPlus("wfs:Transaction", { 195 attributes: { 196 version: this.params.VERSION, 197 service: this.params.SERVICE 198 } 199 }); 200 201 root.setAttribute("xmlns:" + this.format.featurePrefix, this.format.featureNS); 257 var root = this.createEnvelope("wfs:Transaction"); 202 258 203 259 var method, node; … … 301 357 } 302 358 359 // TODO: Replace with slicket Format dealio. (?) 303 360 // add feature id filter 304 361 var filter = this.format.createElementNSPlus("ogc:Filter");
