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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Mon Jun 27 07:21:48 PDT 2016


Author: armin11
Date: 2016-06-27 07:21:48 -0700 (Mon, 27 Jun 2016)
New Revision: 9528

Modified:
   trunk/mapbender/http/php/wms.php
Log:
Fix for srs inheritance of older layers

Modified: trunk/mapbender/http/php/wms.php
===================================================================
--- trunk/mapbender/http/php/wms.php	2016-06-24 10:26:40 UTC (rev 9527)
+++ trunk/mapbender/http/php/wms.php	2016-06-27 14:21:48 UTC (rev 9528)
@@ -514,11 +514,11 @@
 
 ############################################################
 #GetCapabilities
-#Creatig the "GetCapabilities" node 
+#Creating the "GetCapabilities" node 
 $getCapabilities = $doc->createElement("GetCapabilities");
 $getCapabilities = $request->appendChild($getCapabilities);
 
-#Creatig the "Format" node 
+#Creating the "Format" node 
 $wms_format_sql ="SELECT data_format FROM wms_format WHERE fkey_wms_id = $1 AND data_type = 'capability'";
 $v = array($wms_row['wms_id']);
 $t = array("i");
@@ -857,6 +857,12 @@
 	}
 }
 
+//
+//
+//
+
+
+
 #SQL statement to get additional layer information from layer epsg	
 $epsg_sql = "SELECT layer_epsg.epsg, layer_epsg.minx, layer_epsg.miny, " . 
 	"layer_epsg.maxy, layer_epsg.maxx " . 
@@ -869,6 +875,9 @@
 $latLonBoundingBoxCreated = false;
 $BoundingBoxCreated = false;
 
+//pull all other parent layer and their epsg!!
+
+
 while ($epsg_row = db_fetch_array($res_espg_sql)) {
 	#Creating SRS node
 	$srs = $doc->createElement("SRS");
@@ -990,7 +999,7 @@
     	if($layerRow['layer_abstract'] <> "" AND $layerRow['layer_abstract'] <> NULL) {
 		$layerAbstract = $layerRow['layer_abstract'];
 	} else {
-		$layerAbstract = _mb('No abtract for the specific layer was given, please add a description to your layer ressource.');
+		$layerAbstract = _mb('No abstract for the specific layer was given, please add a description to your layer ressource.');
 	}
     	$abstract = $doc->createElement("Abstract");
     	$abstract = $layer->appendChild($abstract);
@@ -1026,13 +1035,76 @@
 			"WHERE fkey_layer_id = ".$layerRow['layer_id'];  
 			//" OR fkey_layer_id = " . $layer_row['layer_id'];
 	$res_layer_srs_sql = db_query($layer_srs_sql);
+	//store srs into array
+	$origLayerEpsg = array();
 	while ($layer_srs_row = db_fetch_array($res_layer_srs_sql)) {
-		#Creating SRS node
+		//Creating SRS node
 		$srs = $doc->createElement("SRS");
 		$srs = $layer->appendChild($srs);
 		$srsText = $doc->createTextNode(str_replace('epsg','EPSG',$layer_srs_row['epsg']));
+		$origLayerEpsg[] = str_replace('epsg','EPSG',$layer_srs_row['epsg']);
 		$srsText = $srs->appendChild($srsText);
 	}
+	//extent this list with srs from all parent layers
+	//build tree
+	$parent_layer_srs_sql = "SELECT layer_id, layer_pos, layer_parent FROM layer WHERE fkey_wms_id = $1";
+	
+	$vPL = array($wmsRow['wms_id']);
+	$tPL = array('i');
+	$resPL = db_prep_query($parent_layer_srs_sql, $vPL, $tPL);
+	while ($layerTree = db_fetch_array($resPL)) {
+		$layerTreeArray['layer_id'][] = $layerTree['layer_id'];
+		$layerTreeArray['layer_pos'][] = $layerTree['layer_pos'];
+		$layerTreeArray['layer_parent'][] = $layerTree['layer_parent'];
+	}
+	$rootLayerFound = false;
+	$layerStructure = array();
+	$searchLayerId = $layerRow['layer_id'];
+	
+	//$layerStructure[] = $searchLayerId;
+	while ($rootLayerFound == false) {
+		$layerStructure[] = $searchLayerId; //pull only parent layerIds
+		$key = array_search($searchLayerId, $layerTreeArray['layer_id']);
+		if (!$key) {
+			$rootLayerFound = true;
+		} else {
+			$parent = $layerTreeArray['layer_parent'][$key];
+			if ($parent == null || $parent == '') {
+				$rootLayerFound = true;
+			} else {
+				$parentId = $layerTreeArray['layer_id'][array_search($parent, $layerTreeArray['layer_pos'])];
+				
+				$searchLayerId = $parentId;
+			}
+		}
+	}
+	//remove first entry 
+	unset($layerStructure[0]);
+	$layerStructure = array_values($layerStructure);
+	//debug*************************************
+	/*foreach ($layerStructure as $singleLayer) {
+		echo $singleLayer."<br>";
+	}
+	die();*/
+	//debug*************************************
+	if (count($layerStructure) > 0) {
+		$parent_layer_srs_sql = "SELECT DISTINCT epsg FROM layer_epsg WHERE fkey_layer_id IN  (".implode(',',$layerStructure).")";  
+		$res_parent_layer_srs_sql = db_query($parent_layer_srs_sql);
+		while ($layer_parent_srs_row = db_fetch_array($res_parent_layer_srs_sql)) {
+			//check if already exists
+			if (!in_array(str_replace('epsg','EPSG',$layer_parent_srs_row['epsg']), $origLayerEpsg)) {
+				//Creating SRS node
+				//$e = new mb_exception("add epsg support from parent layer: ".str_replace('epsg','EPSG',$layer_parent_srs_row['epsg']));
+				$srs = $doc->createElement("SRS");
+				$srs = $layer->appendChild($srs);
+				$srsText = $doc->createTextNode(str_replace('epsg','EPSG',$layer_parent_srs_row['epsg']));
+				$srsText = $srs->appendChild($srsText);
+			} else {
+				//$e = new mb_exception("EPSG from parent layers already defined in sublayer: ".str_replace('epsg','EPSG',$layer_parent_srs_row['epsg']));
+			}
+		}	
+	}
+	//
 	#SQL statement to get additional layer information from layer epsg	
 	$epsg_sql = "SELECT layer_epsg.epsg, layer_epsg.minx, layer_epsg.miny, " . 
 			"layer_epsg.maxy, layer_epsg.maxx FROM layer_epsg " . 



More information about the Mapbender_commits mailing list