[Mapbender-commits] r8994 - trunk/mapbender/http/classes

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Wed Jul 9 04:09:02 PDT 2014


Author: armin11
Date: 2014-07-09 04:09:02 -0700 (Wed, 09 Jul 2014)
New Revision: 8994

Modified:
   trunk/mapbender/http/classes/class_point.php
Log:
Solve problem of transforming coordinates that cannot be transformed via postgis/proj, cause the points are not in the area of the projection that is demanded.

Modified: trunk/mapbender/http/classes/class_point.php
===================================================================
--- trunk/mapbender/http/classes/class_point.php	2014-07-09 11:08:40 UTC (rev 8993)
+++ trunk/mapbender/http/classes/class_point.php	2014-07-09 11:09:02 UTC (rev 8994)
@@ -163,6 +163,38 @@
 		if(SYS_DBTYPE=='pgsql'){
 			$currentEpsg = preg_replace("/EPSG:/", "", $this->epsg);
 			$targetEpsg = preg_replace("/EPSG:/", "", $toEpsg);
+			//get EPSG:4326 extents for which $this->epsg are defined
+			$geometryUnchanged = true;
+			if (defined("SRS_ARRAY") && SRS_ARRAY !== "" ) {
+				//check if this->epsg is 4326
+				$posTargetEpsgBbox = array_search($targetEpsg,explode(",",SRS_ARRAY));
+				if ($posTargetEpsgBbox !== false) {
+					//check if bboxes are defined for special epsg SRS_ARRAY_MAX_EXTENTS
+					if (defined("SRS_ARRAY_MAX_EXTENTS") && SRS_ARRAY_MAX_EXTENTS !== "" ) {
+						$bboxArray = explode("|",SRS_ARRAY_MAX_EXTENTS);
+						$wgs84BboxTargetEpsg = explode(",",$bboxArray[$posTargetEpsgBbox]);
+						//compare point values with bboxes and adopt them if needed
+						//$e = new mb_exception("class_point: bbox compare started before transforming!!!");
+						//$e = new mb_exception("class_point: minx:".$wgs84BboxTargetEpsg[0]." - miny:".$wgs84BboxTargetEpsg[1]." - maxx:".$wgs84BboxTargetEpsg[2]." - maxy:".$wgs84BboxTargetEpsg[3]);
+						if ($this->x < $wgs84BboxTargetEpsg[0]) {
+							$this->x = $wgs84BboxTargetEpsg[0];
+							$geometryUnchanged = false;
+						}
+						if ($this->x > $wgs84BboxTargetEpsg[2]) {
+							$this->x = $wgs84BboxTargetEpsg[2];
+							$geometryUnchanged = false;
+						}
+						if ($this->y < $wgs84BboxTargetEpsg[1]) {
+							$this->y = $wgs84BboxTargetEpsg[1];
+							$geometryUnchanged = false;
+						}
+						if ($this->y > $wgs84BboxTargetEpsg[3]) {
+							$this->y = $wgs84BboxTargetEpsg[3];
+							$geometryUnchanged = false;
+						}
+					}
+				}
+			}
 			db_begin();
 			$sql = "SELECT X(transform(GeometryFromText('POINT(".$this->x." ".$this->y.")',".$currentEpsg."),".$targetEpsg.")) as x, ";
 			$sql .= "Y(transform(GeometryFromText('POINT(".$this->x." ".$this->y.")',".$currentEpsg."),".$targetEpsg.")) as y";



More information about the Mapbender_commits mailing list