[Mapbender-commits] r9172 - in trunk/mapbender: http/css http/php http/plugins lib

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue Mar 17 03:29:54 PDT 2015


Author: syed
Date: 2015-03-17 03:29:54 -0700 (Tue, 17 Mar 2015)
New Revision: 9172

Modified:
   trunk/mapbender/http/css/kmltree.css
   trunk/mapbender/http/php/mod_CalculateAreaAndLength.php
   trunk/mapbender/http/plugins/kmlTree.js
   trunk/mapbender/http/plugins/mb_digitize_widget.php
   trunk/mapbender/lib/mb.ui.displayKmlFeatures.js
Log:
remove several bugs

Modified: trunk/mapbender/http/css/kmltree.css
===================================================================
--- trunk/mapbender/http/css/kmltree.css	2015-03-16 10:20:20 UTC (rev 9171)
+++ trunk/mapbender/http/css/kmltree.css	2015-03-17 10:29:54 UTC (rev 9172)
@@ -213,3 +213,21 @@
     margin: 1px;
 
 }
+
+
+#publishDenied {
+
+position:absolute;
+width:50%;
+cursor:pointer;
+left: -10px;
+
+}
+
+#publishConfirmed {
+
+
+width:50%;
+cursor:pointer;
+
+}

Modified: trunk/mapbender/http/php/mod_CalculateAreaAndLength.php
===================================================================
--- trunk/mapbender/http/php/mod_CalculateAreaAndLength.php	2015-03-16 10:20:20 UTC (rev 9171)
+++ trunk/mapbender/http/php/mod_CalculateAreaAndLength.php	2015-03-17 10:29:54 UTC (rev 9172)
@@ -24,6 +24,7 @@
 $geom_data = $_POST['wkt_geom'];
 $sql;
 // calculate length of a linetring
+// var_dump($geom_data);die;
 if ($geom_type == 'line') {
 
     $sql = "SELECT st_length(st_GeogFromText( $1 )) as meter";
@@ -42,11 +43,11 @@
 
 while($row = db_fetch_array($res)){
 
-    $rslt[0] = $row[0];
+    $rslt[0] = round(floatval($row[0]),4);
 
         if (sizeof($row) > 1) {
 
-            $rslt[1] = $row[1];
+            $rslt[1] = round(floatval($row[1]),4);
 
         }
 }

Modified: trunk/mapbender/http/plugins/kmlTree.js
===================================================================
--- trunk/mapbender/http/plugins/kmlTree.js	2015-03-16 10:20:20 UTC (rev 9171)
+++ trunk/mapbender/http/plugins/kmlTree.js	2015-03-17 10:29:54 UTC (rev 9172)
@@ -108,9 +108,9 @@
                             v[3] = '<img src="' + v[3] + '"></img>';
                         }
                         if (v[4]) {
-                            v[4] = '<img src="../img/osgeo_graphics/check.png"></img><img class="exportImage" src="../img/osgeo_graphics/geosilk/link22.png"></img>';
+                            v[4] = '<img class="publishIcon" src="../img/osgeo_graphics/check.png"></img><img class="exportImage" src="../img/osgeo_graphics/geosilk/link22.png"></img>';
                         } else {
-                            v[4] = '<img src="../img/button_digitize/geomRemove.png"></img>';
+                            v[4] = '<img class="publishIcon" src="../img/button_digitize/geomRemove.png"></img>';
                         }
                         v[5] = Math.round(v[5] / 1024) + 'kb';
                     });
@@ -213,8 +213,9 @@
                             }
                         })
                         .end()
