svn commit: r355 - trunk/mapbender/http/javascripts/mod_wfs_SpatialRequest.php

christoph at osgeo.org christoph at osgeo.org
Mon May 29 06:46:18 EDT 2006


Author: christoph
Date: 2006-05-29 10:46:18+0000
New Revision: 355

Modified:
   trunk/mapbender/http/javascripts/mod_wfs_SpatialRequest.php

Log:
added various buttons 

Modified: trunk/mapbender/http/javascripts/mod_wfs_SpatialRequest.php
Url: https://mapbender.osgeo.org/source/browse/mapbender/trunk/mapbender/http/javascripts/mod_wfs_SpatialRequest.php?view=diff&rev=355&p1=trunk/mapbender/http/javascripts/mod_wfs_SpatialRequest.php&p2=trunk/mapbender/http/javascripts/mod_wfs_SpatialRequest.php&r1=354&r2=355
==============================================================================
--- trunk/mapbender/http/javascripts/mod_wfs_SpatialRequest.php	(original)
+++ trunk/mapbender/http/javascripts/mod_wfs_SpatialRequest.php	2006-05-29 10:46:18+0000
@@ -1,6 +1,6 @@
  <?php
-#$Id: mod_wfs_SpatialRequest.php,v 1.4 2006/03/08 15:26:26 c_baudson Exp $
-#$Header: /cvsroot/mapbender/mapbender/http/javascripts/mod_wfs_SpatialRequest.php,v 1.4 2006/03/08 15:26:26 c_baudson Exp $
+#$Id: mod_wfs_spatialRequest.php,v 1.4 2006/03/08 15:26:26 c_baudson Exp $
+#$Header: /cvsroot/mapbender/mapbender/http/javascripts/mod_wfs_spatialRequest.php,v 1.4 2006/03/08 15:26:26 c_baudson Exp $
 # Copyright (C) 2002 CCGIS 
 #
 # This program is free software; you can redistribute it and/or modify
@@ -17,11 +17,16 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
+session_start();
+import_request_variables("PG");
+require_once("../php/mb_validateSession.php");
 require_once("../../conf/mapbender.conf");
+$con = db_connect(DBSERVER,OWNER,PW);
+db_select_db(DB,$con);
 
 $gui_id = $_REQUEST["gui_id"];
-$con = db_connect($DBSERVER,$OWNER,$PW);
-db_select_db(DB,$con);
+$e_id_css = "setSpatialRequest";
+include '../include/dyn_js.php';
 $sql = "SELECT e_src, e_target FROM gui_element WHERE e_id = 'setSpatialRequest' AND fkey_gui_id = '".$gui_id."'";
 $res = db_query($sql);
 $cnt = 0;
@@ -30,328 +35,323 @@
    $e_target = $row["e_target"];
    $cnt++;
 }
-if($cnt > 1){ echo "alert('setExtRequest: ID not unique!');";}
-echo "var mod_wfs_SpatialRequest_target = '".$e_target."';";
+if($cnt > 1){ echo "alert('setExtRequest: ID not unique!');\n";}
+echo "var mod_wfs_spatialRequest_target = '".$e_target."';\n";
 ?>
