[Mapbender-commits] r8643 - trunk/mapbender/http/javascripts

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Mon Jun 3 01:59:01 PDT 2013


Author: verenadiewald
Date: 2013-06-03 01:59:00 -0700 (Mon, 03 Jun 2013)
New Revision: 8643

Modified:
   trunk/mapbender/http/javascripts/mod_wfsGazetteerEditor_client.php
   trunk/mapbender/http/javascripts/mod_wfsGazetteerEditor_server.php
   trunk/mapbender/http/javascripts/mod_wfs_gazetteer_client.php
   trunk/mapbender/http/javascripts/wfsFilter.js
Log:
wfs 2.0.0: added storedQuery handling, additional changes for lat lon axis order topic, check for possible supported srs (default + otherSRS)

Modified: trunk/mapbender/http/javascripts/mod_wfsGazetteerEditor_client.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_wfsGazetteerEditor_client.php	2013-06-03 08:56:00 UTC (rev 8642)
+++ trunk/mapbender/http/javascripts/mod_wfsGazetteerEditor_client.php	2013-06-03 08:59:00 UTC (rev 8643)
@@ -18,6 +18,7 @@
 # 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__)."/../../core/globalSettings.php");
+include(dirname(__FILE__) . "/../../core/epsg.php");
 
 $gui_id = Mapbender::session()->get("mb_user_gui");
 $target = $_REQUEST["e_target"];
@@ -84,6 +85,7 @@
 
 	echo "var targetString = '" . $target . "';";
 	echo "var e_id_css = '" . $e_id_css . "';";
+	echo "var latLonSrsJson = '" . $latLonSrsJson . "';";
 
 	require(dirname(__FILE__)."/../javascripts/wfsFilter.js");
 
@@ -423,8 +425,8 @@
 	el.onmousedown = null;
 	el.ondblclick = null;
 	el.onmousemove = null;
-	parent.writeTag("mapframe1","measure_display","");
-	parent.writeTag("mapframe1","measure_sub","");
+	parent.writeTag("","measure_display","");
+	parent.writeTag("","measure_sub","");
 	activeButton = null;
 }
 
@@ -522,12 +524,19 @@
 }
 
 function isSearchPreconfigured () {
+	//check for configured search elements in wfs conf
 	var wfsConfElementArray = global_wfsConfObj[global_selectedWfsConfId].element;
 	for (var i = 0; i < wfsConfElementArray.length; i++){
 		if (parseInt(wfsConfElementArray[i].f_search)) {
 			return true;
 		}
 	}
+	//check for stored query elements in wfs conf
+	var storedQueryElementArray = global_wfsConfObj[global_selectedWfsConfId].storedQueryElement;
+	if(storedQueryElementArray) {
+		return true;
+	}
+	
 	return false;
 }
 
@@ -552,7 +561,7 @@
 		divContainer.innerHTML = global_wfsConfObj[global_selectedWfsConfId].g_label;
 		
 		form.appendChild(divContainer);
-	
+		
 		var wfsConfElementArray = global_wfsConfObj[global_selectedWfsConfId].element;
 			
 		for (var i = 0; i < wfsConfElementArray.length; i++){
@@ -589,6 +598,24 @@
 			}
 		}
 
+		//add stored query elements
+		var storedQueryElementArray = global_wfsConfObj[global_selectedWfsConfId].storedQueryElement;
+		if(storedQueryElementArray) {
+			for (var i = 0; i < storedQueryElementArray.length; i++){
+				
+				var spanNode = document.createElement("span");
+				spanNode.setAttribute("id", storedQueryElementArray[i].name+"Span");
+				spanNode.innerHTML = storedQueryElementArray[i].name;
+				var inputNode = document.createElement("input");
+				inputNode.type = "text";
+				inputNode.id = storedQueryElementArray[i].name;
+		
+				form.appendChild(spanNode);
+				form.appendChild(inputNode);
+				form.appendChild(document.createElement("br"));
+			}
+		}
+
 		var submitButton = document.createElement("input");
 		submitButton.type = "submit";
 		submitButton.id = "wfsForm_Submit";
@@ -605,20 +632,96 @@
 	var ind = parent.getMapObjIndexByName("mapframe1");
 	var submit = document.getElementById("wfsForm_Submit");
 	var submit_attr = document.getElementById("attrPanel_Submit");
