[Mapbender-commits] r2472 - in branches/beck_dev/mapbender/http: classes javascripts php

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue May 27 03:03:08 EDT 2008


Author: christoph
Date: 2008-05-27 03:03:07 -0400 (Tue, 27 May 2008)
New Revision: 2472

Modified:
   branches/beck_dev/mapbender/http/classes/class_map.php
   branches/beck_dev/mapbender/http/classes/class_wmc.php
   branches/beck_dev/mapbender/http/classes/class_wms.php
   branches/beck_dev/mapbender/http/javascripts/mod_loadwmc.js
   branches/beck_dev/mapbender/http/php/mod_loadwmc_server.php
Log:
updated merge function

Modified: branches/beck_dev/mapbender/http/classes/class_map.php
===================================================================
--- branches/beck_dev/mapbender/http/classes/class_map.php	2008-05-26 12:12:28 UTC (rev 2471)
+++ branches/beck_dev/mapbender/http/classes/class_map.php	2008-05-27 07:03:07 UTC (rev 2472)
@@ -121,6 +121,16 @@
 		return $this->isOverview;
 	}
 	
+	public function merge ($anotherMap) {
+		$this->width = $anotherMap->width;
+		$this->height = $anotherMap->height;
+		$this->frameName = $anotherMap->frameName;
+		$this->elementName = $anotherMap->elementName;
+		$this->extent = $anotherMap->extent;
+		$this->isOverview = $anotherMap->isOverview;
+		$this->wmsArray = wms::merge(array_merge($anotherMap->getWmsArray(), $this->wmsArray));
+	}
+		
 	/**
 	 * 
 	 * @return 
@@ -208,9 +218,28 @@
 				$newLayer->gui_layer_minscale = $currentLayer->gui_layer_minscale;
 				$newLayer->gui_layer_maxscale = $currentLayer->gui_layer_maxscale;
 				$newLayer->gui_layer_wfs_featuretype = $currentLayer->gui_layer_wfs_featuretype;
-				$newLayer->layer_epsg = $currentLayer->layer_epsg;
-				$newLayer->layer_style = $currentLayer->layer_style;
 
+				// BEWARE THIS IS SUPER UGLY CODE
+				$newLayer->layer_epsg = array();
+				for ($z = 0; $z < count($currentLayer->layer_epsg); $z++) {
+					$newLayer->layer_epsg[$z] = array();
+					$newLayer->layer_epsg[$z]["epsg"] = $currentLayer->layer_epsg[$z]->epsg;
+					$newLayer->layer_epsg[$z]["minx"] = $currentLayer->layer_epsg[$z]->minx;
+					$newLayer->layer_epsg[$z]["miny"] = $currentLayer->layer_epsg[$z]->miny;
+					$newLayer->layer_epsg[$z]["maxx"] = $currentLayer->layer_epsg[$z]->maxx;
+					$newLayer->layer_epsg[$z]["maxy"] = $currentLayer->layer_epsg[$z]->maxy;
+				}
+
+				// BEWARE THIS IS SUPER UGLY CODE
+				$newLayer->layer_style = array();
+				for ($z = 0; $z < count($currentLayer->layer_style); $z++) {
+					$newLayer->layer_style[$z] = array();
+					$newLayer->layer_style[$z]["name"] = $currentLayer->layer_style[$z]->name;
+					$newLayer->layer_style[$z]["title"] = $currentLayer->layer_style[$z]->title;
+					$newLayer->layer_style[$z]["legendurl"] = $currentLayer->layer_style[$z]->legendurl;
+					$newLayer->layer_style[$z]["legendurlformat"] = $currentLayer->layer_style[$z]->legendurlformat;
+				}
+
 			}
 			array_push($this->wmsArray, $wms);
 		}

Modified: branches/beck_dev/mapbender/http/classes/class_wmc.php
===================================================================
--- branches/beck_dev/mapbender/http/classes/class_wmc.php	2008-05-26 12:12:28 UTC (rev 2471)
+++ branches/beck_dev/mapbender/http/classes/class_wmc.php	2008-05-27 07:03:07 UTC (rev 2472)
@@ -333,6 +333,7 @@
 		
 		// reset WMS data
 		array_push($wmcJsArray, "wms = [];");
+		array_push($wmcJsArray, "wms_layer_count = 0;");
 
 		// add WMS for main map frame
 		$wmsArray = $this->mainMap->getWmsArray();
@@ -342,6 +343,7 @@
 			array_push($wmcJsArray, $wmsArray[$i]->createJsObjFromWMS_());
 		}
 
+		array_push($wmcJsArray, "console.log('wms object: %s', $.toJSON(wms));");
 		// delete existing map objects...
 		array_push($wmcJsArray, "mb_mapObj = [];");
 
@@ -374,32 +376,21 @@
 		return $wmcJsArray;
 	}
 
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+	/**
+	 * Merges this WMC with another WMC.
+	 * The settings of the other WMC overwrite the settings of this WMC.
+	 * 
+	 * @return void
+	 * @param $xml2 Object
+	 */
 	public function merge ($xml2) {
 		$someWmc = new wmc();
 		$someWmc->createFromXml($xml2);
 
-//		$this->mainMap = $someWmc->mainMap;
-//		$this->overviewMap = $someWmc->overviewMap;
-//		$this->overviewWmsIndex = $someWmc->overviewWmsIndex;
-//		$this->generalExtensionArray = array_merge($this->generalExtensionArray, $someWmc->generalExtensionArray);
-
-		$this->wmsArray = wms::merge(array_merge($someWmc->wmsArray, $this->wmsArray));
-		return $this->toJavaScript();
+		$this->mainMap->merge($someWmc->mainMap);
+		if (isset($this->overviewMap) && isset($someWmc->overviewMap)) {
+			$this->overviewMap->merge($someWmc->overviewMap);
+		}
 	}
 
 
