[Mapbender-commits] r9044 - trunk/mapbender/http/classes

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue Aug 12 05:01:12 PDT 2014


Author: armin11
Date: 2014-08-12 05:01:12 -0700 (Tue, 12 Aug 2014)
New Revision: 9044

Modified:
   trunk/mapbender/http/classes/class_wfs.php
   trunk/mapbender/http/classes/class_wfsToDb.php
   trunk/mapbender/http/classes/class_wfs_1_1_factory.php
   trunk/mapbender/http/classes/class_wfs_2_0_factory.php
   trunk/mapbender/http/classes/class_wfs_factory.php
   trunk/mapbender/http/classes/class_wfs_featuretype.php
Log:
Enhancement to handle different outputFormats of WFS - implemented for WFS 1.1.0 - todo for 2.0 and maybe 1.0.0 - if supported

Modified: trunk/mapbender/http/classes/class_wfs.php
===================================================================
--- trunk/mapbender/http/classes/class_wfs.php	2014-08-12 12:00:11 UTC (rev 9043)
+++ trunk/mapbender/http/classes/class_wfs.php	2014-08-12 12:01:12 UTC (rev 9044)
@@ -35,6 +35,7 @@
 	var $getFeature;
 	var $transaction;
 	var $overwrite = true;
+	var $wfsOutputFormatArray = array();
 	var $featureTypeArray = array();
 	var $operationsArray = array();
 	var $storedQueriesArray = array();

Modified: trunk/mapbender/http/classes/class_wfsToDb.php
===================================================================
--- trunk/mapbender/http/classes/class_wfsToDb.php	2014-08-12 12:00:11 UTC (rev 9043)
+++ trunk/mapbender/http/classes/class_wfsToDb.php	2014-08-12 12:01:12 UTC (rev 9044)
@@ -118,7 +118,15 @@
 				return false;
 			}
 		}
-		
+		//TODO Insert outputFormats
+		for ($i = 0; $i < count($aWfs->wfsOutputFormatArray); $i++) {
+			$currentOutputFormat = $aWfs->wfsOutputFormatArray[$i];
+			if (!WfsToDb::insertOutputFormat($aWfs->id, $currentOutputFormat)) {
+				db_rollback();
+				return false;
+			}
+		}
+
 		// Insert the feature types
 		for ($i = 0; $i < count($aWfs->featureTypeArray); $i++) {
 			$currentFeatureType = $aWfs->featureTypeArray[$i];
@@ -231,7 +239,7 @@
 			return false;
 		}
 		
-		# delete and refill WFS operations
+		// delete and refill WFS operations
 		$sql = "DELETE FROM wfs_operation WHERE fkey_wfs_id = $1 ";
 		$v = array($aWfs->id);
 		$t = array('i');
@@ -239,7 +247,7 @@
 		if(!$res){
 			db_rollback();
 		}
