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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Wed Oct 5 08:09:26 PDT 2016


Author: armin11
Date: 2016-10-05 08:09:25 -0700 (Wed, 05 Oct 2016)
New Revision: 9616

Modified:
   trunk/mapbender/http/javascripts/initWmcObj.php
Log:
Fix geojson parser to allow featurecollections without title - as they are delivered e.g. from wfs

Modified: trunk/mapbender/http/javascripts/initWmcObj.php
===================================================================
--- trunk/mapbender/http/javascripts/initWmcObj.php	2016-09-30 10:57:27 UTC (rev 9615)
+++ trunk/mapbender/http/javascripts/initWmcObj.php	2016-10-05 15:09:25 UTC (rev 9616)
@@ -404,10 +404,10 @@
 //GEOJSON
 //
 $inputGeojsonArray = $getApi->getGeojson();
-//$e = new mb_exception("get parameter for geojsonzoom: ".$getApi->getGeojsonZoom());
+//$e = new mb_exception("get parameter for geojson: ".$inputGeojsonArray[0]);
 $zoomToExtent = $getApi->getGeojsonZoom();
 $offset = $getApi->getGeojsonZoomOffset();
-$e = new mb_exception("offset from initWmcObj: ".$offset);
+//$e = new mb_exception("offset from initWmcObj: ".$offset);
 /*if ($offset == false) {
 	$e = new mb_exception('no offset given');
 }*/
@@ -432,26 +432,34 @@
 		//load json files from distributed locations
 		//check if url directly geojson is given
 		if ($admin->validateUrl(urldecode($inputGeojson))) {
-			$e = new mb_notice("GEORSS parameter will be interpreted as url - try to resolve external json!");
+			$e = new mb_notice("GEOJSON parameter will be interpreted as url - try to resolve external json!");
+			//TODO: here there may exists firewall problems which cut the request part after the first ampersand!!!!
 			//$e = new mb_exception("found url ".urldecode($inputGeojson));
 			//$e = new mb_exception("found url unencoded ".$inputGeojson);
 			$jsonFile = new connector($inputGeojson);
+			//$e = new mb_exception("GEOJSON: ".$jsonFile->file);
 			//$jsonFile = new connector("http://localhost/mb_trunk/geoportal/testpolygon.json");
 			$geojson = json_decode($jsonFile->file);
 		} else {
-			$e = new mb_notice("GEORSS parameter will be interpreted as string!");
+			$e = new mb_notice("GEOJSON parameter will be interpreted as string!");
 			$geojson = json_decode(urldecode($inputGeojson));
+
 		}
 		if ($geojson !== null && $geojson !== false) {
-			$kmlOrder[] = $geojson->title;
-			$kmls->{$geojson->title}->type = "geojson";
-			$kmls->{$geojson->title}->data = $geojson;
-			$kmls->{$geojson->title}->url = $geojson->title;
-			$kmls->{$geojson->title}->display = true;
+			if (!empty($geojson->title)) {
+				$geojsonTitle = $geojson->title;
+			} else {
+				$geojsonTitle = "notTitleGivenForCollection";
+			}
+			$kmlOrder[] = $geojsonTitle;
+			$kmls->{$geojsonTitle}->type = "geojson";
+			$kmls->{$geojsonTitle}->data = $geojson;
+			$kmls->{$geojsonTitle}->url = $geojsonTitle;
+			$kmls->{$geojsonTitle}->display = true;
 			if ($zoomToExtent == 'true') {
 				$latitudes = array();
 				$longitudes = array();
-				foreach($kmls->{$geojson->title}->data->features as $feature) {
+				foreach($kmls->{$geojsonTitle}->data->features as $feature) {
 					switch ($feature->geometry->type) {
 						case "Polygon":
 							//$e = new mb_exception("Polygon found!");



More information about the Mapbender_commits mailing list