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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue May 10 15:27:37 EDT 2011


Author: armin11
Date: 2011-05-10 12:27:37 -0700 (Tue, 10 May 2011)
New Revision: 7810

Modified:
   trunk/mapbender/http/php/mod_dataISOMetadata.php
   trunk/mapbender/http/php/mod_layerISOMetadata.php
Log:
some fixing

Modified: trunk/mapbender/http/php/mod_dataISOMetadata.php
===================================================================
--- trunk/mapbender/http/php/mod_dataISOMetadata.php	2011-05-10 13:45:26 UTC (rev 7809)
+++ trunk/mapbender/http/php/mod_dataISOMetadata.php	2011-05-10 19:27:37 UTC (rev 7810)
@@ -566,7 +566,7 @@
 		$MD_Keywords->appendChild($keyword);
 	}
 	//pull special keywords from custom categories:
-	$e = new mb_exception("layer: ".$layerId);	
+	$e = new mb_notice("layer: ".$layerId);	
 
 	$sql = "SELECT custom_category.custom_category_key FROM custom_category, layer_custom_category WHERE layer_custom_category.fkey_layer_id = $1 AND layer_custom_category.fkey_custom_category_id =  custom_category.custom_category_id AND custom_category_hidden = 0";
 	$v = array((integer)$layerId);
@@ -583,7 +583,7 @@
 		$MD_Keywords->appendChild($keyword);
 		$countCustom++;
 	}
