OpenLayers OpenLayers

Changeset 7158

Show
Ignore:
Timestamp:
05/13/08 15:32:56 (2 months ago)
Author:
elemoine
Message:

sync with camptocamp/unhcr

Files:

Legend:

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

    r7080 r7158  
    269269    /** 
    270270     * Method: commit 
    271      * Go over the features in the layer and for each take action 
     271     * Go over the features and for each take action 
    272272     * based on the feature state. Possible actions are create, 
    273273     * update and delete. 
    274274     * 
    275275     * Parameters: 
    276      * layer - {<OpenLayers.Layer.Vector>
     276     * features - {Array({<OpenLayers.Feature.Vector>})
    277277     * options - {Object} Map of options, the keys of the map are 
    278278     *           'create', 'update', and 'delete' 
    279279     */ 
    280     commit: function(layer, options) { 
     280    commit: function(features, options) { 
    281281        var toCreate = []; 
    282         for (var i = layer.features.length - 1; i >= 0; i--) { 
    283             var feature = layer.features[i]; 
     282        for (var i = features.length - 1; i >= 0; i--) { 
     283            var feature = features[i]; 
    284284            switch (feature.state) { 
    285285                case OpenLayers.State.INSERT: 
  • sandbox/vector-behavior/lib/OpenLayers/Protocol/SQL/GoogleGears.js

    r7123 r7158  
    3535        this.db.open(this.databaseName); 
    3636        this.db.execute("CREATE TABLE IF NOT EXISTS " + this.tableName + 
    37                         " (fid TEXT UNIQUE, geometry TEXT, properties TEXT)"); 
     37                        " (fid TEXT UNIQUE, geometry TEXT, properties TEXT," + 
     38                        "  state TEXT)"); 
    3839 
    3940        this.db.execute("CREATE INDEX IF NOT EXISTS fid_idx ON " +  
     
    7576        return [feature.fid, 
    7677                feature.geometry.toString(), 
    77                 this.jsonFormat.write(feature.attributes)]; 
     78                this.jsonFormat.write(feature.attributes), 
     79                feature.state]; 
    7880    }, 
    7981 
     
    9193        feature.attributes = this.jsonFormat.read(row.fieldByName('properties')); 
    9294        feature.fid = row.fieldByName('fid'); 
     95        feature.state = row.fieldByName('state'); 
    9396 
    9497        return feature; 
     
    135138        for (var i = 0; i < toCreate.length; i++) { 
    136139            var feature = toCreate[i]; 
    137             this.db.execute("REPLACE INTO " + this.tableName + " (fid, geometry, properties) VALUES (?, ?, ?)", 
     140            this.db.execute("REPLACE INTO " + this.tableName +  
     141                            " (fid, geometry, properties, state) " +  
     142                            "VALUES (?, ?, ?, ?)", 
    138143                            this.freezeFeature(feature)); 
    139             createdFeatures.push(feature); 
     144            createdFeatures.push(feature.clone()); 
    140145        } 
    141146 
     
    168173        for (var i = 0; i < toUpdate.length; i++) { 
    169174            var feature = toUpdate[i]; 
    170             this.db.execute("REPLACE INTO " + this.tableName + " (fid, geometry, properties) VALUES (?, ?, ?)", 
     175            this.db.execute("REPLACE INTO " + this.tableName +  
     176                            " (fid, geometry, properties, state) " +  
     177                            "VALUES (?, ?, ?, ?)", 
    171178                            this.freezeFeature(feature)); 
    172             updatedFeatures.push(feature); 
     179            updatedFeatures.push(feature.clone()); 
    173180        } 
    174181 
     
    208215        OpenLayers.Console.debug("GoogleGears::commit()"); 
    209216        var toCreate = [], toUpdate = []; 
    210  
     217             
    211218        for (var i = features.length - 1; i >= 0; i--) { 
    212219            var feature = features[i];