[Mapbender-commits] r8931 - in trunk/mapbender: http/plugins lib

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Wed Jun 25 02:47:29 PDT 2014


Author: hwbllmnn
Date: 2014-06-25 02:47:29 -0700 (Wed, 25 Jun 2014)
New Revision: 8931

Modified:
   trunk/mapbender/http/plugins/mb_digitize_widget.php
   trunk/mapbender/lib/mb.ui.displayKmlFeatures.js
Log:
always add uuid, created and updated properties


Modified: trunk/mapbender/http/plugins/mb_digitize_widget.php
===================================================================
--- trunk/mapbender/http/plugins/mb_digitize_widget.php	2014-06-25 09:21:48 UTC (rev 8930)
+++ trunk/mapbender/http/plugins/mb_digitize_widget.php	2014-06-25 09:47:29 UTC (rev 8931)
@@ -367,6 +367,7 @@
             });
             editStyleDialog.find('.digitize-save').bind('click', function() {
                 editStyleDialog.dialog('close');
+                feature.properties.updated = new Date().toISOString();
                 kml.refresh(url);
             });
             editStyleDialog.find('input[name="fill"]').spectrum();
@@ -446,6 +447,8 @@
                         feature.properties[k] = v;
                     }
                 });
+                feature.properties.updated = new Date().toISOString();
+
                 attributesDialog.dialog('close');
                 editDialog.dialog('close');
                 kml.refresh(url);
@@ -636,6 +639,7 @@
                 editedFeature.geometry.coordinates[0].push([v.pos.x, v.pos.y]);
             });
         }
+        editedFeature.properties.updated = new Date().toISOString();
         kml.refresh(digitizingFor);
     };
 

Modified: trunk/mapbender/lib/mb.ui.displayKmlFeatures.js
===================================================================
--- trunk/mapbender/lib/mb.ui.displayKmlFeatures.js	2014-06-25 09:21:48 UTC (rev 8930)
+++ trunk/mapbender/lib/mb.ui.displayKmlFeatures.js	2014-06-25 09:47:29 UTC (rev 8931)
@@ -196,7 +196,9 @@
             multi.e.setElement("Mapbender:icon","../img/marker/red.png");
         }
 
-        itm.data.features.push(JSON.parse(multi.toString()));
+        var feat = JSON.parse(multi.toString());
+        itm.data.features.push(feat);
+
         this.element.trigger('kml:loaded',{type:"geojson",data:itm.data,url:itm.url,display: itm.display, refreshing: true});
         $map.setMapRequest();
     },
@@ -552,14 +554,7 @@
                 feats = self.cache[url][map.getSrs()];
                 if(!feats) {
                     $.each(item.data.features, function(_, v) {
-                        if(v.geometry.type === 'Polygon') {
-                            $.each(v.geometry.coordinates, function(_, coords) {
-                                if(coords[0][0] !== coords[coords.length-1][0]
-                                   || coords[0][1] !== coords[coords.length-1][1]) {
-                                    coords.push(coords[0]);
-                                }
-                            });
-                        }
+                        self.fixupFeature(v);
                     });
                     $.ajax({
                         url: '../php/transformgeojson.php?targetEPSG=' + map.getSrs(),
@@ -581,6 +576,27 @@
                 $.each(feats, $.proxy(self, self.renderFeature(canvas)));
             }
         });
+    },
+
+    fixupFeature: function(feat) {
+        if(feat.geometry.type === 'Polygon') {
+            $.each(feat.geometry.coordinates, function(_, coords) {
+                if(coords[0][0] !== coords[coords.length-1][0]
+                 || coords[0][1] !== coords[coords.length-1][1]) {
+                    coords.push(coords[0]);
+                }
+            });
+        }
+
+        if(!feat.properties.uuid) {
+            feat.properties.uuid = UUID.genV1().toString();
+        }
+        if(!feat.properties.updated) {
+            feat.properties.updated = new Date().toISOString();
+        }
+        if(!feat.properties.created) {
+            feat.properties.created = new Date().toISOString();
+        }
     }
 
 };



More information about the Mapbender_commits mailing list