-	if(global_wfsConfObj[global_selectedWfsConfId].featuretype_srs!=parent.mb_mapObj[ind].getSRS()){
-		var msg = "<?php echo _mb("The coordinate reference system (crs) of the objects differ from the crs of the viewer. A query will not be possible. Please change the crs of the viewer first."); ?>\n";
-		msg += parent.mb_mapObj[ind].getSRS()+" und "+global_wfsConfObj[global_selectedWfsConfId].featuretype_srs;
-		alert(msg);
-			
-		//disable Submit Button
-		if(submit)submit.disabled = true;
-		if(submit_attr)submit_attr.disabled = true;
-			
+
+	var epsgCode = parent.mb_mapObj[ind].getSRS().toUpperCase();
+	var epsgCodeSplit = epsgCode.split(":");
+	var epsgString = epsgCodeSplit[1];
+	
+	var ftSrs = global_wfsConfObj[global_selectedWfsConfId].featuretype_srs;	
+	var ftSrsSplit = ftSrs.split(":");
+	
+	if(ftSrsSplit.length > 2) {
+		if(ftSrsSplit.length == 6) {
+			var checkVal = ftSrsSplit[5];
+		}
+		else {
+			var checkVal = ftSrsSplit[6];
+		}
+		
 	}
-	else{
-		//disable Submit Button
+	else {
+		var checkVal = ftSrsSplit[1];
+	}
+
+	//if default featuretype_srs does not match current mapObj srs, check for other srs
+	if(checkVal != epsgString) {
+		//check if other featuretype_srs matches current mapObj srs
+		var otherSrs = global_wfsConfObj[global_selectedWfsConfId].featuretype_other_srs;
+
+		if(otherSrs.length == 0) {
+			var msg = "<?php echo _mb("The coordinate reference system (crs) of the objects differ from the crs of the viewer. A query will not be possible. Please change the crs of the viewer first."); ?>\n";
+			msg += parent.mb_mapObj[ind].getSRS()+" und "+global_wfsConfObj[global_selectedWfsConfId].featuretype_srs;
+			alert(msg);
+
+			//disable Submit Button
+			if(submit)submit.disabled = true;
+				if(submit_attr)submit_attr.disabled = true;	
+			return false;
+		}
+		else {
+			var epsgMatched = false;
+			var msgEpsgString = "";
+			for (var i = 0; i < otherSrs.length; i++) {
+				var ftOtherSrs = otherSrs[i].epsg;	
+				var ftOtherSrsSplit = ftOtherSrs.split(":");
+				
+				if(ftOtherSrsSplit.length > 2) {
+					if(ftOtherSrsSplit.length == 6) {
+						var checkVal = ftOtherSrsSplit[5];
+					}
+					else {
+						var checkVal = ftOtherSrsSplit[6];
+					}
+				}
+				else {
+					var checkVal = ftOtherSrsSplit[1];
+				}
+
+				if(checkVal == epsgString) {
+					epsgMatched = true;
+					break;	
+				}
+				if(i > 0) {
+					msgEpsgString += ", ";	
+				}
+				msgEpsgString += ftOtherSrs;
+			}
+
+			if(epsgMatched) {
+				if(submit)submit.disabled = false;
+				if(submit_attr)submit_attr.disabled = false;
+				var msg = '<?php echo _mb("Please note: Wfs featuretype is  not requested in default srs, other srs is used (variation of transformation possible)! ");?>';
+				alert(msg);
+				return true;
+			}
+			else {
+				var msg = '<?php echo _mb("Please note: Different EPSG of map and wfs featuretype, no spatial request in gazetterWFS possible! ");?>';
+				msg += parent.mb_mapObj[ind].getSRS() + "  -  " + msgEpsgString + ". ";
+				msg += '<?php echo _mb("No EPSG for wfs featuretype matches the map EPSG!");?>';
+				alert(msg);
+
+				//disable Submit Button
+				if(submit)submit.disabled = true;
+				if(submit_attr)submit_attr.disabled = true;	
+				return false;
+			}
+		}
+	}
+	//if default featuretype_srs matches current mapObj srs, allow search
+	else {
 		if(submit)submit.disabled = false;
 		if(submit_attr)submit_attr.disabled = false;
+		return true;
 	}
 }
 
@@ -805,7 +908,7 @@
  
  //-------------------------------------------------------------------------
  
-function createWfsFilter () {
+function createWfsFilter (srs, latLonSrsJson) {
 	var wfsFilter = new WfsFilter();
 
 	/*
@@ -842,9 +945,6 @@
 	 */
 	if (spatialRequestGeom != null) {
 	
-		// get SRS
-		var srs = global_wfsConfObj[global_selectedWfsConfId].featuretype_srs;
-		
 		// get geometry column name
 		var geometryColumnName = "";
 		for (var j = 0; j < el.length; j++) {
@@ -873,7 +973,7 @@
 			}
 		
 		// add spatial filter
-		wfsFilter.addSpatial(spatialRequestGeom, geometryColumnName, filterOption, srs);
+		wfsFilter.addSpatial(spatialRequestGeom, geometryColumnName, filterOption, srs, "", latLonSrsJson);
 	}		
 	return wfsFilter.toString();
 }
@@ -906,21 +1006,83 @@
 	 */
 	document.getElementById("progressWheel").innerHTML = "<table><tr><td><img src='../img/indicator_wheel.gif'></td><td>Searching...</td></tr></table>";
 
-	var u = global_wfsConfObj[global_selectedWfsConfId].wfs_getfeature + parent.mb_getConjunctionCharacter(global_wfsConfObj[global_selectedWfsConfId].wfs_getfeature);
-	u += "REQUEST=getFeature&Typename="+global_wfsConfObj[global_selectedWfsConfId].featuretype_name+"&Version=1.0.0&service=WFS";
-	u += "&filter=";
-	
 	var exportToShape = document.getElementById("exportToShape").checked;
+
+	var storedQueryElementArray = global_wfsConfObj[global_selectedWfsConfId].storedQueryElement;
+	if(storedQueryElementArray) {
+		//for storedQueryId take the first array element's storedQueryId
+		var storedQueryId = storedQueryElementArray[0].storedQueryId;
+		var storedQueryParams = "";
+		for (var i = 0; i < storedQueryElementArray.length; i++){
+			var queryParamName = storedQueryElementArray[i].name;
+			var queryParamValue = document.getElementById(storedQueryElementArray[i].name).value;
+			storedQueryParams += "<wfs:Parameter name=\"" + queryParamName + "\">" + queryParamValue + "</wfs:Parameter>";
+		}
+	}	
+	var ind = parent.getMapObjIndexByName("mapframe1");
+	var srs = parent.mb_mapObj[ind].getSRS();
+	var epsgCode = parent.mb_mapObj[ind].getSRS().toUpperCase();
+	var epsgCodeSplit = epsgCode.split(":");
+	var epsgString = epsgCodeSplit[1];
+	var ftSrs = global_wfsConfObj[global_selectedWfsConfId].featuretype_srs;	
+	var ftSrsSplit = ftSrs.split(":");
 	
+	if(ftSrsSplit.length > 2) {
+		if(ftSrsSplit.length == 6) {
+			var checkVal = ftSrsSplit[5];
+		}
+		else {
+			var checkVal = ftSrsSplit[6];
+		}
+		
+	}
+	else {
+		var checkVal = ftSrsSplit[1];
+	}
+
+	if(checkVal == epsgString) {
+		srs = ftSrs;
+	}
+	else {
+		var otherSrs = global_wfsConfObj[global_selectedWfsConfId].featuretype_other_srs;
+		
+		if(otherSrs.length > 0) {
+			for (var i = 0; i < otherSrs.length; i++) {
+				var ftOtherSrs = otherSrs[i].epsg;	
+				var ftOtherSrsSplit = ftOtherSrs.split(":");
+				
+				if(ftOtherSrsSplit.length > 2) {
+					if(ftOtherSrsSplit.length == 6) {
+						var checkVal = ftOtherSrsSplit[5];
+					}
+					else {
+						var checkVal = ftOtherSrsSplit[6];
+					}
+				}
+				else {
+					var checkVal = ftOtherSrsSplit[1];
+				}
+
+				if(checkVal == epsgString) {
+					srs = ftOtherSrs;
+					break;	
+				}
+			}	
+		}
+	}
+	
 	var parameters = {
-		command:"getSearchResults", 
-		"wfs_conf_id":global_selectedWfsConfId, 
-		"frame":this.name, 
-		"url":u, 
-		"filter":createWfsFilter(), 
-		"backlink":"",
-		"exportToShape":exportToShape
-	};
+			"command" : "getSearchResults",
+			"wfs_conf_id" : global_selectedWfsConfId,
+			"typename" : global_wfsConfObj[global_selectedWfsConfId].featuretype_name,
+			"frame" : this.name,
+			"filter" : createWfsFilter(srs, latLonSrsJson),
+			"backlink" : "",
+			"exportToShape":exportToShape,
+			"destSrs" : srs,
+			"storedQueryParams" : storedQueryParams,
+			"storedQueryId" : storedQueryId
+		};
 	
 	if (!isSearchPreconfigured()) {
 		parent.mb_ajax_get("../javascripts/mod_wfsGazetteerEditor_server.php", parameters, function (jsCode, status) {
@@ -952,10 +1114,15 @@
 	       		}
 	       		else {
 	       			if (geoObj) {
-						var htmlCodeDownload = "<iframe style='visibility:visible' src='../tmp/"+geoObj.filename + "'></iframe>";
-						var downloadPopup = new parent.mb_popup("Download", htmlCodeDownload, 1, 1, -10, 1);
-						downloadPopup.show();
-						downloadPopup.hide();
+	       				var downloadZipFunction = function () {
+	                        parent.window.frames['loadData'].location.href = geoObj.filename;
+                        }
+                        //if($.browser.msie && $.browser.version === '6.0') {
+                        //    setTimeout(downloadZipFunction, 3000);
+                        //}
+                        //else {
+                        	downloadZipFunction();
+                        //}
 					}
 		       		else {
 						alert("<?php echo _mb("An error occured when start download."); ?>");
@@ -995,15 +1162,17 @@
 						}
 		       		}
 		       		else {
-		       			if (jsCode) {
-							var htmlCodeDownload = "<iframe style='visibility:visible' src='../geoportal/download.php?download=" + geoObj.filename + "'></iframe>";
-							var downloadPopup = new parent.mb_popup("Download", htmlCodeDownload, 1, 1, -10, 1);
-							downloadPopup.show();
-							//downloadPopup.hide();
+		       			if (geoObj) {
+		       				var downloadZipFunction = function () {
+		                        parent.window.frames['loadData'].location.href = geoObj.filename;
+	                        }
+	                        //if($.browser.msie && $.browser.version === '6.0') {
+	                        //    setTimeout(downloadZipFunction, 3000);
+	                        //}
+	                        //else {
+	                        	downloadZipFunction();
+	                        //}
 						}
-			       		else {
-							alert("Beim Export ist ein Fehler aufgetreten.");
-			       		}
 					}
 					document.getElementById("progressWheel").innerHTML = "";
 				}
@@ -1158,6 +1327,18 @@
 			}
 		}
 	}
