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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Wed Nov 25 05:06:47 EST 2009


Author: christoph
Date: 2009-11-25 05:06:44 -0500 (Wed, 25 Nov 2009)
New Revision: 5034

Added:
   trunk/mapbender/http/javascripts/mod_georss.php
   trunk/mapbender/http/javascripts/popupballon.js
   trunk/mapbender/http/javascripts/usemap.js
   trunk/mapbender/http/php/geoRSSToGeoJSON.php
Log:


Added: trunk/mapbender/http/javascripts/mod_georss.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_georss.php	                        (rev 0)
+++ trunk/mapbender/http/javascripts/mod_georss.php	2009-11-25 10:06:44 UTC (rev 5034)
@@ -0,0 +1,180 @@
+<?php
+# $Id:$
+# http://www.mapbender.org/index.php/mod_georss.php
+# 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
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
+#require_once(dirname(__FILE__)."/../include/dyn_php.php");
+?>
+var georssTargetArray = [];
+<?php
+
+//for old versions:
+//$e_target = explode(",",$e_target);
+
+for ($i = 0; $i < count($e_target); $i++) {
+	echo "georssTargetArray.push('".$e_target[$i]."');";
+	#echo "georssTargetArray.push('mapframe1');";
+	#echo "georssTargetArray.push('mapframe1');";
+}
+
+//function _mb($a) {
+//return $a;
+//}
+
+
+?>
+var georssWin=null;
+var georssHighlighter;
+var georssUsemap;
+var geoms=null;
+
+<?php
+if ($loadGeorssFromSession == "1" && isset($_SESSION["georssURL"]) && $_SESSION["georssURL"] != "") {
+	//if (isset($_SESSION["georssURL"]) && $_SESSION["georssURL"] != "") {
+	echo "var url=\"".$_SESSION["georssURL"]."\";";
+	//echo "alert(\"Found following url in Session - will try to load it from there: \"+url);";
+	echo "mb_registerInitFunctions(\"loadGeoRSS('".$_SESSION["georssURL"]."');\");";
+	$_SESSION["georssURL"]=null;
+	#echo "return false;"
+}
+?>
+//Show prompt to load URL by hand dynamically - like addWMS
+function loadGeoRSSByForm(){
+   var loadGeoRSSUrl = prompt("GeoRSS-URL:","");
+   if(loadGeoRSSUrl){
+      loadGeoRSS(loadGeoRSSUrl);    
+   }
+}
+
+
+function loadGeoRSS(url){
+	//	
+	//alert("<?php echo _mb("mapframe: ");?>get");
+	//return;
+
+	var targetEPSG = getMapObjByName('mapframe1').epsg;
+	//alert(targetEPSG);
+	//
+	$.post("../php/geoRSSToGeoJSON.php",{url:url,targetEPSG:targetEPSG}, function(jsCode, status){
+			if(status=='success'){
+				if(jsCode==""){
+					alert("<?php echo _mb("No GeoRSS feed information found. Please check your URL.");?>");
+					return;
+				}
+				var geoObj = eval('(' + jsCode + ')');	
+	        	if (typeof(geoObj) == 'object'&&typeof(geoObj.errorMessage)=='undefined') {
+	           		//create georssHighlighter and usemap
+	           		if(typeof(georssHighlighter)==='undefined'){
+						georssHighlighter = new Highlight(georssTargetArray, "geoRssHL", {"position":"absolute", "top":"0px", "left":"0px", "z-index":30}, 2);
+						georssUsemap = new Usemap(georssTargetArray, "geoRssUM", 120, 5, 2);
+	           		}
+	           		else{
+						georssHighlighter.clean();
+						georssUsemap.clean();
+	           		}
+	           		
+	           		//Import Geometries
+				geoms = new GeometryArray();
+	           		geoms.importGeoJSON(geoObj);
+	           		
+	           		//Zoom to Extent of Geometries
+	           		extent = geoms.getBBox();
+	           		mb_calculateExtent(georssTargetArray[0], extent[0].x, extent[0].y, extent[1].x, extent[1].y);
+	           		extent = enlargeExtent(extent, 10, georssTargetArray[0]);
+	           		mb_calculateExtent(georssTargetArray[0], extent[0].x, extent[0].y, extent[1].x, extent[1].y);
+	           		setMapRequest(georssTargetArray[0]);
+					
+					//Add geometries to usemap and georssHighlighter
+					for( var i=0;i<geoms.count();i++){
+						georssHighlighter.add(geoms.get(i),"red");
+						georssUsemap.add(geoms.get(i), geoms.get(i).e.getElementValueByName("title"),null,null,showGeorssTooltip);
+					}
+					georssHighlighter.paint();
+					georssUsemap.setUsemap();
+					eventAfterMapRequest.register("georssHighlighter.paint();");
+					eventAfterMapRequest.register("georssUsemap.setUsemap();");
+					//mb_registerSubFunctions("georssHighlighter.paint();");
+					//mb_registerSubFunctions("georssUsemap.setUsemap();");
+					//Delete geometries as they are now in georssHighlighter and Usemap
+					delete geoms;
+				}
+				else {
+					alert("<?php echo _mb("No GeoRSS feed information found. Please check your URL.");?>");
+					return;
+				}
+	       	}
+		});
+}
+
+function enlargeExtent(extent, pixel, frame){
+	var min = realToMap(frame, extent[0]);
+	var max = realToMap(frame, extent[1]);
+	min.x-=pixel;
+	min.y-=pixel;
+	max.x+=pixel;
+	max.y+=pixel;
+	extent[0] = mapToReal(frame, min)
+	extent[1] = mapToReal(frame, max)
+	return extent;
+}
+
+function showGeorssTooltip(e){
+	actGeom = this.geom;
+	if(!actGeom)
+		return;
+	
+	actFrame = georssTargetArray[0];
+	
+	//Get Mapframe Position
+	x=parseInt(document.getElementById(actFrame).style.left);
+	y=parseInt(document.getElementById(actFrame).style.top);
+	
+	//Hide old Window
+	if(georssWin && georssWin.isVisible()){
+		georssWin.destroy();
+	}
+	//create html code for the information to show
+	var html="<html><br><br><br>";
+	html = html + "<table border = \"1\" width=\"80%\">";
+	//html = html + "<colgroup width=\"40\" span=\"1\"></colgroup>";
+	html = html + "<tr>";
+	//html = html + "<td>"+"Beschreibung"+"</td>";
+	html = html + "<td>"+actGeom.e.getElementValueByName("description")+"</td>";
+	html = html + "</tr><tr>";
+	//html = html + "<td>"+"Link"+"</td>";
+	html = html + "<td><a href=\""+actGeom.e.getElementValueByName("link")+"\" target=\"_blank\">Details</a></td>";
+	//show button if some element is found which include an url to a wms capabilities document	
+	if ( actGeom.e.getElementValueByName("ingrid:wms-url") != '') {
+		html = html + "<tr>";
+		html = html + "<td><a href=\""+actGeom.e.getElementValueByName("ingrid:wms-url")+"\" target=\"_blank\">Capabilities</a></td>";
+		html = html + "</tr>";
+		html = html + "<tr>";
+		html = html + "<td><input type=button value='Laden' onclick=\"mod_addWMS_load(actGeom.e.getElementValueByName('ingrid:wms-url'));\"></td>";
+		html = html + "</tr>";
+	}
+	html = html + "</tr></table></html>";
+
+	
+	//alert(html); 	
+	//Show Modal Popup
+	mb_getMousePos(e,actFrame);
+
+	georssWin = new mb_popup({title:actGeom.e.getElementValueByName("title"),
+		html:html,balloon:true,left:clickX+x,top:clickY+y,modal:true});
+	georssWin.show();
+}