-	$e = new mb_exception("count custom categories: ".$countCustom);
+	$e = new mb_notice("count custom categories: ".$countCustom);
 	//read out the inspire categories and push them in as controlled keywords
 /* example
 <gmd:keyword><gco:CharacterString>Geographical names</gco:CharacterString></gmd:keyword><gmd:thesaurusName><gmd:CI_Citation><gmd:title><gco:CharacterString>GEMET - INSPIRE themes, version 1.0</gco:CharacterString></gmd:title><gmd:date><gmd:CI_Date><gmd:date><gco:Date>2008-06-01</gco:Date></gmd:date><gmd:dateType><gmd:CI_DateTypeCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#CI_DateTypeCode" codeListValue="publication">publication</gmd:CI_DateTypeCode></gmd:dateType></gmd:CI_Date></gmd:date></gmd:CI_Citation></gmd:thesaurusName></gmd:MD_Keywords></gmd:descriptiveKeywords><gmd:descriptiveKeywords><gmd:MD_Keywords><gmd:keyword><gco:CharacterString>BasisDLM</gco:CharacterString></gmd:keyword>	

Modified: trunk/mapbender/http/php/mod_layerISOMetadata.php
===================================================================
--- trunk/mapbender/http/php/mod_layerISOMetadata.php	2011-05-10 13:45:26 UTC (rev 7809)
+++ trunk/mapbender/http/php/mod_layerISOMetadata.php	2011-05-10 19:27:37 UTC (rev 7810)
@@ -18,6 +18,8 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
+//Script to generate a conformant ISO19139 service metadata record for a wms layer which is registrated in the mapbender database. It works as a webservice
+//The record will be fulfill the demands of the INSPIRE metadata regulation from 03.12.2008
 require_once(dirname(__FILE__) . "/../../core/globalSettings.php");
 require_once(dirname(__FILE__) . "/../classes/class_connector.php");
 require_once(dirname(__FILE__) . "/../classes/class_administration.php");
@@ -27,7 +29,7 @@
 
 $admin = new administration();
 
-//define the view or table to use as input for metadata generation if this is wished. If not the data will be directly read from the database tables
+//define the view or table to use as input for metadata generation if this is wished. If not, the data will be directly read from the database tables
 $wmsView = "wms_search_table";
 $wmsView = '';
 //parse request parameter
@@ -116,6 +118,7 @@
 		$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 ";
 	$sql .= "FROM mb_user WHERE mb_user_id = $1";
@@ -123,12 +126,12 @@
 	$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:
-	$hasPermission=$admin->getLayerPermission($mapbenderMetadata['wms_id'],$mapbenderMetadata['layer_name'],ANONYMOUS_USER);
-	//Creating the "MD_Metadata" node
+	$hasPermission=$admin->getLayerPermission($mapbenderMetadata['wms_id'],$mapbenderMetadata['layer_name'],PUBLIC_USER);
+
+	//Creating the central "MD_Metadata" node
 	$MD_Metadata = $iso19139->createElementNS('http://www.isotc211.org/2005/gmd', 'gmd:MD_Metadata');
-	//$MD_Metadata=$iso19139->registerNamespace('srv','http://www.iso211.org/2005/srv');
-	//$wmt_ms_capabilities->setAttribute("updateSequence", $wms_row["wms_timestamp"]);
 	$MD_Metadata = $iso19139->appendChild($MD_Metadata);
 	$MD_Metadata->setAttribute("xmlns:srv", "http://www.isotc211.org/2005/srv");
 	$MD_Metadata->setAttribute("xmlns:gml", "http://www.opengis.net/gml");
@@ -136,11 +139,12 @@
 	$MD_Metadata->setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
 	$MD_Metadata->setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
 	$MD_Metadata->setAttribute("xsi:schemaLocation", "http://www.isotc211.org/2005/gmd ./xsd/gmd/gmd.xsd://www.isotc211.org/2005/srv ./xsd/srv/srv.xsd");
+
 	//generate identifier part 
 	$identifier = $iso19139->createElement("gmd:fileIdentifier");
 	$identifierString = $iso19139->createElement("gco:CharacterString");
 	if (isset($mapbenderMetadata['uuid'])) {
-		$identifierText = $iso19139->createTextNode($mapbenderMetadata['uuid']);//TODO: generate an uuid?
+		$identifierText = $iso19139->createTextNode($mapbenderMetadata['uuid']);
 	}
 	else {
 		$identifierText = $iso19139->createTextNode("no id found");
@@ -148,6 +152,7 @@
 	$identifierString->appendChild($identifierText);
 	$identifier->appendChild($identifierString);
 	$MD_Metadata->appendChild($identifier);
+
 	//generate language part B 10.3 (if available) of the inspire metadata regulation
 	$language = $iso19139->createElement("gmd:language");
 	$languagecode = $iso19139->createElement("gmd:LanguageCode");
@@ -171,8 +176,6 @@
 	$characterSet->appendChild($characterSetCode);
 	$characterSet = $MD_Metadata->appendChild($characterSet);
 
-
-
 	#generate MD_Scope part B 1.3 (if available)
 	$hierarchyLevel = $iso19139->createElement("gmd:hierarchyLevel");
 	$scopecode = $iso19139->createElement("gmd:MD_ScopeCode");
@@ -188,6 +191,7 @@
 	$scopecode->appendChild($scopeText);
 	$hierarchyLevel->appendChild($scopecode);
 	$hierarchyLevel=$MD_Metadata->appendChild($hierarchyLevel);
+
 	#Part B 10.1 responsible party for the resource
 	$contact=$iso19139->createElement("gmd:contact");
 	$CI_ResponsibleParty=$iso19139->createElement("gmd:CI_ResponsibleParty");
@@ -219,6 +223,7 @@
 	$CI_RoleCode->setAttribute("codeList", "http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#CI_RoleCode");
 	$CI_RoleCode->setAttribute("codeListValue", "pointOfContact");
 	$CI_RoleCodeText=$iso19139->createTextNode("pointOfContact");
+
 	#create xml tree
 	$organisationName_cs->appendChild($organisationNameText);
 	$organisationName->appendChild($organisationName_cs);
@@ -235,6 +240,7 @@
 	$CI_ResponsibleParty->appendChild($role);
 	$contact->appendChild($CI_ResponsibleParty);
 	$MD_Metadata->appendChild($contact);
+
 	#generate dateStamp part B 10.2 (if available)
 	$dateStamp = $iso19139->createElement("gmd:dateStamp");
 	$mddate = $iso19139->createElement("gco:Date");
@@ -247,6 +253,7 @@
 	$mddate->appendChild($mddateText);
 	$dateStamp->appendChild($mddate);
 	$dateStamp=$MD_Metadata->appendChild($dateStamp);
+
 	//standard definition - everytime the same
 	$metadataStandardName = $iso19139->createElement("gmd:metadataStandardName");
 	$metadataStandardVersion = $iso19139->createElement("gmd:metadataStandardVersion");
@@ -260,16 +267,17 @@
 	$metadataStandardVersion->appendChild($metadataStandardVersionText);
 	$MD_Metadata->appendChild($metadataStandardName);
 	$MD_Metadata->appendChild($metadataStandardVersion);
-	#do the things for identification
-	#create nodes
+
+	//do the things for identification
+	//create nodes
 	$identificationInfo=$iso19139->createElement("gmd:identificationInfo");
 	$SV_ServiceIdentification=$iso19139->createElement("srv:SV_ServiceIdentification");
-	#add attribut
+	//TODO: add attribut
 	//$SV_ServiceIdentification->setAttribute("id", "dataId");
 	$citation=$iso19139->createElement("gmd:citation");
 	$CI_Citation=$iso19139->createElement("gmd:CI_Citation");
 	#create nodes for things which are defined - howto do the multiplicities? Ask Martin!
-	#Create Resource title element B 1.1
+	//Create Resource title element B 1.1
 	$title=$iso19139->createElement("gmd:title");
 	$title_cs=$iso19139->createElement("gco:CharacterString");
 	if (isset($mapbenderMetadata['wms_title'])) {
@@ -281,6 +289,7 @@
 	$title_cs->appendChild($titleText);
 	$title->appendChild($title_cs);
 	$CI_Citation->appendChild($title);
+
 	#Create date elements B5.2-5.4
 	#Do things for B 5.2 date of publication
 	if (isset($mapbenderMetadata['wms_timestamp_create'])) {
@@ -345,20 +354,9 @@
 		$date1->appendChild($CI_Date);
 		$CI_Citation->appendChild($date1);
 	}
-	#Do things for B 1.5 Resource unique identifier NOTE: not applicable for services
-	//$identifier=$iso19139->createElement("gmd:identifier");
-	//$rs_identifier=$iso19139->createElement("gmd:RS_Identifier");
-	//$code=$iso19139->createElement("gmd:code");
-	//$code_cs=$iso19139->createElement("gco:CharacterString");
-	//$codeText=$iso19139->createTextNode($detail_array['t01_object.obj_id']);
-	//$code_cs->appendChild($codeText);
-	//$code->appendChild($code_cs);
-	//$rs_identifier->appendChild($code);
-	//$identifier->appendChild($rs_identifier);
-	//$CI_Citation->appendChild($identifier);
-	#create tree
 	$citation->appendChild($CI_Citation);
 	$SV_ServiceIdentification->appendChild($citation);
+
 	#Create part for abstract B 1.2
 	$abstract=$iso19139->createElement("gmd:abstract");
 	$abstract_cs=$iso19139->createElement("gco:CharacterString");
@@ -371,6 +369,7 @@
 	$abstract_cs->appendChild($abstractText);
 	$abstract->appendChild($abstract_cs);
 	$SV_ServiceIdentification->appendChild($abstract);
+
 	#Create part for point of contact for service identification
 	#Define relevant objects
 	$pointOfContact=$iso19139->createElement("gmd:pointOfContact");
@@ -415,6 +414,7 @@
 	$CI_ResponsibleParty->appendChild($role);
 	$pointOfContact->appendChild($CI_ResponsibleParty);
 	$SV_ServiceIdentification->appendChild($pointOfContact);
+
 	//generate graphical overview part
 	$sql = "SELECT layer_preview.layer_map_preview_filename FROM layer_preview WHERE layer_preview.fkey_layer_id=$1";
 	$v = array((integer)$mapbenderMetadata["layer_id"]);
@@ -471,12 +471,9 @@
 		$SV_ServiceIdentification->appendChild($graphicOverview);
 	}
 	
-
-
-
-
-
-	/*<gmd:graphicOverview>
+	/*example: 
+	
+	<gmd:graphicOverview>
   		<gmd:MD_BrowseGraphic>
    			 <gmd:fileName>
       				<gco:CharacterString>http://goesr.noaa.gov/browse/datasetIdentifier</gco:CharacterString>
@@ -501,45 +498,55 @@
 		$keyword->appendChild($keyword_cs);
 		$MD_Keywords->appendChild($keyword);
 	}
-	//a special keyword for service type wms ;-)
+	//a special keyword for service type wms as INSPIRE likes it ;-)
 	$keyword=$iso19139->createElement("gmd:keyword");
 	$keyword_cs=$iso19139->createElement("gco:CharacterString");
 	$keywordText = $iso19139->createTextNode("humanGeographicViewer");
 	$keyword_cs->appendChild($keywordText);
 	$keyword->appendChild($keyword_cs);
 	$MD_Keywords->appendChild($keyword);
+	
+	//pull special keywords from custom categories:	
+	$sql = "SELECT custom_category.custom_category_key FROM custom_category, layer_custom_category WHERE layer_custom_category.fkey_layer_id = $1 AND layer_custom_category.fkey_custom_category_id =  custom_category.custom_category_id AND custom_category_hidden = 0";
+	$v = array((integer)$recordId);
+	$t = array('i');
+	$res = db_prep_query($sql,$v,$t);
+	$e = new mb_notice("look for custom categories: ");
+	$countCustom = 0;
+	while ($row = db_fetch_array($res)) {
+		$keyword=$iso19139->createElement("gmd:keyword");
+		$keyword_cs=$iso19139->createElement("gco:CharacterString");
+		$keywordText = $iso19139->createTextNode($row['custom_category_key']);
+		$keyword_cs->appendChild($keywordText);
+		$keyword->appendChild($keyword_cs);
+		$MD_Keywords->appendChild($keyword);
+		$countCustom++;
+	}
 	$descriptiveKeywords->appendChild($MD_Keywords);
 	$SV_ServiceIdentification->appendChild($descriptiveKeywords);
-	//generate constraints part
-	//generate service type part
-	//generate extent part
-	//generate coupling part
-	//end of service identification
-	//generate distribution part
-	//generate data quality part
+
 	#Part B 3 INSPIRE Category
 	#do this only if an INSPIRE keyword (Annex I-III) is set
 	#Resource Constraints B 8
-	//if(isset($mapbenderMetadata['accessconstraints'])){
-		$resourceConstraints=$iso19139->createElement("gmd:resourceConstraints");
-		$MD_LegalConstraints=$iso19139->createElement("gmd:MD_Constraints");
-		$useLimitation=$iso19139->createElement("gmd:useLimitation");
-		$useLimitation_cs=$iso19139->createElement("gco:CharacterString");
-		if(isset($mapbenderMetadata['accessconstraints'])){
-			$useLimitationText=$iso19139->createTextNode($mapbenderMetadata['accessconstraints']);
-		}
-		else
-		{
-			$useLimitationText=$iso19139->createTextNode("no conditions apply");
-		}
- 	//TODO: Mapping of constraints between OWS/registry and INSPIRE 
-		$useLimitation_cs->appendChild($useLimitationText);
-		$useLimitation->appendChild($useLimitation_cs);
-		$MD_LegalConstraints->appendChild($useLimitation);
-		$resourceConstraints->appendChild($MD_LegalConstraints);
-		$SV_ServiceIdentification->appendChild($resourceConstraints);
-	//}
 	$resourceConstraints=$iso19139->createElement("gmd:resourceConstraints");
+	$MD_LegalConstraints=$iso19139->createElement("gmd:MD_Constraints");
+	$useLimitation=$iso19139->createElement("gmd:useLimitation");
+	$useLimitation_cs=$iso19139->createElement("gco:CharacterString");
+	if(isset($mapbenderMetadata['accessconstraints'])){
+		$useLimitationText=$iso19139->createTextNode($mapbenderMetadata['accessconstraints']);
+	}
+	else
+	{
+		$useLimitationText=$iso19139->createTextNode("no conditions apply");
+	}
+ 	//TODO: Mapping of constraints between OWS/registry and INSPIRE see View Service Guidance
+	$useLimitation_cs->appendChild($useLimitationText);
+	$useLimitation->appendChild($useLimitation_cs);
+	$MD_LegalConstraints->appendChild($useLimitation);
+	$resourceConstraints->appendChild($MD_LegalConstraints);
+	$SV_ServiceIdentification->appendChild($resourceConstraints);
+
+	$resourceConstraints=$iso19139->createElement("gmd:resourceConstraints");
 	$MD_LegalConstraints=$iso19139->createElement("gmd:MD_LegalConstraints");
 	$accessConstraints=$iso19139->createElement("gmd:accessConstraints");
 	$MD_RestrictionCode=$iso19139->createElement("gmd:MD_RestrictionCode");
@@ -565,10 +572,11 @@
 	$resourceConstraints->appendChild($MD_LegalConstraints);
 		
 	$SV_ServiceIdentification->appendChild($resourceConstraints);
-	//service type
-	//<srv:serviceType>
-    	//	<gco:LocalName>view</gco:LocalName>
-	//</srv:serviceType>
+/* example
+	<srv:serviceType>
+    		<gco:LocalName>view</gco:LocalName>
+	</srv:serviceType>*/
+
 	$serviceType=$iso19139->createElement("srv:serviceType");
 	$localName=$iso19139->createElement("gco:LocalName");
 	$serviceTypeText=$iso19139->createTextNode("view");
