[Mapbender-commits] r8769 - in trunk/mapbender: cors_proxy/http http/javascripts http/plugins resources/locale/de_DE/LC_MESSAGES

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Thu Feb 6 07:09:33 PST 2014


Author: armin11
Date: 2014-02-06 07:09:32 -0800 (Thu, 06 Feb 2014)
New Revision: 8769

Modified:
   trunk/mapbender/cors_proxy/http/index.php
   trunk/mapbender/http/javascripts/map_obj.js
   trunk/mapbender/http/javascripts/mod_featureInfo.php
   trunk/mapbender/http/plugins/mb_extendedSearch_server.php
   trunk/mapbender/http/plugins/mb_resultList_Highlight.js
   trunk/mapbender/resources/locale/de_DE/LC_MESSAGES/Mapbender.po
Log:
New, user-friendly options for steering feature info

Modified: trunk/mapbender/cors_proxy/http/index.php
===================================================================
--- trunk/mapbender/cors_proxy/http/index.php	2014-01-31 12:05:10 UTC (rev 8768)
+++ trunk/mapbender/cors_proxy/http/index.php	2014-02-06 15:09:32 UTC (rev 8769)
@@ -54,17 +54,17 @@
 //check header - see invoking server
 $headers = apache_request_headers();//from php 5.4 also for php fcgi
 /*foreach ($headers as $header => $value) {
-    echo "$header: $value <br />\n";
+    $e = new mb_exception("cors_proxy: http header: $header: $value");
 }*/
+$originFromHeader = false;
 foreach ($headers as $header => $value) {
     	if ($header === "Origin") {
 		$originFromHeader = $value;
-    	} else {
-		$originFromHeader = false;
-		throwExceptionXml('','CORS Proxy don\'t find Origin header from client!');
-		//$originFromHeader = "http://localhost";
     	}
 }
+if ($originFromHeader == false) {
+	throwExceptionXml('','CORS Proxy don\'t find Origin header from client!');
+}
 //check server against whitelist for cors header
 if (defined("CORS_WHITELIST") && CORS_WHITELIST != "") {
 	//check if server is in cors whitelist

Modified: trunk/mapbender/http/javascripts/map_obj.js
===================================================================
--- trunk/mapbender/http/javascripts/map_obj.js	2014-01-31 12:05:10 UTC (rev 8768)
+++ trunk/mapbender/http/javascripts/map_obj.js	2014-02-06 15:09:32 UTC (rev 8769)
@@ -957,6 +957,76 @@
         return false;
     };
 