+
+	//check if there are stored query elements for search
+	var storedQueryElementArray = global_wfsConfObj[global_selectedWfsConfId].storedQueryElement;
+	if(storedQueryElementArray) {
+		for (var i = 0; i < storedQueryElementArray.length; i++){
+			var elementValue = document.getElementById(storedQueryElementArray[i].name).value;
+			if (elementValue != '') {
+				cnt++;
+			}
+		}
+	}
+	
 	if(inputNotEnough.length>0){
 		alert("Pflichtfelder: "+inputNotEnough.join(', '));
 		document.getElementById("progressWheel").innerHTML = "";

Modified: trunk/mapbender/http/javascripts/mod_wfsGazetteerEditor_server.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_wfsGazetteerEditor_server.php	2013-06-03 08:56:00 UTC (rev 8642)
+++ trunk/mapbender/http/javascripts/mod_wfsGazetteerEditor_server.php	2013-06-03 08:59:00 UTC (rev 8643)
@@ -16,24 +16,43 @@
 # 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__)."/../../core/globalSettings.php");
-require_once(dirname(__FILE__)."/../classes/class_gml2.php");
-require_once(dirname(__FILE__)."/../extensions/JSON.php");
+
+require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
+require_once(dirname(__FILE__)."/../classes/class_json.php");
 require_once(dirname(__FILE__)."/../classes/class_administration.php");
 require_once(dirname(__FILE__)."/../classes/class_wfs_conf.php");
-require_once(dirname(__FILE__)."/../classes/class_connector.php");
+require_once(dirname(__FILE__)."/../classes/class_universal_wfs_factory.php");
+require_once(dirname(__FILE__)."/../classes/class_universal_gml_factory.php");
+require_once(dirname(__FILE__)."/../classes/class_wfs_configuration.php");
 
-$con = db_connect($DBSERVER,$OWNER,$PW);
-db_select_db($DB,$con);
-
+$user = new User(Mapbender::session()->get("mb_user_id"));
 $command = $_REQUEST["command"];
-$wfsFeatureTypeName = $_REQUEST["wfsFeatureTypeName"];
-#$wfsDescribeFeatureType = $_REQUEST["wfsDescribeFeatureType"];
-$wfsGetFeatureAttr = $_REQUEST["wfsGetFeatureAttr"];
-$wfsGetFeature = $_REQUEST["wfsGetFeature"];
-$wfsFilter = $_REQUEST["wfsFilter"];
-$exportToShape = $_REQUEST["exportToShape"] == "true" ? true : false;
 
+function toShape ($filenamePrefix, $geoJson, $destSrs) {
+	$srsArray = explode(":", $destSrs);
+	$srs = array_pop($srsArray);
+		
+	$unique = TMPDIR . "/" . $filenamePrefix;
+	file_put_contents($unique.".json",$geoJson);
+	
+	if(OGR2OGR_PATH) {
+		$pathOgr = OGR2OGR_PATH;
+	}
+	else {
+		$pathOgr = '/usr/bin/ogr2ogr';
+	}
+	$exec =  $pathOgr .' -a_srs EPSG:'.$srs.' -f "ESRI Shapefile" '.$unique.'.shp '. $unique.".json";
+	exec($exec);
+
+ 	$exec = 'zip -j '.$unique.'.zip '.$unique.'.shp '.$unique.'.dbf '.$unique.'.shx '.$unique.'.gfs '.$unique.'.gml '.$unique.'.prj ';
+ 	exec($exec);
+ 	
+	$exec = 'rm -f'.$unique.'.zip '.$unique.'.shp '.$unique.'.dbf '.$unique.'.shx '.$unique.'.gfs '.$unique.'.gml '.$unique.'.prj ';
+	exec($exec);
+	
+	return $unique;
+}
+
 /**
  * checks if a variable name is valid.
  * Currently a valid name would be sth. like Mapbender::session()->get("mb_user_id")
@@ -95,15 +114,22 @@
 	if ($wfsConfIdString != "") {
 		//array_keys(array_flip()) produces an array with unique entries
 		$wfsConfIdArray = array_keys(array_flip(mb_split(",", $wfsConfIdString)));
+		$availableWfsConfIds = $user->getWfsConfByPermission();
+		
+		$wfsConfIdArray = array_intersect($wfsConfIdArray, $availableWfsConfIds);
+		if (count($wfsConfIdArray) === 0) {
+			echo "no wfs conf available.";
+			die();
+		}
 	}
 	else {
-		echo "{}";
+		echo "please specify wfs conf id.";
 		die();
 	}
 	
 	$obj = new WfsConf();
 	$obj->load($wfsConfIdArray);
-	$json = new Services_JSON();
+	$json = new Mapbender_JSON();
 	$output = $json->encode($obj->confArray);
 	echo $output;
 }
@@ -113,58 +139,58 @@
 	$frame = $_REQUEST["frame"];
 	$filter = $_REQUEST["filter"];
 	$url = $_REQUEST["url"];
-
-	/* wfs_conf */
-	$sql = "SELECT * FROM wfs_conf JOIN wfs ON wfs_conf.fkey_wfs_id = wfs.wfs_id ";
-	$sql .= "WHERE wfs_conf.wfs_conf_id = $1";
-	$v = array($wfs_conf_id);
-	$t = array('i');
+	$typename = $_REQUEST["typename"];
+	$exportToShape = $_REQUEST["exportToShape"] == "true" ? true : false;
+	$destSrs = $_REQUEST["destSrs"];
+	$storedQueryId = $_REQUEST["storedQueryId"];
+	$storedQueryParams = $_REQUEST["storedQueryParams"];
 	
-	$res = db_prep_query($sql,$v,$t);
-	if ($row = db_fetch_array($res)) {
-		$g_res_style  = $row["g_res_style"];
+	$wfsConf = WfsConfiguration::createFromDb($wfs_conf_id);
+	if (is_null($wfsConf)) {
+		sendErrorMessage("Invalid WFS conf: " . $wfs_conf_id);
 	}
-	else {
-		die("wfs_conf " . $wfs_conf_id . "data not available");
-	}
 	
-	/* wfs_conf_element */
-	$sql = "SELECT * FROM wfs_conf_element ";
-	$sql .= "JOIN wfs_element ON wfs_conf_element.f_id = wfs_element.element_id ";
-	$sql .= "WHERE wfs_conf_element.fkey_wfs_conf_id = $1 ";
-	$sql .= "AND wfs_conf_element.f_show = 1 ORDER BY wfs_conf_element.f_respos;";
-	$v = array($wfs_conf_id);
-	$t = array('i');
-	
-	#echo $sql;
-	$res = db_prep_query($sql,$v,$t);
-	$col = array();
-	while ($row = db_fetch_array($res)) {
-		array_push($col, $row["element_name"]);
-	}
-	if (count($col) == 0) {
-		die("wfs_conf_element data not available");
-	}
-	
 	// append authorisation condition to filter
 	$filter = checkAccessConstraint($filter, $wfs_conf_id);
 	
 	$admin = new administration();
 	
-	$req = urldecode($url).urlencode($admin->char_decode(stripslashes($filter)));
-	$mygml = new gml2();
-	$mygml->parseFile($req);
-
-	if (!empty($exportToShape)) {
-		$filenamePrefix = md5(microtime());
-		$mygml->toShape($filenamePrefix);
-		header("Content-Type: application/json; charset=utf-8");
-		echo '{"filename": "' . $filenamePrefix . '.zip"}';
-		
+	$filter = administration::convertIncomingString($filter);
+	
+	$wfsId = $wfsConf->wfsId;
+	
+	$myWfsFactory = new UniversalWfsFactory();
+	$myWfs = $myWfsFactory->createFromDb($wfsId);
+	$data = $myWfs->getFeature($typename, $filter,$destSrs, $storedQueryId, $storedQueryParams);
+	
+	#new mb_exception($data);
+	
+	if ($data === null) die('{}');
+	
+	if (defined("WFS_RESPONSE_SIZE_LIMIT") && WFS_RESPONSE_SIZE_LIMIT < strlen($data)) {
+		die("Too many results, please restrict your search.");
 	}
+	
+	$gmlFactory = new UniversalGmlFactory();
+	$myGml = $gmlFactory->createFromXml($data, $wfsConf);
+	
+	if (!is_null($myGml)) {
+		$geoJson = $myGml->toGeoJSON();
+		if ($exportToShape) {
+			$filenamePrefix = md5(microtime());
+			$zipFile = toShape($filenamePrefix, $geoJson, $destSrs);
+			header("Content-Type: application/json; charset=utf-8");
+			echo '{"filename": "' . $zipFile . '.zip"}';
+		}
+		else {
+			header("Content-type:application/x-json; charset=utf-8");
+			echo $geoJson;
+		}
+	}
 	else {
-		header("Content-Type: application/json; charset=utf-8");
-		echo $mygml->toGeoJSON();
+		$geoJson = "{}";
+		header("Content-type:application/x-json; charset=utf-8");
+		echo $geoJson;
 	}
 }
 else if($command == "getFeature"){

Modified: trunk/mapbender/http/javascripts/mod_wfs_gazetteer_client.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_wfs_gazetteer_client.php	2013-06-03 08:56:00 UTC (rev 8642)
+++ trunk/mapbender/http/javascripts/mod_wfs_gazetteer_client.php	2013-06-03 08:59:00 UTC (rev 8643)
@@ -108,10 +108,12 @@
 	include '../extensions/jquery-ui-1.7.2.custom/js/jquery-1.3.2.min.js';
 	include '../include/dyn_php.php';
 	include(dirname(__FILE__) . "/../../conf/" . $wfs_spatial_request_conf_filename);
+	include(dirname(__FILE__) . "/../../core/epsg.php");
 
 	echo "var targetString = '" . $target . "';";
 	echo "var wfsConfIdString = '" . $wfsConfIdString . "';";
 	echo "var e_id_css = '" . $e_id_css . "';";
+	echo "var latLonSrsJson = '" . $latLonSrsJson . "';";
 ?>
 
 // Element var showResultInPopup
@@ -141,6 +143,7 @@
 var resultGeom = null;
 var frameName = e_id_css;
 var inputNotEnough = [];
+var isLatLonSrs = null;
 
 //start button management spatialRequest ////////
 var button_point = "point";
@@ -296,9 +299,9 @@
 		requestGeometryHighlight = new parent.Highlight(targetArray, "requestGeometryHighlight", styleProperties, 2);
 		parent.mb_registerSubFunctions("window.frames['" + frameName +"'].requestGeometryHighlight.paint()");
 
-
+		init_wfsSpatialRequest();
 		initModWfsGazetteer();
-		init_wfsSpatialRequest();
+		//init_wfsSpatialRequest();
 	}
 	catch (exc) {
 		alert(exc);
@@ -839,6 +842,25 @@
 			form.appendChild(document.createElement("br"));
 		}
 	}
+
+	//add stored query elements
+	var storedQueryElementArray = global_wfsConfObj[global_selectedWfsConfId].storedQueryElement;
+	if(storedQueryElementArray) {
+		for (var i = 0; i < storedQueryElementArray.length; i++){
+			
+			var spanNode = document.createElement("span");
+			spanNode.setAttribute("id", storedQueryElementArray[i].name+"Span");
+			spanNode.innerHTML = storedQueryElementArray[i].name;
+			var inputNode = document.createElement("input");
+			inputNode.type = "text";
+			inputNode.id = storedQueryElementArray[i].name;
+	
+			form.appendChild(spanNode);
+			form.appendChild(inputNode);
+			form.appendChild(document.createElement("br"));
+		}
+	}
+	
 	var submitButton = document.createElement("input");
 	submitButton.type = "submit";
 	submitButton.id = "submitButton";
@@ -867,7 +889,7 @@
 	}
 	form.appendChild(delFilterButton);
 