@@ -576,8 +584,6 @@
 	$serviceType->appendChild($localName);
 	$SV_ServiceIdentification->appendChild($serviceType);
 
-
-
 	$serviceTypeVersion=$iso19139->createElement("srv:serviceTypeVersion");
 	$serviceTypeVersion_cs=$iso19139->createElement("gco:CharacterString");
 	$serviceTypeVersionText=$iso19139->createTextNode("1.1.1");
@@ -586,25 +592,6 @@
 	$serviceTypeVersion->appendChild($serviceTypeVersion_cs);
 	$SV_ServiceIdentification->appendChild($serviceTypeVersion);
 
-
-	# Part B 1.7 Dataset Language
-	#if(isset($detail_array['t01_object.data_language'])){
-		#$language=$iso19139->createElement("gmd:language");
-		#$LanguageCode=$iso19139->createElement("gmd:LanguageCode");
-		#$LanguageCodeText=$iso19139->createTextNode($detail_array['t01_object.data_language']);
-		#$LanguageCode->appendChild($LanguageCodeText);
-		#$language->appendChild($LanguageCode);
-		#$SV_ServiceIdentification->appendChild($language);
-	#}
-	#Topic Category B 2.1 - not needed for services
-	#if(isset($detail_array['t011_obj_geo_topic_cat.topic_category'])){
-		#$topicCategory=$iso19139->createElement("gmd:topicCategory");
-		#$MD_TopicCategoryCode=$iso19139->createElement("gmd:MD_TopicCategoryCode");
-		#$MD_TopicCategoryText=$iso19139->createTextNode($detail_array['t011_obj_geo_topic_cat.topic_category']);
-		#$MD_TopicCategoryCode->appendChild($MD_TopicCategoryText);
-		#$topicCategory->appendChild($MD_TopicCategoryCode);
-		#$SV_ServiceIdentification->appendChild($topicCategory);
-	#}
 	#Geographical Extent
 	$bbox = array();
 	//initialize if no extent is defined in the database