@@ -929,7 +920,7 @@
 
 		// add layer to existing WMS ...
 		$currentWms = $wmsArray[$wmsIndex];
-		$currentWms->newLayer($currentLayer);
+		$currentWms->newLayer($currentLayer, null);
 		$currentMap->setWmsArray($wmsArray);
 		return true;
 	}
@@ -967,8 +958,9 @@
 	}
 
 	/**
+	 * Creates a WMC document (XML) from the current object
 	 * 
-	 * @return 
+	 * @return String XML
 	 */
 	private function createXml() {
 		$wmcToXml = new WmcToXml($this);

Modified: branches/beck_dev/mapbender/http/classes/class_wms.php
===================================================================
--- branches/beck_dev/mapbender/http/classes/class_wms.php	2008-05-26 12:12:28 UTC (rev 2471)
+++ branches/beck_dev/mapbender/http/classes/class_wms.php	2008-05-27 07:03:07 UTC (rev 2472)
@@ -827,19 +827,22 @@
 		}
 		$newLayer->layer_abstract = $currentLayer["abstract"];
 
-/*
+
 		//
 		// set layer epsg
 		//
-		$currentLayerEpsg = array();
-		$currentLayerEpsg["epsg"] = $currentExtent->epsg;
-		$currentLayerEpsg["minx"] = $currentExtent->min->x;
-		$currentLayerEpsg["miny"] = $currentExtent->min->y; 
-		$currentLayerEpsg["maxx"] = $currentExtent->max->x;
-		$currentLayerEpsg["maxy"] = $currentExtent->max->y;
-		array_push($newLayer->objLayer[$i]->layer_epsg, $currentLayerEpsg);
-*/
+		$newLayer->layer_epsg = array();
+		if ($currentExtent !== null) {
+			$currentLayerEpsg = array();
+			$currentLayerEpsg["epsg"] = $currentExtent->epsg;
+			$currentLayerEpsg["minx"] = $currentExtent->min->x;
+			$currentLayerEpsg["miny"] = $currentExtent->min->y; 
+			$currentLayerEpsg["maxx"] = $currentExtent->max->x;
+			$currentLayerEpsg["maxy"] = $currentExtent->max->y;
+			array_push($newLayer->layer_epsg, $currentLayerEpsg);
+		}
 
+
 		//
 		// set layer style
 		//
@@ -920,7 +923,7 @@
 			for($j=0; $j<count($this->objLayer[$i]->layer_epsg);$j++){
 				if($i==0){
 					if($parent){
-					$str .= "parent.";
+						$str .= "parent.";
 					}
 					$str .= "wms_addSRS('". 
 						$this->objLayer[$i]->layer_epsg[$j]["epsg"] ."','". 
@@ -930,7 +933,7 @@
 						$this->objLayer[$i]->layer_epsg[$j]["maxy"] ."');\n";
 				}
 				if($parent){
-				$str .=  "parent.";
+					$str .=  "parent.";
 				}
 				$str .= "layer_addEpsg('". 
 					$this->objLayer[$i]->layer_epsg[$j]["epsg"] ."','". 

Modified: branches/beck_dev/mapbender/http/javascripts/mod_loadwmc.js
===================================================================
--- branches/beck_dev/mapbender/http/javascripts/mod_loadwmc.js	2008-05-26 12:12:28 UTC (rev 2471)
+++ branches/beck_dev/mapbender/http/javascripts/mod_loadwmc.js	2008-05-27 07:03:07 UTC (rev 2472)
@@ -145,6 +145,7 @@
 						try {
 							if (resultObj.javascript && typeof(resultObj.javascript) == "object") {
 								for (var j=0; j < resultObj.javascript.length; j++) {
+									console.log("Statement: %s", resultObj.javascript[j]);
 									eval(resultObj.javascript[j]);
 								}
 							}	

Modified: branches/beck_dev/mapbender/http/php/mod_loadwmc_server.php
===================================================================
--- branches/beck_dev/mapbender/http/php/mod_loadwmc_server.php	2008-05-26 12:12:28 UTC (rev 2471)
+++ branches/beck_dev/mapbender/http/php/mod_loadwmc_server.php	2008-05-27 07:03:07 UTC (rev 2472)
@@ -117,19 +117,30 @@
 	case 'mergeWmc':
 		$params = $queryObj->parameters;
 		
+		$e = new mb_notice("CREATING WMC1...");
+
 		// generate a WMC for the current client state
 		$currentWmc = new wmc();
 		$currentWmc->createFromJs($params->mapObject, $params->generalTitle, $params->extensionData);
 
+		$e = new mb_notice("CREATED WMC1");
+		$e = new mb_notice("CREATING WMC2...");
+
 		// get the desired WMC from the database
 		$wmcId = $queryObj->parameters->id;
 		$wmcXml = wmc::getDocument($wmcId);
 
+		$e = new mb_notice("CREATED WMC2...");
+
+		$e = new mb_notice("MERGING...");
 		// merge the two WMCs
 		$currentWmc->merge($wmcXml);
 		
+		$e = new mb_notice("MERGED.");
 		// load the merged WMC
+		$e = new mb_notice("EXPORTING TO JS...");
 		$jsArray = $currentWmc->toJavaScript();
+		$e = new mb_notice("JS EXPORT FINISHED.");
 		if ($jsArray) {
 			$resultObj["javascript"] = $jsArray;
 		}



More information about the Mapbender_commits mailing list