-var mod_wfs_SpatialRequest_color1 = "white";
-var mod_wfs_SpatialRequest_color2 = "black";
-var mod_wfs_SpatialRequest_font = "Arial, Helvetica, sans-serif";
-var mod_wfs_SpatialRequest_fontsize = "9px";
-var mod_wfs_SpatialRequest_basepoint = "#8a2be2";
-var mod_wfs_SpatialRequest_linepoint = "#ff00ff";
-var mod_wfs_SpatialRequest_bg = "";
-var mod_wfs_SpatialRequest_pgsql = true;
-
-var mod_wfs_SpatialRequest_win = null;
-
-var mod_wfs_SpatialRequest_useExtent = true;
-
-var mod_wfs_SpatialRequest_elName = "setSpatialRequest";
-var mod_wfs_SpatialRequest_frameName = "";
-var mod_wfs_SpatialRequest_epsg;
-var mod_wfs_SpatialRequest_width;
-var mod_wfs_SpatialRequest_height;
-var mod_wfs_SpatialRequest_RX = new Array();
-var mod_wfs_SpatialRequest_RY = new Array();
-var mod_wfs_SpatialRequest_Dist = new Array();
-var mod_wfs_SpatialRequest_TotalDist = new Array();
-var mod_wfs_SpatialRequestSubFunctions = new Array();
-
-var mod_wfs_SpatialRequest_img_on = new Image(); mod_wfs_SpatialRequest_img_on.src = "<?php  echo preg_replace("/_off/","_on",$e_src);  ?>";
-var mod_wfs_SpatialRequest_img_off = new Image(); mod_wfs_SpatialRequest_img_off.src = "<?php  echo $e_src;  ?>";
-var mod_wfs_SpatialRequest_img_over = new Image(); mod_wfs_SpatialRequest_img_over.src = "<?php  echo preg_replace("/_off/","_over",$e_src);  ?>";
-
-function init_mod_wfs_SpatialRequest(ind){
-	mb_button[ind] = document.getElementById(mod_wfs_SpatialRequest_elName);
-	mb_button[ind].img_over = mod_wfs_SpatialRequest_img_over.src;
-	mb_button[ind].img_on = mod_wfs_SpatialRequest_img_on.src;
-	mb_button[ind].img_off = mod_wfs_SpatialRequest_img_off.src;
+
+var wfsAreaType_point = "point";
+var wfsAreaType_polygon = "polygon";
+var wfsAreaType_rectangle = "rectangle";
+var wfsAreaType_extent = "extent";
+var wfsAreaType_current = "";
+
+var activeButton = null;
+var mod_wfs_spatialRequest_geometry;
+
+var mod_wfs_spatialRequest_frameName = "";
+var mod_wfs_spatialRequest_epsg;
+var mod_wfs_spatialRequest_width;
+var mod_wfs_spatialRequest_height;
+
+var mod_wfs_spatialRequestSubFunctions = new Array();
+var mod_wfs_spatialRequest_bg = "";
+var mod_wfs_spatialRequest_pgsql = true;
+var mod_wfs_spatialRequest_win = null;
+var mod_wfs_spatialRequest_thema = false;
+
+try{if(wfsResultToDigitize){wfsResultToDigitize=true;}}catch(e){wfsResultToDigitize=false;}
+
+// ------------------------------------------------------------------------------------------
+// ------------ button handling -------------------------------------------------------------
+
+function displayButtons() {
+	for (var i = 0 ; i < buttonWfs_id.length ; i ++) {
+		if (parseInt(buttonWfs_on[i])==1) {
+			document.write("<div id='div_"+buttonWfs_id[i]+"' style='position:absolute; top:"+buttonWfs_y[i]+"; left:"+buttonWfs_x[i]+"'><img name=\""+buttonWfs_id[i]+"\" onmouseover=\"mb_regButton_frame('initWfsButton', null, "+i+");\" id=\""+buttonWfs_id[i]+"\" title=\""+buttonWfs_titleUp[i]+"\" src=\""+buttonWfs_srcUp[i]+"\"></div>");
+		}
+	}
+}
+
+function initWfsButton(ind, pos) {
+	mb_button[ind] = document.getElementById(buttonWfs_id[pos]);
+	mb_button[ind].img_over = buttonWfs_srcUp[pos];
+	mb_button[ind].img_on = buttonWfs_srcDown[pos];
+	mb_button[ind].img_off = buttonWfs_srcUp[pos];
 	mb_button[ind].status = 0;
-	mb_button[ind].elName = mod_wfs_SpatialRequest_elName;
-	mb_button[ind].fName = mod_wfs_SpatialRequest_frameName;
-	mb_button[ind].go = new Function ("mod_wfs_SpatialRequest_do()");
-	mb_button[ind].stop = new Function ("mod_wfs_SpatialRequest_disable()");
-	var ind = getMapObjIndexByName(mod_wfs_SpatialRequest_target);
-	mod_wfs_SpatialRequest_width = mb_mapObj[ind].width;
-	mod_wfs_SpatialRequest_height = mb_mapObj[ind].height;
-	mod_wfs_SpatialRequest_epsg = mb_mapObj[ind].epsg;
+	mb_button[ind].elName = buttonWfs_id[pos];
+	mb_button[ind].fName = "";
+	mb_button[ind].go = new Function ("wfsEnable(mb_button["+ind+"], " + pos + ")");
+	mb_button[ind].stop = new Function ("wfsDisable(mb_button["+ind+"], " + pos + ")");
+	var ind = getMapObjIndexByName(mod_wfs_spatialRequest_target);
+	mod_wfs_spatialRequest_width = mb_mapObj[ind].width;
+	mod_wfs_spatialRequest_height = mb_mapObj[ind].height;
+	mod_wfs_spatialRequest_epsg = mb_mapObj[ind].epsg;
 	mb_registerSubFunctions("drawDashedLineExt()");
 	mb_registerPanSubElement("measuring");
+}	
+
+function wfsEnable(obj) {
+	if (obj.id == button_point) {
+		if (activeButton == null) {
+			activeButton = obj;
+		}
+		mod_wfs_spatialRequest_geometry = new Geometry(geomTypePoint);
+		wfsAreaType_current = wfsAreaType_point;
+		mod_wfs_spatialRequest_digitize_go(geomTypePoint);		
+	}
+	if (obj.id == button_polygon) {
+		if (activeButton == null) {
+			activeButton = obj;
+		}
+		mod_wfs_spatialRequest_geometry = new Geometry(geomTypePolygon);
+		wfsAreaType_current = wfsAreaType_polygon;
+		mod_wfs_spatialRequest_digitize_go(geomTypePolygon);		
+		var measureSub = "";
+		for(var i=0; i<mod_wfs_spatialRequestSubFunctions.length; i++){
+			measureSub += eval(mod_wfs_spatialRequestSubFunctions[i]);
+		}   
+		writeTag(mod_wfs_spatialRequest_target,"measure_sub",measureSub);
+	}
+	else if (obj.id == button_rectangle){
+		if (activeButton == null) {
+			activeButton = obj;
+		}
+		mod_wfs_spatialRequest_geometry = new Geometry(geomTypeLine);
+		wfsAreaType_current = wfsAreaType_rectangle;
+		mod_selAreaExt_click();	
+	}
+	else if (obj.id == button_extent){
+		if (activeButton == null) {
+			activeButton = obj;
+		}
+		mod_wfs_spatialRequest_geometry = new Geometry(geomTypeLine);
+		wfsAreaType_current = wfsAreaType_extent;
+		var ind = getMapObjIndexByName(mod_wfs_spatialRequest_target);
+		var p0 = mapToReal(mod_wfs_spatialRequest_target, new Point(0,0));
+		var p1 = mapToReal(mod_wfs_spatialRequest_target, new Point(mb_mapObj[ind].width,mb_mapObj[ind].height)); 
+		mod_wfs_spatialRequest_geometry.addPoint(p0);
+		mod_wfs_spatialRequest_geometry.addPoint(p1);
+		mod_getAreaExt_send();
+	}
+	else if (obj.id == button_dialogue) {
+		activeButton = obj;
+		mod_wfs_SpatialRequest_dialog();
+	}
 }
 
-function useExtentIsSet () {
-	return mod_wfs_SpatialRequest_useExtent;
+function wfsDisable(obj) {
+	var el = window.frames[mod_wfs_spatialRequest_target].document; 
+	el.onmousedown = null;
+	el.ondblclick = null;
+	el.onmousemove = null;
+	writeTag(mod_wfs_spatialRequest_target,"measure_display","");
+	writeTag(mod_wfs_spatialRequest_target,"measure_sub","");
+	activeButton = null;
 }
 
-function register_setExtRequestSubFunctions(stringFunction){
-	mod_wfs_SpatialRequestSubFunctions[mod_wfs_SpatialRequestSubFunctions.length] = stringFunction;
+// ------------------------------------------------------------------------------------------
+
+// ----------------------------------------------------------------------------------------------
+// -------------------- rectangle -----------------------------------------------------------------
+
+function mod_selAreaExt_click(){
+   var el = window.frames[mod_wfs_spatialRequest_target].document;
+   el.onmouseover = mod_selAreaExt_init;
+   el.onmousedown = mod_box_start;
+   el.onmouseup = mod_selAreaExt_get;
+   el.onmousemove = mod_box_run;
 }
-function mod_wfs_SpatialRequest_do(){
-	mod_wfs_SpatialRequest_dialog();
+function mod_selAreaExt_init(e){
+   mb_isBF = mod_wfs_spatialRequest_target;
+   mb_zF = mod_wfs_spatialRequest_target;
 }
-function mod_wfs_SpatialRequest_decide(){
-	if(mod_wfs_SpatialRequest_geom == 'rectangle'){
-		mod_wfs_SpatialRequest_useExtent = false;
-		mod_selAreaExt_click();	
-	}	
-	else if (mod_wfs_SpatialRequest_geom == 'extent') {
-		mod_wfs_SpatialRequest_useExtent = true;
-		var ind = getMapObjIndexByName(mod_wfs_SpatialRequest_target);
-		var pos_a = makeClickPos2RealWorldPos(mod_wfs_SpatialRequest_target,0,0);
-		var pos_b = makeClickPos2RealWorldPos(mod_wfs_SpatialRequest_target,mb_mapObj[ind].width,mb_mapObj[ind].height);
-		
-		mod_wfs_SpatialRequest_RX[0] = pos_a[0];
-		mod_wfs_SpatialRequest_RY[0] = pos_a[1];
-		mod_wfs_SpatialRequest_RX[1] = pos_b[0];
-		mod_wfs_SpatialRequest_RY[1] = pos_b[1];
+function mod_selAreaExt_get(e){
+	mod_selAreaExt_setValidClipping(mod_box_stop(e));
+	mb_isBF = mod_wfs_spatialRequest_target;
+	mb_zF = mod_wfs_spatialRequest_target;
+}
+function mod_selAreaExt_setValidClipping(coords){
+	mod_wfs_spatialRequest_geometry.addPoint(new Point(coords[0],coords[1]));
+	mod_wfs_spatialRequest_geometry.addPoint(new Point(coords[2],coords[3]));
+	
+	if(mod_wfs_spatialRequest_geometry.count() == 2){
 		mod_getAreaExt_send();
 	}
 	else{
-		mod_wfs_SpatialRequest_useExtent = false;
-		mod_wfs_SpatialRequest_go();		
+		alert("Ausschnitt ungültig!")
+		mb_disableThisButton(activeButton.id);
 	}
 }
-function mod_wfs_SpatialRequest_go(){	
-	var el = window.frames[mod_wfs_SpatialRequest_target].document;
-	el.onmousedown = mod_wfs_SpatialRequest_start;
-	el.onmousemove = mod_wfs_SpatialRequest_run;
+// ----------------------------------------------------------------------------------------------
+
+
+// ----------------------------------------------------------------------------------------------
+// -------------------- polygon && point --------------------------------------------------------
+
+function mod_wfs_spatialRequest_digitize_go(geomtype){
+	if (geomtype == geomTypePolygon) {
+		mod_wfs_spatialRequest_geometry = new Geometry(geomTypePolygon);
+	}
+	s = new Snapping(mod_wfs_spatialRequest_target);
+
+	var el = window.frames[mod_wfs_spatialRequest_target].document;
+	el.onmousedown = mod_wfs_spatialRequest_start;
+	el.onmousemove = mod_wfs_spatialRequest_run;
 	var measureSub = "";
-	for(var i=0; i<mod_wfs_SpatialRequestSubFunctions.length; i++){
-		measureSub += eval(mod_wfs_SpatialRequestSubFunctions[i]);
+	for(var i=0; i<mod_wfs_spatialRequestSubFunctions.length; i++){
+		measureSub += eval(mod_wfs_spatialRequestSubFunctions[i]);
 	}   
-	writeTag(mod_wfs_SpatialRequest_target,"measure_sub",measureSub);
-}
-function mod_wfs_SpatialRequest_disable(){
-	var el = window.frames[mod_wfs_SpatialRequest_target].document; 
-	el.onmousedown = null;
-	el.onmousemove = null;
-	writeTag(mod_wfs_SpatialRequest_target,"measure_display","");
-	writeTag(mod_wfs_SpatialRequest_target,"measure_sub","");
+	writeTag(mod_wfs_spatialRequest_target,"measure_sub",measureSub);
 }
-function mod_wfs_SpatialRequest_timeout(){
-	var el = window.frames[mod_wfs_SpatialRequest_target].document; 
-	el.onmousedown = null;
-	el.ondblclick = null;
-	el.onmousemove = null;
+
+// ---------------------------------------------------------------------------------------------
+
+function mod_wfs_spatialRequest_run(e) {
+	if (mod_wfs_spatialRequest_geometry.count() >= 3) {
+		mb_getMousePos(e,mod_wfs_spatialRequest_target);
+		var pos = new Point(clickX,clickY).round(2);
+		s.check(pos);
+	}
 }
-function mod_wfs_SpatialRequest_disableTimeout(){
-	var el = window.frames[mod_wfs_SpatialRequest_target].document;
-	el.onmousedown = mod_wfs_SpatialRequest_start;
-	el.onmousemove = mod_wfs_SpatialRequest_run;
-}
-function mod_wfs_SpatialRequest_start(e){
-	mb_getMousePos(e,mod_wfs_SpatialRequest_target);
-	var realWorldPos = makeClickPos2RealWorldPos(mod_wfs_SpatialRequest_target,clickX,clickY);
-	mod_wfs_SpatialRequest_RX[mod_wfs_SpatialRequest_RX.length] = Math.round(realWorldPos[0] * 100)/100;
-	mod_wfs_SpatialRequest_RY[mod_wfs_SpatialRequest_RY.length] = Math.round(realWorldPos[1] * 100)/100;
-	if(mod_wfs_SpatialRequest_geom == 'point'){
+
+function mod_wfs_spatialRequest_start(e){
+	var realWorldPos;
+	if (s.isSnapped() == true) {
+		realWorldPos = s.getSnappedPoint(mod_wfs_spatialRequest_geometry); 
+		s.clean();
+	}
+	else {
+		parent.mb_getMousePos(e,mod_wfs_spatialRequest_target);
+		realWorldPos = parent.mapToReal(mod_wfs_spatialRequest_target,new Point(parent.clickX,parent.clickY)).round(2);
+	}
+
+	mod_wfs_spatialRequest_geometry.addPoint(realWorldPos);
+
+	if (mod_wfs_spatialRequest_geometry.count() == 1) {
+		s.add(mod_wfs_spatialRequest_geometry, 0);
+	}
+	if (s.isSnapped() && mod_wfs_spatialRequest_geometry.count() >= 3 && mod_wfs_spatialRequest_geometry.get(-1).equals(mod_wfs_spatialRequest_geometry.get(0))) {
+		mod_wfs_spatialRequest_geometry.close();
 		mod_getAreaExt_send();
 		return;
 	}
-	if(mod_wfs_SpatialRequest_RX.length > 1){
-		var dist_x = Math.abs(mod_wfs_SpatialRequest_RX[mod_wfs_SpatialRequest_RX.length-2] - mod_wfs_SpatialRequest_RX[mod_wfs_SpatialRequest_RX.length-1]);
-		var dist_y = Math.abs(mod_wfs_SpatialRequest_RY[mod_wfs_SpatialRequest_RY.length-2] - mod_wfs_SpatialRequest_RY[mod_wfs_SpatialRequest_RY.length-1]);
-		var dist = Math.round(Math.sqrt(Math.pow(dist_x,2) + Math.pow(dist_y,2))*100)/100;
-		mod_wfs_SpatialRequest_Dist[mod_wfs_SpatialRequest_Dist.length] = dist;
-		var totalDist = mod_wfs_SpatialRequest_TotalDist[mod_wfs_SpatialRequest_TotalDist.length-1] + dist;
-		mod_wfs_SpatialRequest_TotalDist[mod_wfs_SpatialRequest_TotalDist.length] = Math.round(totalDist * 100)/100;
+	
+	if(wfsAreaType_current == wfsAreaType_point){
+		mod_getAreaExt_send();
+		return;
 	}
-	else{
-		mod_wfs_SpatialRequest_Dist[mod_wfs_SpatialRequest_Dist.length] = 0;
-		mod_wfs_SpatialRequest_TotalDist[mod_wfs_SpatialRequest_TotalDist.length] = 0;
-	}   
 	drawDashedLineExt();
 }
 function drawDashedLineExt(){
-	var str_mPoints = "<div style='position:absolute;left:0px;top:0px' ><img src='"+mb_trans.src+"' width='"+mod_wfs_SpatialRequest_width+"' height='0'></div>";
-	str_mPoints += "<div style='position:absolute;left:0px;top:0px' ><img src='"+mb_trans.src+"' width='0' height='"+mod_wfs_SpatialRequest_height+"'></div>";
-	for(var i=0; i<mod_wfs_SpatialRequest_RX.length; i++){
-		var pos = makeRealWorld2mapPos(mod_wfs_SpatialRequest_target,mod_wfs_SpatialRequest_RX[i],mod_wfs_SpatialRequest_RY[i]);
-		str_mPoints += "<div style='font-size:1px;position:absolute;top:"+(pos[1]-2)+"px;left:"+(pos[0]-2)+"px;width:4px;height:4px;background-color:"+mod_wfs_SpatialRequest_basepoint+"'></div>";
-		if(i>0){
-//			str_mPoints += "<div  style='font-family:"+mod_wfs_SpatialRequest_font+";font-size:"+mod_wfs_SpatialRequest_fontsize+";color:"+mod_wfs_SpatialRequest_color1+";";
-//			if(mod_wfs_SpatialRequest_bg != ""){
-//				str_mPoints += "background-color:"+mod_wfs_SpatialRequest_bg+";";
-//			}
-//			str_mPoints += "position:absolute;top:"+(pos[1] + 3)+"px;left:"+(pos[0]+3)+"px;z-index:20'>"+mod_wfs_SpatialRequest_TotalDist[i]+"</div>";
-//			str_mPoints += "<div  style='font-family:"+mod_wfs_SpatialRequest_font+";font-size:"+mod_wfs_SpatialRequest_fontsize+";color:"+mod_wfs_SpatialRequest_color2+";position:absolute;top:"+(pos[1] + 4)+"px;left:"+(pos[0]+4)+"px;z-index:21'>"+mod_wfs_SpatialRequest_TotalDist[i]+"</div>";
+	var str_mPoints = "<div style='position:absolute;left:0px;top:0px' ><img src='"+mb_trans.src+"' width='"+mod_wfs_spatialRequest_width+"' height='0'></div>";
+	str_mPoints += "<div style='position:absolute;left:0px;top:0px' ><img src='"+mb_trans.src+"' width='0' height='"+mod_wfs_spatialRequest_height+"'></div>";
+	for(var i=0; i<mod_wfs_spatialRequest_geometry.count(); i++){
+		var pos = realToMap(mod_wfs_spatialRequest_target,mod_wfs_spatialRequest_geometry.get(i));
+		str_mPoints += "<div style='font-size:1px;position:absolute;top:"+(pos.y-2)+"px;left:"+(pos.x-2)+"px;width:3px;height:3px;background-color:#ff0000'></div>";
+	}
+	if(mod_wfs_spatialRequest_geometry.count()>1){
+		for(var k=1; k<mod_wfs_spatialRequest_geometry.count(); k++){
+			var pos0 = realToMap(mod_wfs_spatialRequest_target,mod_wfs_spatialRequest_geometry.get(k));
+			var pos1 = realToMap(mod_wfs_spatialRequest_target,mod_wfs_spatialRequest_geometry.get(k-1));
+			str_mPoints += evaluateDashesExt(pos1,pos0,k);
 		}
 	}
-	if(mod_wfs_SpatialRequest_RX.length>1){
-		for(var k=1; k<mod_wfs_SpatialRequest_RX.length; k++){
-			var pos0 = makeRealWorld2mapPos(mod_wfs_SpatialRequest_target,mod_wfs_SpatialRequest_RX[k], mod_wfs_SpatialRequest_RY[k]);
-			var pos1 = makeRealWorld2mapPos(mod_wfs_SpatialRequest_target,mod_wfs_SpatialRequest_RX[k-1], mod_wfs_SpatialRequest_RY[k-1]);
-			str_mPoints += evaluateDashesExt(pos1[0],pos1[1],pos0[0],pos0[1],k);
-		}
-	}
-	writeTag(mod_wfs_SpatialRequest_target,"measuring",str_mPoints);
+	writeTag(mod_wfs_spatialRequest_target,"measuring",str_mPoints);
 }
-function evaluateDashesExt(x1,y1,x2,y2,count){
+function evaluateDashesExt(p1,p0,count){
 	var str_dashedLine = "";
-	var s = 10;
-	var d = Math.sqrt(Math.pow((y1-y2),2) + Math.pow((x1-x2),2)) ;
-	var n = Math.round(d/s);
-	var s_x =  (x2 - x1)/n;
-	var s_y =  (y2 - y1)/n;
+	var d = p0.dist(p1);
+	var n = Math.round(d);
+	var s =  p0.minus(p1).dividedBy(n);
 	for(var i=1; i<n; i++){
-		var x = Math.round(x1 + i * s_x)-2;
-		var y = Math.round(y1 + i * s_y)-2;
-		if(x >= 0 && x <= mod_wfs_SpatialRequest_width && y >= 0 && y <= mod_wfs_SpatialRequest_height){
-			str_dashedLine += "<div style='font-size:1px;position:absolute;top:"+y+"px;left:"+x+"px;width:4px;height:4px;background-color:"+mod_wfs_SpatialRequest_linepoint+"'></div>";
+		var currPoint = p1.plus(s.times(i)).minus(new Point(2,2)).round(0); 
+		if(currPoint.x >= 0 && currPoint.x <= mod_wfs_spatialRequest_width && currPoint.y >= 0 && currPoint.y <= mod_wfs_spatialRequest_height){
+			str_dashedLine += "<div style='font-size:1px;position:absolute;top:"+currPoint.y+"px;left:"+currPoint.x+"px;width:3px;height:3px;background-color:#ff0000'></div>";
 		}
 	}
-//	str_dashedLine += "<div style='font-family:"+mod_wfs_SpatialRequest_font+";font-size:"+mod_wfs_SpatialRequest_fontsize+";color:"+mod_wfs_SpatialRequest_color1+";";
-//	if(mod_wfs_SpatialRequest_bg != ""){
-//		str_dashedLine += "background-color:"+mod_wfs_SpatialRequest_bg+";";
-//	}   
-//	str_dashedLine += "position:absolute;top:"+(Math.round(y1 + (y2-y1)/2 +3))+"px;left:"+(Math.round(x1 + (x2-x1)/2 +3))+"px'>"+mod_wfs_SpatialRequest_Dist[count]+"</div>";
-//	str_dashedLine += "<div style='font-family:"+mod_wfs_SpatialRequest_font+";font-size:"+mod_wfs_SpatialRequest_fontsize+";color:"+mod_wfs_SpatialRequest_color2+";position:absolute;top:"+(Math.round(y1 + (y2-y1)/2 + 4))+"px;left:"+(Math.round(x1 + (x2-x1)/2+4))+"px'>"+mod_wfs_SpatialRequest_Dist[count]+"</div>";
 	return str_dashedLine;
 }
-function mod_wfs_SpatialRequest_run(e){
-//	mb_getMousePos(e,mod_wfs_SpatialRequest_target);
-//	var pos = makeClickPos2RealWorldPos(mod_wfs_SpatialRequest_target,clickX,clickY);
-//	var dist_x = Math.abs(mod_wfs_SpatialRequest_RX[mod_wfs_SpatialRequest_RX.length-1] - pos[0]);
-//	var dist_y = Math.abs(mod_wfs_SpatialRequest_RY[mod_wfs_SpatialRequest_RY.length-1] - pos[1]);
-//	if(isNaN(dist_x) == false && clickX > 0 && clickX < mod_wfs_SpatialRequest_width && clickY > 0 && clickY < mod_wfs_SpatialRequest_height){
-//		var str_display = "<span style='font-family:"+mod_wfs_SpatialRequest_font+";font-size:"+mod_wfs_SpatialRequest_fontsize+";color:"+mod_wfs_SpatialRequest_color2+";'>"+(Math.round(Math.sqrt(Math.pow(dist_x,2) + Math.pow(dist_y,2))*100)/100)+" m</span>";
-//		writeTag(mod_wfs_SpatialRequest_target,"measure_display",str_display);
-//		mb_arrangeElement(mod_wfs_SpatialRequest_target,"measure_display",clickX +2, clickY - 10);
-//	}
-//	else{
-//		writeTag(mod_wfs_SpatialRequest_target,"measure_display","");
-//	}
-}
-function mod_wfs_SpatialRequest_close(){
-	if(mod_wfs_SpatialRequest_RX.length < 3 || (mod_wfs_SpatialRequest_RX[mod_wfs_SpatialRequest_RX.length-1] == mod_wfs_SpatialRequest_RX[0] && mod_wfs_SpatialRequest_RY[mod_wfs_SpatialRequest_RY.length-1] == mod_wfs_SpatialRequest_RY[0])){return;}
-	mod_wfs_SpatialRequest_RX[mod_wfs_SpatialRequest_RX.length] = mod_wfs_SpatialRequest_RX[0];
-	mod_wfs_SpatialRequest_RY[mod_wfs_SpatialRequest_RY.length] = mod_wfs_SpatialRequest_RY[0];
-	if(mod_wfs_SpatialRequest_RX.length > 1){
-		// circumference
-		var dist_x = Math.abs(mod_wfs_SpatialRequest_RX[mod_wfs_SpatialRequest_RX.length-2] - mod_wfs_SpatialRequest_RX[mod_wfs_SpatialRequest_RX.length-1]);
-		var dist_y = Math.abs(mod_wfs_SpatialRequest_RY[mod_wfs_SpatialRequest_RY.length-2] - mod_wfs_SpatialRequest_RY[mod_wfs_SpatialRequest_RY.length-1]);
-		var dist = Math.round(Math.sqrt(Math.pow(dist_x,2) + Math.pow(dist_y,2))*100)/100;
-		mod_wfs_SpatialRequest_Dist[mod_wfs_SpatialRequest_Dist.length] = dist;
-		var totalDist = mod_wfs_SpatialRequest_TotalDist[mod_wfs_SpatialRequest_TotalDist.length-1] + dist;
-		mod_wfs_SpatialRequest_TotalDist[mod_wfs_SpatialRequest_TotalDist.length] = Math.round(totalDist * 100)/100;
-	}
-	else{
-		mod_wfs_SpatialRequest_Dist[mod_wfs_SpatialRequest_Dist.length] = 0;
-		mod_wfs_SpatialRequest_TotalDist[mod_wfs_SpatialRequest_TotalDist.length] = 0;
+function mod_wfs_spatialRequest_close(){
+	if(mod_wfs_spatialRequest_geometry.count() < 3){
+		return;
 	}
+	mod_wfs_spatialRequest_geometry.closeGeometry();
 	drawDashedLineExt();
 	mod_getAreaExt_send();
-	
-}
-function mod_wfs_SpatialRequest_delete(){
-	mod_wfs_SpatialRequest_RX = new Array();
-	mod_wfs_SpatialRequest_RY = new Array();
-	mod_wfs_SpatialRequest_Dist = new Array();
-	mod_wfs_SpatialRequest_TotalDist = new Array();
-	writeTag(mod_wfs_SpatialRequest_target,"measuring","");
-	writeTag(mod_wfs_SpatialRequest_target,"measure_display","");
-}
-/***************************************init Zoombox*********************************************/
-function mod_selAreaExt_click(){
-   var el = window.frames[mod_wfs_SpatialRequest_target].document;
-   el.onmouseover = mod_selAreaExt_init;
-   el.onmousedown = mod_box_start;
-   el.onmouseup = mod_selAreaExt_get;
-   el.onmousemove = mod_box_run;
-}
-function mod_selAreaExt_disable(){
-   var el = window.frames[mod_wfs_SpatialRequest_target].document; 
-   el.onmousedown = null;
-   el.onmouseup = null;
-   el.onmousemove = null;
-}
-function mod_selAreaExt_init(e){
-   mb_isBF = mod_wfs_SpatialRequest_target;
-   mb_zF = mod_wfs_SpatialRequest_target;
 }
-function mod_selAreaExt_get(e){
-	mod_selAreaExt_setValidClipping(mod_box_stop(e));
-	mb_isBF = mod_wfs_SpatialRequest_target;
-	mb_zF = mod_wfs_SpatialRequest_target;
+
+function register_setExtRequestSubFunctions(stringFunction){
+	mod_wfs_spatialRequestSubFunctions[mod_wfs_spatialRequestSubFunctions.length] = stringFunction;
 }
-function mod_selAreaExt_setValidClipping(coords){
-	//alert(coords.join(","));
-	mod_wfs_SpatialRequest_RX[0] = coords[0];
-	mod_wfs_SpatialRequest_RY[0] = coords[1];
-	mod_wfs_SpatialRequest_RX[1] = coords[2];
-	mod_wfs_SpatialRequest_RY[1] = coords[3];
-	
-	if(coords.length > 2){
-		mod_getAreaExt_send();
-	}
-	else{
-		alert("Ausschnitt ungültig!")
-	}
+
+function mod_getAreaExt_send(){	
+	mb_setwfsrequest(mod_wfs_spatialRequest_target,mod_wfs_spatialRequest_geometry);
+	mod_wfs_spatialRequest_delete();
+	mb_disableThisButton(activeButton.id);
 }
 
+function mod_wfs_spatialRequest_delete(){
+	writeTag(mod_wfs_spatialRequest_target,"measuring","");
+	writeTag(mod_wfs_spatialRequest_target,"measure_display","");
+}
 
+function mod_wfs_spatialRequest_timeout(){
+	var el = window.frames[mod_wfs_spatialRequest_target].document; 
+	el.onmousedown = null;
+	el.ondblclick = null;
+	el.onmousemove = null;
+}
 
+function mod_wfs_spatialRequest_disableTimeout(){
+	var el = window.frames[mod_wfs_spatialRequest_target].document;
+	el.onmousedown = mod_wfs_spatialRequest_start;
+}
 
-/*********************************************************************/
-mod_wfs_SpatialRequest_win = null;
-mod_wfs_SpatialRequest_thema = false;
-mod_wfs_SpatialRequest_geom = false;
+function isSetWfsResultToDigitize() {
+	return wfsResultToDigitize;
+}
 
 function mod_wfs_SpatialRequest_dialog(){	
-	if(!mod_wfs_SpatialRequest_win || mod_wfs_SpatialRequest_win == null || mod_wfs_SpatialRequest_win.closed == true){
-		mod_wfs_SpatialRequest_win = window.open("","mod_wfs_SpatialRequest_win","width=200,height=150,resizable=yes");
-		mod_wfs_SpatialRequest_win.document.open("text/html");
+	if(!mod_wfs_spatialRequest_win || mod_wfs_spatialRequest_win == null || mod_wfs_spatialRequest_win.closed == true){
+		mod_wfs_spatialRequest_win = window.open("","mod_wfs_spatialRequest_win","width=200,height=150,resizable=yes");
+		mod_wfs_spatialRequest_win.document.open("text/html");
 		
-		mod_wfs_SpatialRequest_win.document.writeln('<script language="JavaScript" type="text/javascript">');	
-		mod_wfs_SpatialRequest_win.document.writeln('function set(obj){');
-			mod_wfs_SpatialRequest_win.document.writeln('for(var i=0; i< document.getElementsByName("geom").length; i++){');
-				mod_wfs_SpatialRequest_win.document.writeln('if(document.getElementsByName("geom")[i].checked){');
-					mod_wfs_SpatialRequest_win.document.writeln('window.opener.mod_setExtRequest_geom = document.getElementsByName("geom")[i].value;'); 
-				mod_wfs_SpatialRequest_win.document.writeln('}');
-			mod_wfs_SpatialRequest_win.document.writeln('}');
-			mod_wfs_SpatialRequest_win.document.writeln('window.opener.mod_wfs_SpatialRequest_geom = obj.value;');
-			mod_wfs_SpatialRequest_win.document.writeln('window.opener.mod_wfs_SpatialRequest_decide();');
-			mod_wfs_SpatialRequest_win.document.writeln('window.close();');
-			mod_wfs_SpatialRequest_win.document.writeln('return false;	');
-		mod_wfs_SpatialRequest_win.document.writeln('}');
-		mod_wfs_SpatialRequest_win.document.writeln('</script>');
+		mod_wfs_spatialRequest_win.document.writeln('<script language="JavaScript" type="text/javascript">');	
+		mod_wfs_spatialRequest_win.document.writeln('function set(obj){');
+			mod_wfs_spatialRequest_win.document.writeln('for(var i=0; i< document.getElementsByName("geom").length; i++){');
+				mod_wfs_spatialRequest_win.document.writeln('if(document.getElementsByName("geom")[i].checked){');
+					mod_wfs_spatialRequest_win.document.writeln('window.opener.mod_setExtRequest_geom = document.getElementsByName("geom")[i].value;'); 
+				mod_wfs_spatialRequest_win.document.writeln('}');
+			mod_wfs_spatialRequest_win.document.writeln('}');
+//			mod_wfs_spatialRequest_win.document.writeln('window.opener.mod_wfs_spatialRequest_geom = obj.value;');
+			mod_wfs_spatialRequest_win.document.writeln('window.opener.wfsEnable(obj);');
+			mod_wfs_spatialRequest_win.document.writeln('window.close();');
+			mod_wfs_spatialRequest_win.document.writeln('return false;	');
+		mod_wfs_spatialRequest_win.document.writeln('}');
+		mod_wfs_spatialRequest_win.document.writeln('</script>');
 		
-		mod_wfs_SpatialRequest_win.document.writeln("<form>");
-		mod_wfs_SpatialRequest_win.document.writeln("<input id='point' name='geom' type='radio' value='point' onclick='set(this)'> Punkt<br>");
-		mod_wfs_SpatialRequest_win.document.writeln("<input id='rectangle' name='geom' type='radio' value='rectangle' onclick='set(this)'> Rechteck<br>");
-		mod_wfs_SpatialRequest_win.document.writeln("<input id='polygon' name='geom' type='radio' value='polygon'onclick='set(this)'> Polygon<br>");
+		mod_wfs_spatialRequest_win.document.writeln("<form>");
+		mod_wfs_spatialRequest_win.document.writeln("<input id='point' name='geom' type='radio' value='"+button_point+"' onclick='set(this)'> Punkt<br>");
+		mod_wfs_spatialRequest_win.document.writeln("<input id='rectangle' name='geom' type='radio' value='"+button_rectangle+"' onclick='set(this)'> Rechteck<br>");
+		mod_wfs_spatialRequest_win.document.writeln("<input id='polygon' name='geom' type='radio' value='"+button_polygon+"'onclick='set(this)'> Polygon<br>");
+		mod_wfs_spatialRequest_win.document.writeln("<input id='extent' name='geom' type='radio' value='"+button_extent+"'onclick='set(this)'> Extent<br>");
 		var checked = "";
-		if (mod_wfs_SpatialRequest_useExtent) {
-			checked = " checked";
-		}		
-		//mod_wfs_SpatialRequest_win.document.writeln("<input id='extent' name='geom' type='radio' value='extent' onclick='set(this)' " + checked + "> Extent<br>");
-		mod_wfs_SpatialRequest_win.document.writeln("</form>");
-		mod_wfs_SpatialRequest_win.document.close();
+//		if (mod_wfs_spatialRequest_useExtent) {
+//			checked = " checked";
+//		}		
+		//mod_wfs_spatialRequest_win.document.writeln("<input id='extent' name='geom' type='radio' value='extent' onclick='set(this)' " + checked + "> Extent<br>");
+		mod_wfs_spatialRequest_win.document.writeln("</form>");
+		mod_wfs_spatialRequest_win.document.close();
 	}
 	else{
-		mod_wfs_SpatialRequest_win.focus();
+		mod_wfs_spatialRequest_win.focus();
 	}	
 }
-function mod_getAreaExt_send(){	
-	if(mod_wfs_SpatialRequest_geom == 'point'){
-		mb_setwfsrequest(mod_wfs_SpatialRequest_target,'point', mod_wfs_SpatialRequest_RX, mod_wfs_SpatialRequest_RY);
-		mod_wfs_SpatialRequest_delete();
-		mod_wfs_SpatialRequest_disable();
-	}
-	else if(mod_wfs_SpatialRequest_geom == 'polygon'){
-		mb_setwfsrequest(mod_wfs_SpatialRequest_target,'polygon', mod_wfs_SpatialRequest_RX, mod_wfs_SpatialRequest_RY);
-		mod_wfs_SpatialRequest_delete();
-		mod_wfs_SpatialRequest_disable();
-	}
-	else if(mod_wfs_SpatialRequest_geom == 'rectangle'){
-		mb_setwfsrequest(mod_wfs_SpatialRequest_target,'rectangle', mod_wfs_SpatialRequest_RX, mod_wfs_SpatialRequest_RY);
-		mod_wfs_SpatialRequest_delete();
-		mod_selAreaExt_disable();
-	}	
-	else if(mod_wfs_SpatialRequest_geom == 'extent'){
-		mb_setwfsrequest(mod_wfs_SpatialRequest_target,'rectangle', mod_wfs_SpatialRequest_RX, mod_wfs_SpatialRequest_RY);
-		mod_wfs_SpatialRequest_delete();
-		mod_selAreaExt_disable();
-	}	
-	mb_disableThisButton('setSpatialRequest');
+//deprecated stuff
+function mod_wfs_spatialRequest_dialog(){	
 }
+function useExtentIsSet () {
+	return mod_wfs_spatialRequest_useExtent;
+}
+
+displayButtons();




More information about the Mapbender_commits mailing list