@@ -683,13 +670,6 @@
 <srv:couplingType>
 	<srv:SV_CouplingType codeList="SV_CouplingType" codeListValue="tight"/>
 </srv:couplingType>
-
-	$couplingType=$iso19139->createElement("srv:couplingType");
-	$SV_CouplingType=$iso19139->createElement("srv:SV_CouplingType");
-	$SV_CouplingType->setAttribute("codeList", "SV_CouplingType");
-	$SV_CouplingType->setAttribute("codeListValue", "tight");
-	
-
 <srv:couplingType gco:nilReason="missing"/>
 <srv:containsOperations gco:nilReason="missing"/>
 <srv:operatesOn xlink:href="http://image2000.jrc.it#image2000_1_nl2_multi"/>*/
@@ -700,7 +680,6 @@
 	$containsOperation=$iso19139->createElement("srv:containsOperations");
 	$SV_OperationMetadata=$iso19139->createElement("srv:SV_OperationMetadata");
 
-
 	$operationName=$iso19139->createElement("srv:operationName");
 	$operationName_cs=$iso19139->createElement("gco:CharacterString");
 
@@ -715,7 +694,6 @@
 	$DCPList->setAttribute("codeList", "DCPList");
 	$DCPList->setAttribute("codeListValue", "WebService");
 
