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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Fri Sep 30 01:27:51 PDT 2016


Author: armin11
Date: 2016-09-30 01:27:50 -0700 (Fri, 30 Sep 2016)
New Revision: 9612

Modified:
   trunk/mapbender/http/javascripts/initWmcObj.php
Log:
New possibility to set an offset in [m] if zoom to external geojson is demanded

Modified: trunk/mapbender/http/javascripts/initWmcObj.php
===================================================================
--- trunk/mapbender/http/javascripts/initWmcObj.php	2016-09-29 15:31:42 UTC (rev 9611)
+++ trunk/mapbender/http/javascripts/initWmcObj.php	2016-09-30 08:27:50 UTC (rev 9612)
@@ -175,6 +175,7 @@
 	"KML"=>getConfiguration("KML"),
 	"GEOJSON"=>getConfiguration("GEOJSON"),
 	"GEOJSONZOOM"=>getConfiguration("GEOJSONZOOM"),
+	"GEOJSONZOOMOFFSET"=>getConfiguration("GEOJSONZOOMOFFSET"),
 	"ZOOM"=>getConfiguration("ZOOM")
 );
 $getApi = new GetApi($getParams);
@@ -405,6 +406,11 @@
 $inputGeojsonArray = $getApi->getGeojson();
 //$e = new mb_exception("get parameter for geojsonzoom: ".$getApi->getGeojsonZoom());
 $zoomToExtent = $getApi->getGeojsonZoom();
+$offset = $getApi->getGeojsonZoomOffset();
+//$e = new mb_exception("offset from initWmcObj: ".$offset);
+/*if ($offset == false) {
+	$e = new mb_exception('no offset given');
+}*/
 //$e = new mb_exception("zoomToExtent from initWmcObj: ".$zoomToExtent);
 if ($zoomToExtent == 'true') {
 	$minx = false;
@@ -420,7 +426,9 @@
 	unset($wmcGetApi->generalExtensionArray['KMLORDER']);
 	unset($wmcGetApi->generalExtensionArray['KMLS']);
 	$kmlOrder = array();
+	//$i = 0;
 	foreach ($inputGeojsonArray as $inputGeojson) {
+		//$e = new mb_exception($inputGeojson);
 		//load json files from distributed locations
 		//check if url directly geojson is given
 		if ($admin->validateUrl(urldecode($inputGeojson))) {
@@ -470,12 +478,25 @@
 				}
 			}
 		}
+	//$i++;
 	}
 	if ($zoomToExtent == 'true') {
 		$minx = min($longitudes);
 		$miny = min($latitudes);
 		$maxx = max($longitudes);
 		$maxy = max($latitudes);
+		if ($offset !== false) {
+			$averageLatitude = ($maxy - $miny) / 2;
+			$r = 6371000.0;
+			$pi = 3.14159265359;
+			$rho = 180.0 / $pi;
+			$offsetLon = $offset * $rho / $r;
+			$offsetLat = $offset * $rho / ($r * cos(($averageLatitude / $rho)));
+			$minx = $minx - $offsetLon;
+			$miny = $miny - $offsetLat;
+			$maxx = $maxx + $offsetLon;
+			$maxy = $maxy + $offsetLat;
+		}
 		//overwrite extend from getApi
 		$bbox = new Mapbender_bbox($minx,$miny,$maxx,$maxy,"EPSG:4326");
 		$wmcGetApi->mainMap->setExtent($bbox);



More information about the Mapbender_commits mailing list