[Mapbender-commits] r9823 - trunk/mapbender/http/php

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Fri Dec 1 02:09:52 PST 2017


Author: armin11
Date: 2017-12-01 02:09:52 -0800 (Fri, 01 Dec 2017)
New Revision: 9823

Modified:
   trunk/mapbender/http/php/mod_exportWmc2Json.php
Log:
Enhance wmc export handler to export hierarchical objects

Modified: trunk/mapbender/http/php/mod_exportWmc2Json.php
===================================================================
--- trunk/mapbender/http/php/mod_exportWmc2Json.php	2017-11-23 14:09:45 UTC (rev 9822)
+++ trunk/mapbender/http/php/mod_exportWmc2Json.php	2017-12-01 10:09:52 UTC (rev 9823)
@@ -16,12 +16,12 @@
 require_once(dirname(__FILE__)."/../../core/globalSettings.php");
 require_once(dirname(__FILE__) . "/../classes/class_wmc.php");
 require_once(dirname(__FILE__) . "/../../conf/mobilemap.conf");
-
 $user = new User();
 $admin = new administration();
 $userId = $user->id;
 $mb_myBBOX = null;
 $mb_myBBOXEpsg = null;
+$withHierarchy = false;
 //check for parameter wmc_id
 if(!isset($_GET["wmc_id"])){
 	echo 'Error: wmc_id not requested<br>';
@@ -52,6 +52,20 @@
 	die();
 }
 