-
 	$DCP->appendChild($DCPList);
 	
 //connectPoint **********************************
@@ -744,10 +722,10 @@
 	$containsOperation->appendChild($SV_OperationMetadata);
 
 	$SV_ServiceIdentification->appendChild($containsOperation);
+
 	//fill in operatesOn fields with datasetid if given
 	/*<srv:operatesOn xlink:href="http://image2000.jrc.it#image2000_1_nl2_multi"/>*/
 	while ($row_metadata = db_fetch_array($res_metadataurl)) {
-		
 			switch ($row_metadata['origin']) {
 				case 'capabilities':
 					$operatesOn=$iso19139->createElement("srv:operatesOn");
@@ -769,16 +747,14 @@
 			}
 		}
 	
-
-
-	
 /*
 	$serviceTypeVersion_cs->appendChild($serviceTypeVersionText);
 	$serviceTypeVersion->appendChild($serviceTypeVersion_cs);
 	$SV_ServiceIdentification->appendChild($serviceTypeVersion);
 */
 	$identificationInfo->appendChild($SV_ServiceIdentification);
-//distributionInfo
+
+	//distributionInfo
 	$gmd_distributionInfo=$iso19139->createElement("gmd:distributionInfo");
 	$MD_Distribution=$iso19139->createElement("gmd:MD_Distribution");
 	$gmd_distributionFormat=$iso19139->createElement("gmd:distributionFormat");