-	checkSrs();
+	//checkSrs();
 
 	if(initializeOnLoad == 1) {
 		return validate();
@@ -880,23 +902,106 @@
 	}
 }
 
+//if element changeEPSG is active, call function checkSrs after changing srs
+if(parent.$("#changeEPSG").length === 1) {
+	parent.$("#changeEPSG").live("change", function () {
+		//checkSrs();
+		var submit = document.getElementById("submitButton");
+		if(submit)submit.disabled = false;
+	});
+}
+
+
 function checkSrs(){
 	//check SRS
 	var ind = parent.getMapObjIndexByName("mapframe1");
 	var submit = document.getElementById("submitButton");
-	var patternString = parent.mb_mapObj[ind].getSRS().toUpperCase();
-	var pattern = new RegExp(patternString);
+	var epsgCode = parent.mb_mapObj[ind].getSRS().toUpperCase();
+	var epsgCodeSplit = epsgCode.split(":");
+	var epsgString = epsgCodeSplit[1];
+	
+	var ftSrs = global_wfsConfObj[global_selectedWfsConfId].featuretype_srs;	
+	var ftSrsSplit = ftSrs.split(":");
+	
+	if(ftSrsSplit.length > 2) {
+		if(ftSrsSplit.length == 6) {
+			var checkVal = ftSrsSplit[5];
+		}
+		else {
+			var checkVal = ftSrsSplit[6];
+		}
+		
+	}
+	else {
+		var checkVal = ftSrsSplit[1];
+	}
 
-	if(global_wfsConfObj[global_selectedWfsConfId].featuretype_srs.match(pattern) == -1){
-		var msg = '<?php echo _mb("Different EPSG of map and wfs featuretype, no spatial request possible!");?>';
-		msg += parent.mb_mapObj[ind].getSRS()+"  -  "+global_wfsConfObj[global_selectedWfsConfId].featuretype_srs;
-		alert(msg);
+	//if default featuretype_srs does not match current mapObj srs, check for other srs
+	if(checkVal != epsgString) {
+		//check if other featuretype_srs matches current mapObj srs
+		var otherSrs = global_wfsConfObj[global_selectedWfsConfId].featuretype_other_srs;
 
-		//disable Submit Button
-		if(submit)submit.disabled = true;
+		if(otherSrs.length == 0) {
+			var msg = '<?php echo _mb("Different EPSG of map and wfs featuretype, no spatial request in gazetterWFS possible! ");?>';
+			msg += parent.mb_mapObj[ind].getSRS() + "  -  " + global_wfsConfObj[global_selectedWfsConfId].featuretype_srs + " ";
+			msg += '<?php echo _mb("No other EPSG for wfs featuretype available!");?>';
+			alert(msg);
+
+			//disable Submit Button
+			if(submit)submit.disabled = true;
+			return false;
+		}
+		else {
+			var epsgMatched = false;
+			var msgEpsgString = "";
+			for (var i = 0; i < otherSrs.length; i++) {
+				var ftOtherSrs = otherSrs[i].epsg;	
+				var ftOtherSrsSplit = ftOtherSrs.split(":");
+				
+				if(ftOtherSrsSplit.length > 2) {
+					if(ftOtherSrsSplit.length == 6) {
+						var checkVal = ftOtherSrsSplit[5];
+					}
+					else {
+						var checkVal = ftOtherSrsSplit[6];
+					}
+				}
+				else {
+					var checkVal = ftOtherSrsSplit[1];
+				}
+
+				if(checkVal == epsgString) {
+					epsgMatched = true;
+					break;	
+				}
+				if(i > 0) {
+					msgEpsgString += ", ";	
+				}
+				msgEpsgString += ftOtherSrs;
+			}
+
+			if(epsgMatched) {
+				if(submit)submit.disabled = false;
+				var msg = '<?php echo _mb("Please note: Wfs featuretype is  not requested in default srs, other srs is used (variation of transformation possible)! ");?>';
+				alert(msg);
+				return true;
+			}
+			else {
+				var msg = '<?php echo _mb("Please note: Different EPSG of map and wfs featuretype, no spatial request in gazetterWFS possible! ");?>';
+				msg += parent.mb_mapObj[ind].getSRS() + "  -  " + msgEpsgString + ". ";
+				msg += '<?php echo _mb("No EPSG for wfs featuretype matches the map EPSG!");?>';
+				alert(msg);
+
+				//disable Submit Button
+				if(submit)submit.disabled = true;		
+				return false;
+			}
+		}
 	}
-	else{
+	//if default featuretype_srs matches current mapObj srs, allow search
+	else {
 		if(submit)submit.disabled = false;
+		return true;
 	}
 }
 
@@ -920,6 +1025,14 @@
 		}
 	}
 