+if (isset($_REQUEST["withHierarchy"]) & $_REQUEST["withHierarchy"] != "") {
+	//validate to csv integer list
+	$testMatch = $_REQUEST["withHierarchy"];
+	if ($testMatch !== '1'){ 
+		echo 'Parameter <b>withHierarchy</b> is not valid - should be 1 or omitted.<br/>'; 
+		die(); 		
+	}
+	if ($testMatch == '1') {
+		$withHierarchy = true;
+		//$e = new mb_exception("set hierarchy to true");
+	}
+	$testMatch = NULL;
+}
+
 if (isset($_REQUEST["epsg"]) & $_REQUEST["epsg"] != "") {
 	//validate to csv integer list
 	$testMatch = $_REQUEST["epsg"];
@@ -167,6 +181,7 @@
 	global $backgroundLayer;
 	global $mb_myBBOXEpsg;
 	global $mb_myBBOX;
+	global $withHierarchy;
 	//maybe faster to parse the xml itself and read the new layer_names and getmapurls directly
 	/* example reduced wmc json
 	{"wmc":{"id":"6","title":"Testwmc","bbox":"","timeStamp":"123123123"},"layerList":[{"internal":true,"currentFormat":"image/png","id":31452,"opacity":50},{"internal":"false","currentFormat":"image/jpeg","getMapUrl":"","layerTitle":"","layerName":"","layerAbstract":"","layerBbox":"","opacity":"50"}]}
@@ -271,35 +286,81 @@
 		//<Layer queryable="0" hidden="0">
 		//gui_wms_opacity
 		//use only layer which are not hidden and no root layer and support the requested SRS
-		if ($layerParent != '' && in_array($crs, $layerSRS)) {
-			if (!isset($layerId) || $layerId == '') {
-				$wmcObject->layerList[$layerCount]->internal = false; 
-				$wmcObject->layerList[$layerCount]->layerName = (string)$layerArray[$i]->Name;
-				$wmcObject->layerList[$layerCount]->opacity = (integer)$mbExtensions->gui_wms_opacity;
-				$wmcObject->layerList[$layerCount]->active = $layerActive;
-				$wmcObject->layerList[$layerCount]->currentFormat = (string)$layerArray[$i]->FormatList->Format[0];
-				$wmcObject->layerList[$layerCount]->getMapUrl = (string)$layerArray[$i]->Server->OnlineResource->attributes('http://www.w3.org/1999/xlink')->href;
-				$wmcObject->layerList[$layerCount]->layerTitle = (string)$layerArray[$i]->Title;
-				$wmcObject->layerList[$layerCount]->layerAbstract = (string)$layerArray[$i]->Abstract;
-				$wmcObject->layerList[$layerCount]->layerQueryable = $layerQueryable;
-				$wmcObject->layerList[$layerCount]->queryLayer = (integer)$mbExtensions->querylayer;
-				//layerBbox - TODO
-				$layerCount++;
-			} else {
-				if (!in_array($layerId,$backgroundLayer)) {
-					$wmcObject->layerList[$layerCount]->internal = true; 
-					$wmcObject->layerList[$layerCount]->layerId = (integer)$mbExtensions->layer_id;
+		if ($withHierarchy == true) {
+			if (in_array($crs, $layerSRS)) {
+				if (!isset($layerId) || $layerId == '') {
+					$wmcObject->layerList[$layerCount]->internal = false; 
+					$wmcObject->layerList[$layerCount]->layerName = (string)$layerArray[$i]->Name;
 					$wmcObject->layerList[$layerCount]->opacity = (integer)$mbExtensions->gui_wms_opacity;
 					$wmcObject->layerList[$layerCount]->active = $layerActive;
 					$wmcObject->layerList[$layerCount]->currentFormat = (string)$layerArray[$i]->FormatList->Format[0];
+					$wmcObject->layerList[$layerCount]->getMapUrl = (string)$layerArray[$i]->Server->OnlineResource->attributes('http://www.w3.org/1999/xlink')->href;
+					$wmcObject->layerList[$layerCount]->layerTitle = (string)$layerArray[$i]->Title;
+					$wmcObject->layerList[$layerCount]->layerAbstract = (string)$layerArray[$i]->Abstract;
 					$wmcObject->layerList[$layerCount]->layerQueryable = $layerQueryable;
 					$wmcObject->layerList[$layerCount]->queryLayer = (integer)$mbExtensions->querylayer;
-					//$wmcObject->layerList[$layerCount]->hidden = $layerHidden;
-					//$wmcObject->layerList[$i]->layerHidden = $layerHidden;
-					//$wmcObject->layerList[$layerCount]->layerParent = $layerParent;
+					if ($layerParent == '') {
+						$wmcObject->layerList[$layerCount]->layerParent = null;
+					} else {
+						$wmcObject->layerList[$layerCount]->layerParent = (integer)$mbExtensions->layer_parent;
+					}
+					$wmcObject->layerList[$layerCount]->layerPos = (integer)$mbExtensions->layer_pos;
+					//layerBbox - TODO
 					$layerCount++;
+				} else {
+					if (!in_array($layerId,$backgroundLayer)) {
+						$wmcObject->layerList[$layerCount]->internal = true; 
+						$wmcObject->layerList[$layerCount]->layerId = (integer)$mbExtensions->layer_id;
+						$wmcObject->layerList[$layerCount]->opacity = (integer)$mbExtensions->gui_wms_opacity;
+						$wmcObject->layerList[$layerCount]->active = $layerActive;
+						$wmcObject->layerList[$layerCount]->currentFormat = (string)$layerArray[$i]->FormatList->Format[0];
+						$wmcObject->layerList[$layerCount]->layerQueryable = $layerQueryable;
+						$wmcObject->layerList[$layerCount]->queryLayer = (integer)$mbExtensions->querylayer;
+
+						if ($layerParent == '') {
+							$wmcObject->layerList[$layerCount]->layerParent = null;
+						} else {
+							$wmcObject->layerList[$layerCount]->layerParent = (integer)$mbExtensions->layer_parent;
+						}
+						$wmcObject->layerList[$layerCount]->layerPos = (integer)$mbExtensions->layer_pos;
+						//$wmcObject->layerList[$layerCount]->hidden = $layerHidden;
+						//$wmcObject->layerList[$i]->layerHidden = $layerHidden;
+						//$wmcObject->layerList[$layerCount]->layerParent = $layerParent;
+						$layerCount++;
+					}
 				}
 			}
+		} else {
+			if ($layerParent != '' && in_array($crs, $layerSRS)) {
+				if (!isset($layerId) || $layerId == '') {
+					$wmcObject->layerList[$layerCount]->internal = false; 
+					$wmcObject->layerList[$layerCount]->layerName = (string)$layerArray[$i]->Name;
+					$wmcObject->layerList[$layerCount]->opacity = (integer)$mbExtensions->gui_wms_opacity;
+					$wmcObject->layerList[$layerCount]->active = $layerActive;
+					$wmcObject->layerList[$layerCount]->currentFormat = (string)$layerArray[$i]->FormatList->Format[0];
+					$wmcObject->layerList[$layerCount]->getMapUrl = (string)$layerArray[$i]->Server->OnlineResource->attributes('http://www.w3.org/1999/xlink')->href;
+					$wmcObject->layerList[$layerCount]->layerTitle = (string)$layerArray[$i]->Title;
+					$wmcObject->layerList[$layerCount]->layerAbstract = (string)$layerArray[$i]->Abstract;
+					$wmcObject->layerList[$layerCount]->layerQueryable = $layerQueryable;
+					$wmcObject->layerList[$layerCount]->queryLayer = (integer)$mbExtensions->querylayer;
+					//layerBbox - TODO
+					$layerCount++;
+				} else {
+					if (!in_array($layerId,$backgroundLayer)) {
+						$wmcObject->layerList[$layerCount]->internal = true; 
+						$wmcObject->layerList[$layerCount]->layerId = (integer)$mbExtensions->layer_id;
+						$wmcObject->layerList[$layerCount]->opacity = (integer)$mbExtensions->gui_wms_opacity;
+						$wmcObject->layerList[$layerCount]->active = $layerActive;
+						$wmcObject->layerList[$layerCount]->currentFormat = (string)$layerArray[$i]->FormatList->Format[0];
+						$wmcObject->layerList[$layerCount]->layerQueryable = $layerQueryable;
+						$wmcObject->layerList[$layerCount]->queryLayer = (integer)$mbExtensions->querylayer;
+						//$wmcObject->layerList[$layerCount]->hidden = $layerHidden;
+						//$wmcObject->layerList[$i]->layerHidden = $layerHidden;
+						//$wmcObject->layerList[$layerCount]->layerParent = $layerParent;
+						$layerCount++;
+					}
+				}
+			}
 		}	
 	}
 	echo json_encode($wmcObject);



More information about the Mapbender_commits mailing list