svn commit: r896 - trunk/mapbender/http/classes/class_wms.php

christoph at osgeo.org christoph at osgeo.org
Tue Nov 21 03:16:46 EST 2006


Author: christoph
Date: 2006-11-21 08:16:46+0000
New Revision: 896

Modified:
   trunk/mapbender/http/classes/class_wms.php

Log:
* added wms metadata
* added flag overwrite

Modified: trunk/mapbender/http/classes/class_wms.php
Url: https://mapbender.osgeo.org/source/browse/mapbender/trunk/mapbender/http/classes/class_wms.php?view=diff&rev=896&p1=trunk/mapbender/http/classes/class_wms.php&p2=trunk/mapbender/http/classes/class_wms.php&r1=895&r2=896
==============================================================================
--- trunk/mapbender/http/classes/class_wms.php	(original)
+++ trunk/mapbender/http/classes/class_wms.php	2006-11-21 08:16:46+0000
@@ -17,8 +17,8 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
-include_once("../../conf/mapbender.conf");
-require_once("class_connector.php");
+include_once(dirname(__FILE__)."/../../conf/mapbender.conf");
+require_once(dirname(__FILE__)."/class_connector.php");
   
 class wms {
   var $lastURL;
@@ -33,7 +33,22 @@
   var $wms_getfeatureinfo;
   var $wms_getlegendurl;
   var $wms_upload_url;
-
+  
+  var $fees;
+  var $accessconstraints;
+  var $contactperson;
+  var $contactposition;
+  var $contactorganization;
+  var $address;
+  var $city;
+  var $stateorprovince;
+  var $postcode;
+  var $country;
+  var $contactvoicetelephone;
+  var $contactfacsimiletelephone;
+  var $contactelectronicmailaddress;
+  
+  var $wms_keyword = array();
   var $data_type = array(); 
   var $data_format = array();
 
@@ -45,6 +60,7 @@
   var $gui_wms_epsg;
   
   var $default_epsg = 0;
+  var $overwrite = true;
   
   function wms() {
 	
@@ -99,6 +115,49 @@
 		if(strtoupper($element[tag]) == "ABSTRACT" && $element[level] == '3'){
 			$this->wms_abstract = $element[value];
 		}
+		if(strtolower($element[tag]) == "fees"){
+			$this->fees = $element[value];
+		}
+		if(strtolower($element[tag]) == "accessconstraints"){
+			$this->accessconstraints = $element[value];
+		}
+		if(strtolower($element[tag]) == "contactperson"){
+			$this->contactperson = $element[value];
+		}
+		if(strtolower($element[tag]) == "contactposition"){
+			$this->contactposition = $element[value];
+		}
+		if(strtolower($element[tag]) == "contactorganization"){
+			$this->contactorganization = $element[value];
+		}
+		if(strtolower($element[tag]) == "address"){
+			$this->address = $element[value];
+		}
+		if(strtolower($element[tag]) == "city"){
+			$this->city = $element[value];
+		}
+		if(strtolower($element[tag]) == "stateorprovince"){
+			$this->stateorprovince = $element[value];
+		}
+		if(strtolower($element[tag]) == "postcode"){
+			$this->postcode = $element[value];
+		}
+		if(strtolower($element[tag]) == "country"){
+			$this->country = $element[value];
+		}
+		if(strtolower($element[tag]) == "contactvoicetelephone"){
+			$this->contactvoicetelephone = $element[value];
+		}
+		if(strtolower($element[tag]) == "contactfacsimiletelephone"){
+			$this->contactfacsimiletelephone = $element[value];
+		}
+		if(strtolower($element[tag]) == "contactelectronicmailaddress"){
+			$this->contactelectronicmailaddress = $element[value];
+		}
+  		if(strtolower($element[tag]) == "keyword" && $section != 'layer'){
+			$this->wms_keyword[count($this->wms_keyword)] = $element[value];
+		}
+		
 		/*map section*/
 		if($this->wms_version == "1.0.0"){
 	 		if(strtoupper($element[tag]) == "MAP" && $element[type] == "open"){
@@ -330,6 +389,12 @@
 			if(strtoupper($element[tag]) == "TITLE"){
 				$this->objLayer[$cnt_layer]->layer_title = $element[value];
 			}
+			if(strtoupper($element[tag]) == "ABSTRACT"){
+				$this->objLayer[$cnt_layer]->layer_abstract = $element[value];
+			}
+			if(strtoupper($element[tag]) == "KEYWORD"){
+				$this->objLayer[$cnt_layer]->layer_keyword[count($this->objLayer[$cnt_layer]->layer_keyword)] = $element[value];
+			}
       		if(strtoupper($element[tag]) == "DATAURL" && $element[type] == "open"){
 				$dataurl = true;
 			}
@@ -362,7 +427,7 @@
 				$this->objLayer[$cnt_layer]->layer_epsg[$cnt_epsg]["maxx"] = $element[attributes][maxx];
 				$this->objLayer[$cnt_layer]->layer_epsg[$cnt_epsg]["maxy"] = $element[attributes][maxy];
 			}
-			if(strtoupper($element[tag]) == "BOUNDINGBOX"){
+			if(strtoupper($element[tag]) == "BOUNDINGBOX" && $element[attributes][SRS] != "EPSG:4326"){
 				$cnt_epsg++;
 				$this->objLayer[$cnt_layer]->layer_epsg[$cnt_epsg]["epsg"] = $element[attributes][SRS];
 				$this->objLayer[$cnt_layer]->layer_epsg[$cnt_epsg]["minx"] = $element[attributes][minx];
@@ -437,6 +502,10 @@
 		}
 	}
 	for($i=0;$i<count($this->objLayer);$i++){
+		if(!is_int($this->objLayer[$i]->layer_parent)){
+			$this->objLayer[$i]->layer_abstract = $this->wms_abstract;
+			$this->objLayer[$i]->layer_keyword = $this->wms_keyword;
+		}
 		if($this->objLayer[$i]->layer_name == ""){
 			$this->objLayer[$i]->layer_name = $this->objLayer[$i]->layer_title;
 		}
@@ -539,6 +608,8 @@
 			echo "<tr><td>".$this->objLayer[$i]->layer_style[$j][name]."</td><td>".$this->objLayer[$i]->layer_style[$j][title]."</td><td>".$this->objLayer[$i]->layer_style[$j][legendurl]."</td><td>".$this->objLayer[$i]->layer_style[$j][legendurlformat]."</td></tr>";
 		}
 		echo "</table>";
+        echo "<hr>";
+        echo "<hr>";
 	}
 } 
   function addLayer($id,$parent){	
@@ -631,12 +702,18 @@
 
 	# TABLE wms
 	$sql = "INSERT INTO wms (wms_version, wms_title, wms_abstract, wms_getcapabilities, wms_getmap, ";
-	$sql.= "wms_getfeatureinfo, wms_getlegendurl, wms_getcapabilities_doc,wms_upload_url) ";
-	$sql .= "VALUES($1,$2,$3,$4,$5,$6,$7,$8,$9)";
+	$sql.= "wms_getfeatureinfo, wms_getlegendurl, wms_getcapabilities_doc, wms_upload_url, fees, ";
+	$sql .= "accessconstraints, contactperson, contactposition, contactorganization, address, city, ";
+	$sql .= "stateorprovince, postcode, country, contactvoicetelephone, contactfacsimiletelephone, contactelectronicmailaddress, ";
+	$sql .= "wms_owner,wms_timestamp) ";
+	$sql .= "VALUES($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22,$23,$24)";
 	$v = array($this->wms_version,$this->wms_title,$this->wms_abstract,$this->wms_getcapabilities,
 		$this->wms_getmap,$this->wms_getfeatureinfo,$this->wms_getlegendurl,$this->wms_getcapabilities_doc,
-		$this->wms_upload_url);
-	$t = array('s','s','s','s','s','s','s','s','s');
+		$this->wms_upload_url,$this->fees,$this->accessconstraints,$this->contactperson,$this->contactposition,
+		$this->contactorganization,$this->address,$this->city,$this->stateorprovince,$this->postcode,$this->country,
+		$this->contactvoicetelephone,$this->contactfacsimiletelephone,$this->contactelectronicmailaddress,
+		$_SESSION['mb_user_id'],strtotime("now"));
+	$t = array('s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','i','i');
 	$res = db_prep_query($sql,$v,$t);
 	if(!$res){
 		db_rollback();
@@ -680,11 +757,14 @@
 		db_rollback();	
 	}
 	db_commit();
+    
+    #Changes JW
+    $this->wms_id = $myWMS;
 }
 function insertLayer($i,$myWMS){
 	$sql = "INSERT INTO layer(fkey_wms_id, layer_pos, layer_parent, layer_name, layer_title, ";
-	$sql .= " layer_queryable, layer_minscale, layer_maxscale,layer_dataurl,layer_metadataurl) ";
-	$sql .= "VALUES($1,$2,$3,$4,$5,$6,$7,$8,$9,$10)";
+	$sql .= " layer_queryable, layer_minscale, layer_maxscale,layer_dataurl,layer_metadataurl,layer_abstract) ";
+	$sql .= "VALUES($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11)";
 	if($this->objLayer[$i]->layer_id != null){
 		$tmpPos =  $this->objLayer[$i]->layer_id;
 	}
@@ -697,9 +777,9 @@
 	$v = array($myWMS,$tmpPos,$this->objLayer[$i]->layer_parent,$this->objLayer[$i]->layer_name,
 			$this->objLayer[$i]->layer_title,
 			$this->objLayer[$i]->layer_queryable,$this->objLayer[$i]->layer_minscale,
-			$this->objLayer[$i]->layer_maxscale,$this->objLayer[$i]->layer_dataurl_href,$this->objLayer[$i]->layer_metadataurl		
-		);
-	$t = array('i','i','s','s','s','i','i','i','s','s');
+			$this->objLayer[$i]->layer_maxscale,$this->objLayer[$i]->layer_dataurl_href,
+			$this->objLayer[$i]->layer_metadataurl,$this->objLayer[$i]->layer_abstract);
+	$t = array('i','i','s','s','s','i','i','i','s','s','s');
 	$res = db_prep_query($sql,$v,$t);
 	if(!$res){
 		db_rollback();	
@@ -710,7 +790,10 @@
 	$this->insertLayerEPSG($i);
 	
 	# TABLE layer_style for each layer
-	$this->insertLayerStyle($i);	
+	$this->insertLayerStyle($i);
+	
+	# insert Keywords
+	$this->insertLayerKeyword($i);	
 }
 function updateLayer($i,$myWMS){
 	$sql = "SELECT layer_id FROM layer WHERE fkey_wms_id = $1 AND layer_name = $2";
@@ -734,8 +817,9 @@
 	$sql .= "layer_minscale = $5, ";
 	$sql .= "layer_maxscale = $6, ";
 	$sql .= "layer_dataurl = $7, ";
-	$sql .= "layer_metadataurl = $8 ";
-	$sql .= "WHERE layer_id = $9";
+	$sql .= "layer_metadataurl = $8, ";
+	$sql .= "layer_abstract = $9 ";
+	$sql .= "WHERE layer_id = $10";
 	
 	if($this->objLayer[$i]->layer_id != null){
 		$tmpPos =  $this->objLayer[$i]->layer_id;
@@ -750,10 +834,20 @@
 			$this->objLayer[$i]->layer_title,
 			$this->objLayer[$i]->layer_queryable,$this->objLayer[$i]->layer_minscale,
 			$this->objLayer[$i]->layer_maxscale,$this->objLayer[$i]->layer_dataurl_href,
-			$this->objLayer[$i]->layer_metadataurl, $l_id		
+			$this->objLayer[$i]->layer_metadataurl,$this->objLayer[$i]->layer_abstract, $l_id		
 		);
-	$t = array('i','s','s','i','i','i','s','s','i');
+	$t = array('i','s','s','i','i','i','s','s','s','i');
 	$res = db_prep_query($sql,$v,$t);
+	if($this->overwrite == true){
+		$sql = "UPDATE layer SET ";
+		$sql .= "layer_title = $1, ";
+		$sql .= "layer_abstract = $2 ";
+		$sql .= "WHERE layer_id = $3";
+		
+		$v = array($this->objLayer[$i]->layer_title,$this->objLayer[$i]->layer_abstract, $l_id);
+		$t = array('s','s','i');
+		$res = db_prep_query($sql,$v,$t);
+	}
 	if(!$res){
 		db_rollback();	
 	}
@@ -764,6 +858,9 @@
 	
 	# TABLE layer_style for each layer
 	$this->insertLayerStyle($i);
+	if($this->overwrite == true){
+		$this->insertLayerKeyword($i);
+	}
 }
 function insertGuiLayer($i,$myWMS,$gui_id){
 	# table gui_layer
@@ -855,31 +952,97 @@
 		}
 	}
 }
