[Mapbender-commits] r8085 - in branches/2.7/http: javascripts php

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Wed Aug 31 04:45:24 EDT 2011


Author: verenadiewald
Date: 2011-08-31 01:45:24 -0700 (Wed, 31 Aug 2011)
New Revision: 8085

Modified:
   branches/2.7/http/javascripts/mod_measure.php
   branches/2.7/http/php/mod_evalArea.php
Log:
http://trac.osgeo.org/mapbender/ticket/865

Modified: branches/2.7/http/javascripts/mod_measure.php
===================================================================
--- branches/2.7/http/javascripts/mod_measure.php	2011-08-31 08:14:15 UTC (rev 8084)
+++ branches/2.7/http/javascripts/mod_measure.php	2011-08-31 08:45:24 UTC (rev 8085)
@@ -344,6 +344,22 @@
 		url += "&srs="+ escape(srs[1]);
 		url += "&length=" + mod_measure_TotalDist[mod_measure_TotalDist.length-1];
 		url += "&distance="  + mod_measure_TotalDist[mod_measure_TotalDist.length-2];
+		
+		$.get(url, function (json) {
+                	var data = eval('(' + json + ')');
+			if (!measurePopupInstance) {
+				var measurePopupInstance = $("<div />").html("<h3>Fl&auml;che:</h3> " + data.area + " m&sup2;<br><br><h3>Umfang:</h3> " + data.perimeter + " m<br>").dialog({
+                                    title: "Messinformationen"});
+			}
+			else {
+				measurePopupInstance.html("<h3>Fl&auml;che:</h3>" + data.area + " m&sup2;<br><br><h3>Umfang:</h3> " + data.perimeter + " m<br>").dialog("open");
+			}
+			
+			return;
+		});
+		return;
+
+                /*
 		if(!mod_measure_win || mod_measure_win == null || mod_measure_win.closed == true){
 			mod_measure_win = window.open(url,"mod_measure_win","width=200,height=150,resizable=yes");
 		}
@@ -351,8 +367,20 @@
 			mod_measure_win.document.location.href = url;
 		}
 		mod_measure_win.focus();
+                */
 	}
 	else{
+                if (!measurePopupInstance) {
+                        var measurePopupInstance = $("<div />").html("<h3>Strecke: </h3>" + mod_measure_TotalDist[mod_measure_TotalDist.length-1] + " m").dialog({
+                            title: "Messinformation"
+                        });
+                }
+                else {
+                        measurePopupInstance.html("<h3>Strecke: </h3>" + mod_measure_TotalDist[mod_measure_TotalDist.length-1] + " m").dialog("open");
+                }
+                return;
+
+                /*
 		if(!mod_measure_win || mod_measure_win == null || mod_measure_win.closed == true){
 			mod_measure_win = window.open("","mod_measure_win","width=200,height=150,resizable=yes");
 			mod_measure_win.document.open("text/html");
@@ -364,6 +392,7 @@
 			mod_measure_win.document.write("<span style = 'font-family : Arial, Helvetica, sans-serif;font-size : 12px;font-weight : bold;';>Strecke: " +mod_measure_TotalDist[mod_measure_TotalDist.length-1]+" m</span>");
 			mod_measure_win.document.close();
 		}
-		mod_measure_win.focus();      
+		mod_measure_win.focus();
+                */
 	}
 }

Modified: branches/2.7/http/php/mod_evalArea.php
===================================================================
--- branches/2.7/http/php/mod_evalArea.php	2011-08-31 08:14:15 UTC (rev 8084)
+++ branches/2.7/http/php/mod_evalArea.php	2011-08-31 08:45:24 UTC (rev 8085)
@@ -1,7 +1,7 @@
 <?php
 # $Id$
 # http://www.mapbender.org/index.php/mod_evalArea.php
-# Copyright (C) 2002 CCGIS 
+# Copyright (C) 2002 CCGIS
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -17,37 +17,10 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
+import_request_variables("PG");
 require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
-
 require_once(dirname(__FILE__)."/../classes/class_administration.php");
-include '../include/dyn_css.php';
-?>
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
-<head>
-<meta http-equiv="cache-control" content="no-cache">
-<meta http-equiv="pragma" content="no-cache">
-<meta http-equiv="expires" content="0">
-<?php
-echo '<meta http-equiv="Content-Type" content="text/html; charset='.CHARSET.'">';	
-?>
-<title>Resultset</title>
-<style type="text/css">
-	<!--
 
-	body{
-		font-family : Arial, Helvetica, sans-serif;
-		font-size : 12px;
-		font-weight : bold;
-	}
-	.h{
-		font-style : oblique;
-	}
-	-->
-</style>
-</head>
-<body>
-<?php
 $x = $_REQUEST["x"];
 $y = $_REQUEST["y"];
 $epsg = $_REQUEST["srs"];