-		for ($i = 1; $i < count($aWfs->operationsArray); $i++) {
+		for ($i = 0; $i < count($aWfs->operationsArray); $i++) {
 			$currentOp = $aWfs->operationsArray[$i];
 			if (!WfsToDb::insertOperation($aWfs->id, $currentOp)) {
 				db_rollback();
@@ -247,6 +255,22 @@
 			}
 		}
 	
+		// delete and refill WFS outputFormats
+		$sql = "DELETE FROM wfs_output_formats WHERE fkey_wfs_id = $1 ";
+		$v = array($aWfs->id);
+		$t = array('i');
+		$res = db_prep_query($sql,$v,$t);
+		if(!$res){
+			db_rollback();
+		}
+		for ($i = 0; $i < count($aWfs->wfsOutputFormatArray); $i++) {
+			$currentOutputFormat = $aWfs->wfsOutputFormatArray[$i];
+			if (!WfsToDb::insertOutputFormat($aWfs->id, $currentOutputFormat)) {
+				db_rollback();
+				return false;
+			}
+		}
+
 		if ($updateMetadataOnly) {
 			# delete and refill wfs_termsofuse
 			$sql = "DELETE FROM wfs_termsofuse WHERE fkey_wfs_id = $1 ";
@@ -517,6 +541,33 @@
 	}
 
 	/**
+	 * Inserts a new WFS feature type outputFormat into the database.
+	 * 
+	 * @return Boolean
+	 * @param $aWfsFeatureTypeId Integer
+	 * @param $aWfsFeatureTypeOutputFormat String
+	 */
+	private static function insertFeatureTypeOutputFormat ($aWfsFeatureTypeId, $aWfsFeatureTypeOutputFormatString) {
+		$sql = "INSERT INTO wfs_featuretype_output_formats (fkey_featuretype_id, output_format) VALUES ($1, $2)";
+		
+		$v = array(
+			$aWfsFeatureTypeId, 
+			$aWfsFeatureTypeOutputFormatString
+		);
+		$t = array("i", "s");
+		
+		$e = new mb_notice("class_wfsToDb.php: INSERTING Featuretype outputFormat (FT: $aWfsFeatureTypeId, outputFormat: $aWfsFeatureTypeOutputFormatString");
+		$res = db_prep_query($sql, $v, $t);
+		
+		if (!$res) {
+			$e = new mb_exception("Error while inserting WFS featuretype outputFormat into the database.");
+			return false;
+		}
+		
+		return true;
+	}
+
+	/**
 	 * Inserts a new WFS feature type MetadataURL into the database.
 	 * 
 	 * @return Boolean
@@ -704,6 +755,32 @@
 	}
 	
 	/**
+	 * Inserts a new WFS outputFormat into the database.
+	 *
+	 * @return Boolean
+	 * @param $aWfsOutputFormat string
+	 */
+	private static function insertOutputFormat ($aWfsId, $aWfsOutputFormat) {
+		$sql = "INSERT INTO wfs_output_formats (fkey_wfs_id, output_format) " .
+				"VALUES($1, $2)";
+	
+		$v = array(
+				$aWfsId,
+				$aWfsOutputFormat
+		);
+		$t = array('i','s');
+	
+		$res = db_prep_query($sql,$v,$t);
+		if (!$res) {
+			$e = new mb_exception("Error while inserting WFS outputFormat into database.");
+			return false;
+		}
+	
+		return true;
+	}
+
+
+	/**
 	 * Inserts a new WFS StoredQuery as wfs conf into the database.
 	 *
 	 * @return Boolean
@@ -1089,6 +1166,15 @@
 				return false;	
 			}
 		}
+
+		// insert feature type outputFormats
+		for ($i = 0; $i < count($aWfsFeatureType->featuretypeOutputFormatArray); $i++) {
+			$outputFormat = $aWfsFeatureType->featuretypeOutputFormatArray[$i];
+			if (!WfsToDb::insertFeatureTypeOutputFormat($aWfsFeatureType->id, $outputFormat)) {
+				return false;	
+			}
+		}
+
 		// insert feature type MetadataURL
 		$e = new mb_notice("Number of metadataurls for featuretype ".$aWfsFeatureType->id." : ".count($aWfsFeatureType->metadataUrlArray));
 		for ($i = 0; $i < count($aWfsFeatureType->metadataUrlArray); $i++) {
@@ -1191,7 +1277,7 @@
 			}
 		}		
 		
-		// delete obsolete WFS feature type elements
+		// delete obsolete WFS featuretype elements
 		$v = array($aWfsFeatureType->id);
 		$t = array("i");
 		$sql = "DELETE FROM wfs_element WHERE fkey_featuretype_id = $1";
@@ -1210,7 +1296,7 @@
 
 		$res = db_prep_query($sql,$v,$t);
 		if (!$res) {
-			$e = new mb_exception("Error while deleting obsolete WFS feature type element in database.");
+			$e = new mb_exception("Error while deleting obsolete WFS featuretype element in database.");
 			return false;
 		}
 
@@ -1301,6 +1387,18 @@
 					return false;	
 				}
 			}
+			//delete and refill outputFormats
+			$sql = "DELETE FROM wfs_featuretype_output_formats WHERE fkey_featuretype_id = $1";
+			$v = array($aWfsFeatureType->id);
+			$t = array('i');
+			$res = db_prep_query($sql,$v,$t);
+			//insert current outputFormats
+			for ($i = 0; $i < count($aWfsFeatureType->featuretypeOutputFormatArray); $i++) {
+				$outputFormat = $aWfsFeatureType->featuretypeOutputFormatArray[$i];
+				if (!WfsToDb::insertFeatureTypeOutputFormat($aWfsFeatureType->id, $outputFormat)) {
+					return false;	
+				}
+			}
 		}
 		if ($overwrite) {
 			// update keywords

Modified: trunk/mapbender/http/classes/class_wfs_1_1_factory.php
===================================================================
--- trunk/mapbender/http/classes/class_wfs_1_1_factory.php	2014-08-12 12:00:11 UTC (rev 9043)
+++ trunk/mapbender/http/classes/class_wfs_1_1_factory.php	2014-08-12 12:01:12 UTC (rev 9044)
@@ -273,9 +273,14 @@
 				$myWfs->transaction = $wfs11Cap->xpath('/wfs:WFS_Capabilities/ows:OperationsMetadata/ows:Operation[@name="Transaction"]/ows:DCP/ows:HTTP/ows:Post/@xlinkhref');
 				$myWfs->transaction = html_entity_decode($myWfs->transaction[0]);#post
 
+				//get supported formats [mimetypes]
+				$myWfs->wfsOutputFormatArray = $wfs11Cap->xpath('/wfs:WFS_Capabilities/ows:OperationsMetadata/ows:Operation[@name="GetFeature"]/ows:Parameter[@name="outputFormat"]/ows:Value');
+				//debug:
+				/*foreach($myWfs->wfsOutputFormatArray as $outputFormat){
+					$e = new mb_exception("class_wfs_1_1_factory.php: wfs outputFormat: ".$outputFormat);
+				}*/
 
 				//get list of featuretypes
-				
 				$capFeatureTypes = $wfs11Cap->xpath('/wfs:WFS_Capabilities/wfs:FeatureTypeList/wfs:FeatureType');
 				$i = 1; //cause index of xml objects begin with 1
 				foreach ($capFeatureTypes as $featureType) {
@@ -304,6 +309,15 @@
 						$featuretype_crsArray[] = $otherSRS;
 						
 					}
+					//outputFormats
+					/*<OutputFormats><Format>text/xml; subtype=gml/3.1.1</Format></OutputFormats>*/
+					$featuretypeOutputFormats = array();
+					$outputFormats = $featureType->OutputFormats->Format;
+					foreach ($outputFormats as $outputFormat) {
+						$featuretypeOutputFormats[] = $outputFormat;
+						$e = new mb_exception("class_wfs_1_1_factory.php: add outputFormat for WFS: ".$outputFormat);
+					}
+
 					//<wfs:MetadataURL type="FGDC" format="text/xml">http://www.ogccatservice.com/csw.cgi?service=CSW&version=2.0.0&request=GetRecords&constraintlanguage=CQL&constraint="recordid=urn:uuid:4ee8b2d3-9409-4a1d-b26b-6782e4fa3d59"</wfs:MetadataURL>
 					$metadataURLArray = $featureType->MetadataURL;
 					$featuretype_metadataUrl = array();
@@ -344,6 +358,7 @@
 							$currentFeatureType->latLonBboxArray['maxx'] = $featuretype_latlon_maxx;
 							$currentFeatureType->latLonBboxArray['maxy'] = $featuretype_latlon_maxy;
 							$currentFeatureType->crsArray = $featuretype_crsArray;
+							$currentFeatureType->featuretypeOutputFormatArray = $featuretypeOutputFormats;
 							$currentFeatureType->metadataUrlArray = $featuretype_metadataUrl;
 							$myWfs->addFeatureType($currentFeatureType);
 						}

