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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Fri May 27 07:34:20 EDT 2011


Author: armin11
Date: 2011-05-27 04:34:20 -0700 (Fri, 27 May 2011)
New Revision: 7832

Modified:
   trunk/mapbender/http/php/mod_exportISOMetadata.php
   trunk/mapbender/http/php/mod_wmc2ol.php
Log:
Export metadata into folder and possibility for mod_wmc2ol.php to get georss files in different crs than the client is defined.

Modified: trunk/mapbender/http/php/mod_exportISOMetadata.php
===================================================================
--- trunk/mapbender/http/php/mod_exportISOMetadata.php	2011-05-27 10:11:38 UTC (rev 7831)
+++ trunk/mapbender/http/php/mod_exportISOMetadata.php	2011-05-27 11:34:20 UTC (rev 7832)
@@ -27,34 +27,21 @@
 //define the view or table where to read out the layer ids for which metadatafiles should be generated
 $wmsView = "search_wms_view";
 
-if (isset($argv[1])) {
-	if ($argv[1]=='ALL') {
-		
-		$invokedFromCli = true;
-		//command ok
-	} else {
-		echo $argv[0]."\n";
-		echo "Wrong invokation! Workflow terminated!\n";
-		die();
-	}
-} else {
-	//would have been called from web
-	//parse request parameter
-	//make all parameters available as upper case
-	foreach($_REQUEST as $key => $val) {
-		$_REQUEST[strtoupper($key)] = $val;
-	}
-	//validate request params
-	if (!isset($_REQUEST['TYPE'])) {
-		echo 'GET Parameter Type lacks'; 
-		die();
-	}
-	if (isset($_REQUEST['TYPE']) and $_REQUEST['TYPE'] != "ALL") {
-		//
-		echo 'validate: <b>'.$_REQUEST['TYPE'].'</b> is not valid.<br/>'; 
-		die();
-	}
+//would have been called from web
+//parse request parameter
+//make all parameters available as upper case
+foreach($_REQUEST as $key => $val) {
+	$_REQUEST[strtoupper($key)] = $val;
 }
+//validate request params
+if (!isset($_REQUEST['TYPE'])) {
+	echo 'GET Parameter Type lacks'; 
+	die();
+}
+if (isset($_REQUEST['TYPE']) and $_REQUEST['TYPE'] != "ALL") {
+	echo 'validate: <b>'.$_REQUEST['TYPE'].'</b> is not valid.<br/>'; 
+	die();
+}
 
 $sql = "SELECT layer_id ";
 $sql .= "FROM ".$wmsView;
@@ -66,17 +53,30 @@
 $generatorScript = '/mapbender/php/mod_layerISOMetadata.php?';
 $generatorScriptMetadata = '/mapbender/php/mod_dataISOMetadata.php?';
 
-if ($invokedFromCli){
-	$generatorBaseUrl = 'http://localhost/'.$generatorScript;
-	$generatorBaseUrlMetadata = 'http://localhost/'.$generatorScriptMetadata;
-} else {
-	$generatorBaseUrl = 'http://'.$_SERVER['HTTP_HOST'].$generatorScript;
-	$generatorBaseUrlMetadata = 'http://'.$_SERVER['HTTP_HOST'].$generatorScriptMetadata;
-}
+$generatorBaseUrl = 'http://'.$_SERVER['HTTP_HOST'].$generatorScript;
+$generatorBaseUrlMetadata = 'http://'.$_SERVER['HTTP_HOST'].$generatorScriptMetadata;
 
 $countLayer = 0;
 $countMetadataURL = 0;
-
+echo date('Y-m-d - H:i:s', time())."<br>";
+//remove files from METADATA_DIR!
+if ($handle = opendir(METADATA_DIR)) {
+	echo "Delete files from temporary metadata folder:<br>";
+    	/* This is the correct way to loop over the directory. */
+    	while (false !== ($file = readdir($handle))) {
+		//check if file name begin with "mapbender";
+		$pos = strpos($file, "mapbender");
+		if ($pos !== false) {
+			//delete file with unlink
+			unlink(METADATA_DIR."/".$file); 
+			echo METADATA_DIR."/".$file." has been deleted!<br>";
+		} else {
+        		echo "$file will not be deleted!<br>";
+		}
+    	}
+   	closedir($handle);
+}
+echo "Begin to create new metadata: ".date('Y-m-d - H:i:s', time())."<br>";
 while($row = db_fetch_array($res)){
 	$generatorUrl = $generatorBaseUrl."SERVICE=WMS&outputFormat=iso19139&id=".$row['layer_id'];
 	echo "URL requested : ".$generatorUrl."<br>";
@@ -102,7 +102,7 @@
 mb_metadata.metadata_id = relation.fkey_metadata_id WHERE mb_metadata.export2csw = TRUE
 
 SQL;
-	$countMetadataURL = 0;
+	
 	$res_metadata = db_query($sql);
 	while ($row_metadata = db_fetch_array($res_metadata)) {
 		$generatorUrlMetadata = $generatorBaseUrlMetadata."outputFormat=iso19139&id=".$row_metadata['uuid'];
@@ -117,13 +117,12 @@
 			}
 			echo "Data metadate file for layer ".$row['layer_id']." and metadata ".$row_metadata['uuid']." written to ".METADATA_DIR."</BLOCKQUOTE><br>";
 			fclose($h);
+			$countMetadataURL++;	
 		}
-		$countMetadataURL++;	
+		
 	}
 	$countLayer++;
 }
 echo "Number of generated Service Metadata Records (one for each layer): ".$countLayer."<br>";
 echo "Number of generated Data Metadata Records (multiple for each layer): ".$countMetadataURL."<br>";