+	//clear storedQuery search fields if available
+	var storedQueryElementArray = global_wfsConfObj[global_selectedWfsConfId].storedQueryElement;
+	if(storedQueryElementArray) {
+		for (var i = 0; i < storedQueryElementArray.length; i++){
+			document.getElementById(storedQueryElementArray[i].name).value = "";
+		}
+	}
+
 	//remove geometry from spatialrequest, remove drawn rectangle or polygon and hint
 	spatialRequestGeom = null;
 	requestGeometryHighlight.clean();
@@ -980,6 +1093,17 @@
     	cnt = 2;
 	}
 
+	//check if there are stored query elements for search
+	var storedQueryElementArray = global_wfsConfObj[global_selectedWfsConfId].storedQueryElement;
+	if(storedQueryElementArray) {
+		for (var i = 0; i < storedQueryElementArray.length; i++){
+			var elementValue = document.getElementById(storedQueryElementArray[i].name).value;
+			if (elementValue != '') {
+				cnt++;
+			}
+		}
+	}
+
 //	if(spatialRequestGeom == null){
 //		alert("Bitte räumliche Eingrenzung vornehmen.");
 //		return false;
@@ -988,7 +1112,11 @@
 	return cnt;
 }
 function validate(){
-
+	//check if current srs is valid for requesting wfs featuretype
+	var validSrs = checkSrs();
+	if(!validSrs) {
+		return false;
+	}
 	parent.Mapbender.modules[frameName].events.onWfsConfSelect.trigger({
 		wfsConfId: global_selectedWfsConfId
 	});
@@ -1005,7 +1133,7 @@
 	}
 
 	var filterParameterCount = getNumberOfFilterParameters();
