[Mapbender-commits] r9165 - in trunk/mapbender: http/php http/plugins lib
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Tue Mar 10 05:57:47 PDT 2015
Author: syed
Date: 2015-03-10 05:57:47 -0700 (Tue, 10 Mar 2015)
New Revision: 9165
Modified:
trunk/mapbender/http/php/mod_GetPublishedData.php
trunk/mapbender/http/plugins/mb_digitize_widget.php
trunk/mapbender/lib/mb.ui.displayKmlFeatures.js
Log:
add area and length attributes for specified features
Modified: trunk/mapbender/http/php/mod_GetPublishedData.php
===================================================================
--- trunk/mapbender/http/php/mod_GetPublishedData.php 2015-03-09 13:53:51 UTC (rev 9164)
+++ trunk/mapbender/http/php/mod_GetPublishedData.php 2015-03-10 12:57:47 UTC (rev 9165)
@@ -1,7 +1,6 @@
<?php
-ini_set('display_errors', 'On');
-error_reporting(E_ALL);
+
/**
* @version Changed: ### 2015-02-23 14:00:42 UTC ###
* @author Raphael.Syed <raphael.syed at WhereGroup.com> http://WhereGroup.com
@@ -50,8 +49,15 @@
$kmls = array_values($myWmc->generalExtensionArray["KMLS"]);
//create the fileName
+
$file = "myDataCollection.".$outputFormat;
+if (isset($kmls[0]["data"]['@context'])) {
+
+ $file = rawurldecode($kmls[0]["data"]['@context']['title']).'.'.$outputFormat;
+
+}
+
if (sizeof($kmls) > 1) {
# create a file for each featureCollection and push them in a zip
Modified: trunk/mapbender/http/plugins/mb_digitize_widget.php
===================================================================
--- trunk/mapbender/http/plugins/mb_digitize_widget.php 2015-03-09 13:53:51 UTC (rev 9164)
+++ trunk/mapbender/http/plugins/mb_digitize_widget.php 2015-03-10 12:57:47 UTC (rev 9165)
@@ -589,18 +589,21 @@
var featureCollectionContent = "<div class='digitize-image digitize-style'></div>"+
"<br><br>"+
"<div><table id='featureCollTbl'>"+
- // "<tr><td>uuid</td><td><input type='text' name='uuid' value='"+feature['@context'].uuid+"'/></td></tr>"+
- // "<tr><td>title</td><td><input type='text' name='title' value='"+feature['@context'].title+"'/></td></tr>"+
- // "<tr><td>created</td><td><input type='text' name='created' value='"+feature['@context'].created+"'/></td></tr>"+
- // "<tr><td>updated</td><td><input type='text' name='updated' value='"+feature['@context'].updated+"'/></td></tr>"+
"</table></div>"+
"<br><br/>"+
"<div class='digitize-image digitize-add'></div>"+
"<div class='digitize-image digitize-save'></div>";
$('#featureCollAttrDlg').append(featureCollectionContent);
$.each(feature['@context'], function(index, val) {
+ if (index == 'uuid' || index == 'created' || index == 'updated') {
- $('#featureCollTbl').append("<tr><td>"+index+"</td><td><input type='text' name='"+index+"' value='"+val+"'/></td></tr>");
+ $('#featureCollTbl').append("<tr><td>"+index+"</td><td><input style='width:230px;' type='text' name='"+index+"' value='"+val+"' disabled /></td></tr>");
+
+ }else{
+
+ $('#featureCollTbl').append("<tr><td>"+index+"</td><td><input style='width:230px;' type='text' name='"+index+"' value='"+val+"'/></td></tr>");
+
+ }
});
featureCollAttrDlg.find('.digitize-save').bind('click', function() {
featureCollAttrDlg.find('table input').each(function() {
@@ -654,7 +657,15 @@
var rows = '';
$.each(feature.properties, function(k, v) {
if(k.match(/Mapbender:/)) return;
- rows += '<tr><td>' + k + '</td><td><input type="text" name="' + k + '" value="' + v + '"></input></td></tr>';
+ if (k == "Fläche [m²]" || k == "Länge [m]") {
+
+ rows += '<tr><td>' + k + '</td><td><input disabled type="text" name="' + k + '" value="' + v + '"></input></td></tr>';
+
+ }else {
+
+ rows += '<tr><td>' + k + '</td><td><input type="text" name="' + k + '" value="' + v + '"></input></td></tr>';
+
+ }
});
attributesDialog.find('table').html(rows);
attributesDialog.find('.digitize-add').bind('click', function() {
Modified: trunk/mapbender/lib/mb.ui.displayKmlFeatures.js
===================================================================
--- trunk/mapbender/lib/mb.ui.displayKmlFeatures.js 2015-03-09 13:53:51 UTC (rev 9164)
+++ trunk/mapbender/lib/mb.ui.displayKmlFeatures.js 2015-03-10 12:57:47 UTC (rev 9165)
@@ -419,6 +419,7 @@
var geom = new Geometry();
var multi = new MultiGeometry(tp);
+
for (var i = 0; i < pts.length; ++i) {
var pt = Proj4js.transform(this.targetProj, this.wgs84, pts[i].pos);
geom.addPoint(pt);
@@ -427,33 +428,107 @@
multi.add(geom);
multi.e = new Wfs_element();
+
var icon = multi.e.getElementValueByName("Mapbender:icon");
multi.e.setElement('title', 'title');
multi.e.setElement('name', 'name');
- attributesDialog.find('table input').each(function() {
- var name = $(this).attr('name');
- if (name) {
- multi.e.setElement($(this).attr('name'), $(this).val());
+
+ // cloning the geoms to calculate the area or length
+ var modifiedGeom = $.extend(true, {}, geom);
+ var modifiedData = new MultiGeometry(tp);
+ // add geometry: proof if polygon or linestring and add area or length
+ if (geom.geomType != 'point') {
+
+ if (geom.geomType == 'polygon') {
+
+ modifiedGeom.addPoint(geom.list[0]);
+ modifiedData.add(modifiedGeom);
+
+ } else {
+
+ modifiedData.add(modifiedGeom);
}
- });
- if (icon == "false" || icon === false) {
- multi.e.setElement("Mapbender:iconOffsetX", -10);
- multi.e.setElement("Mapbender:iconOffsetY", -34);
- multi.e.setElement("Mapbender:icon", "../img/marker/red.png");
- }
+ // calculate current area (polygon) or length(linestring)
+ $.ajax({
+ url: '../php/mod_CalculateAreaAndLength.php',
+ type: 'POST',
+ data: {
+ geom_type: modifiedData.geomType,
+ wkt_geom: modifiedData.toText()
+ },
+ success: function(data) {
- var feat = JSON.parse(multi.toString());
- itm.data.features.push(feat);
+ if (geom.geomType == 'polygon') {
- this.element.trigger('kml:loaded', {
- type: "geojson",
- data: itm.data,
- url: itm.url,
- display: itm.display,
- refreshing: true,
- });
- $map.setMapRequest();
+ multi.e.setElement('Fläche [m²]', data);
+
+ } else {
+
+ multi.e.setElement('Länge [m]', data);
+ }
+
+ },
+ 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);
+ multi.e.setElement("Mapbender:icon", "../img/marker/red.png");
+ }
+
+ var feat = JSON.parse(multi.toString());
+ itm.data.features.push(feat);
+
+ $('#mapframe1').data('kml').element.trigger('kml:loaded', {
+ type: "geojson",
+ data: itm.data,
+ url: itm.url,
+ display: itm.display,
+ refreshing: true,
+ });
+ $map.setMapRequest();
+
+ }
+ });
+
+
+ } 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("Mapbender:iconOffsetX", -10);
+ multi.e.setElement("Mapbender:iconOffsetY", -34);
+ multi.e.setElement("Mapbender:icon", "../img/marker/red.png");
+ }
+
+ var feat = JSON.parse(multi.toString());
+ itm.data.features.push(feat);
+
+ $('#mapframe1').data('kml').element.trigger('kml:loaded', {
+ type: "geojson",
+ data: itm.data,
+ url: itm.url,
+ display: itm.display,
+ refreshing: true,
+ });
+ $map.setMapRequest();
+
+
+ }
},
refresh: function(url) {
@@ -523,7 +598,7 @@
name = o.url;
if (name.match(/\w*\W(?:kml|gpx|geojson)$/)) {
name = name.match(/\w*\W(?:kml|gpx|geojson)$/)[0];
- }else {
+ } else {
name = 'ImportFeatures';
}
More information about the Mapbender_commits
mailing list