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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Wed Jun 26 07:53:41 PDT 2019


Author: armin11
Date: 2019-06-26 07:53:41 -0700 (Wed, 26 Jun 2019)
New Revision: 10162

Modified:
   trunk/mapbender/http/php/mod_callCswMetadata.php
Log:
Parse dataset identifier from external csw metadata

Modified: trunk/mapbender/http/php/mod_callCswMetadata.php
===================================================================
--- trunk/mapbender/http/php/mod_callCswMetadata.php	2019-06-26 13:42:20 UTC (rev 10161)
+++ trunk/mapbender/http/php/mod_callCswMetadata.php	2019-06-26 14:53:41 UTC (rev 10162)
@@ -513,7 +513,7 @@
 //}
 $existsSpatialFilter = false;
 $searchBboxArray = explode(",", $searchBbox);
-//TODO: test the right filter!
+//TODO: test the right filter! - inspire has other ones and no logical option!
 if ($searchBbox !== NULL) {
     $existsSpatialFilter = true;
     switch ($searchTypeBbox) {
@@ -835,8 +835,44 @@
 			}
 			*/
 			$identifikationXPath = "";
-			$datasetIdentifier = $cswClient->operationResult->xpath('/csw:GetRecordsResponse/csw:SearchResults/gmd:MD_Metadata['.$k.']/gmd:identificationInfo/'.$identifikationXPath.'/@uuid');
-			$datasetidentifier = (string)$datasetidentifier[0];
+			if ($searchResource == 'dataset' || $searchResource == 'series') {
+				//dataset identifier
+				$datasetId = 'undefined';
+				$code = $cswClient->operationResult->xpath('///gmd:MD_Metadata/gmd:identificationInfo/'.$identifikationXPath.'/gmd:citation/gmd:CI_Citation/gmd:identifier/gmd:MD_Identifier/gmd:code/gco:CharacterString');
+				if (isset($code[0]) && $code[0] != '') {
+					//new implementation:
+					//http://inspire.ec.europa.eu/file/1705/download?token=iSTwpRWd&usg=AOvVaw18y1aTdkoMCBxpIz7tOOgu
+					//from 2017-03-02 - the MD_Identifier - see C.2.5 Unique resource identifier - it is separated with a slash - the codespace should be everything after the last slash 
+					//now try to check if a single slash is available and if the md_identifier is a url
+					$parsedUrl = parse_url($code[0]);
+					if (($parsedUrl['scheme'] == 'http' || $parsedUrl['scheme'] == 'https') && strpos($parsedUrl['path'],'/') !== false) {
+						$explodedUrl = explode('/', $code[0]);
+						$datasetId = $explodedUrl[count($explodedUrl) - 1];
+						$datasetIdCodeSpace = rtrim($code[0], $datasetId);	
+					} else {
+						if (($parsedUrl['scheme'] == 'http' || $parsedUrl['scheme'] == 'https') && strpos($code[0],'#') !== false) {
+							//$e = new mb_exception($code[0]);
+							$explodedUrl = explode('#', $code[0]);
+							$datasetId = $explodedUrl[1];
+							$datasetIdCodeSpace = $explodedUrl[0];
+						} else {
+							$datasetId = $code[0];
+							$datasetIdCodeSpace = "";	
+						}
+					}
+				} else { //try to read code from RS_Identifier 		
+					$code = $cswClient->operationResult->xpath('///gmd:MD_Metadata/gmd:identificationInfo/'.$identifikationXPath.'/gmd:citation/gmd:CI_Citation/gmd:identifier/gmd:RS_Identifier/gmd:code/gco:CharacterString');
+					$codeSpace = $cswClient->operationResult->xpath('gmd:MD_Metadata/gmd:identificationInfo/'.$identifikationXPath.'/gmd:citation/gmd:CI_Citation/gmd:identifier/gmd:RS_Identifier/gmd:codeSpace/gco:CharacterString');
+					if (isset($codeSpace[0]) && isset($code[0]) && $codeSpace[0] != '' && $code[0] != '') {
+						$datasetId = $code[0];
+						$datasetIdCodeSpace = $codeSpace[0];
+					} else {
+						//neither MD_Identifier nor RS_Identifier are defined in a right way
+						$e = new mb_notice("class_iso19139.php: No datasetId found in metadata record!");
+					}
+				}
+				$resultObject->{$searchResource}->srv[$k-1]->datasetId = $datasetIdCodeSpace.$datasetId;
+			}
 			//preview image if available
 			$previewImage = $cswClient->operationResult->xpath('/csw:GetRecordsResponse/csw:SearchResults/gmd:MD_Metadata['.$k.']/gmd:identificationInfo/'.$identifikationXPath.'/gmd:graphicOverview/gmd:MD_BrowseGraphic/gmd:fileName/gco:CharacterString');
 



More information about the Mapbender_commits mailing list