Modified: trunk/mapbender/http/classes/class_wfs_2_0_factory.php
===================================================================
--- trunk/mapbender/http/classes/class_wfs_2_0_factory.php	2014-08-12 12:00:11 UTC (rev 9043)
+++ trunk/mapbender/http/classes/class_wfs_2_0_factory.php	2014-08-12 12:01:12 UTC (rev 9044)
@@ -379,7 +379,6 @@
 
 
 				//Operation Metadata Part
-
 				$myWfs->getCapabilities = $wfs20Cap->xpath('/wfs:WFS_Capabilities/ows:OperationsMetadata/ows:Operation[@name="GetCapabilities"]/ows:DCP/ows:HTTP/ows:Get/@xlinkhref');
 				$myWfs->getCapabilities = html_entity_decode($myWfs->getCapabilities[0]);
 				$e = new mb_notice($myWfs->getCapabilities);#get
@@ -395,7 +394,6 @@
 
 
 				//get list of featuretypes
-				
 				$capFeatureTypes = $wfs20Cap->xpath('/wfs:WFS_Capabilities/wfs:FeatureTypeList/wfs:FeatureType');
 				$i = 1; //cause index of xml objects begin with 1
 				foreach ($capFeatureTypes as $featureType) {

Modified: trunk/mapbender/http/classes/class_wfs_factory.php
===================================================================
--- trunk/mapbender/http/classes/class_wfs_factory.php	2014-08-12 12:00:11 UTC (rev 9043)
+++ trunk/mapbender/http/classes/class_wfs_factory.php	2014-08-12 12:01:12 UTC (rev 9044)
@@ -121,6 +121,15 @@
 			} else {
 				$aWfs->auth = false;
 			}