Added: trunk/mapbender/http/javascripts/popupballon.js
===================================================================
--- trunk/mapbender/http/javascripts/popupballon.js	                        (rev 0)
+++ trunk/mapbender/http/javascripts/popupballon.js	2009-11-25 10:06:44 UTC (rev 5034)
@@ -0,0 +1,560 @@
+/* 
+* $Id: popup.js 3097 2008-10-02 15:27:36Z nimix $
+* COPYRIGHT: (C) 2002 by ccgis. This program is free software under the GNU General Public
+* License (>=v2). Read the file gpl.txt that comes with Mapbender for details. 
+*/
+//http://www.mapbender.org/index.php/popup
+var popup_count = 1;
+var popup_top = 150;
+
+/**
+ * @class A class representing a popup window
+ *
+ * @constructor
+ * @param {String/Object} title the title text of the popup or Options object
+ * Elelemts of the options object (all optional):
+ *  left: position left
+ *  top: position top
+ *  width: popup width
+ *  height: popup height
+ *  title: popup title
+ *  frameName: name of the popups iframe if it loads a frame  (recommended to set destroy to false)
+ *  opacity: opacity of the frame default:1
+ *  moveOpacity: opacity while the user moves or resizes the frame default:0.8
+ *  html:content html of the frame (not parsed if url not false)
+ *  url:content url of the frame
+ *  minWidth: minimum width of the popup if the user resizes it
+ *  maxWidth: maximum width of the popup if the user resizes it
+ *  minHeight: minimum height of the popup if the user resizes it
+ *  maxHeight: maximum height of the popup if the user resizes it
+ *  minTop: minimum top position if the user moves the popup default:"document"
+ *  minLeft: minimum left position if the user moves the popup default:"document"
+ *  maxRight: maximum right position if the user moves/resizes the popup 
+ *  maxBottom: maximum bottom position if the user moves/resized the popup
+ * 	style: additional styles for the popup window
+ *  destroy: remove dom of popup if user closes it (don't use it for iframes with framename) default:true
+ *  closeCallback: function that is called if the user closes the window
+ *  resizeable: allow user to change the size default:true
+ *  dragable: allow user to move the window default:true
+ *  balloon: balloon popup from top, left (disables resizeable and dragable)
+ *  modal: create modal popup default:false
+ * 
+ * @param {String} html the "body" of the popup, can also be "url:http://foo.de" to display a website
+ * @param {Number} width width of the popup
+ * @param {Number} height hight of the popup
+ * @param {Number} posx left position of the popup
+ * @param {Number} popy top posision of the popup
+ * 
+ */
+function mb_popup(title,html,width,height,posx,posy,fName,opacity) {
+	//get first free place
+	var create_pos=popup_count;
+	for(var i = 0; i < popup_count;i++)
+		if(!document.getElementById("popup"+String(i))){
+			create_pos=i;
+			break;
+		}
+
+	this.id="popup"+String(++popup_top);
+		
+	//Set defaults
+	defaults = {
+		left:25*create_pos,
+		top:25*create_pos,
+		width:300,height:250,
+		title:"Title",
+		frameName:this.id,
+		id:this.id
+	};
+
+	if(typeof(title)!='object'){
+		this.options = defaults;
+		
+		//Set vars
+		if(posx)this.options.left=posx;
+		if(posy)this.options.top=posy;
+		if(width)this.options.width=width;
+		if(height)this.options.height=height;
+		if(title)this.options.title=title;
+		if(fName)this.options.frameName=fName;
+		if(opacity)this.options.opacity;
+		if(html){
+			if(html.indexOf("url:")==0)
+				this.options.url=html.substr(4);
+			else
+				this.options.html=html;
+		}
+	}
+	else
+		this.options=$.extend(defaults, title);
+
+	this.id = this.options.id;
+	
+	popup_count++;
+	
+	//create dom popup
+	$("body").append("<div style=\"display:none;z-index:"+popup_top+"\" id=\""+this.id+"\"></div>");
+	this.div = $("#"+this.id).mbPopup(this.options);
+}
+
+/**
+ * Shows the popup
+ */
+mb_popup.prototype.show = function(){
+	if(!document.getElementById(this.id)){
+		//(re)create dom popup
+		$("body").append("<div style=\"display:none;z-index:"+popup_top+"\" id=\""+this.id+"\"></div>");
+		this.div = $("#"+this.id).mbPopup(this.options);
+	}
+	if(!this.isVisible())
+		$("#"+this.id).show();
+}
+
+/**
+ * Hides the popup
+ */
+mb_popup.prototype.hide = function(){	
+	$("#"+this.id).hide();
+	$("#balloon_"+this.id).hide();
+	$("#modal_mouse_catcher").remove();
+}
+
+/**
+ * Hides the popup
+ */
+mb_popup.prototype.destroy = function(){	
+	$("#"+this.id).remove();
+	$("#balloon_"+this.id).remove();
+	$("#modal_mouse_catcher").remove();
+}
+
+/**
+ * sets the width of the popup window
+ *
+ * @param {Number} width new width of the popup  
+ */
+mb_popup.prototype.setWidth = function(width){
+	var div=document.getElementById(this.id);
+	if(div)div.style.width=width;
+}
+
+/**
+ * sets the height of the popup window
+ *
+ * @param {Number} height new height of the popup  
+ */
+mb_popup.prototype.setHeight = function(height){
+	var div=document.getElementById(this.id);
+	if(div)div.style.height=height;
+}
+
+/**
+ * sets the left position of the popup window
+ *
+ * @param {Number} left new left position of the popup  
+ */
+mb_popup.prototype.setLeft = function(left){
+	var div=document.getElementById(this.id);
+	if(div)div.style.left=left;
+}
+
+/**
+ * sets the top position of the popup window
+ *
+ * @param {Number} top new top position of the popup  
+ */
+mb_popup.prototype.setTop = function(topp){
+	var div=document.getElementById(this.id);
+	if(div)div.style.top=topp;
+}
+
+/**
+ * sets the opacity of the popup window
+ *
+ * @param {Number} opacity new opacity value of the popup  
+ */
+mb_popup.prototype.setOpacity = function(opacityy){
+	var div=document.getElementById(this.id);
+	if(div)div.style.opacity=opacityy;
+}
+
+/**
+ * sets the title of the popup window
+ *
+ * @param {String} title new title text of the popup  
+ */
+mb_popup.prototype.setTitle = function(title){
+	$("#"+this.id+" h1").text(title);
+}
+
+/**
+ * sets the html content of the popup window
+ *
+ * @param {String} html new html "body" of the popup  
+ */
+mb_popup.prototype.setHtml = function(htmll){
+	this.options.url=null;
+	this.options.html=htmll;
+	$("#"+this.id+" .Content").html('<div class="scrollDiv">'+htmll+'</div>');
+}
+/**
+ * behaves like document.open(); (clear popup)
+ */
+mb_popup.prototype.open = function(){
+	oDoc = this.getDocument();
+	if(oDoc!=null){
+		return oDoc.open();
+	}
+	this.setHtml("");
+}
+
+/**
+ * behaves like document.write(); (appends content to the popup)
+ * 
+ * @param {String} text or html to write into the document
+ */
+mb_popup.prototype.write = function(str){
+	oDoc = this.getDocument();
+	if(oDoc!=null){
+		return oDoc.write(str);
+	}
+	this.setHtml(this.options.html+str);
+}
+
+/**
+ * behaves like document.close(); (finish loading state if popup is an iframe)
+ */
+mb_popup.prototype.close = function(){
+	oDoc = this.getDocument();
+	if(oDoc!=null){
+		return oDoc.close();
+	}
+}
+
+/**
+ * sets the url of the content
+ *
+ * @param {String} url new url of the popup  
+ */
+mb_popup.prototype.setUrl = function(url){
+	this.options.url=url;
+	this.options.html=null;
+	
+	oDoc = this.getDocument();
+	if(oDoc){
+		oDoc.location.href = url;
+	}
+	else{
+		$("#"+this.id+" .Content").html('<iframe src="'+url+'"></iframe>');
+	}
+}
+
+/**
+ * reposition
+ */
+mb_popup.prototype.reposition =function(){
+//TODO	
+}
+
+/**
+ * gets the visible state of the popup window
+ * @return visible state of the popup
+ * @type Boolean
+ */
+mb_popup.prototype.isVisible = function(){
+	return $("#"+this.id+":visible").length>0?true:false;
+}
+
+/**
+ * (re) set Some Options of the popup Window and rerender it
+ * @param options object that contains the new options
+ */
+mb_popup.prototype.set = function(options){
+	this.destroy();
+	this.options=$.extend(this.options, options);
+	this.show();
+}
+
+/**
+ * get the DOM document of the client iframe
+ * @return DOM document or null if the popup doesn't contain an iframe
+ */
+mb_popup.prototype.getDocument = function(){
+	iFrame = $("#"+this.id+" iframe")[0];
+	try{
+		//try to load contentWindow first since not every browser 
+		//supports contentDocument (or gives the window instead)
+		oDoc = iFrame.contentWindow || iFrame.contentDocument;
+		if (oDoc.document) {
+	        oDoc = oDoc.document;
+    	}
+    	return oDoc;
+	}
+	catch(e){return null;}
+}
+
+/**
+ * get Scroll position
+ */
+function getScrollPos() {  
+	var scrOf ={X:0,Y:0,wW:$(window).width(),dW:$().width(),wH:$(window).height(),dH:$().height()};  
+	
+	if( typeof( window.pageYOffset ) == 'number' ) {  
+		//Netscape compliant  
+		scrOf.Y = window.pageYOffset;  
+		scrOf.X = window.pageXOffset;  
+	} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {  
+		//DOM compliant  
+		scrOf.Y = document.body.scrollTop;  
+		scrOf.X = document.body.scrollLeft;  
+	} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {  
+		//IE6 standards compliant mode  
+		scrOf.Y = document.documentElement.scrollTop;  
+		scrOf.X = document.documentElement.scrollLeft;  
+	}
+	return scrOf;  
+}
+
+
+
+(function($){
+	$.fn.mbPopup = function(options){
+		//default settings
+		defaults = {
+			left:0,top:0,width:300,height:250,
+			title:"",frameName:"",
+			opacity:1.0,moveOpacity:0.8,html:false,url:false,
+			minWidth:false,maxWidth:false,
+			minHeight:false,maxHeight:false,
+			minTop:"document",minLeft:"document",
+			maxRight:false,maxBottom:false,
+			dragable:true,resizeable:true,balloon:false,
+			style:null,destroy:true,modal:false,
+			closeCallback:null
+		};
+		//override defaults
+		settings=$.extend(defaults,options)
+		this.settings = settings;
+		
+		//add Styles
+		this.addClass("mbPopup");
+		
+		//append additions styles
+		if(settings.style)
+			this.css(settings.style);
+		
+		//automated settings for balloon popup
+		if(settings.balloon){
+			$("body").append("<div id='balloon_"+settings.id+"' class='balloonBL' style='visibility:hidden;'>");
+			settings.resizeable = false;
+			settings.dragable = false;
+		}
+
+		//calculate positioning (mainly needed for balloon style)
+		pos = $.mbPopupFn.calcPositioning(settings, this);
+
+		//set balloon arm position
+		if(settings.balloon){
+			$("#balloon_"+settings.id).attr("class", "balloon"+(pos.position>=2?"B":"T")+(pos.position%2?"R":"L"))
+				.css({"z-index":(popup_top),visibility:"visible",left:String(pos.bX)+"px",top:String(pos.bY)+"px"});
+			settings.left = pos.pX;
+			settings.top = pos.pY;
+		}
+		
+		//fix IE width and height by adding the padding values
+		if($.browser.msie){
+			settings.width = pos.pW;
+			settings.height = pos.pH;
+		}
+		
+		//Set dimensions
+		this.css({top:String(settings.top)+"px",
+			left:String(settings.left)+"px",
+			width:String(settings.width)+"px",
+			height:String(settings.height)+"px",
+			opacity:settings.opacity
+			});
+		
+		//Insert content
+		if(settings.url)
+			html = ('<iframe name="'+settings.frameName+'" src="'+settings.url+'"></iframe>');
+		else
+			html = ('<div class="scrollDiv">'+settings.html+'</div>');
+	
+		this.html('<div class="Title Drag"><h1>'+settings.title+'</h1></div><div class="Content">'+html+'</div><img src="../img/close_icon.png" class="Close" alt="close" />'+(settings.resizeable?'<div class="Resize" />':''));
+	
+		var data = {El:this,fY:settings.minTop,fX:settings.minLeft,tX:settings.maxRight,tY:settings.maxBottom,
+			fW:settings.minWidth,tW:settings.maxWidth,fH:settings.minHeight,tH:settings.maxHeight,
+			destroy:settings.destroy,opacity:settings.opacity,moveOpacity:settings.moveOpacity,close:settings.closeCallback}
+		
+		//Make window Dragable
+		if(settings.dragable)
+			$(".Drag", this).bind('mousedown',data,function(event){
+				//set to top
+				event.data.El.css("z-index",popup_top++);
+				event.data.El.css('opacity',event.data.moveOpacity)
+				//create helper div to steal mouse events
+				$("body").append("<div style=\"position:absolute;top:0px;left:0px;width:"+$().width()+"px;height:"+$().height()+"px;z-index:"+(popup_top+2)+($.browser.msie?";background:url(../img/transparent.gif)":"")+"\" id=\"mouse_catcher\"></div>");
+				$("iframe", event.data.El).hide();
+							
+				//Parse setiings of min and max position
+				var data = $.mbPopupFn.parseDimensions(event);
+				
+				//bind mouse events to popup
+				$().bind("mousemove",$.extend(data,{drag:true}),$.mbPopupFn.move).bind('mouseup',event.data,$.mbPopupFn.stop);
+			});
+		
+		//Make Window resizable
+		if(settings.resizeable)
+			$(".Resize", this).bind('mousedown',data,function(event){
+				//set to top
+				event.data.El.css("z-index",popup_top++);
+				event.data.El.css('opacity',event.data.moveOpacity)
+				//create helper div to steal mouse events
+				$("body").append("<div style=\"position:absolute;top:0px;left:0px;width:"+$().width()+"px;height:"+$().height()+"px;z-index:"+(popup_top+2)+($.browser.msie?";background:url(../img/transparent.gif)":"")+"\" id=\"mouse_catcher\"></div>");
+				$("iframe", event.data.El).hide();
+	
+				//Parse setiings of min and max position
+				var data = $.mbPopupFn.parseDimensions(event);
+				
+				//bind mouse events to popup
+				$().bind("mousemove",$.extend(data,{drag:false}),$.mbPopupFn.move).bind('mouseup',event.data,$.mbPopupFn.stop);
+			});
+		
+		//closeButton
+		this.closePopup = function(event){
+			if(event.data.close)
+				event.data.close();
+			$("#modal_mouse_catcher").remove();
+			if(event.data.destroy){
+				event.data.El.slideUp('slow', function(){$(this).remove();});
+				$("#balloon_"+event.data.El.attr("id")).remove();
+			}
+			else{
+				event.data.El.slideUp('slow');
+				$("#balloon_"+event.data.El.attr("id")).fadeOut();
+			}
+		};
+		$(".Close", this).bind('click',data, this.closePopup);
+		
+		//create div to make window modal
+		if(settings.modal){
+			$("body").append("<div style=\"position:absolute;top:0px;left:0px;width:"+$().width()+"px;height:"+$().height()+"px;z-index:"+(popup_top-1)+($.browser.msie?";background:url(../img/transparent.gif)":"")+"\" id=\"modal_mouse_catcher\"></div>");
+			$("#modal_mouse_catcher").bind('click',data, this.closePopup);
+		}
+
+		//raise on click
+		this.click(function(){this.style.zIndex=popup_top++;$("#balloon_"+this.id).css("z-index", popup_top++);});
+		$("#balloon_"+settings.id).click(function(){$("#"+this.id.substr(8)).css("z-index", popup_top++);this.style.zIndex=popup_top++;});
+		
+		//raise top postition
+		popup_top++;
+	};
+	//helper functions
+	$.mbPopupFn = {
+		//on mouse action
+		move:function(event){
+			//drag
+			if(event.data.drag){
+				var newPos = {X:event.data.X+event.pageX-event.data.pX,
+					Y:event.data.Y+event.pageY-event.data.pY};
+				if(event.data.fX!==false&&newPos.X<event.data.fX)
+					newPos.X=event.data.fX;
+				if(event.data.fY!==false&&newPos.Y<event.data.fY)
+					newPos.Y=event.data.fY;
+				if(event.data.tX!==false&&newPos.X>event.data.tX-event.data.W)
+					newPos.X=event.data.tX-event.data.W;
+				if(event.data.tY!==false&&newPos.Y>event.data.tY-event.data.H)
+					newPos.Y=event.data.tY-event.data.H;
+				
+				event.data.El.css({left:newPos.X,top:newPos.Y});
+				return;
+			}
+			//resize
+			var newDim = {W:Math.max(event.pageX-event.data.pX+event.data.W,0),
+				H:Math.max(event.pageY-event.data.pY+event.data.H,0)};
+			if(event.data.fW!==false&&newDim.W<event.data.fW)
+				newDim.W=event.data.fW;
+			if(event.data.fH!==false&&newDim.H<event.data.fH)
+				newDim.H=event.data.fH;
+			if(event.data.tW!==false&&newDim.W>event.data.tW)
+				newDim.W=event.data.tW;
+			if(event.data.tH!==false&&newDim.H>event.data.tH)
+				newDim.H=event.data.tH;
+			if(event.data.tX!==false&&newDim.W+event.data.X>event.data.tX)
+				newDim.W=event.data.tX-event.data.X;
+			if(event.data.tY!==false&&newDim.H+event.data.Y>event.data.tY)
+				newDim.H=event.data.tY-event.data.Y;	
+						
+			event.data.El.css({width:newDim.W,height:newDim.H});
+			
+		},
+		stop:function(event){
+			event.data.El.css('opacity',event.data.opacity)
+			$("iframe", event.data.El).show();
+			$().unbind('mousemove',$.mbPopupFn.move).unbind('mouseup',$.mbPopupFn.stop);
+			$("#mouse_catcher").remove();
+		},
+		//parse move and resize dimensions
+		parseDimensions:function(d){
+			var dim = getScrollPos();
+			var bd = {X:parseInt($(d.data.El).css("border-left-width"))+parseInt($(d.data.El).css("border-right-width")),
+				Y:parseInt($(d.data.El).css("border-top-width"))+parseInt($(d.data.El).css("border-bottom-width"))};
+			ret = {El:d.data.El,
+				fX:(d.data.fX=="window"?dim.X:(d.data.fX=="document"?0:(d.data.fX<0?dim.dW-d.data.fX:d.data.fX))),
+				fY:(d.data.fX=="window"?dim.Y:(d.data.fY=="document"?0:(d.data.fY<0?dim.dH-d.data.fY:d.data.fY))),
+				tX:(d.data.tX=="window"?dim.X+dim.wW:(d.data.tX=="document"?dim.dW:(d.data.tX<0?dim.dW-d.data.tX:d.data.tX))),
+				tY:(d.data.tY=="window"?dim.Y+dim.wH:(d.data.tY=="document"?dim.dH:(d.data.tH<0?dim.dH-d.data.tH:d.data.tY))),
+				fW:(d.data.fW=="window"?dim.wW:(d.data.fW=="document"?dim.dW:(d.data.fW<0?dim.dW-d.data.fW:d.data.fW))),
+				fH:(d.data.fH=="window"?dim.wH:(d.data.fH=="document"?dim.dH:(d.data.fH<0?dim.dH-d.data.fH:d.data.fH))),
+				tW:(d.data.tW=="window"?dim.wW:(d.data.tW=="document"?dim.dW:(d.data.tW<0?dim.dW-d.data.tW:d.data.tW))),
+				tH:(d.data.tH=="window"?dim.wH:(d.data.tH=="document"?dim.dH:(d.data.tH<0?dim.dH-d.data.tH:d.data.tH))),
+				X:parseInt(d.data.El.css("left")),
+				Y:parseInt(d.data.El.css("top")),
+				W:parseInt(d.data.El.css("width")),
+				H:parseInt(d.data.El.css("height")),
+				pX:d.pageX,pY:d.pageY
+			};
+			if(ret.tX)ret.tX-=bd.X;
+			if(ret.tY)ret.tY-=bd.Y;
+			return ret;	
+		},
+		calcPositioning:function(settings, el){
+			var dim = getScrollPos();
+			
+			pos = {};
+			pos.pH = settings.height + (parseInt(el.css("padding-top"))+parseInt(el.css("padding-bottom")));
+			pos.pW = settings.width + (parseInt(el.css("padding-left"))+parseInt(el.css("padding-right")));
+			if(settings.balloon){
+				pos.bH = $("#balloon_"+settings.id).height();
+				pos.bW = $("#balloon_"+settings.id).width();
+	
+				pos.position = 0;
+				
+				if(settings.top-pos.pH-pos.bH-parseInt(el.css("border-top-width"))<dim.Y){
+					//bubble on top
+					pos.pY = settings.top+pos.bH-parseInt(el.css("border-top-width"));
+				}
+				else{
+					//bubble on bottom
+					pos.pY = settings.top-pos.pH-pos.bH+($.browser.msie?parseInt(el.css("border-bottom-width")):-parseInt(el.css("border-top-width")));
+					pos.position+=2;
+				}
+				if(settings.left+pos.pW+parseInt(el.css("border-left-width"))+parseInt(el.css("border-right-width"))>(dim.X+dim.wW)){
+					//bubble on right
+					pos.pX = settings.left-parseInt(el.css("border-left-width"))-parseInt(el.css("border-right-width"))-pos.pW;
+					pos.position++;
+				}
+				else{
+					//bubble on left
+					pos.pX = settings.left-parseInt(el.css("border-left-width"));
+				}
+				
+				pos.bX=(settings.left-(pos.position%2?pos.bW:0));
+				pos.bY=(settings.top-(pos.position>=2?pos.bH:0));
+			}
+			return pos;
+		}
+	};
+	})
+(jQuery);