@@ -795,6 +771,7 @@
 
 	$gmd_linkage=$iso19139->createElement("gmd:linkage");
 	$gmd_URL=$iso19139->createElement("gmd:URL");
+
 	//Check if anonymous user has rights to access this layer - if not ? which resource should be advertised? TODO
 	if ($hasPermission) {
 		$gmd_URLText=$iso19139->createTextNode("http://".$_SERVER['HTTP_HOST']."/mapbender/php/wms.php?inspire=1&layer_id=".$mapbenderMetadata['layer_id']."");
@@ -824,8 +801,6 @@
 	$gmdProtocol->appendChild($gmdProtocol_cs);
 	$CI_OnlineResource->appendChild($gmdProtocol);
 
-
-
 	$gmdName_cs->appendChild($gmdNameText);
 	$gmdName->appendChild($gmdName_cs);
 	$CI_OnlineResource->appendChild($gmdName);
@@ -1022,7 +997,7 @@
 if ($_REQUEST['VALIDATE'] == "true"){
 	validateInspireMetadata($iso19139Doc, $recordId);
 } else {
-	pushISO19139($iso19139Doc, $recordId); //throw it out!
+	pushISO19139($iso19139Doc, $recordId); //throw it out to world!
 }
 ?>
 



More information about the Mapbender_commits mailing list