+    /**
+     * get all featureInfoRequests for layers, that have featureinfo activated
+     *
+     * @member Map
+     * @param float x the x-value of the click position in pixel
+     * @param float y the y-value of the click position in pixel
+     * 
+     * @type string[]
+     */
+    this.getFeatureInfoRequestsForLayers = function(clickPoint, ignoreWms){
+        var allRequests = [];
+        //loop through all wms to get the FeatureInfoRequests
+        for (var i = 0; i < this.wms.length; i++) {
+            var ignoreThisWms = false;
+            if (typeof ignoreWms !== "undefined" &&
+            ignoreWms.constructor === Array) {
+            
+                for (var j = 0; j < ignoreWms.length; j++) {
+                    if (ignoreWms[j] == this.wms[i].wms_id) {
+                        ignoreThisWms = true;
+                        break;
+                    }
+                }
+            }
+            if (!ignoreThisWms) {
+		//get all layers for this wms which have activated featureInfo Button
+		//loop over all layers of this wms
+	 	for (var j = 0; j < this.wms[i].objLayer.length; j++) {
+			if (this.wms[i].objLayer[j].gui_layer_querylayer == 1 && this.wms[i].objLayer[j].gui_layer_queryable == 1) {
+				var featureInfoObj = {};
+                   		featureInfoObj.title = this.wms[i].objLayer[j].gui_layer_title;
+				//pull featureinfo request
+				var featureInfoRequest = this.wms[i].getFeatureInfoRequest(this, clickPoint);
+				//exchange layer parameter with current layer name
+				featureInfoRequest = changeURLParameterValue(featureInfoRequest,"LAYERS", this.wms[i].objLayer[j].layer_name);
+				featureInfoObj.request = featureInfoRequest;
+				//get url to legend
+				featureInfoObj.legendurl = this.wms[i].objLayer[j].layer_style[0].legendurl;
+				//return new request!
+		    		allRequests.push(featureInfoObj);
+			} 
+		}
+            }
+        }
+        if (allRequests.length > 0) {
+            return allRequests;
+        }
+        return false;
+    };
+
+	function changeURLParameterValue(url, param, newValue){
+    		var newAdditionalURL = "";
+    		var tempArray = url.split("?");
+    		var baseURL = tempArray[0];
+   		var additionalURL = tempArray[1];
+    		var temp = "";
+    		if (additionalURL) {
+        		tempArray = additionalURL.split("&");
+       		for (i=0; i<tempArray.length; i++){
+            			if(tempArray[i].split('=')[0] != param){
+                			newAdditionalURL += temp + tempArray[i];
+                			temp = "&";
+            			}
+        		}
+    		}
+    		var rows_txt = temp + "" + param + "=" + newValue;
+    		return baseURL + "?" + newAdditionalURL + rows_txt;
+	}
+
+
 	var calculateDistanceGeographic = function (a, b) {
 		var lon_from = (a.x * Math.PI) / 180;
 		var lat_from = (a.y * Math.PI) / 180;

Modified: trunk/mapbender/http/javascripts/mod_featureInfo.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_featureInfo.php	2014-01-31 12:05:10 UTC (rev 8768)
+++ trunk/mapbender/http/javascripts/mod_featureInfo.php	2014-02-06 15:09:32 UTC (rev 8769)
@@ -32,6 +32,10 @@
 if(typeof(featureInfoPopupPosition)==='undefined')
 	var featureInfoPopupPosition = 'center';
 var reverseInfo = typeof reverseInfo === "undefined" ? "false" : reverseInfo;
+if(typeof(featureInfoLayerPreselect)==='undefined')
+	var featureInfoLayerPreselect = false;
+if(typeof(featureInfoDrawClick)==='undefined')
+	var featureInfoDrawClick = false;
 
 var mod_featureInfo_elName = "<?php echo $e_id;?>";
 var mod_featureInfo_frameName = "";
@@ -42,6 +46,15 @@
 var mod_featureInfo_img_off = new Image(); mod_featureInfo_img_off.src ="<?php  echo $e_src;  ?>";
 var mod_featureInfo_img_over = new Image(); mod_featureInfo_img_over.src = "<?php  echo preg_replace("/_off/","_over",$e_src);  ?>";
 
+if (featureInfoDrawClick) {
+	var standingHighlight = null;
+	Mapbender.events.afterMapRequest.register( function(){
+		if(standingHighlight){
+			standingHighlight.paint();
+		}
+	});
+}
+
 eventInit.register(function () {
 	mb_regButton(function init_featureInfo1(ind){
 		mod_featureInfo_mapObj = getMapObjByName(mod_featureInfo_target);
@@ -112,9 +125,31 @@
 }
 function mod_featureInfo_event(e){
 	var point = mod_featureInfo_mapObj.getMousePosition(e);
-	
+	if (featureInfoDrawClick) {
+		var map = Mapbender.modules[options.target];
+		if(standingHighlight !== null){ 
+			standingHighlight.clean();
+		}else{
+			standingHighlight = new Highlight(
+				[options.target],
+				"standingHighlight", 
+				{"position":"absolute", "top":"0px", "left":"0px", "z-index":100}, 
+				2);
+		}
+		//calculate realworld position
+		realWorldPoint = Mapbender.modules[options.target].convertPixelToReal(point);
+		//get coordinates from point
+		var ga = new GeometryArray();
+		//TODO set current epsg!
+		ga.importPoint({
+			coordinates:[realWorldPoint.x,realWorldPoint.y,null]
+		},Mapbender.modules[options.target].getSRS())
+		var m = ga.get(-1,-1);
+		standingHighlight.add(m, "#ff0000");
+		standingHighlight.paint();
+		map.setMapRequest();
+	}
 	eventBeforeFeatureInfo.trigger({"fName":mod_featureInfo_target});
-	
 	//TODO that code should go to featureInfo Redirect module
 	if(document.getElementById("FeatureInfoRedirect")){
 		//fill the frames
@@ -124,45 +159,79 @@
 				window.frames.FeatureInfoRedirect.document.getElementById(mod_featureInfo_mapObj.wms[i].wms_id).src = req;
 		}
 	}
-	else{
-		urls = mod_featureInfo_mapObj.getFeatureInfoRequests(point, ignoreWms);
-		if(urls){
-			for(var i=0;i<urls.length;i++){ //To change order : var i=urls.length-1; i>=0; i--
-				//TODO: also rewind the LAYERS parameter for a single WMS FeatureInfo REQUEST if needed?
-				var cnt = i;
-				if (reverseInfo == 'true') {
-					urls[i] = changeURLValueOrder(urls[i], 'LAYERS');
+	else {
+		//maybe someone will show all selectable layers in a window before 
+		if (featureInfoLayerPreselect) {
+			$("#featureInfo_preselect").remove();
+			//build list of possible featureInfo requests
+			urls = mod_featureInfo_mapObj.getFeatureInfoRequestsForLayers(point, ignoreWms);
+			if (urls.length == 0 || typeof urls.length =='undefined') {
+				alert("<?php echo _mb("Please enable some layer to be requestable");?>!");
+				return false;
+			}
+			featureInfoList = "<table border='1'>";
+			for(var i=0;i<urls.length;i++){
+				featureInfoList += "<tr><td><a href='"+urls[i].request+"' target='_blank'>"+urls[i].title+"</a></td><td><img src='"+urls[i].legendurl+"' alt='<?php echo _mb("No legend available!");?>'/></td></tr>";
+			}
+			featureInfoList += "</table>";
+			$("<div id='featureInfo_preselect'></div>").dialog({
+				bgiframe: true,
+				autoOpen: true,
+				modal: true,
+				title: '<?php echo _mb("Please choose a requestable Layer");?>',
+				width:parseInt(featureInfoPopupWidth, 10),
+				height:parseInt(featureInfoPopupHeight, 10),
+				position:dialogPosition,
+				buttons: {
+					"Close": function(){
+						if(standingHighlight !== null){ 
+							standingHighlight.clean();
+						}
+						$(this).dialog('close').remove();
+					}
 				}
-				if(featureInfoPopupPosition.length == 2 && !isNaN(featureInfoPopupPosition[0]) && !isNaN(featureInfoPopupPosition[1])) {
-					var dialogPosition = [];
-					dialogPosition[0] = featureInfoPopupPosition[0]+cnt*25;
-					dialogPosition[1] = featureInfoPopupPosition[1]+cnt*25;
-				}
-				else {
-					var dialogPosition = featureInfoPopupPosition;
-				}
-				if(featureInfoLayerPopup == 'true'){
-					$("<div><iframe frameborder='0' height='100%' width='100%' id='featureInfo_"+ i + "' title='<?php echo _mb("Information");?>' src='" + urls[i] + "'></iframe></div>").dialog({
-						bgiframe: true,
-						autoOpen: true,
-						modal: false,
-						title: '<?php echo _mb("Information");?>',
-						width:parseInt(featureInfoPopupWidth, 10),
-						height:parseInt(featureInfoPopupHeight, 10),
-						position:dialogPosition,
-						buttons: {
-							"Ok": function(){
-								$(this).dialog('close').remove();
+			}).parent().css({position:"fixed"});
+			$("#featureInfo_preselect").append(featureInfoList);
+		} else {
+			urls = mod_featureInfo_mapObj.getFeatureInfoRequests(point, ignoreWms);
+			if(urls){
+				for(var i=0;i<urls.length;i++){ //To change order : var i=urls.length-1; i>=0; i--
+					//TODO: also rewind the LAYERS parameter for a single WMS FeatureInfo REQUEST if needed?
+					var cnt = i;
+					if (reverseInfo == 'true') {
+						urls[i] = changeURLValueOrder(urls[i], 'LAYERS');
+					}
+					if(featureInfoPopupPosition.length == 2 && !isNaN(featureInfoPopupPosition[0]) && !isNaN(featureInfoPopupPosition[1])) {
+						var dialogPosition = [];
+						dialogPosition[0] = featureInfoPopupPosition[0]+cnt*25;
+						dialogPosition[1] = featureInfoPopupPosition[1]+cnt*25;
+					}
+					else {
+						var dialogPosition = featureInfoPopupPosition;
+					}
+					if(featureInfoLayerPopup == 'true'){
+						$("<div><iframe frameborder='0' height='100%' width='100%' id='featureInfo_"+ i + "' title='<?php echo _mb("Information");?>' src='" + urls[i] + "'></iframe></div>").dialog({
+							bgiframe: true,
+							autoOpen: true,
+							modal: false,
+							title: '<?php echo _mb("Information");?>',
+							width:parseInt(featureInfoPopupWidth, 10),
+							height:parseInt(featureInfoPopupHeight, 10),
+							position:dialogPosition,
+							buttons: {
+								"Ok": function(){
+									$(this).dialog('close').remove();
+								}
 							}
-						}
-					}).parent().css({position:"fixed"});
-				}
-				else
-					window.open(urls[i], "" , "width="+featureInfoPopupWidth+",height="+featureInfoPopupHeight+",scrollbars=yes,resizable=yes");		
-			} //end for
-		} //end if urls
-		else
-			alert(unescape("Please select a layer! \n Bitte waehlen Sie eine Ebene zur Abfrage aus!"));
+						}).parent().css({position:"fixed"});
+					}
+					else
+						window.open(urls[i], "" , "width="+featureInfoPopupWidth+",height="+featureInfoPopupHeight+",scrollbars=yes,resizable=yes");		
+				} //end for
+			} //end if urls
+			else
+				alert(unescape("Please select a layer! \n Bitte waehlen Sie eine Ebene zur Abfrage aus!"));
+		}
+		setFeatureInfoRequest(mod_featureInfo_target,point.x,point.y);
 	}
-	setFeatureInfoRequest(mod_featureInfo_target,point.x,point.y);
 }

Modified: trunk/mapbender/http/plugins/mb_extendedSearch_server.php
===================================================================
--- trunk/mapbender/http/plugins/mb_extendedSearch_server.php	2014-01-31 12:05:10 UTC (rev 8768)
+++ trunk/mapbender/http/plugins/mb_extendedSearch_server.php	2014-02-06 15:09:32 UTC (rev 8769)
@@ -110,6 +110,7 @@
 			$entries['translations']['helpSearchResources'] = 'Hierbei können Sie sich aussuchen, welche Art von Ressourcen Sie suchen wollen – je nach Auswahl wird dann nur dieser Ressourcentyp in der Trefferanzeige aufgeführt.';
 
 			$exceptionGroupTitle = "Es wurde noch kein Titel für die Gruppe eingestellt!";
+			$entries['translations']['labelOpenData'] = "nur freie Daten";
 			break;
 		case 'en':
 			$entries['translations']['extendedSearchTitle'] = 'Extended Search';
@@ -167,7 +168,7 @@
 			$entries['translations']['helpSearchResources'] = 'You can select in this category, which kind of ressource you are looking for. According to this assortment only this type of ressource will be enlisted in the output index.';
 
 			$exceptionGroupTitle = "The title for this group have not been defined till now!";
-
+			$entries['translations']['labelOpenData'] = "restrict to OpenData";
 			break;
 		case 'fr':
 			break;

Modified: trunk/mapbender/http/plugins/mb_resultList_Highlight.js
===================================================================
--- trunk/mapbender/http/plugins/mb_resultList_Highlight.js	2014-01-31 12:05:10 UTC (rev 8768)
+++ trunk/mapbender/http/plugins/mb_resultList_Highlight.js	2014-02-06 15:09:32 UTC (rev 8769)
@@ -43,7 +43,6 @@
  * and Simplified BSD license.  
  * http://svn.osgeo.org/mapbender/trunk/mapbender/license/license.txt
  */
-
 //check element vars
 options.maxHighlightedPoints	= options.maxHighlightedPoints || 5;
 options.resultHighlightColor 	= options.resultHighlightColor || "#ff0000";
@@ -57,7 +56,6 @@
 		var modelIndex = $(row).data("modelindex");
 		var feature = me.model.getFeature(modelIndex);
 
-		
 		if(standingHighlight !== null){ standingHighlight.clean();}
 		standingHighlight = new Highlight(
 				[options.target[1],options.target[2]],
@@ -75,7 +73,7 @@
 		var me = Mapbender.modules[options.target[0]];
 		var modelIndex = $(row).data("modelindex");
 		var feature = me.model.getFeature(modelIndex);
-	
+
 		if (options.maxHighlightedPoints > 0 && feature.getTotalPointCount() > options.maxHighlightedPoints) {
 			feature = feature.getBBox4();
 		}

Modified: trunk/mapbender/resources/locale/de_DE/LC_MESSAGES/Mapbender.po
===================================================================
--- trunk/mapbender/resources/locale/de_DE/LC_MESSAGES/Mapbender.po	2014-01-31 12:05:10 UTC (rev 8768)
+++ trunk/mapbender/resources/locale/de_DE/LC_MESSAGES/Mapbender.po	2014-02-06 15:09:32 UTC (rev 8769)
@@ -3656,5 +3656,10 @@
 msgid "CRS Error"
 msgstr "Fehler bei den Koordinatensystemen"
 
+msgid "Please choose a requestable Layer"
+msgstr "Wählen Sie bitte die abfragbare Ebene aus"
 
+msgid "Please enable some layer to be requestable"
+msgstr "Aktivieren Sie bitte die Abfragbarkeit einer Ebene"
 
+



More information about the Mapbender_commits mailing list