Added: trunk/mapbender/http/javascripts/usemap.js
===================================================================
--- trunk/mapbender/http/javascripts/usemap.js	                        (rev 0)
+++ trunk/mapbender/http/javascripts/usemap.js	2009-11-25 10:06:44 UTC (rev 5034)
@@ -0,0 +1,261 @@
+/* 
+* $Id:$
+* COPYRIGHT: (C) 2001 by ccgis. This program is free software under the GNU General Public
+* License (>=v2). Read the file gpl.txt that comes with Mapbender for details. 
+*/
+
+function Usemap(usemapTargets, name, zIndex, pointBuffer, lineBuffer) {
+	var targets = usemapTargets;
+	this.name = name;
+	this.zIndex = zIndex;
+	this.pointBuffer = pointBuffer;
+	this.lineBuffer = lineBuffer;
+	
+	//add a geometry to the actual usemap
+	this.add = function(geom, title, mouseover, mouseout, click, mousemove){
+		gA.addCopy(geom);
+		if (typeof(title) != 'undefined') {gA.get(-1).title = title;} 
+		else {gA.get(-1).title = "";}
+		if (typeof(mouseover) != 'undefined') {gA.get(-1).mouseover = mouseover;} 
+		else {gA.get(-1).mouseover = null;}
+		if (typeof(mouseout) != 'undefined') {gA.get(-1).mouseout = mouseout;} 
+		else {gA.get(-1).mouseout = null;}
+		if (typeof(click) != 'undefined') {gA.get(-1).click = click;} 
+		else {gA.get(-1).click = null;}
+		if (typeof(mousemove) != 'undefined') {gA.get(-1).mousemove = mousemove;} 
+		else {gA.get(-1).mousemove = null;}
+	};
+	
+	//(re)generate Usemap
+	this.setUsemap = function(){
+		
+		//first clean the Usemap
+		this.hide();
+		
+		var actualMapObj;
+		var actualImageMap;
+		var actualImage;
+		var actualDoc;
+		
+		//go throught the maps
+		for(var t=0;t<targets.length;t++){
+			
+			//initialize actual dom elements
+			actualMapObj = getMapObjIndexByName(targets[t]);
+			actualDoc = window.frames[targets[t]].document;
+			actualImageMap = actualDoc.getElementById(this.name);
+			actualImage = actualDoc.getElementById(this.name+"_img");
+
+			//if the usemap doesn't exist create it
+			if(!actualImageMap){
+				actualImageMap = actualDoc.createElement("map");
+				actualImage = actualDoc.createElement("img");
+				actualImage.id = this.name+"_img";
+				actualImageMap.id = this.name;
+				actualImage.name = this.name+"_img";
+				actualImageMap.name = this.name;
+				actualImage.setAttribute("useMap", "#"+this.name);
+				actualImage.style.position = "absolute";
+				actualImage.style.left = "0px";
+				actualImage.style.top = "0px";
+				actualImage.style.border = "none";
+				actualDoc.body.appendChild(actualImage);
+				actualDoc.body.appendChild(actualImageMap);
+				actualImage.src = "../img/transparent.gif";
+			}
+			//set Usemap Image dimensions
+			actualImage.style.zIndex = this.zIndex;
+			actualImage.style.width = mb_mapObj[actualMapObj].width;
+			actualImage.style.height = mb_mapObj[actualMapObj].height;
+			
+			//generate areas
+			for(var i=0;i<gA.count();i++){
+				var m = gA.get(i);
+				for(j=0;j<m.count();j++){
+					var area = actualDoc.createElement("area");
+					//add pointer to geometry object
+					area.geom = m;
+					
+					//apply shape
+					g = m.get(j);
+					switch(g.geomType){
+					case geomType.point:
+						this.setPointAttributes(area, g, targets[t]);
+						break;
+					case geomType.line:
+						this.setLineAttributes(area, g, targets[t]);
+						break;
+					case geomType.polygon:
+						this.setPolygonAttributes(area, g, targets[t]);
+						break;
+					}
+					
+					//append to dom and set event handelers
+/*					if($.browser.msie){
+						alert(actualImageMap.areas.length)
+				        actualImageMap.areas[actualImageMap.areas.length] = area;
+					}
+					else
+*/					actualImageMap.appendChild(area);
+
+					area.title = m.title;
+					area.onmouseover = m.mouseover;
+					area.onmouseout = m.mouseout;
+					area.onmousemove = m.mousemove;
+				 	area.onclick = m.click;
+				}
+			}
+		}
+	};
+	
+	this.setPointAttributes = function(area, m, target){
+		//apply point shape to area
+		m = realToMap(target, m.get(0));
+		area.setAttribute("shape", 'circle');
+		area.setAttribute("coords", parseInt(m.x)+","+parseInt(m.y)+","+this.pointBuffer);
+	};
+	this.setLineAttributes = function(area, m, target){
+		//apply line shape to area
+		area.setAttribute("shape", 'poly');
+		if(m.count()==1)
+			return this.setPointAttributes(area,m,target);
+		
+		points = [];
+		
+		first_point= realToMap(target,m.get(0));
+		this_point = realToMap(target,m.get(1));
+		//get vector from point 0 to point 1
+		last_vec = this_point.minus(first_point);
+		//get 90° rotated vector
+		last_vec_o = new Point(-last_vec.y, last_vec.x);
+		//calculate vectors with linebuffer length
+		last_vec_o = last_vec_o.times(this.lineBuffer/last_vec_o.dist(new Point(0,0)));
+		last_vec = last_vec.times(this.lineBuffer/last_vec.dist(new Point(0,0)));
+		
+		//add first pointsets
+		points.unshift(first_point.plus(last_vec_o).minus(last_vec));
+		points.push(first_point.minus(last_vec_o).minus(last_vec));
+		
+		for(var i=1;i<m.count()-1;i++){
+			next_point = realToMap(target,m.get(i+1));
+			//get vector from point n to point n+1
+			vec = next_point.minus(this_point);
+			//get orthogonal (90° rotated) vector		
+			vec_o = new Point(-vec.y, vec.x);
+
+			//resize vectors to linebuffer length
+			vec_o = vec_o.times(this.lineBuffer/vec_o.dist(new Point(0,0)));
+			vec = vec.times(this.lineBuffer/vec.dist(new Point(0,0)));
+			
+			//if direction is the same continue
+			if(vec.equals(last_vec))
+				continue;
+			
+			// calculate angle between the two vectors by 
+			// calculating the argument diffenrences between complex numbers
+			// arg(x + i*y)  
+			var angle = (Math.atan2(vec.x,vec.y)-Math.atan2(last_vec.x,last_vec.y))
+			//ensure that angle is -180<=angle<=180
+			if(angle<-Math.PI)angle=2*Math.PI+angle;
+			if(angle>+Math.PI)angle=2*Math.PI-angle;
+			
+			//calculate the distance between the next points on boundary
+			//and the line point
+			//the point will be in the direction of angle/2 relative to last_vec_o
+			//since cosine is adjacent side / hypothenuse and we know that 
+			//the adjacent side is lineBuffer the hypothenus (our distance) is
+			var ndist = this.lineBuffer/(Math.cos(angle/2))
+			//direction of next points on boundary
+			var int_vec = vec_o.plus(last_vec_o);
+			//resize direction vector to our distance
+			int_vec = int_vec.times(ndist/int_vec.dist(new Point(0,0)));
+			
+			//look if we have a sharp corner (>90°)
+			if(Math.abs(angle)>Math.PI/2){
+				//look where we have the outer edge of corner > 90°
+				if(angle<0){
+					//angle is negative so the outer edge is "on top"
+					//push cutted edge points
+					points.push(this_point.minus(last_vec_o).plus(last_vec));
+					points.push(this_point.minus(vec_o).minus(vec));
+					//TODO look if we need the inner edge or maybe even not the last inserted point
+					//push inner edge
+					points.unshift(this_point.plus(int_vec));
+				}
+				else{
+					//angle is positive so the outer edge is "on bottom"
+					//push cutted edge points
+					points.unshift(this_point.plus(last_vec_o).plus(last_vec));
+					points.unshift(this_point.plus(vec_o).minus(vec));
+					//TODO look if we need the inner edge or maybe even not the last inserted point
+					//push inner edge
+					points.push(this_point.minus(int_vec));
+				}
+			}
+			//otherwise only calculate intersection of bufferboundary lines
+			else{
+				points.unshift(this_point.plus(int_vec));
+				points.push(this_point.minus(int_vec));
+			}
+			//copy for next point
+			last_vec = vec;
+			last_vec_o = vec_o;
+			this_point = next_point;
+		}
+		//add last pointsets
+		points.unshift(this_point.plus(last_vec_o).plus(last_vec));
+		points.push(this_point.minus(last_vec_o).plus(last_vec));
+
+		coords = [];
+		for (var i=0; i<points.length; i++) {
+			coords.push(String(parseInt(points[i].x)));
+			coords.push(String(parseInt(points[i].y)));
+		}
+		area.setAttribute("coords", coords.join(","));
+	};
+	this.setPolygonAttributes = function(area, m, target){
+		//apply polygon shape to area
+		area.setAttribute("shape", 'poly');
+		coords = [];
+		for (var i=0; i<m.count(); i++) {
+			pos = realToMap(target, m.get(i));
+			coords.push(String(parseInt(pos.x)));
+			coords.push(String(parseInt(pos.y)));
+		}
+		area.setAttribute("coords", coords.join(","));
+	};
+	
+	
+	this.hide = function(){
+		//hide the Usemap
+		var actualImageMap;
+		var actualImage;
+		var actualDoc;
+		for(var i=0;i<targets.length;i++){
+			//get actual frame
+			actualDoc = window.frames[targets[i]].document;
+			
+			//clear map
+			actualImageMap = actualDoc.getElementById(this.name);
+			if(actualImageMap)
+				actualImageMap.innerHTML = "";
+			
+			//hide hidden image
+			actualImage = actualDoc.getElementById(this.name+"_img");
+			if(actualImage){
+				actualImage.style.width = "0px";
+				actualImage.style.height = "0px";
+			}
+		}
+	};
+	
+	this.clean = function(){
+		this.hide();
+		if (gA.count() > 0) {
+			delete gA;
+			gA = new GeometryArray();
+		}
+	};
+	
+	var gA = new GeometryArray();
+}

