[Mapbender-commits] r9168 - trunk/mapbender/http/php
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Tue Mar 10 07:55:16 PDT 2015
Author: syed
Date: 2015-03-10 07:55:16 -0700 (Tue, 10 Mar 2015)
New Revision: 9168
Added:
trunk/mapbender/http/php/mod_CalculateAreaAndLength.php
Log:
add mod to calculate area or length
Added: trunk/mapbender/http/php/mod_CalculateAreaAndLength.php
===================================================================
--- trunk/mapbender/http/php/mod_CalculateAreaAndLength.php (rev 0)
+++ trunk/mapbender/http/php/mod_CalculateAreaAndLength.php 2015-03-10 14:55:16 UTC (rev 9168)
@@ -0,0 +1,47 @@
+<?php
+
+
+/**
+ * @version Changed: ### 2015-03-10 12:53:25 UTC ###
+ * @author Raphael.Syed <raphael.syed at WhereGroup.com> http://WhereGroup.com
+ */
+
+
+
+
+//import classes
+require_once(dirname(__FILE__) . "/../classes/class_wmc.php");
+require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
+
+
+/**
+ * publish the choosed data
+ */
+
+// get data from session and request
+$user_id = Mapbender::session()->get("mb_user_id");
+$geom_type = $_POST['geom_type'];
+$geom_data = $_POST['wkt_geom'];
+$sql;
+// calculate length of a linetring
+if ($geom_type == 'line') {
+
+ $sql = "SELECT st_length(st_GeogFromText( $1 )) as meter";
+
+} else if ($geom_type == 'polygon') {
+
+ $sql = "SELECT st_area(st_GeogFromText( $1 )) as sqm";
+}
+
+
+$v = array($geom_data);
+$t = array("c");
+$res = db_prep_query($sql, $v, $t);
+//fetch the array
+if($row = db_fetch_array($res)){
+
+ $rslt = $row[0];
+ echo $rslt;
+}
+
+
More information about the Mapbender_commits
mailing list