[Mapbender-commits] r9478 - trunk/mapbender/lib

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Thu May 26 23:40:50 PDT 2016


Author: armin11
Date: 2016-05-26 23:40:50 -0700 (Thu, 26 May 2016)
New Revision: 9478

Modified:
   trunk/mapbender/lib/editGroup.php
   trunk/mapbender/lib/mb.ui.displayKmlFeatures.js
Log:
Fix wrong commit from paul

Modified: trunk/mapbender/lib/editGroup.php
===================================================================
--- trunk/mapbender/lib/editGroup.php	2016-05-25 10:30:42 UTC (rev 9477)
+++ trunk/mapbender/lib/editGroup.php	2016-05-27 06:40:50 UTC (rev 9478)
@@ -74,6 +74,7 @@
 		$changes->facsimiletelephone = $facsimiletelephone;
 		$changes->email = $email;
 		$changes->logo_path = $logo_path;
+		$changes->homepage = $homepage;
 		$group->change($changes);	
 		
 		$group->create();	
@@ -104,6 +105,7 @@
 		$changes->facsimiletelephone = $facsimiletelephone;
 		$changes->email = $email;
 		$changes->logo_path = $logo_path;
+		$changes->homepage = $homepage;
 		$group->change($changes);		
 
 		$group->commit();	
@@ -126,6 +128,7 @@
 	$facsimiletelephone = "";
 	$email = "";
 	$logo_path = "";
+	$homepage = "";
 }
 
 /*HTML*****************************************************************************************************/
@@ -178,6 +181,7 @@
 		$facsimiletelephone = $data["facsimiletelephone"];
 		$email = $data["email"];
 		$logo_path = $data["logo_path"];