@@ -55,94 +28,27 @@
 $posX = explode (",", $x);
 $posY = explode (",", $y);
 
-$numeric = is_numeric($epsg);
-foreach($posX as $x) $numeric = $numeric && is_numeric($x);
-foreach($posY as $y) $numeric = $numeric && is_numeric($y);
-
-if (!$numeric) // Security check
-{
-        die("Elements of x and y, as well as srs need to be numeric!");
-}
-
-
-if(SYS_DBTYPE=='pgsql'){
-	if(count($posX) > 3){
-	  $sql = "SELECT area2d(GeometryFromText('MULTIPOLYGON(((";
-	  for($i=0; $i<count($posX); $i++){
-	  	if($i>0){$sql .= ",";}
-	  	$sql .= $posX[$i] . " " . $posY[$i];
-	  }
-	  $sql .= ")))',".rawurldecode($epsg).")) as myArea";
-	  $res = db_query($sql);
-	  if($row = db_fetch_array($res)){
-	     echo "Fl&auml;che: ".round($row[0]*100)/100 . " m<sup>2</sup>";
-	  }
-	}
+echo "{";
+if(SYS_DBTYPE=='pgsql' && count($posX) > 3){
+  $sql = "SELECT area2d(GeometryFromText('MULTIPOLYGON(((";
+  for($i=0; $i<count($posX); $i++){
+	if($i>0){$sql .= ",";}
+	$sql .= $posX[$i] . " " . $posY[$i];
+  }
+  $sql .= ")))',".rawurldecode($epsg).")) as myArea";
+  $res = db_query($sql);
+  if($row = db_fetch_array($res)){
+	 echo "'area': ".round($row[0]*100)/100 ;
+  }
 	else{
-	   echo "Fl&auml;che: 0 m<sup>2</sup>";
+		 echo "'area': 0";
 	}
-}else{
-	#echo "Fl�chenberechnung f�r MySQL liegt derzeit nicht vor<br></sup>";
-	#$con = db_connect($GEOS_DBSERVER,$GEOS_PORT,$GEOS_OWNER,$GEOS_PW);
-	#db_select_db($GEOS_DBSERVER,$con);
-	$con_string = "host=$GEOS_DBSERVER port=$GEOS_PORT dbname=$GEOS_DB user=$GEOS_OWNER password=$GEOS_PW";
-	
-	$con = pg_connect($con_string) or die ("Error while connecting database");
-	
-	
-	if(count($posX) > 3){
-	  $sql = "SELECT area2d(GeometryFromText('MULTIPOLYGON(((";
-	  $i==0;
-	  for($i=0; $i<count($posX); $i++){
-	  	if($i>0){$sql .= ",";}
-	  	$sql .= $posX[$i] . " " . $posY[$i];
-	  }
-	  $sql .= ")))',".rawurldecode($epsg).")) as myArea";
-	  $res = pg_query($con,$sql);
-	  
-	  $cnt = 0;
-	  while(pg_fetch_row($res)){
-	  	 $area = pg_fetch_result($res,$cnt,0);
-	     echo "Fl&auml;che: ".round($area*100)/100 . " m<sup>2</sup>";
-	     $cnt++;
-	  }
-	}
-	else{
-	   echo "Fl&auml;che: 0 m<sup>2</sup>";
-	}
 }
-
-echo "<br>";
-echo "Umfang: ". htmlentities($length,ENT_QUOTES) . " m";
-
-echo "<br><br><input type='button' value='Schlie&szlig;en' onclick='window.close()'>";
-#Centroid(geometry)
-/*
-$sql = "SELECT Centroid(GeometryFromText('MULTIPOLYGON(((";
-for($i=0; $i<count($posX); $i++){
-	if($i>0){$sql .= ",";}
-	$sql .= $posX[$i] . " " . $posY[$i];
+else{
+	 echo "'area': 0";
 }
-$sql .= ")))',".rawurldecode($epsg).")) as myCentroid";
-$res = db_query($con,$sql);
-if(db_fetch_row($res)){
-   echo "Zentrum: ".db_result($res,0,"myCentroid");
+if($length == "undefined") {
+    $length = "0";
 }
-*/
-
-#box3d(geometry)
-/*
-$sql = "SELECT box3d(GeometryFromText('MULTIPOLYGON(((";
-for($i=0; $i<count($posX); $i++){
-	if($i>0){$sql .= ",";}
-	$sql .= $posX[$i] . " " . $posY[$i];
-}
-$sql .= ")))',".rawurldecode($epsg).")) as myBox";
-$res = db_query($sql);
-if(db_fetch_row($res)){
-   echo "Aussen: ".db_result($res,0,"myBox");
-}
-*/
-?>
-</body>
-</html>
+echo ",'perimeter': ". $length . "}";
+?>
\ No newline at end of file



More information about the Mapbender_commits mailing list