-                        .find('tr').bind('click', function() {
-                            var id = $($(this).find('td')[0]).text();
+                        .find('.publishIcon').bind('click', function() {
+                            // var id = $($(this).find('td')[0]).text();
+                            var id = $(this).parent().parent().children(':first').html();
                             var d;
                             $.each(origData, function(_, val) {
                                 if (val[0] == id) {
@@ -302,8 +303,8 @@
 
                                             publishDialog = $('<div id="wmcPublishConfirm"></div>').dialog({
                                                 title: "Publish datacollection " + d[1],
-                                                width: 720,
-                                                height: 180,
+                                                width: 373,
+                                                height: 'auto',
                                                 position: {
                                                     my: "center",
                                                     at: "top",
@@ -322,9 +323,9 @@
                                                 " licences are supported in this application. Please read the licenses carefully before" +
                                                 " you activate this option. All of your data will be available for each person in the web" +
                                                 " in different formats and may be redistributed freely without any copyright. </div>" +
-                                                "<table style='margin-top:7px' ><tr><th id = 'publishDenied' style='width:50%;cursor:pointer'><img src='../img/button_digitize/geomRemove.png'></img>  No, I dont't want to publish</th>" +
+                                                "<table style='margin-top:7px' ><tr><th id = 'publishDenied'><img src='../img/button_digitize/geomRemove.png'></img>  No, I dont't want to publish</th>" +
                                                 "<th style='width:16%;visibility:hidden'>empty</th>" +
-                                                "<th id = 'publishConfirmed' style='width:50%;cursor:pointer'><img src='../img/osgeo_graphics/check.png'></img>  Yes, I know what I am doing </th></tr></table>";
+                                                "<th id = 'publishConfirmed'><img src='../img/osgeo_graphics/check.png'></img>  Yes, I know what I am doing </th></tr></table>";
 
                                             $(publishDialog).append(publishDlgContent);
 

Modified: trunk/mapbender/http/plugins/mb_digitize_widget.php
===================================================================
--- trunk/mapbender/http/plugins/mb_digitize_widget.php	2015-03-16 10:20:20 UTC (rev 9171)
+++ trunk/mapbender/http/plugins/mb_digitize_widget.php	2015-03-17 10:29:54 UTC (rev 9172)
@@ -93,10 +93,10 @@
     var editAttributesHtml = '<div title="Feature attributes">' +
         '<div class="digitize-image digitize-style"></div>' +
         '<div class="digitize-preview"></div><br></br>' +
-        '<div class="attrAccordion">' +
-        '<table><tr><td>Name</td><td><input type="text" name="name" value="Titel"></input></td></tr>' +
+        // '<div class="attrAccordion">' +
+        '<table id="arp"><tr><td>Name</td><td><input id="arp-input" type="text" name="name" value="Titel"></input></td></tr>' +
         '<tr><td>Description</td><td><input type="text" name="description" value="Beschreibung CDATA"></input></td></tr>' +
-        '</table></div><br></br>' +
+        '</table><br></br>' +
         '<div class="digitize-image digitize-add"></div>' +
         '<div class="digitize-image digitize-save"></div>' +
         '</div>';
@@ -242,6 +242,7 @@
             $('#kmlTree li.kmltree-selected').removeClass('kmltree-selected');
             attributesDialog.dialog('close');
             editStyleDialog.dialog('close');
+            console.log('ende');
         });
         attributesDialog = $(editAttributesHtml);
         attributesDialog.dialog({
@@ -666,6 +667,7 @@
                 attributesDialog.dialog('open');
                 attributesDialog.find('*').unbind();
                 attributesDialog.html(tableEditAttributesHtml);
+
                 var geometryDiv = $('<div class= "geometry-div"></div>');
                 // create for each section [#4] one table in a div and put it in html of .attrAccordion
                 var nonEditableRows = '<h3 style="text-align:center;">Fix-Data</h3><div><table class="ftr-data-tbl fix-data">';//</table></div>';
@@ -687,17 +689,17 @@
 
                         editableRows += '<tr><td>' + k + '</td><td><input type="text" name="' + k + '" value="' + v + '"></input></td></tr>';
 
-                    } else if( k.match('marker') != null  ){
+                    } else if( k.match('marker') != null || k == 'stroke' || k == 'stroke-opacity' || k == 'stroke-width' || k == 'fill' || k == 'fill-opacity' ){
 
                         styleRows += '<tr><td>' + k + '</td><td><input type="text" name="' + k + '" value="' + v + '"></input></td></tr>';
 
-                    } else if( k == "Fläche [m²]" || k == "Länge [m]" ||  k == "Umfang [m]" ){
+                    } else if( k == "Area [m²]" || k == "Length [m]" ||  k == "Boundary-Length [m]" ){
 
                             geometryDiv.append('<div><p class = " geometry-p "name="' + k + '">'+ k +' : ' + v + '</p></div>');
 
                     } else{
 
-                        customRows += '<tr><td>' + k + '</td><td><input type="text" name="' + k + '" value="' + v + '"></input></td></tr>';
+                        customRows += '<tr><td>' + k + '</td><td><input type="text" name="' + k + '" value="' + v + '"></input></td><td><img class="removeCustomFeatAttr" src="../img/button_digitize/geomRemove.png"></td></tr>';
 
                     }
                 });
@@ -729,7 +731,7 @@
                 // $(divider).after(rows);
                 // $( '.attrAccodion' ).accordion();
                 attributesDialog.find('.digitize-add').bind('click', function() {
-                    var newRow = $('<tr><td><input style="width:100px" type="text"></input></td><td><input style="width:100px" type="text"></input></td></tr>');
+                    var newRow = $('<tr><td><input style="width:81px" type="text"></input></td><td><input style="width:100px" type="text"></input></td></tr>');
                     attributesDialog.find('.ftr-data-tbl.custom-data').append(newRow);
                     newRow.find('input').first().bind('change', function() {
                         newRow.find('input').last().attr('name', $(this).val());
@@ -755,6 +757,16 @@
                     editDialog.dialog('close');
                     kml.refresh(url);
                 });
+
+                // remove custom attributes
+                attributesDialog.find('.removeCustomFeatAttr').bind('click',function(){
+
+                    var attrName = $(this).parent().parent().children(':first').html();
+                    delete feature.properties[attrName];
+                    $(this).parent().parent().remove();
+
+                });
+
                 var preview = attributesDialog.find('.digitize-preview').html('').get(0);
                 kml.renderPreview(feature, preview);
             }
@@ -937,8 +949,8 @@
                 });
             attributesDialog.find('.digitize-save').bind('click', function() {
                 kml.addGeometry(pts, digitizingFor, attributesDialog);
+                attributesDialog.find('.digitize-save').unbind('click');
                 attributesDialog.dialog('close');
-                attributesDialog.find('.digitize-save').unbind('click');
             });
         }
     };
@@ -949,17 +961,25 @@
         that.activate();
     };
 
-    var featureModified = function() {
+ var featureModified = function() {
+
         var kml = $('#mapframe1').data('kml');
         var digit = o.$target.data('mb_digitize');
+        var geom = new Geometry();
+        var geomType = editedFeature.geometry.type.toLowerCase();
         //digit.modeOff();
         var pts = $.extend(true, {}, digit._digitizePoints);
         $.each(pts, function(_, v) {
             if(!$.isPlainObject(v.pos)) {
                 v.pos = {x: v.pos.x, y: v.pos.y};
             }
-            Proj4js.transform(kml.targetProj, kml.wgs84, v.pos);
+            var newPoint = Proj4js.transform(kml.targetProj, kml.wgs84, v.pos);
+            // Proj4js.transform(kml.targetProj, kml.wgs84, v.pos);
+            geom.addPoint(newPoint);
         });
+        geom.geomType = geomType;
+        var multi = new MultiGeometry(geomType);
+        multi.add(geom);
 
         if(status === 'edit-point') {
             editedFeature.geometry.coordinates = [pts[0].pos.x, pts[0].pos.y];
@@ -974,8 +994,46 @@
                 editedFeature.geometry.coordinates[0].push([v.pos.x, v.pos.y]);
             });
         }
-        editedFeature.properties.updated = new Date().toISOString();
-        kml.refresh(digitizingFor);
+
+        if (status != 'edit-point') {
+
+            // calculate current area (polygon) or length(linestring)
+            $.ajax({
+                url: '../php/mod_CalculateAreaAndLength.php',
+                type: 'POST',
+                dataType: 'json',
+                data: {
+                    geom_type: geomType,
+                    wkt_geom: multi.toText()
+                },
+                success: function(data) {
+
+                    if (geom.geomType == 'polygon') {
+
+                        editedFeature.properties['Area [m²]'] = data[0];
+                        editedFeature.properties['Boundary-Length [m]'] = data[1];
+
+                    } else {
+
+                        editedFeature.properties['Length [m]'] = data[0];
+                    }
+
+                },
+                complete: function() {
+
+
+                    editedFeature.properties.updated = new Date().toISOString();
+                    kml.refresh(digitizingFor);
+
+                }
+            });
+
+        }else{
+
+            editedFeature.properties.updated = new Date().toISOString();
+            kml.refresh(digitizingFor);
+
+        }
     };
 
     this.activate = function () {

Modified: trunk/mapbender/lib/mb.ui.displayKmlFeatures.js
===================================================================
--- trunk/mapbender/lib/mb.ui.displayKmlFeatures.js	2015-03-16 10:20:20 UTC (rev 9171)
+++ trunk/mapbender/lib/mb.ui.displayKmlFeatures.js	2015-03-17 10:29:54 UTC (rev 9172)
@@ -423,6 +423,7 @@
         for (var i = 0; i < pts.length; ++i) {
             var pt = Proj4js.transform(this.targetProj, this.wgs84, pts[i].pos);
             geom.addPoint(pt);
+            console.log(pt);
         }
         geom.geomType = tp;
         multi.add(geom);
@@ -437,6 +438,14 @@
         var modifiedGeom = $.extend(true, {}, geom);
         var modifiedData = new MultiGeometry(tp);
             // add geometry: proof if polygon or linestring and add area or length
+
+        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') {
@@ -462,24 +471,16 @@
 
                     if (geom.geomType == 'polygon') {
 
-                        multi.e.setElement('Fläche [m²]', data[0]);
-                        multi.e.setElement('Umfang [m]', data[1]);
+                        multi.e.setElement('Area [m²]', data[0]);
+                        multi.e.setElement('Boundary-Length [m]', data[1]);
 
                     } else {
 
-                        multi.e.setElement('Länge [m]', data[0]);
+                        multi.e.setElement('Length [m]', data[0]);
                     }
 
                 },
                 complete: function() {
-
-                    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("Mapbender:iconOffsetX", -10);
                         multi.e.setElement("Mapbender:iconOffsetY", -34);



More information about the Mapbender_commits mailing list