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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Wed Nov 28 08:28:44 PST 2012


Author: armin11
Date: 2012-11-28 08:28:44 -0800 (Wed, 28 Nov 2012)
New Revision: 8515

Modified:
   trunk/mapbender/http/php/mod_inspireAtomFeedISOMetadata.php
   trunk/mapbender/http/php/mod_inspireDownloadFeed.php
Log:
Some extensions for INSPIRE download services based on ATOM feeds

Modified: trunk/mapbender/http/php/mod_inspireAtomFeedISOMetadata.php
===================================================================
--- trunk/mapbender/http/php/mod_inspireAtomFeedISOMetadata.php	2012-11-27 06:23:16 UTC (rev 8514)
+++ trunk/mapbender/http/php/mod_inspireAtomFeedISOMetadata.php	2012-11-28 16:28:44 UTC (rev 8515)
@@ -318,7 +318,7 @@
 		$sql = <<<SQL
 			select wfs_id, uuid, wfs_timestamp, providername, fkey_mb_group_id, wfs_owner, electronicmailaddress, wfs_timestamp_create, fees, accessconstraints from wfs where wfs_id = $1;
 SQL;
-		$v = array((integer)$mapbenderMetadata['resourceId']);
+		$v = array((integer)$mapbenderMetadata['serviceId']);
 		$t = array('i');
 		$res = db_prep_query($sql,$v,$t);
 		$mbMetadata = db_fetch_array($res);
@@ -361,7 +361,7 @@
 	
 	//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['serviceGroupId']) or is_null($mapbenderMetadata['serviceGroupId']) or $mapbenderMetadata['serviceGroupId'] == 0){