Added: trunk/mapbender/http/php/geoRSSToGeoJSON.php
===================================================================
--- trunk/mapbender/http/php/geoRSSToGeoJSON.php	                        (rev 0)
+++ trunk/mapbender/http/php/geoRSSToGeoJSON.php	2009-11-25 10:06:44 UTC (rev 5034)
@@ -0,0 +1,40 @@
+<?php
+# $Id: mod_wfs_result.php 2144 2008-02-26 23:16:14Z christoph $
+# http://www.mapbender.org/index.php/Administration
+# 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
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
+require_once(dirname(__FILE__) . "/../classes/class_connector.php");
+require_once(dirname(__FILE__) . "/../classes/class_georss_geometry.php");
+
+header("Content-Type: text/x-json");
+$geoRSS = new geoRSS();
+$geoRSS->targetEPSG = '4326';
+$geoRSS->setImportTags(array("title","description","link","ingrid:wms-url"));
+try {
+	#echo $geoRSS->parseFile("http://www.portalu.de/opensearch/query?q=wms+datatype:metadata+ranking:score+partner:sn+partner:bw+partner:bund+partner:he+partner:nw+partner:sl+partner:mv+partner:st+partner:bb+partner:hb+partner:be+partner:hh+partner:ni+partner:sh+partner:hb+partner:by&h=10&p=1&xml=1&georss=1&ingrid=1");
+	#echo $geoRSS->parseFile("http://www.fao.org/geonetwork/srv/en/rss.latest?georss=simple");
+	if (isset($_REQUEST["targetEPSG"])){
+		$geoRSS->targetEPSG = $bodytag = str_replace("EPSG:", "",$_REQUEST["targetEPSG"]);
+	}
+	echo $geoRSS->parseFile($_REQUEST["url"]);
+	
+} catch (Exception $e) {
+	die;
+}
+
+?>



More information about the Mapbender_commits mailing list