-
+	
 	if(filterParameterCount == 0 && spatialRequestGeom == null && initializeOnLoad != 1){
 	//if(filterParameterCount == 0 && spatialRequestGeom == null){
 	//if(filterParameterCount == 0){
@@ -1019,7 +1147,58 @@
 			var el = global_wfsConfObj[global_selectedWfsConfId].element;
 			//var srs = global_wfsConfObj[global_selectedWfsConfId].featuretype_srs;
 			var ind = parent.getMapObjIndexByName("mapframe1");
+			var epsgCode = parent.mb_mapObj[ind].getSRS().toUpperCase();
+			var epsgCodeSplit = epsgCode.split(":");
+			var epsgString = epsgCodeSplit[1];
 			var srs = parent.mb_mapObj[ind].getSRS();
+
+			var ftSrs = global_wfsConfObj[global_selectedWfsConfId].featuretype_srs;	
+			var ftSrsSplit = ftSrs.split(":");
+			
+			if(ftSrsSplit.length > 2) {
+				if(ftSrsSplit.length == 6) {
+					var checkVal = ftSrsSplit[5];
+				}
+				else {
+					var checkVal = ftSrsSplit[6];
+				}
+				
+			}
+			else {
+				var checkVal = ftSrsSplit[1];
+			}
+
+			if(checkVal == epsgString) {
+				srs = ftSrs;
+			}
+			else {
+				var otherSrs = global_wfsConfObj[global_selectedWfsConfId].featuretype_other_srs;
+				
+				if(otherSrs.length > 0) {
+					for (var i = 0; i < otherSrs.length; i++) {
+						var ftOtherSrs = otherSrs[i].epsg;	
+						var ftOtherSrsSplit = ftOtherSrs.split(":");
+						
+						if(ftOtherSrsSplit.length > 2) {
+							if(ftOtherSrsSplit.length == 6) {
+								var checkVal = ftOtherSrsSplit[5];
+							}
+							else {
+								var checkVal = ftOtherSrsSplit[6];
+							}
+						}
+						else {
+							var checkVal = ftOtherSrsSplit[1];
+						}
+
+						if(checkVal == epsgString) {
+							srs = ftOtherSrs;
+							break;	
+						}
+					}	
+				}
+			}
+						
 			var ftName = global_wfsConfObj[global_selectedWfsConfId].featuretype_name;
 
 			var pattern = /:[a-zA-Z0-9_]+/;
@@ -1169,21 +1348,34 @@
 				}
 			}
 