-		$e = new mb_exception("mod_dataLinkDownloadISOMetadata.php: fkey_mb_group_id not found!");
+		$e = new mb_exception("mod_inspireAtomFeedISOMetadata.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 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";
 		$vDep = array($mapbenderMetadata['serviceOwnerId']);
@@ -369,7 +369,7 @@
 		$resDep = db_prep_query($sqlDep, $vDep, $tDep);
 		$departmentMetadata = db_fetch_array($resDep);
 	} else {
-		$e = new mb_exception("mod_dataLinkDownloadISOMetadata.php: fkey_mb_group_id found!");
+		$e = new mb_exception("mod_inspireAtomFeedISOMetadata.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 FROM mb_group WHERE mb_group_id = $1 LIMIT 1";
 		$vDep = array($mapbenderMetadata['serviceGroupId']);
 		$tDep = array('i');
@@ -480,13 +480,21 @@
 	$CI_ResponsibleParty=$iso19139->createElement("gmd:CI_ResponsibleParty");
 	$organisationName=$iso19139->createElement("gmd:organisationName");
 	$organisationName_cs=$iso19139->createElement("gco:CharacterString");
+	$e = new mb_exception("Atom: mb_group_name: ".$departmentMetadata['mb_group_name']." - serviceOnwerId: ".$mapbenderMetadata['serviceOwnerId']);
 	if (isset($departmentMetadata['mb_group_name'])) {
-		$organisationNameText = $iso19139->createTextNode($departmentMetadata['mb_group_name']); 
+		$organisationNameText = $iso19139->createTextNode($departmentMetadata['mb_group_name']);
 	}
 	else
 	{
 		$organisationNameText=$iso19139->createTextNode('department not known');
 	}
+	//$organisationNameText=$iso19139->createTextNode('wald');
+	//create xml tree
+	$organisationName_cs->appendChild($organisationNameText);
+	$organisationName->appendChild($organisationName_cs);
+	$CI_ResponsibleParty->appendChild($organisationName);
+
+
 	$contactInfo=$iso19139->createElement("gmd:contactInfo");
 	$CI_Contact=$iso19139->createElement("gmd:CI_Contact");
 	$address=$iso19139->createElement("gmd:address");
@@ -507,10 +515,8 @@
 	$CI_RoleCode->setAttribute("codeListValue", "pointOfContact");
 	$CI_RoleCodeText=$iso19139->createTextNode("pointOfContact");
 
-	//create xml tree
-	$organisationName_cs->appendChild($organisationNameText);
-	$organisationName->appendChild($organisationName_cs);
-	$CI_ResponsibleParty->appendChild($organisationName);
+	
+
 	$electronicMailAddress_cs->appendChild($electronicMailAddressText);
 	$electronicMailAddress->appendChild($electronicMailAddress_cs);
 	$CI_Address->appendChild($electronicMailAddress);
@@ -681,11 +687,11 @@
 	$CI_RoleCode=$iso19139->createElement("gmd:CI_RoleCode");
 	$CI_RoleCode->setAttribute("codeList", "http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#CI_RoleCode");
 	$CI_RoleCode->setAttribute("codeListValue", "publisher");
-	if (isset($mapbenderMetadata['serviceDepartment'])) {
+	if (isset($mapbenderMetadata['serviceDepartment']) && $mapbenderMetadata['serviceDepartment'] != NULL) {
 		$resOrgaText = $iso19139->createTextNode($mapbenderMetadata['serviceDepartment']);
 	}
 	else {
-		$resOrgaText= $iso19139->createTextNode("not yet defined");
+		$resOrgaText= $iso19139->createTextNode($departmentMetadata['mb_group_name']);
 	}
 	if (isset($mapbenderMetadata['serviceDepartmentMail'])) {
 		$resMailText = $iso19139->createTextNode($mapbenderMetadata['serviceDepartmentMail']);
@@ -761,8 +767,8 @@
 	//read keywords for resource out of the database:
 	if ($generateFrom == 'wfs') {
 		$sql = <<<SQL
-			SELECT keyword.keyword as keyword FROM keyword, wfs_featuretype_keyword WHERE wfs_featuretype_keyword.fkey_featuretype_id IN $1 AND wfs_featuretype_keyword.fkey_keyword_id=keyword.keyword_id union 
-SELECT custom_category.custom_category_key as keyword FROM custom_category, wfs_featuretype_custom_category WHERE wfs_featuretype_custom_category.fkey_featuretype_id IN $1 AND wfs_featuretype_custom_category.fkey_custom_category_id =  custom_category.custom_category_id AND custom_category_hidden = 0;
+			SELECT keyword.keyword as keyword FROM keyword, wfs_featuretype_keyword WHERE wfs_featuretype_keyword.fkey_featuretype_id IN ( $1 ) AND wfs_featuretype_keyword.fkey_keyword_id=keyword.keyword_id union 
+SELECT custom_category.custom_category_key as keyword FROM custom_category, wfs_featuretype_custom_category WHERE wfs_featuretype_custom_category.fkey_featuretype_id IN ( $1 ) AND wfs_featuretype_custom_category.fkey_custom_category_id =  custom_category.custom_category_id AND custom_category_hidden = 0;
 SQL;
 		//get keywords for all featuretypes
 		//$mapbenderMetadata['featureTypes'] - array of ft ids
@@ -812,14 +818,16 @@
 	$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']);
+	
+	if(isset($mapbenderMetadata['serviceFees']) && $mapbenderMetadata['serviceFees'] != ''){
+		$useLimitationText=$iso19139->createTextNode($mapbenderMetadata['serviceFees']);
 	}
 	else
 	{
 		$useLimitationText=$iso19139->createTextNode("no conditions apply");
 	}
- 	//TODO: Mapping of constraints between OWS/registry and INSPIRE see View Service Guidance / Draft SDS guidance 
+ 	//TODO: Mapping of constraints between OWS/registry and INSPIRE see View Service Guidance / Draft SDS guidance / MD guidance
+	//Add restricted network access, not free to guest user, licence information, costs for proxy, log of requests - see disclaimer!! - It will be good to read the dynamical generated disclaimer for this
 	$useLimitation_cs->appendChild($useLimitationText);
 	$useLimitation->appendChild($useLimitation_cs);
 	$MD_LegalConstraints->appendChild($useLimitation);
@@ -835,11 +843,15 @@
 	$MD_RestrictionCodeText=$iso19139->createTextNode("otherRestrictions");
 	$otherConstraints=$iso19139->createElement("gmd:otherConstraints");
 	$otherConstraints_cs=$iso19139->createElement("gco:CharacterString");
-	if (isset($mapbenderMetadata['accessconstraints']) & strtoupper($mapbenderMetadata['accessconstraints']) != 'NONE'){
-			$otherConstraintsText=$iso19139->createTextNode($mapbenderMetadata['accessconstraints']);
+	if (isset($mapbenderMetadata['serviceAccessConstraints']) && strtoupper($mapbenderMetadata['serviceAccessConstraints']) != 'NONE' && $mapbenderMetadata['serviceAccessConstraints'] != ''){
+			$otherConstraintsText=$iso19139->createTextNode($mapbenderMetadata['serviceAccessConstraints']);
 	}
-	else {
-			$otherConstraintsText=$iso19139->createTextNode("no constraints");
+	else {	
+		if ($mapbenderMetadata['serviceAccessConstraints'] == '') {
+			$otherConstraintsText=$iso19139->createTextNode("No readable limitations are given - the serviceprovider have to be contacted and asked!");
+		} else {
+			$otherConstraintsText=$iso19139->createTextNode("no limitations");
+		}
 	}
 	$otherConstraints_cs->appendChild($otherConstraintsText);
 	$otherConstraints->appendChild($otherConstraints_cs);

Modified: trunk/mapbender/http/php/mod_inspireDownloadFeed.php
===================================================================
--- trunk/mapbender/http/php/mod_inspireDownloadFeed.php	2012-11-27 06:23:16 UTC (rev 8514)
+++ trunk/mapbender/http/php/mod_inspireDownloadFeed.php	2012-11-28 16:28:44 UTC (rev 8515)
@@ -50,6 +50,24 @@
 	$_REQUEST[strtoupper($key)] = $val;
 }
 
+//check if opensearchdescription is requested
+if (isset($_REQUEST['GETOPENSEARCH']) & $_REQUEST['GETOPENSEARCH'] != "") {
+	//validate 
+	$testMatch = $_REQUEST["GETOPENSEARCH"];	
+ 	if ($testMatch != "true" && $testMatch != "false"){ 
+		echo 'GETOPENSEARCH: <b>'.$testMatch.'</b> is not valid.<br/>'; 
+		die(); 		
+ 	}
+	$getOpenSearch = $testMatch;
+	if ($getOpenSearch == 'true') {
+		$getOpenSearch = true;
+	} else {
+		$getOpenSearch = false;
+	}
+	$testMatch = NULL;
+}
+
+
 //validate request params
 if (isset($_REQUEST['ID']) & $_REQUEST['ID'] != "") {
 	//validate uuid
@@ -152,6 +170,107 @@
 $feedDoc->preserveWhiteSpace = false;
 $feedDoc->formatOutput = true;
 
+function generateOpenSearchDescription($feedDoc, $recordId, $generateFrom) {
+	global $admin, $type, $imageResolution, $maxImageSize, $maxFeatureCount, $mapbenderMetadata, $indexMapbenderMetadata, $layerId, $wfsId, $mapbenderPath;
+	//part which generates the feed 
+	$feed =  $feedDoc->createElementNS('http://a9.com/-/spec/opensearch/1.1/', 'OpenSearchDescription');
+	$feed = $feedDoc->appendChild($feed);
+	//$feed->setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
+	$feed->setAttribute("xmlns:inspire_dls", "http://inspire.ec.europa.eu/schemas/inspire_dls/1.0");
+	$feed->setAttribute("xmlns:xsi", "http://www.w3c.org/2001/XMLSchema-instance");
+	$feed->setAttribute("xsi:schemaLocation", "http://a9.com/-/spec/opensearch/1.1/ OpenSearch.xsd");
+	//ShortName
+	$osShortName = $feedDoc->createElement("ShortName");
+	$osShortNameText = $feedDoc->createTextNode("INSPIRE Download Service.");
+	$osShortName->appendChild($osShortNameText);
+	$feed->appendChild($osShortName);
+	//Description
+	$osDescription = $feedDoc->createElement("Description");
+	$osDescriptionText = $feedDoc->createTextNode("Search Description für INSPIRE Download Service.");
+	$osDescription->appendChild($osDescriptionText);
+	$feed->appendChild($osDescription);
+	//Url - self
+	$urlSelf = $feedDoc->createElement("Url");
+	$urlSelf->setAttribute("type", "application/opensearchdescription+xml");
+	$urlSelf->setAttribute("rel", "self");
+	$urlSelf->setAttribute("template", $mapbenderPath."..".$_SERVER['SCRIPT_NAME']."?getopensearch=true");
+	$feed->appendChild($urlSelf);
+	//Url - results Atom
+	$urlSelf = $feedDoc->createElement("Url");
+	$urlSelf->setAttribute("type", "application/atom+xml");
+	$urlSelf->setAttribute("rel", "results");
+	$urlSelf->setAttribute("template", $mapbenderPath."..".$_SERVER['SCRIPT_NAME']."?q={searchTerms}");
+	$feed->appendChild($urlSelf);
+	//Url - describedby
+	$urlDescribedby = $feedDoc->createElement("Url");
+	$urlDescribedby->setAttribute("type", "application/atom+xml");
+	$urlDescribedby->setAttribute("rel", "describedby");
+	$urlDescribedby->setAttribute("template", $mapbenderPath."..".$_SERVER['SCRIPT_NAME']."?spatial_dataset_identifier_code={inspire_dls:spatial_dataset_identifier_code?}&spatial_dataset_identifier_namespace={inspire_dls:spatial_dataset_identifier_namespace?}&crs={inspire_dls:crs?}&language={language?}&q={searchTerms?}");
+	$feed->appendChild($urlDescribedby);
+	//Url - results single part (e.g. zipfile)
+	$urlResults = $feedDoc->createElement("Url");
+	$urlResults->setAttribute("type", "application/zip");
+	$urlResults->setAttribute("rel", "results");
+	$urlResults->setAttribute("template", $mapbenderPath."..".$_SERVER['SCRIPT_NAME']."?spatial_dataset_identifier_code={inspire_dls:spatial_dataset_identifier_code?}&spatial_dataset_identifier_namespace={inspire_dls:spatial_dataset_identifier_namespace?}&crs={inspire_dls:crs?}&language={language?}&q={searchTerms?}");
+	$feed->appendChild($urlResults);
+	//Url -results multi part
+	/*
+	$urlResults = $feedDoc->createElement("Url");
+	$urlResults->setAttribute("type", "application/atom");
+	$urlResults->setAttribute("rel", "results");
+	$urlResults->setAttribute("template", $mapbenderPath."..".$_SERVER['SCRIPT_NAME']."?spatial_dataset_identifier_code={inspire_dls:spatial_dataset_identifier_code?}&spatial_dataset_identifier_namespace={inspire_dls:spatial_dataset_identifier_namespace?}&crs={inspire_dls:crs?}&language={language?}&q={searchTerms?}");
+	$feed->appendChild($urlResults);
+	*/
+	//Metadata for OpenSearch
+	//Contact
+	$osContact = $feedDoc->createElement("Contact");
+	$osContactText = $feedDoc->createTextNode("kontakt at geoportal.rlp.de");
+	$osContact->appendChild($osContactText);
+	$feed->appendChild($osContact);
+	//Tags
+	$osTags = $feedDoc->createElement("Tags");
+	$osTagsText = $feedDoc->createTextNode("Tags");
+	$osTags->appendChild($osTagsText);
+	$feed->appendChild($osTags);
+	//LongName
+	$osLongName = $feedDoc->createElement("LongName");
+	$osLongNameText = $feedDoc->createTextNode("LongName");
+	$osLongName->appendChild($osLongNameText);
+	$feed->appendChild($osLongName);
+	//Image
+	$osImage = $feedDoc->createElement("Image");
+	$osImage->setAttribute("height", "16");
+	$osImage->setAttribute("width", "16");
+	$osImage->setAttribute("type", "image/png");
+	$osImageText = $feedDoc->createTextNode("http://www.geoportal.rlp.de/fileadmin/design/logo_gdi-rp.png");
+	$osImage->appendChild($osImageText);
+	$feed->appendChild($osImage);
+	//Query
+	$osQuery = $feedDoc->createElement("Query");
+	$osQuery->setAttribute("inspire_dls:spatial_dataset_identifier_namespace", "http://www.geoportal.rlp.de");
+	$osQuery->setAttribute("inspire_dls:spatial_dataset_identifier_code", "some uuid");
+	$osQuery->setAttribute("inspire_dls:crs", "EPSG:25832");
+	$osQuery->setAttribute("language", "de");
+	$osQuery->setAttribute("title", "Titel des Datensatzes");
+	$osQuery->setAttribute("count", "1");
+	//$osQueryText = $feedDoc->createTextNode("Query");
+	//$osQuery->appendChild($osQueryText);
+	$feed->appendChild($osQuery);
+	//Developer
+	$osDeveloper = $feedDoc->createElement("Developer");
+	$osDeveloperText = $feedDoc->createTextNode("Rheinland-Pfalz, Zentrale Stelle GDI-RP");
+	$osDeveloper->appendChild($osDeveloperText);
+	$feed->appendChild($osDeveloper);
+	//Language
+	$osLanguage = $feedDoc->createElement("Language");
+	$osLanguageText = $feedDoc->createTextNode("de");
+	$osLanguage->appendChild($osLanguageText);
+	$feed->appendChild($osLanguage);
+	return $feedDoc->saveXML();
+}
+
+
+
 //Some needfull functions to pull metadata out of the database.
 //List of data which is needed to build the feed:
 //header part ******
@@ -413,12 +532,18 @@
 	//<link href="http://xyz.org/metadata" rel="describedby" type="application/vnd.iso.19139+xml"/>
 	$feedLink = $feedDoc->createElement("link");
 	if ($type == 'SERVICE') {
-		$feedLink->setAttribute("href", $mapbenderPath."php/mod_inspireAtomFeedISOMetadata.php?Id=".$recordId."&outputFormat=iso19139&generateFrom=".$generateFrom);
+		if ($generateFrom == 'wfs') {
+			$feedLink->setAttribute("href", $mapbenderPath."php/mod_inspireAtomFeedISOMetadata.php?Id=".$recordId."&outputFormat=iso19139&generateFrom=".$generateFrom."&wfsid=".$wfsId);
+		} else {
+			$feedLink->setAttribute("href", $mapbenderPath."php/mod_inspireAtomFeedISOMetadata.php?Id=".$recordId."&outputFormat=iso19139&generateFrom=".$generateFrom."&layerid=".$layerId);
+		}
+		
+		
 	} else { //DATASET
 		$feedLink->setAttribute("href", $mapbenderPath."php/mod_dataISOMetadata.php?id=".$mapbenderMetadata[$m]->metadata_uuid."&outputFormat=iso19139");
 	}
 	$feedLink->setAttribute("rel", "describedby");
-	$feedLink->setAttribute("rel", "application/vnd.iso.19139+xml");
+	$feedLink->setAttribute("type", "application/vnd.iso.19139+xml");
 	//$feedLink->setAttribute("title", "Metadaten");
 	//$feedLink->setAttribute("hreflang", "de");
 	$feed->appendChild($feedLink);
@@ -450,7 +575,7 @@
 	//opensearch descriptionlink 5.1.5
 	if ($type == 'SERVICE') {
 		$feedLink = $feedDoc->createElement("link");
-		$feedLink->setAttribute("href", $mapbenderPath."php/mb_datalinkOpensearchDescription.php?ID=".$recordId);
+		$feedLink->setAttribute("href", $mapbenderPath."php/mod_inspireDownloadFeed.php?id=".$recordId."&type=".$type."&generateFrom=".$generateFrom."&wfsid=".$wfsId."&layerid=".$layerId."&getopensearch=true");
 		$feedLink->setAttribute("rel", "search");
 		$feedLink->setAttribute("type", "application/opensearchdescription+xml");
 		//$feedLink->setAttribute("hreflang", "de");
@@ -1083,6 +1208,14 @@
 }
 
 //function to give away the xml data
+function pushOpenSearch($feedDoc, $recordId, $generateFrom) {
+	header("Content-type: application/xhtml+xml; charset=UTF-8");
+	$xml = generateOpenSearchDescription($feedDoc, $recordId, $generateFrom);
+	echo $xml;
+	die();
+}
+
+//function to give away the xml data
 function pushFeed($feedDoc, $recordId, $generateFrom) {
 	header("Content-type: application/xhtml+xml; charset=UTF-8");
 	$xml = generateFeed($feedDoc, $recordId, $generateFrom);
@@ -1188,8 +1321,12 @@
 }
 
 
-//do all the other things which had to be done ;-)
-pushFeed($feedDoc, $recordId, $generateFrom); //throw it out to world!
+if ($getOpenSearch) {
+	pushOpenSearch($feedDoc, $recordId, $generateFrom);
+} else {
+	pushFeed($feedDoc, $recordId, $generateFrom); //throw it out to world!
+}
 
+
 ?>
 



More information about the Mapbender_commits mailing list