OpenLayers OpenLayers

Changeset 3890

Show
Ignore:
Timestamp:
08/10/07 23:29:17 (1 year ago)
Author:
tschaub
Message:

editing updates

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sandbox/tschaub/wfsv/examples/wfs-v.html

    r3881 r3890  
    3434            var panel = new OpenLayers.Control.WFSEditor("/geoserver/wfsv", 
    3535                                                         "topp:archsites", 
    36                                                          "Point"); 
     36                                                         "Point", 
     37                                                         {staticLayer: wms}); 
    3738              
    3839            map.addControl(panel); 
    39 //            map.addControl(new OpenLayers.Control.KeyboardDefaults); 
    4040            map.zoomToMaxExtent(); 
    4141        } 
  • sandbox/tschaub/wfsv/lib/OpenLayers/Control/FeatureEditor.js

    r3889 r3890  
    3636     */ 
    3737    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, 
    3850     
    3951    /** 
     
    93105                {displayClass: "olControlModifyFeature" + this.geometryType} 
    94106        ); 
    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, 
    101124                          this.modifyControl, 
    102125                          this.drawControl, 
     
    109132        }); 
    110133 
     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); 
    111154    }, 
    112155     
  • sandbox/tschaub/wfsv/lib/OpenLayers/Control/ModifyFeature.js

    r3884 r3890  
    2121     */ 
    2222    geometryTypes: null, 
     23     
     24    /** 
     25     * APIProperty: onModify 
     26     * Called on each feature modification. 
     27     */ 
     28    onModify: function(feature) {}, 
    2329 
    2430    /** 
     
    7177                                 onDrag: function(feature) { 
    7278                                    control.onDrag.apply(control, [feature]); 
     79                                 }, 
     80                                 onComplete: function() { 
     81                                    control.onModify(control.feature) 
    7382                                 }}); 
    7483    }, 
  • sandbox/tschaub/wfsv/lib/OpenLayers/Control/SaveFeatures.js

    r3889 r3890  
    2121     
    2222    /** 
     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    /** 
    2338     * Constructor: OpenLayers.Control.SaveFeatures 
    2439     */ 
    2540    initialize: function(layer, url, options) { 
     41        this.wfsOptions = OpenLayers.Util.extend({}, options.wfsOptions); 
    2642        this.layer = layer; 
    2743        this.url = url; 
    2844        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); 
    3046    }, 
    3147     
     
    3551     */ 
    3652    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); 
    4754 
    4855        var url = this.url; 
     
    6067                                     onFailure: failure 
    6168                                    }); 
     69         
    6270    }, 
    6371 
     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     
    6498    CLASS_NAME: "OpenLayers.Control.SaveFeatures" 
    6599 
  • sandbox/tschaub/wfsv/lib/OpenLayers/Format/GML.js

    r3884 r3890  
    502502    createFeatureXML: function(feature) { 
    503503        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); 
    507505        var geometryNode; 
    508506        if(builder) { 
     
    538536     
    539537    /** 
    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 
    541549     * Object containing methods to do the actual geometry node building 
    542550     *     based on geometry type. 
    543551     */ 
    544     buildGeometryNode: { 
     552    buildGeometry: { 
    545553        // TBD retrieve the srs from layer 
    546554        // srsName is non-standard, so not including it until it's right. 
     
    549557 
    550558        /** 
    551          * Method: buildGeometryNode.point 
     559         * Method: buildGeometry.point 
    552560         * Given an OpenLayers point geometry, create a GML point. 
    553561         * 
     
    565573         
    566574        /** 
    567          * Method: buildGeometryNode.multipoint 
     575         * Method: buildGeometry.multipoint 
    568576         * Given an OpenLayers multipoint geometry, create a GML multipoint. 
    569577         * 
     
    581589                pointMember = this.createElementNS(this.gmlns, 
    582590                                                   "gml:pointMember"); 
    583                 pointGeom = this.buildGeometryNode.point.apply(this, 
     591                pointGeom = this.buildGeometry.point.apply(this, 
    584592                                                               [points[i]]); 
    585593                pointMember.appendChild(pointGeom); 
     
    590598         
    591599        /** 
    592          * Method: buildGeometryNode.linestring 
     600         * Method: buildGeometry.linestring 
    593601         * Given an OpenLayers linestring geometry, create a GML linestring. 
    594602         * 
     
    606614         
    607615        /** 
    608          * Method: buildGeometryNode.multilinestring 
     616         * Method: buildGeometry.multilinestring 
    609617         * Given an OpenLayers multilinestring geometry, create a GML 
    610618         *     multilinestring. 
     
    624632                lineMember = this.createElementNS(this.gmlns, 
    625633                                                  "gml:lineStringMember"); 
    626                 lineGeom = this.buildGeometryNode.linestring.apply(this, 
     634                lineGeom = this.buildGeometry.linestring.apply(this, 
    627635                                                                   [lines[i]]); 
    628636                lineMember.appendChild(lineGeom); 
     
    633641         
    634642        /** 
    635          * Method: buildGeometryNode.linearring 
     643         * Method: buildGeometry.linearring 
    636644         * Given an OpenLayers linearring geometry, create a GML linearring. 
    637645         * 
     
    649657         
    650658        /** 
    651          * Method: buildGeometryNode.polygon 
     659         * Method: buildGeometry.polygon 
    652660         * Given an OpenLayers polygon geometry, create a GML polygon. 
    653661         * 
     
    666674                ringMember = this.createElementNS(this.gmlns, 
    667675                                                  "gml:" + type); 
    668                 ringGeom = this.buildGeometryNode.linearring.apply(this, 
     676                ringGeom = this.buildGeometry.linearring.apply(this, 
    669677                                                                   [rings[i]]); 
    670678                ringMember.appendChild(ringGeom); 
     
    675683         
    676684        /** 
    677          * Method: buildGeometryNode.multipolygon 
     685         * Method: buildGeometry.multipolygon 
    678686         * Given an OpenLayers multipolygon geometry, create a GML multipolygon. 
    679687         * 
     
    692700                polyMember = this.createElementNS(this.gmlns, 
    693701                                                  "gml:polygonMember"); 
    694                 polyGeom = this.buildGeometryNode.polygon.apply(this, 
     702                polyGeom = this.buildGeometry.polygon.apply(this, 
    695703                                                                [polys[i]]); 
    696704                polyMember.appendChild(polyGeom); 
  • sandbox/tschaub/wfsv/lib/OpenLayers/Format/WFS.js

    r3889 r3890  
    3838     
    3939    initialize: function(options, layer) { 
    40         console.log(layer); 
    4140        OpenLayers.Format.GML.prototype.initialize.apply(this, [options]); 
    4241        this.layer = layer; 
     
    4544        }     
    4645        if (this.layer.geometry_column) { 
    47             this.geometryName = this.layer.options.geometry_column; 
     46            this.geometryName = this.layer.geometry_column; 
    4847        } 
    4948        if (this.layer.typename) { 
    50             this.featureName = this.layer.options.typename; 
     49            this.featureName = this.layer.typename; 
    5150        } 
    5251    }, 
  • sandbox/tschaub/wfsv/theme/default/style.css

    r3887 r3890  
    172172} 
    173173.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 {  
    174182  background-image: url("img/add_point_on.png"); 
    175183  background-repeat: no-repeat; 
    176184} 
    177 .olControlModifyFeaturePointItemInactive {  
     185.olControlSaveFeaturesItemInactive {  
    178186  background-image: url("img/add_point_off.png"); 
    179187  background-repeat: no-repeat;