-
-
-
+echo date('Y-m-d - H:i:s', time())."<br>";

Modified: trunk/mapbender/http/php/mod_wmc2ol.php
===================================================================
--- trunk/mapbender/http/php/mod_wmc2ol.php	2011-05-27 10:11:38 UTC (rev 7831)
+++ trunk/mapbender/http/php/mod_wmc2ol.php	2011-05-27 11:34:20 UTC (rev 7832)
@@ -172,7 +172,7 @@
 		$html.="<title>".$xml->General->Title."</title>\n";
 	}
 	//include OL libs from local source - must be minimized, for new functions use the newest openlayers lib - directly from ol site
-	$e = new mb_exception('georss request : '.$_REQUEST['GEORSS']);
+	$e = new mb_notice('georss request : '.$_REQUEST['GEORSS']);
 	if(isset($_REQUEST["withDigitize"]) or isset($_REQUEST["GEORSS"])){
 		if(($_REQUEST["withDigitize"]=='1') or ($_REQUEST["GEORSS"]!='')){
 			#$html.="<script src='http://".$_SERVER['HTTP_HOST']."/mapbender/extensions/OpenLayers-2.8/OpenLayers.js'></script>\n";
@@ -591,7 +591,25 @@
 						$georssElements = $georssXml->entry[$i]->children('http://www.georss.org/georss');
 						$gmlElements = $georssElements->children('http://www.opengis.net/gml');
 						$coords = explode(" ", $gmlElements->Point->pos);
-					
+						$geoRssEpsg = $gmlElements->Point->attributes()->srsName;
+						$geoRssEpsgId = str_replace('EPSG:','',$geoRssEpsg);
+						//transform coordinates if other epsg was choosen
+						if ($geoRssEpsgId != $xml_epsg){
+							//coords have to be transformed
+							$sql= "select asewkt(transform(GeometryFromText ( 'POINT ( ";
+							$sql .= $coords[0]." ".$coords[1]." )',". $geoRssEpsgId ."),".intval($xml_epsg)."))";
+							//select asewkt(transform(GeometryFromText ( 'POINT ( 7 50 )', 4326 ),31466));
+							$e = new mb_notice("mod_wms2ol.php: sql (transform)=".$sql);
+							$res = db_query($sql);
+							//read out result
+							$pointNew = db_fetch_row($res);
+							$e = new mb_notice("mod_wms2ol.php: pointNew=".$pointNew[0]);
+							$pattern = '~POINT\((.*)\)~i';
+							preg_match($pattern, $pointNew[0], $subpattern);
+							$e = new mb_notice("mod_wms2ol.php: subpattern=".$subpattern[1]);
+							$coords = explode(' ',$subpattern[1]);
+						}
+						
 						$html.="	var point = new OpenLayers.Geometry.Point(";
 						$html.="".$coords[0].",".$coords[1].");\n";
 						$html.="	pointFeatures[".$i."] = new OpenLayers.Feature.Vector(point, {title: \"".$georssXml->entry[$i]->title."\", description : \"".str_replace("\"", "'",$georssXml->entry[$i]->content)."\", link : \"".$georssXml->entry[$i]->link->attributes()->href."\"});\n";	



More information about the Mapbender_commits mailing list