Changeset 3890
- Timestamp:
- 08/10/07 23:29:17 (1 year ago)
- Files:
-
- sandbox/tschaub/wfsv/examples/wfs-v.html (modified) (1 diff)
- sandbox/tschaub/wfsv/lib/OpenLayers/Control/FeatureEditor.js (modified) (3 diffs)
- sandbox/tschaub/wfsv/lib/OpenLayers/Control/ModifyFeature.js (modified) (2 diffs)
- sandbox/tschaub/wfsv/lib/OpenLayers/Control/SaveFeatures.js (modified) (3 diffs)
- sandbox/tschaub/wfsv/lib/OpenLayers/Format/GML.js (modified) (13 diffs)
- sandbox/tschaub/wfsv/lib/OpenLayers/Format/WFS.js (modified) (2 diffs)
- sandbox/tschaub/wfsv/theme/default/style.css (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
sandbox/tschaub/wfsv/examples/wfs-v.html
r3881 r3890 34 34 var panel = new OpenLayers.Control.WFSEditor("/geoserver/wfsv", 35 35 "topp:archsites", 36 "Point"); 36 "Point", 37 {staticLayer: wms}); 37 38 38 39 map.addControl(panel); 39 // map.addControl(new OpenLayers.Control.KeyboardDefaults);40 40 map.zoomToMaxExtent(); 41 41 } sandbox/tschaub/wfsv/lib/OpenLayers/Control/FeatureEditor.js
r3889 r3890 36 36 */ 37 37 layerOptions: null, 38 39 /** 40 * Property: transId 41 * {Integer} 42 */ 43 transId: 0, 44 45 /** 46 * Property: staticLayer 47 * {<OpenLayers.Layer>} 48 */ 49 staticLayer: null, 38 50 39 51 /** … … 93 105 {displayClass: "olControlModifyFeature" + this.geometryType} 94 106 ); 95 96 this.commitControl = new OpenLayers.Control.SaveFeatures( 97 this.vectorLayer, 98 this.url); 99 100 this.addControls([this.commitControl, 107 this.modifyControl.onModify = function(feature) { 108 feature.state = OpenLayers.State.UPDATE; 109 }; 110 111 // save control 112 var success = this.saveSuccess.bind(this); 113 var failure = this.saveFailure.bind(this); 114 this.saveControl = new OpenLayers.Control.SaveFeatures( 115 this.vectorLayer, 116 this.url, 117 {onSuccess: success, 118 onFailure: failure, 119 wfsOptions: { 120 layerName: this.featureType 121 }}); 122 123 this.addControls([this.saveControl, 101 124 this.modifyControl, 102 125 this.drawControl, … … 109 132 }); 110 133 134 }, 135 136 /** 137 * Method: saveSuccess 138 */ 139 saveSuccess: function(response) { 140 this.transId += 1; 141 this.vectorLayer.removeFeatures(this.vectorLayer.features); 142 this.defaultControl.activate(); 143 if(this.staticLayer) { 144 this.staticLayer.mergeNewParams({transaction_id: this.transId}); 145 } 146 }, 147 148 /** 149 * Method: saveFailure 150 */ 151 saveFailure: function(response) { 152 this.defaultControl.activate(); 153 OpenLayers.Console.log('failed', response); 111 154 }, 112 155 sandbox/tschaub/wfsv/lib/OpenLayers/Control/ModifyFeature.js
r3884 r3890 21 21 */ 22 22 geometryTypes: null, 23 24 /** 25 * APIProperty: onModify 26 * Called on each feature modification. 27 */ 28 onModify: function(feature) {}, 23 29 24 30 /** … … 71 77 onDrag: function(feature) { 72 78 control.onDrag.apply(control, [feature]); 79 }, 80 onComplete: function() { 81 control.onModify(control.feature) 73 82 }}); 74 83 }, sandbox/tschaub/wfsv/lib/OpenLayers/Control/SaveFeatures.js
r3889 r3890 21 21 22 22 /** 23 * Property: onSuccess 24 */ 25 onSuccess: function() {}, 26 27 /** 28 * Property: onFailure 29 */ 30 onFailure: function() {}, 31 32 /** 33 * Property: wfsOptions 34 */ 35 wfsOptions: null, 36 37 /** 23 38 * Constructor: OpenLayers.Control.SaveFeatures 24 39 */ 25 40 initialize: function(layer, url, options) { 41 this.wfsOptions = OpenLayers.Util.extend({}, options.wfsOptions); 26 42 this.layer = layer; 27 43 this.url = url; 28 44 OpenLayers.Control.prototype.initialize.apply(this, [options]); 29 this.wfs = new OpenLayers.Format.WFS( {}, this);45 this.wfs = new OpenLayers.Format.WFS(this.wfsOptions, layer); 30 46 }, 31 47 … … 35 51 */ 36 52 trigger: function() { 37 38 }, 39 40 /** 41 * APIMethod: commit 42 * Write out the data to a WFS server. 43 */ 44 commit: function() { 45 46 var data = this.wfs.write(this.features); 53 var data = this.wfs.write(this.layer.features); 47 54 48 55 var url = this.url; … … 60 67 onFailure: failure 61 68 }); 69 62 70 }, 63 71 72 /** 73 * Method: commitSuccess 74 * Called when the Ajax request returns a response 75 * 76 * Parameters: 77 * response - {XmlNode} from server 78 */ 79 commitSuccess: function(request) { 80 var response = request.responseText; 81 if (response.indexOf('SUCCESS') != -1) { 82 this.onSuccess(response); 83 } else if (response.indexOf('FAILED') != -1 || 84 response.indexOf('Exception') != -1) { 85 this.onFailure(response); 86 } 87 }, 88 89 /** 90 * Method: commitFailure 91 * Called when the Ajax request fails 92 * 93 * Parameters: 94 * response - {XmlNode} from server 95 */ 96 commitFailure: function(request) {}, 97 64 98 CLASS_NAME: "OpenLayers.Control.SaveFeatures" 65 99 sandbox/tschaub/wfsv/lib/OpenLayers/Format/GML.js
r3884 r3890 502 502 createFeatureXML: function(feature) { 503 503 var geometry = feature.geometry; 504 var className = geometry.CLASS_NAME; 505 var type = className.substring(className.lastIndexOf(".") + 1); 506 var builder = this.buildGeometryNode[type.toLowerCase()]; 504 var geometryNode = this.buildGeometryNode(geometry); 507 505 var geometryNode; 508 506 if(builder) { … … 538 536 539 537 /** 540 * Property: buildGeometryNode 538 * APIMethod: buildGeometryNode 539 */ 540 buildGeometryNode: function(geometry) { 541 var className = geometry.CLASS_NAME; 542 var type = className.substring(className.lastIndexOf(".") + 1); 543 var builder = this.buildGeometry[type.toLowerCase()]; 544 return builder.apply(this, [geometry]); 545 }, 546 547 /** 548 * Property: buildGeometry 541 549 * Object containing methods to do the actual geometry node building 542 550 * based on geometry type. 543 551 */ 544 buildGeometry Node: {552 buildGeometry: { 545 553 // TBD retrieve the srs from layer 546 554 // srsName is non-standard, so not including it until it's right. … … 549 557 550 558 /** 551 * Method: buildGeometry Node.point559 * Method: buildGeometry.point 552 560 * Given an OpenLayers point geometry, create a GML point. 553 561 * … … 565 573 566 574 /** 567 * Method: buildGeometry Node.multipoint575 * Method: buildGeometry.multipoint 568 576 * Given an OpenLayers multipoint geometry, create a GML multipoint. 569 577 * … … 581 589 pointMember = this.createElementNS(this.gmlns, 582 590 "gml:pointMember"); 583 pointGeom = this.buildGeometry Node.point.apply(this,591 pointGeom = this.buildGeometry.point.apply(this, 584 592 [points[i]]); 585 593 pointMember.appendChild(pointGeom); … … 590 598 591 599 /** 592 * Method: buildGeometry Node.linestring600 * Method: buildGeometry.linestring 593 601 * Given an OpenLayers linestring geometry, create a GML linestring. 594 602 * … … 606 614 607 615 /** 608 * Method: buildGeometry Node.multilinestring616 * Method: buildGeometry.multilinestring 609 617 * Given an OpenLayers multilinestring geometry, create a GML 610 618 * multilinestring. … … 624 632 lineMember = this.createElementNS(this.gmlns, 625 633 "gml:lineStringMember"); 626 lineGeom = this.buildGeometry Node.linestring.apply(this,634 lineGeom = this.buildGeometry.linestring.apply(this, 627 635 [lines[i]]); 628 636 lineMember.appendChild(lineGeom); … … 633 641 634 642 /** 635 * Method: buildGeometry Node.linearring643 * Method: buildGeometry.linearring 636 644 * Given an OpenLayers linearring geometry, create a GML linearring. 637 645 * … … 649 657 650 658 /** 651 * Method: buildGeometry Node.polygon659 * Method: buildGeometry.polygon 652 660 * Given an OpenLayers polygon geometry, create a GML polygon. 653 661 * … … 666 674 ringMember = this.createElementNS(this.gmlns, 667 675 "gml:" + type); 668 ringGeom = this.buildGeometry Node.linearring.apply(this,676 ringGeom = this.buildGeometry.linearring.apply(this, 669 677 [rings[i]]); 670 678 ringMember.appendChild(ringGeom); … … 675 683 676 684 /** 677 * Method: buildGeometry Node.multipolygon685 * Method: buildGeometry.multipolygon 678 686 * Given an OpenLayers multipolygon geometry, create a GML multipolygon. 679 687 * … … 692 700 polyMember = this.createElementNS(this.gmlns, 693 701 "gml:polygonMember"); 694 polyGeom = this.buildGeometry Node.polygon.apply(this,702 polyGeom = this.buildGeometry.polygon.apply(this, 695 703 [polys[i]]); 696 704 polyMember.appendChild(polyGeom); sandbox/tschaub/wfsv/lib/OpenLayers/Format/WFS.js
r3889 r3890 38 38 39 39 initialize: function(options, layer) { 40 console.log(layer);41 40 OpenLayers.Format.GML.prototype.initialize.apply(this, [options]); 42 41 this.layer = layer; … … 45 44 } 46 45 if (this.layer.geometry_column) { 47 this.geometryName = this.layer. options.geometry_column;46 this.geometryName = this.layer.geometry_column; 48 47 } 49 48 if (this.layer.typename) { 50 this.featureName = this.layer. options.typename;49 this.featureName = this.layer.typename; 51 50 } 52 51 }, sandbox/tschaub/wfsv/theme/default/style.css
r3887 r3890 172 172 } 173 173 .olControlModifyFeaturePointItemActive { 174 background-image: url("img/move_feature_on.png"); 175 background-repeat: no-repeat; 176 } 177 .olControlModifyFeaturePointItemInactive { 178 background-image: url("img/move_feature_off.png"); 179 background-repeat: no-repeat; 180 } 181 .olControlSaveFeaturesItemActive { 174 182 background-image: url("img/add_point_on.png"); 175 183 background-repeat: no-repeat; 176 184 } 177 .olControl ModifyFeaturePointItemInactive {185 .olControlSaveFeaturesItemInactive { 178 186 background-image: url("img/add_point_off.png"); 179 187 background-repeat: no-repeat;