+			// pull outputFormats
+			$sql_of = "SELECT * FROM wfs_output_formats WHERE fkey_wfs_id = $1";
+			$v = array($aWfs->id);
+			$t = array("i");
+			$res_of = db_prep_query($sql_of, $v, $t);
+			while($row = db_fetch_array($res_of)){
+				$aWfs->wfsOutputFormatArray[] = $row["output_format"];
+			}
+			
 			// Featuretypes
 			$sql_fe = "SELECT * FROM wfs_featuretype WHERE fkey_wfs_id = $1 ORDER BY featuretype_id";
 			$v = array($aWfs->id);
@@ -180,7 +189,20 @@
 					);
 					$cnt_crs++;
 				}
+				// outputFormats
+				$sql_outputformats = "SELECT output_format FROM wfs_featuretype_output_formats WHERE fkey_featuretype_id = $1";
+				$v = array($this->featureTypeArray[$fe_cnt]->id);
+				$t = array("i");
+				$res_outputformats = db_prep_query($sql_outputformats, $v, $t);
+				$cnt_outputformats = 0;
+				while(db_fetch_row($res_outputformats)){
+					$this->featureTypeArray[$fe_cnt]->addOutputFormat(
+							db_result($res_outputformats, $cnt_outputformats, "output_format")
+					);
+					$cnt_outputformats++;
+				}
 				
+				//
 				### read out keywords
 				$sql = "SELECT keyword FROM keyword, wfs_featuretype_keyword WHERE keyword_id = fkey_keyword_id AND fkey_featuretype_id = $1";
 				$v = array($this->featureTypeArray[$fe_cnt]->id);

Modified: trunk/mapbender/http/classes/class_wfs_featuretype.php
===================================================================
--- trunk/mapbender/http/classes/class_wfs_featuretype.php	2014-08-12 12:00:11 UTC (rev 9043)
+++ trunk/mapbender/http/classes/class_wfs_featuretype.php	2014-08-12 12:01:12 UTC (rev 9044)
@@ -40,6 +40,7 @@
 	var $featuretype_md_topic_category_id = array();
 	var $featuretype_inspire_category_id = array();
 	var $featuretype_custom_category_id = array();
+	var $featuretypeOutputFormatArray = array();
 
 	public function __construct ($aWfs) {
 		$this->wfs = $aWfs;
@@ -88,8 +89,12 @@
 		array_push($this->metadataUrlArray, $metadataUrl);
 		return $this;
 	}
-	
 
+	public function addOutputFormat ($outputFormat) {
+		array_push($this->featuretypeOutputFormatArray, $outputFormat);
+		return $this;
+	}
+
 	public function addElement ($name, $type) {
 		$newElement = new stdClass();
 



More information about the Mapbender_commits mailing list