-			if(spatialRequestGeom!=null){
+			if(spatialRequestGeom!=null) {
+				//check if the current used srs is in array for latlon axis order (defined in ../../core/epsg.php)
+				isLatLonSrs	= null;
+				var latLonSrsArray = parent.$.parseJSON(latLonSrsJson);
+				if(parent.$.inArray(srs, latLonSrsArray) != -1) {
+					isLatLonSrs	= 1;
+				}
+				
 				var currentAndCondition = "";
 				if(spatialRequestGeom.geomType == "polygon"){
 					if(buttonPolygon.filteroption=='within'){
 						currentAndCondition = "<Within><ogc:PropertyName>";
 						for (var j=0; j < el.length; j++) {
 							if(el[j]['f_geom']==1){
-								currentAndCondition += ftns + el[j]['element_name'];								var elementName = el[j]['element_name'];
+								currentAndCondition += ftns + el[j]['element_name'];
+								var elementName = el[j]['element_name'];
 							}
 						}
 						currentAndCondition += "</ogc:PropertyName><gml:Polygon srsName=\""+srs+"\">";
 						currentAndCondition += "<gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>";
-						for(var k=0; k<spatialRequestGeom.count(); k++){
+						for(var k=0; k<spatialRequestGeom.count(); k++) {
 							if(k>0)	currentAndCondition += " ";
-							currentAndCondition += spatialRequestGeom.get(k).x+","+spatialRequestGeom.get(k).y;
+							if(isLatLonSrs == 1) {
+								currentAndCondition += spatialRequestGeom.get(k).y+","+spatialRequestGeom.get(k).x;
+							}
+							else {
+								currentAndCondition += spatialRequestGeom.get(k).x+","+spatialRequestGeom.get(k).y;
+							}	
 						}
 						currentAndCondition += "</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs>";
 						currentAndCondition += "</gml:Polygon></Within>";
@@ -1192,14 +1384,20 @@
 						currentAndCondition = "<Intersects><ogc:PropertyName>";
 						for (var j=0; j < el.length; j++) {
 							if(el[j]['f_geom']==1){
-								currentAndCondition += ftns + el[j]['element_name'];								var elementName = el[j]['element_name'];
+								currentAndCondition += ftns + el[j]['element_name'];								
+								var elementName = el[j]['element_name'];
 							}
 						}
 						currentAndCondition += "</ogc:PropertyName><gml:Polygon srsName=\""+srs+"\">";
 						currentAndCondition += "<gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>";
 						for(var k=0; k<spatialRequestGeom.count(); k++){
 							if(k>0)	currentAndCondition += " ";
-							currentAndCondition += spatialRequestGeom.get(k).x+","+spatialRequestGeom.get(k).y;
+							if(isLatLonSrs == 1) {
+								currentAndCondition += spatialRequestGeom.get(k).y+","+spatialRequestGeom.get(k).x;
+							}
+							else {
+								currentAndCondition += spatialRequestGeom.get(k).x+","+spatialRequestGeom.get(k).y;
+							}
 						}
 						currentAndCondition += "</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs>";
 						currentAndCondition += "</gml:Polygon></Intersects>";
@@ -1213,20 +1411,34 @@
 						currentAndCondition = "<Within><ogc:PropertyName>";
 						for (var j=0; j < el.length; j++) {
 							if(el[j]['f_geom']==1){
-								currentAndCondition += ftns + el[j]['element_name'];								var elementName = el[j]['element_name'];
+								currentAndCondition += ftns + el[j]['element_name'];								
+								var elementName = el[j]['element_name'];
 							}
 						}
 						currentAndCondition += "</ogc:PropertyName><gml:Polygon srsName=\""+srs+"\">";
 						currentAndCondition += "<gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>";
-						currentAndCondition += rectangle[0].x+","+rectangle[0].y;
-						currentAndCondition += " ";
-						currentAndCondition += rectangle[0].x+","+rectangle[1].y;
-						currentAndCondition += " ";
-						currentAndCondition += rectangle[1].x+","+rectangle[1].y;
-						currentAndCondition += " ";
-						currentAndCondition += rectangle[1].x+","+rectangle[0].y;
-						currentAndCondition += " ";
-						currentAndCondition += rectangle[0].x+","+rectangle[0].y;
+						if(isLatLonSrs == 1) {
+							currentAndCondition += rectangle[0].y+","+rectangle[0].x;
+							currentAndCondition += " ";
+							currentAndCondition += rectangle[0].y+","+rectangle[1].x;
+							currentAndCondition += " ";
+							currentAndCondition += rectangle[1].y+","+rectangle[1].x;
+							currentAndCondition += " ";
+							currentAndCondition += rectangle[1].y+","+rectangle[0].x;
+							currentAndCondition += " ";
+							currentAndCondition += rectangle[0].y+","+rectangle[0].x;	
+						}
+						else {
+							currentAndCondition += rectangle[0].x+","+rectangle[0].y;
+							currentAndCondition += " ";
+							currentAndCondition += rectangle[0].x+","+rectangle[1].y;
+							currentAndCondition += " ";
+							currentAndCondition += rectangle[1].x+","+rectangle[1].y;
+							currentAndCondition += " ";
+							currentAndCondition += rectangle[1].x+","+rectangle[0].y;
+							currentAndCondition += " ";
+							currentAndCondition += rectangle[0].x+","+rectangle[0].y;
+						}
 						currentAndCondition += "</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs>";
 						currentAndCondition += "</gml:Polygon></Within>";
 					}
@@ -1234,25 +1446,39 @@
 						currentAndCondition = "<Intersects><ogc:PropertyName>";
 						for (var j=0; j < el.length; j++) {
 							if(el[j]['f_geom']==1){
-								currentAndCondition += ftns + el[j]['element_name'];								var elementName = el[j]['element_name'];
+								currentAndCondition += ftns + el[j]['element_name'];								
+								var elementName = el[j]['element_name'];
 							}
 						}
 						currentAndCondition += "</ogc:PropertyName><gml:Polygon srsName=\""+srs+"\">";
 						currentAndCondition += "<gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>";
-						currentAndCondition += rectangle[0].x+","+rectangle[0].y;
-						currentAndCondition += " ";
-						currentAndCondition += rectangle[0].x+","+rectangle[1].y;
-						currentAndCondition += " ";
-						currentAndCondition += rectangle[1].x+","+rectangle[1].y;
-						currentAndCondition += " ";
-						currentAndCondition += rectangle[1].x+","+rectangle[0].y;
-						currentAndCondition += " ";
-						currentAndCondition += rectangle[0].x+","+rectangle[0].y;
+						if(isLatLonSrs == 1) {
+							currentAndCondition += rectangle[0].y+","+rectangle[0].x;
+							currentAndCondition += " ";
+							currentAndCondition += rectangle[0].y+","+rectangle[1].x;
+							currentAndCondition += " ";
+							currentAndCondition += rectangle[1].y+","+rectangle[1].x;
+							currentAndCondition += " ";
+							currentAndCondition += rectangle[1].y+","+rectangle[0].x;
+							currentAndCondition += " ";
+							currentAndCondition += rectangle[0].y+","+rectangle[0].x;
+						}
+						else {
+							currentAndCondition += rectangle[0].x+","+rectangle[0].y;
+							currentAndCondition += " ";
+							currentAndCondition += rectangle[0].x+","+rectangle[1].y;
+							currentAndCondition += " ";
+							currentAndCondition += rectangle[1].x+","+rectangle[1].y;
+							currentAndCondition += " ";
+							currentAndCondition += rectangle[1].x+","+rectangle[0].y;
+							currentAndCondition += " ";
+							currentAndCondition += rectangle[0].x+","+rectangle[0].y;	
+						}
 						currentAndCondition += "</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs>";
 						currentAndCondition += "</gml:Polygon></Intersects>";
 					}
 				}
-				else if(spatialRequestGeom.geomType == "point"){
+				else if(spatialRequestGeom.geomType == "point") {
 					var tmp = spatialRequestGeom.get(0);
 					var mapPos = parent.makeRealWorld2mapPos("mapframe1",tmp.x, tmp.y);
 					var buffer = mb_wfs_tolerance/2;
@@ -1271,8 +1497,14 @@
 						}
 					}
 					currentAndCondition += "</ogc:PropertyName><gml:Polygon srsName=\""+srs+"\"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>";
-					currentAndCondition += realWorld1[0] + "," + realWorld1[1] + " " + realWorld2[0] + "," + realWorld2[1] +  " ";
-					currentAndCondition += realWorld3[0] + "," + realWorld3[1] + " " + realWorld4[0] + "," + realWorld4[1] + " " + realWorld1[0] + "," + realWorld1[1];
+					if(isLatLonSrs == 1) {
+						currentAndCondition += realWorld1[1] + "," + realWorld1[0] + " " + realWorld2[1] + "," + realWorld2[0] +  " ";
+						currentAndCondition += realWorld3[1] + "," + realWorld3[0] + " " + realWorld4[1] + "," + realWorld4[0] + " " + realWorld1[1] + "," + realWorld1[0];
+					}
+					else {
+						currentAndCondition += realWorld1[0] + "," + realWorld1[1] + " " + realWorld2[0] + "," + realWorld2[1] +  " ";
+						currentAndCondition += realWorld3[0] + "," + realWorld3[1] + " " + realWorld4[0] + "," + realWorld4[1] + " " + realWorld1[0] + "," + realWorld1[1];
+					}
 					currentAndCondition += "</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></Intersects>";
 				}
 				if (currentAndCondition !== "") {
@@ -1288,6 +1520,18 @@
 
 			var filter = "<ogc:Filter>"+andConditionString+"</ogc:Filter>";
 
+			var storedQueryElementArray = global_wfsConfObj[global_selectedWfsConfId].storedQueryElement;
+			if(storedQueryElementArray) {
+				//for storedQueryId take the first array element's storedQueryId
+				var storedQueryId = storedQueryElementArray[0].storedQueryId;
+				var storedQueryParams = "";
+				for (var i = 0; i < storedQueryElementArray.length; i++){
+					var queryParamName = storedQueryElementArray[i].name;
+					var queryParamValue = document.getElementById(storedQueryElementArray[i].name).value;
+					storedQueryParams += "<wfs:Parameter name=\"" + queryParamName + "\">" + queryParamValue + "</wfs:Parameter>";
+				}
+			}	
+
 			document.getElementById("res").innerHTML = "<table><tr><td><img src='"+progressIndicatorImg+"'></td><td>"+progressIndicatorText+"</td></tr></table>";
 			var parameters = {
 				"command" : "getSearchResults",
@@ -1296,7 +1540,9 @@
 				"frame" : this.name,
 				"filter" : filter,
 				"backlink" : "",
-				"destSrs" : srs
+				"destSrs" : srs,
+				"storedQueryParams" : storedQueryParams,
+				"storedQueryId" : storedQueryId
 			};
 
 			parent.mb_ajax_get("../php/mod_wfs_gazetteer_server.php", parameters, function (jsCode, status) {

Modified: trunk/mapbender/http/javascripts/wfsFilter.js
===================================================================
--- trunk/mapbender/http/javascripts/wfsFilter.js	2013-06-03 08:56:00 UTC (rev 8642)
+++ trunk/mapbender/http/javascripts/wfsFilter.js	2013-06-03 08:59:00 UTC (rev 8643)
@@ -102,8 +102,18 @@
 		return true;
 	};
 	
-	this.addSpatial = function (spatialRequestGeom, geometryColumn, filteroption, srs, target) {
+	this.addSpatial = function (spatialRequestGeom, geometryColumn, filteroption, srs, target, latLonSrsJson) {
 		if(typeof(spatialRequestGeom) != "undefined"){
+			
+			//check if the current used srs is in array for latlon axis order (defined in ../../core/epsg.php)
+			if(latLonSrsJson) {
+				isLatLonSrs	= null;
+				var latLonSrsArray = parent.$.parseJSON(latLonSrsJson);
+				if(parent.$.inArray(srs, latLonSrsArray) != -1) {
+					isLatLonSrs	= 1;
+				}
+			}
+						
 			var spatialRequestFilter = "";
 			if(spatialRequestGeom.geomType == geomType.polygon){
 				spatialRequestFilter += "<" + filteroption + "><ogc:PropertyName>" +
@@ -113,7 +123,12 @@
 					if (k > 0) {
 						spatialRequestFilter += " ";
 					}
-					spatialRequestFilter += spatialRequestGeom.get(k).x+","+spatialRequestGeom.get(k).y;
+					if(isLatLonSrs == 1) {
+						spatialRequestFilter += spatialRequestGeom.get(k).y+","+spatialRequestGeom.get(k).x;
+					}
+					else {
+						spatialRequestFilter += spatialRequestGeom.get(k).x+","+spatialRequestGeom.get(k).y;
+					}
 				}
 				spatialRequestFilter += "</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs>";
 				spatialRequestFilter += "</gml:Polygon></" + filteroption + ">";
@@ -122,9 +137,22 @@
 				var rectangle = [];
 				rectangle = spatialRequestGeom.getBBox();
 				
-				spatialRequestFilter += "<" + filteroption + "><ogc:PropertyName>" +
+				if(isLatLonSrs == 1) {
+					spatialRequestFilter += "<" + filteroption + "><ogc:PropertyName>" +
 					geometryColumn + "</ogc:PropertyName><gml:Polygon srsName=\""+srs+"\">" +
 					"<gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>" +
+					rectangle[0].y+","+rectangle[0].x + " " +
+					rectangle[0].y+","+rectangle[1].x + " " +	
+					rectangle[1].y+","+rectangle[1].x + " " +
+					rectangle[1].y+","+rectangle[0].x + " " + 
+					rectangle[0].y+","+rectangle[0].x +
+					"</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs>" + 
+					"</gml:Polygon></" + filteroption + ">";
+				}
+				else {
+					spatialRequestFilter += "<" + filteroption + "><ogc:PropertyName>" +
+					geometryColumn + "</ogc:PropertyName><gml:Polygon srsName=\""+srs+"\">" +
+					"<gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>" +
 					rectangle[0].x+","+rectangle[0].y + " " +
 					rectangle[0].x+","+rectangle[1].y + " " +	
 					rectangle[1].x+","+rectangle[1].y + " " +
@@ -132,6 +160,8 @@
 					rectangle[0].x+","+rectangle[0].y +
 					"</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs>" + 
 					"</gml:Polygon></" + filteroption + ">";
+					
+				}
 			}
 			else if(spatialRequestGeom.geomType == geomType.point){
 				var tmp = spatialRequestGeom.get(0);
@@ -144,8 +174,14 @@
 				spatialRequestFilter += "<Intersects><ogc:PropertyName>";
 				spatialRequestFilter += geometryColumn;
 				spatialRequestFilter += "</ogc:PropertyName><gml:Polygon srsName=\""+srs+"\"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>";	
-				spatialRequestFilter += realWorld1[0] + "," + realWorld1[1] + " " + realWorld2[0] + "," + realWorld2[1] +  " ";
-				spatialRequestFilter += realWorld3[0] + "," + realWorld3[1] + " " + realWorld4[0] + "," + realWorld4[1] + " " + realWorld1[0] + "," + realWorld1[1]; 
+				if(isLatLonSrs == 1) {
+					spatialRequestFilter += realWorld1[1] + "," + realWorld1[0] + " " + realWorld2[1] + "," + realWorld2[0] +  " ";
+					spatialRequestFilter += realWorld3[1] + "," + realWorld3[0] + " " + realWorld4[1] + "," + realWorld4[0] + " " + realWorld1[1] + "," + realWorld1[0];
+				}
+				else {
+					spatialRequestFilter += realWorld1[0] + "," + realWorld1[1] + " " + realWorld2[0] + "," + realWorld2[1] +  " ";
+					spatialRequestFilter += realWorld3[0] + "," + realWorld3[1] + " " + realWorld4[0] + "," + realWorld4[1] + " " + realWorld1[0] + "," + realWorld1[1];
+				}
 				spatialRequestFilter += "</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></Intersects>";
 			}
 /*



More information about the Mapbender_commits mailing list