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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue Nov 14 08:33:02 PST 2017


Author: armin11
Date: 2017-11-14 08:33:02 -0800 (Tue, 14 Nov 2017)
New Revision: 9816

Modified:
   trunk/mapbender/http/php/mod_inspireDownloadFeed.php
Log:
Enhancement for INSPIRE ATOM Feed generator - support of new unique resource identifier

Modified: trunk/mapbender/http/php/mod_inspireDownloadFeed.php
===================================================================
--- trunk/mapbender/http/php/mod_inspireDownloadFeed.php	2017-11-14 15:46:40 UTC (rev 9815)
+++ trunk/mapbender/http/php/mod_inspireDownloadFeed.php	2017-11-14 16:33:02 UTC (rev 9816)
@@ -697,69 +697,42 @@
 	//Handle CRS - maybe in 'urn:ogc:def:crs:EPSG:6.9:4326' or 'EPSG:4326' or 'epsg:4326' or 'urn:ogc:def:crs:EPSG::4326' format!
 	//*********************** New use crs class for checking if the order has to be changed in the filter!!!
 	$crsObject = new Crs($crs);
-	if ($crsObject->alterAxisOrder("wms"."_".$mapbenderMetadata[$i]->wms_version) == true) {
+	if ($crsObject->alterAxisOrder("wms"."_".$mapbenderMetadata[$m]->wms_version) == true) {
 		$alterAxisOrder = true;
 	} else {
 		$alterAxisOrder = false;
 	}
 	//**************************************************************************************
 	$epsgId = $crsObject->identifierCode;
-
-
-	//TODO test this also in sqls from mapbenders database - see wms 1.3.0 - for layer metadata
-	//explode strings
-	//alter all to uppercase 
-
-
-
-
-	/*$crsUpper = str_replace("epsg","EPSG",$crs);
-	//explode strings
-	$crsUpperArray = explode(":",$crsUpper);
-	switch (count($crsUpperArray)) {
-		case 7:
-			$epsgId = $crsUpperArray[6];
-		break;
-		case 2:
-			$epsgId = $crsUpperArray[1];
-		break;	
+	//**************************************************************************************
+	switch ($generateFrom) {
+		case "wmslayer":
+			$serviceType = "wms";
+			$serviceId = $mapbenderMetadata[$m]->fkey_wms_id;
+			$ownerId = $mapbenderMetadata[$m]->wms_owner;
+			break;
+		case "wfs":
+			$serviceType = "wfs";
+			$serviceId = $mapbenderMetadata[$m]->wfs_id;
+			$ownerId = $mapbenderMetadata[$m]->wfs_owner;
+			break;
+		case "dataurl":
+			$serviceType = "wms";
+			$serviceId = $mapbenderMetadata[$m]->fkey_wms_id;
+			$ownerId = $mapbenderMetadata[$m]->wms_owner;
+			break;
+		case "metadata":
+			$serviceType = "metadata";
+			$serviceId = $mapbenderMetadata[$m]->metadata_id;
+			$ownerId = $mapbenderMetadata[$m]->md_owner;
+			break;
+		default:
+			break;
 	}
-	//check if order have to be altered
-	if (strpos($crsUpper,'urn') !== false) {
-		//check if axis order should be changed 
-		if (check_epsg_wms_13($epsgId)) {
-			//alter order of axis for 4326
-			$alterAxisOrder = true;
-		} else {
-			$alterAxisOrder = false;	
-		}
-	}*/
-	//infos about the registrating department, check first if a special metadata point of contact is defined in the service table - function from mod_showMetadata - TODO: should be defined in admin class
-	if (!isset($mapbenderMetadata[$m]->fkey_mb_group_id) or is_null($mapbenderMetadata[$m]->fkey_mb_group_id) or $mapbenderMetadata[$m]->fkey_mb_group_id == 0){
-		$e = new mb_exception("mod_inspireDownloadFeed.php: fkey_mb_group_id not found!");
-		//Get information about owning user of the relation mb_user_mb_group - alternatively the defined fkey_mb_group_id from the service must be used!
-		$sqlDep = "SELECT mb_group_name, mb_group_title, mb_group_id, mb_group_logo_path, mb_group_address, mb_group_email, mb_group_postcode, mb_group_city, mb_group_voicetelephone, mb_group_facsimiletelephone, a.timestamp FROM mb_group AS a, mb_user AS b, mb_user_mb_group AS c WHERE b.mb_user_id = $1  AND b.mb_user_id = c.fkey_mb_user_id AND c.fkey_mb_group_id = a.mb_group_id AND c.mb_user_mb_group_type=2 LIMIT 1";
-		if ($generateFrom != "wfs") {
-			$vDep = array($mapbenderMetadata[$m]->wms_owner);
-		} else {
-			$vDep = array($mapbenderMetadata[$m]->wfs_owner);
-		}
-
-		$tDep = array('i');
-		$resDep = db_prep_query($sqlDep, $vDep, $tDep);
-		$departmentMetadata = db_fetch_array($resDep);
-	} else {
-		$e = new mb_exception("mod_inspireDownloadFeed.php: fkey_mb_group_id found!");
-		$sqlDep = "SELECT mb_group_name , mb_group_title, mb_group_id, mb_group_logo_path , mb_group_address, mb_group_email, mb_group_postcode, mb_group_city, mb_group_voicetelephone, mb_group_facsimiletelephone, timestamp FROM mb_group WHERE mb_group_id = $1 LIMIT 1";
-		$vDep = array($mapbenderMetadata[$m]->fkey_mb_group_id);
-		$tDep = array('i');
-		$resDep = db_prep_query($sqlDep, $vDep, $tDep);
-		$departmentMetadata = db_fetch_array($resDep);
-	}
-
-	//infos about the owner of the service - he is the man who administrate the metadata - register the service
-	$sql = "SELECT mb_user_email, timestamp ";
-	$sql .= "FROM mb_user WHERE mb_user_id = $1";
+	$departmentMetadata = $admin->getOrgaInfoFromRegistry($serviceType, $serviceId, $ownerId);
+	$userMetadata['mb_user_email'] = $departmentMetadata['mb_user_email'];
+	$userMetadata['timestamp'] = $departmentMetadata['mb_user_timestamp'];
+	//**************************************************************************************
 	switch ($generateFrom) {
 		case "wmslayer":
 			$v = array($mapbenderMetadata[$m]->wms_owner);
@@ -779,10 +752,6 @@
 			$hasPermission = true;
 		break;
 	}
-	$t = array('i');
-	$res = db_prep_query($sql,$v,$t);
-	$userMetadata = db_fetch_array($res);
-	
 	//check if resource is freely available to anonymous user - which are all users who search thru metadata catalogues:
 	/*if ($generateFrom != "wfs") {
 		$hasPermission=$admin->getLayerPermission($mapbenderMetadata[$m]->fkey_wms_id,$mapbenderMetadata[$m]->layer_name,PUBLIC_USER);
@@ -869,10 +838,18 @@
 	}
 	$feed->setAttribute("xmlns:lang", "de");
 	//echo "<test>".$mapbenderMetadata['fkey_wms_id'].":".$mapbenderMetadata['wms_owner']."</test>";
+
+	//pull the namespace from database
+	$metadataArray['datasetid_codespace'] = $mapbenderMetadata[$m]->datasetid_codespace;
+	$uniqueResourceIdentifierCodespace = $admin->getIdentifierCodespaceFromRegistry($departmentMetadata, $metadataArray);
+
+	//overwrite datasetid_codespace
+	$mapbenderMetadata[$m]->datasetid_codespace = $uniqueResourceIdentifierCodespace;
+
 	//qualifying id of the referenced ressource: Either dataset id or the id of the metadata record 
-	if (isset($mapbenderMetadata[$m]->datasetid) && $mapbenderMetadata[$m]->datasetid != '' ) {
+	/*if (isset($mapbenderMetadata[$m]->datasetid) && $mapbenderMetadata[$m]->datasetid != '' ) {
 		$ressourceId = $mapbenderMetadata[$m]->datasetid_codespace."#".$mapbenderMetadata[$m]->datasetid;
-	}
+	}*/
 
 	//check if the metadata set has a title and abstract if not given (in case of dataurl, use layer information!)
 	//first use metadata title then layer title
@@ -1923,10 +1900,14 @@
 		$mapbenderMetadata[$indexMapbenderMetadata]->format = $row['format'];
 		$mapbenderMetadata[$indexMapbenderMetadata]->md_timestamp = $row['md_timestamp'];
 		//check if codespace was given in metadata or it must be generated from uuid and default codespace
-		if (($mapbenderMetadata[$indexMapbenderMetadata]->datasetid_codespace == '' or !isset($mapbenderMetadata[$indexMapbenderMetadata]->datasetid_codespace)) or ($mapbenderMetadata[$indexMapbenderMetadata]->datasetid == '' or !isset($mapbenderMetadata[$indexMapbenderMetadata]->datasetid))) {
+		/*if (($mapbenderMetadata[$indexMapbenderMetadata]->datasetid_codespace == '' or !isset($mapbenderMetadata[$indexMapbenderMetadata]->datasetid_codespace)) or ($mapbenderMetadata[$indexMapbenderMetadata]->datasetid == '' or !isset($mapbenderMetadata[$indexMapbenderMetadata]->datasetid))) {
 			//generate one:
 			$mapbenderMetadata[$indexMapbenderMetadata]->datasetid_codespace = METADATA_DEFAULT_CODESPACE;
 			$mapbenderMetadata[$indexMapbenderMetadata]->datasetid = $mapbenderMetadata[$indexMapbenderMetadata]->metadata_uuid;
+		}*/
+		if ($mapbenderMetadata[$indexMapbenderMetadata]->datasetid == '' or !isset($mapbenderMetadata[$indexMapbenderMetadata]->datasetid)) {
+			//generate one:
+			$mapbenderMetadata[$indexMapbenderMetadata]->datasetid = $mapbenderMetadata[$indexMapbenderMetadata]->metadata_uuid;
 		}
 		//$e = new mb_exception("test");
 		//overwrite some elements if the feed should be generated from metadata itself: access constraints, use limitations, ...
@@ -2018,10 +1999,14 @@
 
 				//$mapbenderMetadata[$indexMapbenderMetadata]->format = $row['format'];
 				//check if codespace was given in metadata or it must be generated from uuid and default codespace
-				if (($mapbenderMetadata[$indexMapbenderMetadata]->datasetid_codespace == '' or !isset($mapbenderMetadata[$indexMapbenderMetadata]->datasetid_codespace)) or ($mapbenderMetadata[$indexMapbenderMetadata]->datasetid == '' or !isset($mapbenderMetadata[$indexMapbenderMetadata]->datasetid))) {
+				/*if (($mapbenderMetadata[$indexMapbenderMetadata]->datasetid_codespace == '' or !isset($mapbenderMetadata[$indexMapbenderMetadata]->datasetid_codespace)) or ($mapbenderMetadata[$indexMapbenderMetadata]->datasetid == '' or !isset($mapbenderMetadata[$indexMapbenderMetadata]->datasetid))) {
 					//generate one:
 					$mapbenderMetadata[$indexMapbenderMetadata]->datasetid_codespace = METADATA_DEFAULT_CODESPACE;
 					$mapbenderMetadata[$indexMapbenderMetadata]->datasetid = $mapbenderMetadata[$indexMapbenderMetadata]->metadata_uuid;
+				}*/
+				if ($mapbenderMetadata[$indexMapbenderMetadata]->datasetid == '' or !isset($mapbenderMetadata[$indexMapbenderMetadata]->datasetid)) {
+					//generate one:
+					$mapbenderMetadata[$indexMapbenderMetadata]->datasetid = $mapbenderMetadata[$indexMapbenderMetadata]->metadata_uuid;
 				}
 				if ($generateFrom == "wfs" or $mapbenderMetadata[$indexMapbenderMetadata]->origin == "wfs") {
 					$latlonbbox = explode(",",$mapbenderMetadata[$indexMapbenderMetadata]->latlonbbox);



More information about the Mapbender_commits mailing list