+function insertLayerKeyword($i){
+	$sql = "DELETE FROM layer_keyword WHERE fkey_layer_id = $1";
+	$v = array($this->objLayer[$i]->db_id);
+	$t = array('s');
+	$res = db_prep_query($sql,$v,$t);
+		
+	$k = $this->objLayer[$i]->layer_keyword;
+	for($j=0; $j<count($k); $j++){
+		$sql = "SELECT keyword_id FROM keyword WHERE keyword = $1";
+		$v = array($this->objLayer[$i]->layer_keyword[$j]);
+		$t = array('s');
+		$res = db_prep_query($sql,$v,$t);
+		if($row = db_fetch_array($res)){
+			$t_layer_id = $row["keyword_id"];	
+		}
+		else if(!$row = db_fetch_array($res)){
+			$sql1 = "INSERT INTO keyword (keyword)";
+			$sql1 .= "VALUES ($1)";
+			$v1 = array($k[$j]);
+			$t1 = array('s');
+			$res1 = db_prep_query($sql1,$v1,$t1);
+			$t_layer_id = db_insert_id($con,'keyword', 'keyword_id');
+			if(!$res1){
+				db_rollback();	
+			}
+		}
+		$sql1 = "INSERT INTO layer_keyword (fkey_keyword_id,fkey_layer_id)";
+		$sql1 .= "VALUES ($1,$2)";
+		$v1 = array($t_layer_id,$this->objLayer[$i]->db_id);
+		$t1 = array('i','i');
+		$res1 = db_prep_query($sql1,$v1,$t1);
+		if(!$res1){
+			db_rollback();	
+		}
+	}
+}
 function updateObjInDB($myWMS){
 	db_begin();
 	
-	# TABLE wms
 	$sql = "UPDATE wms SET ";
 	$sql .= "wms_version = $1 ,";
-	$sql .= "wms_title  = $2 ,";
-	$sql .= "wms_abstract  = $3 ,";
-	$sql .= "wms_getcapabilities  = $4 ,";
-	$sql .= "wms_getmap  = $5 ,";
-	$sql .= "wms_getfeatureinfo  = $6 ,";
-	$sql .= "wms_getlegendurl  = $7 ,";
-	$sql .= "wms_getcapabilities_doc = $8 ,";
-	$sql .= "wms_upload_url = $9 ";
+	$sql .= "wms_getcapabilities  = $2 ,";
+	$sql .= "wms_getmap  = $3 ,";
+	$sql .= "wms_getfeatureinfo  = $4 ,";
+	$sql .= "wms_getlegendurl  = $5 ,";
+	$sql .= "wms_getcapabilities_doc = $6 ,";
+	$sql .= "wms_upload_url = $7,  ";
+	$sql .= "wms_owner = $8, ";
+	$sql .= "wms_timestamp = $9 ";
 	$sql .= " WHERE wms_id = $10";
-	
-	$v = array($this->wms_version,$this->wms_title,$this->wms_abstract,$this->wms_getcapabilities,
+
+	$v = array($this->wms_version,$this->wms_getcapabilities,
 		$this->wms_getmap,$this->wms_getfeatureinfo,$this->wms_getlegendurl,
-		$this->wms_getcapabilities_doc,$this->wms_upload_url,$myWMS);
-	$t = array('s','s','s','s','s','s','s','s','s','i');
+		$this->wms_getcapabilities_doc,$this->wms_upload_url,$_SESSION["mb_user_id"],strtotime("now"),$myWMS);
+	$t = array('s','s','s','s','s','s','s','i','i','i');
+
 	$res = db_prep_query($sql,$v,$t);
 	if(!$res){
 		db_rollback();	
 	}
 	
+	if($this->overwrite == true){
+		$sql = "UPDATE wms SET ";
+		$sql .= "wms_title  = $1 ,";
+		$sql .= "wms_abstract  = $2 ,";
+		$sql .= "fees = $3, ";
+		$sql .= "accessconstraints = $4, ";
+		$sql .= "contactperson = $5, ";
+		$sql .= "contactposition = $6, ";
+		$sql .= "contactorganization = $7, ";
+		$sql .= "address = $8, ";
+		$sql .= "city = $9, ";
+		$sql .= "stateorprovince = $10, ";
+		$sql .= "postcode = $11, ";
+		$sql .= "country = $12, ";
+		$sql .= "contactvoicetelephone = $13, ";
+		$sql .= "contactfacsimiletelephone = $14, ";
+		$sql .= "contactelectronicmailaddress = $15 ";
+		$sql .= " WHERE wms_id = $16";
+	
+		$v = array($this->wms_title,$this->wms_abstract,$this->fees,$this->accessconstraints,
+			$this->contactperson,$this->contactposition,$this->contactorganization,$this->address,
+			$this->city,$this->stateorprovince,$this->postcode,$this->country,$this->contactvoicetelephone,
+			$this->contactfacsimiletelephone,$this->contactelectronicmailaddress,$myWMS);
+		$t = array('s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','i');
+		$res = db_prep_query($sql,$v,$t);
+		if(!$res){
+			db_rollback();	
+		}
+	}
+	
 	# delete and refill srs and formats
 	$sql = "DELETE FROM wms_srs WHERE fkey_wms_id = $1 ";
 	$v = array($myWMS);
@@ -1319,12 +1482,14 @@
 	var $layer_parent;
 	var $layer_name;
 	var $layer_title;
+	var $layer_abstract;
 	var $layer_pos;
 	var $layer_queryable;
 	var $layer_minscale;
 	var $layer_maxscale;	
     var $layer_dataurl_href;
     var $layer_metadataurl;
+    var $layer_keyword = array();
 	var $layer_epsg = array();
 	var $layer_style = array();
 	




More information about the Mapbender_commits mailing list