Changeset 7514
- Timestamp:
- 07/15/08 16:19:26 (2 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
sandbox/topp/trimet/lib/OpenLayers/Protocol/WFS/v1_0_0.js
r7506 r7514 29 29 }, 30 30 31 32 31 /** 33 32 * Property: namespaces … … 65 64 66 65 /** 66 * Property: featureType 67 * {String} Local feature typeName. 68 */ 69 featureType: null, 70 71 /** 72 * Property: featureNS 73 * {String} Feature namespace. 74 */ 75 featureNS: null, 76 77 /** 67 78 * Property: geometryName 68 79 * {String} Name of the geometry attribute for features. Default is … … 72 83 73 84 /** 85 * Property: featurePrefix 86 * {String} Namespace alias for feature type. Default is "feature". 87 */ 88 featurePrefix: "feature", 89 90 /** 74 91 * Property: layer 75 92 * {<OpenLayers.Layer.Vector>} … … 96 113 * options - {Object} Optional object whose properties will be set on the 97 114 * instance. 115 * 116 * Valid options properties: 117 * featureType - {String} Local (without prefix) feature typeName (required). 118 * featureNS - {String} Feature namespace (optional). 119 * featurePrefix - {String} Feature namespace alias (optional - only used 120 * if featureNS is provided). Default is 'feature'. 121 * geometryName - {String} Name of geometry attribute. Default is 'the_geom'. 98 122 */ 99 123 initialize: function(options) { 100 OpenLayers.Protocol.prototype.initialize.apply(this, [options]); 101 124 OpenLayers.Protocol.prototype.initialize.apply(this, [options]); 125 if(this.featureNS) { 126 this.namespaces = OpenLayers.Util.extend( 127 {feature: options.featureNS}, 128 OpenLayers.Protocol.WFS.v1_0_0.prototype.namespaces 129 ); 130 } 102 131 this.filterFormat = new OpenLayers.Format.Filter(); 103 132 }, … … 111 140 */ 112 141 setFormat: function(format){ 142 OpenLayers.Util.extend(format.namespaces, this.namespaces); 113 143 OpenLayers.Protocol.prototype.setFormat.apply(this, arguments); 114 format.namespaces = this.namespaces;115 144 }, 116 145 … … 139 168 var query = this.format.createElementNSPlus("wfs:Query", { 140 169 attributes: { 141 typeName: options.featureType, 170 typeName: (options.featureNS ? this.featurePrefix + ":" : "") + 171 options.featureType, 142 172 srsName: options.srsName || this.srsName 143 173 } 144 174 }); 145 var loc = options.featureType.indexOf(":"); 146 if(loc > 0) { 147 var prefix = options.featureType.substring(0, loc); 148 query.setAttribute("xmlns:" + prefix, options.featureNS); 175 if(options.featureNS) { 176 query.setAttribute("xmlns:feature", options.featureNS); 149 177 } 150 178 … … 175 203 }; 176 204 177 var data = this.format.write(root); 205 var data = OpenLayers.Format.XML.prototype.write.apply( 206 this.format, [root] 207 ); 178 208 179 209 return OpenLayers.Request.POST({ … … 223 253 return envelope; 224 254 }, 225 226 227 255 228 256 /** … … 394 422 update: function(feature) { 395 423 var node = this.format.createElementNSPlus("wfs:Update", { 396 attributes: {typeName: this.featureType} 424 attributes: { 425 typeName: (options.featureNS ? this.featurePrefix + ":" : "") + 426 options.featureType 427 } 397 428 }); 398 429 var prop = this.format.createElementNSPlus("wfs:Property"); … … 434 465 "delete": function(feature) { 435 466 var node = this.format.createElementNSPlus("wfs:Delete", { 436 attributes: {typeName: this.featureType} 467 attributes: { 468 typeName: (options.featureNS ? this.featurePrefix + ":" : "") + 469 options.featureType 470 } 437 471 }); 438 472 … … 450 484 451 485 var deleteNode = this.format.createElementNSPlus("wfs:Delete", { 452 attributes: {typeName: this.featureType} 486 attributes: { 487 typeName: (options.featureNS ? this.featurePrefix + ":" : "") + 488 options.featureType 489 } 453 490 }); 454 491
