[Mapbender-commits] r8086 - in trunk/mapbender/http: javascripts php

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Wed Aug 31 04:48:20 EDT 2011


Author: verenadiewald
Date: 2011-08-31 01:48:20 -0700 (Wed, 31 Aug 2011)
New Revision: 8086

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

Modified: trunk/mapbender/http/javascripts/mod_measure.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_measure.php	2011-08-31 08:45:24 UTC (rev 8085)
+++ trunk/mapbender/http/javascripts/mod_measure.php	2011-08-31 08:48:20 UTC (rev 8086)
@@ -1,7 +1,7 @@
 <?php
 # $Id$
 # http://www.mapbender.org/index.php/mod_measure.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
@@ -72,12 +72,12 @@
 		el1.id = mod_measure_target+"_measure_display";
 		el1.style.zIndex = "22";
 		el2.id = mod_measure_target+"_measuring";
-		
+
 		map_el.appendChild(el);
 		map_el.appendChild(el1);
 		map_el.appendChild(el2);
 	}
-	
+
 	mb_button[ind] = document.getElementById(mod_measure_elName);
 	mb_button[ind].img_over = mod_measure_img_over.src;
 	mb_button[ind].img_on = mod_measure_img_on.src;
@@ -129,7 +129,7 @@
 }
 function mod_measure_start(e){
 	var mousepos = mod_measure_mapObj.getMousePosition(e);
-	
+
 	var realWorldPos = makeClickPos2RealWorldPos(mod_measure_target,mousepos.x,mousepos.y);
 	if(mod_measure_epsg=="EPSG:4326"){
 		mod_measure_RX[mod_measure_RX.length] = realWorldPos[0];
@@ -213,7 +213,7 @@
 	str_dashedLine += "<div style='font-family:"+mod_measure_font+";font-size:"+mod_measure_fontsize+";color:"+mod_measure_color1+";";
 	if(mod_measure_bg != ""){
 		str_dashedLine += "background-color:"+mod_measure_bg+";";
-	}   
+	}
 	str_dashedLine += "position:absolute;top:"+(Math.round(y1 + (y2-y1)/2 +3))+"px;left:"+(Math.round(x1 + (x2-x1)/2 +3))+"px'>"+mod_measure_Dist[count]+"</div>";
 	str_dashedLine += "<div style='font-family:"+mod_measure_font+";font-size:"+mod_measure_fontsize+";color:"+mod_measure_color2+";position:absolute;top:"+(Math.round(y1 + (y2-y1)/2 + 4))+"px;left:"+(Math.round(x1 + (x2-x1)/2+4))+"px'>"+mod_measure_Dist[count]+"</div>";
 	return str_dashedLine;
@@ -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,19 +367,32 @@
 			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");
 			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.document.close();
 		}
 		else{
 			mod_measure_win.document.open("text/html");
 			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: trunk/mapbender/http/php/mod_evalArea.php
===================================================================
--- trunk/mapbender/http/php/mod_evalArea.php	2011-08-31 08:45:24 UTC (rev 8085)
+++ trunk/mapbender/http/php/mod_evalArea.php	2011-08-31 08:48:20 UTC (rev 8086)
@@ -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