+		$homepage = $data["homepage"];
 	}
 	$owner = new User(intval($owner_id));
 	if ($owner->isValid()) {
@@ -304,6 +308,14 @@
    echo "</td>";
 echo "</tr>";
 
+#logo
+echo "<tr>";
+   echo "<td>Homepage: </td>";
+   echo "<td>";
+      echo "<input type='text' size='30' name='homepage' value='" .
+          htmlentities($homepage, ENT_QUOTES, "UTF-8") . "'>";
+   echo "</td>";
+echo "</tr>";
 # blank row
 echo "<tr>";
    echo "<td colspan='2'> </td>";
@@ -329,4 +341,4 @@
 <input type='hidden' name='action' value=''>
 </form>
 </body>
-</html>
\ No newline at end of file
+</html>

Modified: trunk/mapbender/lib/mb.ui.displayKmlFeatures.js
===================================================================
--- trunk/mapbender/lib/mb.ui.displayKmlFeatures.js	2016-05-25 10:30:42 UTC (rev 9477)
+++ trunk/mapbender/lib/mb.ui.displayKmlFeatures.js	2016-05-27 06:40:50 UTC (rev 9478)
@@ -426,14 +426,15 @@
         var item = this._kmls[url];
 
         var bbox = this.getBbox(item.data.features[idx]);
-
+        var bufferx = (bbox[2] - bbox[0]) * 0.2;
+        var buffery = (bbox[3] - bbox[1]) * 0.2;
         var min = Proj4js.transform(this.wgs84, this.targetProj, {
-            x: bbox[0],
-            y: bbox[1]
+            x: bbox[0] - bufferx,
+            y: bbox[1] - buffery
         });
         var max = Proj4js.transform(this.wgs84, this.targetProj, {
-            x: bbox[2],
-            y: bbox[3]
+            x: bbox[2] + bufferx,
+            y: bbox[3] + buffery
         });
 
         map.calculateExtent(
@@ -484,8 +485,65 @@
     setQueriedLayer: function(url) {
         this.queriedLayer = url;
     },
+    
+    addFeature: function(url, feature) {
+        if(!feature){
+            return;
+        }
+        this.cache = {};
+        var itm = this._kmls[url];
+        feature.properties.created = feature.properties.updated = new Date().toISOString();
+        feature.properties.uuid = UUID.genV4().toString();
+        itm.data.features.push(feature);
+        $('#mapframe1').data('kml').element.trigger('kml:loaded', {
+            type: "geojson",
+            data: itm.data,
+            url: itm.url,
+            display: itm.display,
+            refreshing: true,
+        });
+        return itm.data.features.length - 1;
+    },
+    translateFeature: function(feature, newCentroid){
+        var fc = this.getCentroid(feature);
+        var dx = newCentroid.x - fc.x;
+        var dy = newCentroid.y - fc.y;
+        switch (feature.geometry.type.toLowerCase()) {
+            case 'point':
+                feature.geometry.coordinates[0] = feature.geometry.coordinates[0] + dx;
+                feature.geometry.coordinates[1] = feature.geometry.coordinates[1] + dy;
+                return feature;
+            case 'linestring':
+                var coords = feature.geometry.coordinates;
+                for(var j = 0; j < coords.length; j++){
+                    coords[j][0] = coords[j][0] + dx;
+                    coords[j][1] = coords[j][1] + dy;
+                }
+                return feature;
 
-    addGeometry: function(pts, url, attributesDialog) {
+            case 'polygon':
+                coords = feature.geometry.coordinates;
+                for(var i = 0; i < coords.length; i++){
+                    for(var j = 0; j < coords[i].length; j++){
+                        coords[i][j][0] = coords[i][j][0] + dx;
+                        coords[i][j][1] = coords[i][j][1] + dy;
+                    }
+                }
+                return feature;
+        }
+        return undefined;
+    },
+    
+    
+    copyFeature: function(feature) {
+        var temp = $.extend(true, {}, feature);
+        temp.properties.name = temp.properties.name + '_copied';
+        temp.properties.created = feature.properties.updated = temp.properties.uuid = null;
+        this.fixupFeature(temp);
+        return temp;
+    },
+
+    addGeometry: function(pts, url, attributes) {
         this.cache = {};
         var $map = $(this.element).mapbender();
         var self = this;
@@ -512,14 +570,10 @@
         var modifiedGeom = $.extend(true, {}, geom);
         var modifiedData = new MultiGeometry(tp);
             // add geometry: proof if polygon or linestring and add area or length
+        for(var k_ in attributes){
+            multi.e.setElement(k_, attributes[k_]);
+        }
 
-        attributesDialog.find('table input').each(function() {
-            var name = $(this).attr('name');
-            if (name) {
-                multi.e.setElement($(this).attr('name'), $(this).attr('value'));
-            }
-        });
-
         if (geom.geomType != 'point') {
 
             if (geom.geomType == 'polygon') {
@@ -582,13 +636,6 @@
 
 
         } else {
-
-            attributesDialog.find('table input').each(function() {
-                var name = $(this).attr('name');
-                if (name) {
-                    multi.e.setElement($(this).attr('name'), $(this).val());
-                }
-            });
             if (icon == "false" || icon === false) {
                 multi.e.setElement("iconOffsetX", -10);
                 multi.e.setElement("iconOffsetY", -34);
@@ -785,6 +832,11 @@
         }
         return bbox;
     },
+    
+    getCentroid: function(feature){
+        var bbox = this.getBbox(feature);
+        return bbox ? {x: (bbox[0] + bbox[2]) / 2, y: (bbox[1] + bbox[3]) / 2} : undefined;
+    },
 
     getBbox: function(feature) {
         switch (feature.geometry.type.toLowerCase()) {
@@ -992,7 +1044,18 @@
         });
         canvas.path(path + 'Z').attr(feature.properties);
     },
-
+    renderLabel: function(canvas, feature) {
+        var label;
+        if(feature.label && (label=feature.properties[feature.label])){
+            var map = $('#mapframe1').mapbender();
+            var self = this;
+            var path;
+            var centroid = this.getCentroid(feature);
+            var pt = map.convertRealToPixel(centroid);
+            canvas.text(pt.x, pt.y, label);
+        }
+    },
+    
     renderFeature: function(canvas) {
         var self = this;
         return function(_, feature) {
@@ -1011,6 +1074,7 @@
                         self.renderPolygon(canvas, feature);
                         break;
                 };
+                self.renderLabel(canvas, feature);
             } catch (e) {
                 console && console.log('Problem rendering feature', feature, e)
             }



More information about the Mapbender_commits mailing list