[Mapbender-commits] r10037 - in trunk/mapbender/http: classes php

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue Jan 22 06:37:18 PST 2019


Author: armin11
Date: 2019-01-22 06:37:18 -0800 (Tue, 22 Jan 2019)
New Revision: 10037

Modified:
   trunk/mapbender/http/classes/class_cswClient.php
   trunk/mapbender/http/classes/class_iso19139.php
   trunk/mapbender/http/php/mod_callCswMetadata.php
Log:
Further enhancements for external metadata search via csw interfaces

Modified: trunk/mapbender/http/classes/class_cswClient.php
===================================================================
--- trunk/mapbender/http/classes/class_cswClient.php	2019-01-22 07:50:21 UTC (rev 10036)
+++ trunk/mapbender/http/classes/class_cswClient.php	2019-01-22 14:37:18 UTC (rev 10037)
@@ -201,8 +201,8 @@
 					//TODO add other values if needed!
 					$postRequest .= '>';
     					$postRequest .= '<csw:Query typeNames="csw:Record">';
-					$postRequest .= '<csw:ElementSetName>summary</csw:ElementSetName>';
-					//$postRequest .= '<csw:ElementSetName>full</csw:ElementSetName>';
+					//$postRequest .= '<csw:ElementSetName>summary</csw:ElementSetName>';
+					$postRequest .= '<csw:ElementSetName>full</csw:ElementSetName>';
 					if ($recordtype !== false) {
             					$postRequest .= '<csw:Constraint version="1.0.0">';
                 				$postRequest .= '<ogc:Filter>';
@@ -285,6 +285,7 @@
 			$cswResponseObject->registerXPathNamespace("csw", "http://www.opengis.net/cat/csw/2.0.2");
 			$cswResponseObject->registerXPathNamespace("ogc", "http://www.opengis.net/ogc");
 			$cswResponseObject->registerXPathNamespace("gco", "http://www.isotc211.org/2005/gco");
+			$cswResponseObject->registerXPathNamespace("srv", "http://www.isotc211.org/2005/srv");
 			//$iso19139Xml->registerXPathNamespace("ogc", "http://www.opengis.net/ogc");
 			$cswResponseObject->registerXPathNamespace("xlink", "http://www.w3.org/1999/xlink");
 			$cswResponseObject->registerXPathNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
@@ -341,7 +342,7 @@
 					case "getrecordspaging":
 						$metadataRecord = $cswResponseObject->xpath('/csw:GetRecordsResponse/csw:SearchResults/gmd:MD_Metadata');
 						if (is_array($metadataRecord) && count($metadataRecord) < 1 || !is_array($metadataRecord)) {
-							$this->operationResult = "No result for counting metadata records via csw query!";
+							$this->operationResult = "No result for getrecordspaging for metadata records via csw query!";
 							$this->operationSuccessful = false;
 							return false;
 						} else {
@@ -348,6 +349,7 @@
 							$this->operationSuccessful = true;
 							//give back all records in json
 							$this->operationResult = $cswResponseObject;
+//$e = new mb_exception("class_cswClient.php: returned xml result from csw operation getrecordspaging: ".$cswResponseObject->asXML());
 							return true;
 						}
 						break;

Modified: trunk/mapbender/http/classes/class_iso19139.php
===================================================================
--- trunk/mapbender/http/classes/class_iso19139.php	2019-01-22 07:50:21 UTC (rev 10036)
+++ trunk/mapbender/http/classes/class_iso19139.php	2019-01-22 14:37:18 UTC (rev 10037)
@@ -281,6 +281,7 @@
 			$iso19139Xml->registerXPathNamespace("gmd", "http://www.isotc211.org/2005/gmd");
 			$iso19139Xml->registerXPathNamespace("gco", "http://www.isotc211.org/2005/gco");
 			$iso19139Xml->registerXPathNamespace("gml", "http://www.opengis.net/gml");
+			$iso19139Xml->registerXPathNamespace("srv", "http://www.isotc211.org/2005/srv");
 			//$iso19139Xml->registerXPathNamespace("ogc", "http://www.opengis.net/ogc");
 			$iso19139Xml->registerXPathNamespace("xlink", "http://www.w3.org/1999/xlink");
 			$iso19139Xml->registerXPathNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
@@ -293,8 +294,15 @@
 			$this->createDate = $this->createDate[0];
 			$this->changeDate = $iso19139Xml->xpath('//gmd:MD_Metadata/gmd:dateStamp/gco:Date');
 			$this->changeDate = $this->changeDate[0];
+			$this->hierachyLevel = $iso19139Xml->xpath('//gmd:MD_Metadata/gmd:hierarchyLevel/gmd:MD_ScopeCode');
+			$this->hierachyLevel = $this->hierachyLevel[0];
+			if ($this->hierachyLevel == 'service') {				
+				$identifikationXPath = "srv:SV_ServiceIdentification";	
+			} else {
+				$identifikationXPath = "gmd:MD_DataIdentification";
+			}
 			//TODO: check if this is set, maybe DateTime must be searched instead?
-			$this->title = $iso19139Xml->xpath('//gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:title/gco:CharacterString');
+			$this->title = $iso19139Xml->xpath('//gmd:MD_Metadata/gmd:identificationInfo/'.$identifikationXPath.'/gmd:citation/gmd:CI_Citation/gmd:title/gco:CharacterString');
 			$this->title = $this->title[0];
 			//dataset identifier - howto model into md_metadata?
 			//check where datasetid is defined - maybe as RS_Identifier or as MD_Identifier see http://inspire.jrc.ec.europa.eu/documents/Metadata/INSPIRE_MD_IR_and_ISO_v1_2_20100616.pdf page 18
@@ -301,7 +309,7 @@
 			//First check if MD_Identifier is set, then check if RS_Identifier is used!
 			//Initialize datasetid
 			$this->datasetId = 'undefined';
-			$code = $iso19139Xml->xpath('//gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:identifier/gmd:MD_Identifier/gmd:code/gco:CharacterString');
+			$code = $iso19139Xml->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
@@ -324,8 +332,8 @@
 					}
 				}
 			} else { //try to read code from RS_Identifier 		
-				$code = $iso19139Xml->xpath('//gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:identifier/gmd:RS_Identifier/gmd:code/gco:CharacterString');
-				$codeSpace = $iso19139Xml->xpath('//gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:identifier/gmd:RS_Identifier/gmd:codeSpace/gco:CharacterString');
+				$code = $iso19139Xml->xpath('//gmd:MD_Metadata/gmd:identificationInfo/'.$identifikationXPath.'/gmd:citation/gmd:CI_Citation/gmd:identifier/gmd:RS_Identifier/gmd:code/gco:CharacterString');
+				$codeSpace = $iso19139Xml->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] != '') {
 					$this->datasetId = $code[0];
 					$this->datasetIdCodeSpace = $codeSpace[0];
@@ -335,13 +343,13 @@
 				}
 			}
 			//abstract
-			$this->abstract = $iso19139Xml->xpath('//gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:abstract/gco:CharacterString');
+			$this->abstract = $iso19139Xml->xpath('//gmd:MD_Metadata/gmd:identificationInfo/'.$identifikationXPath.'/gmd:abstract/gco:CharacterString');
 			$this->abstract = $this->abstract[0];
-			$this->keywords = $iso19139Xml->xpath('//gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:descriptiveKeywords/gmd:MD_Keywords/gmd:keyword/gco:CharacterString');
+			$this->keywords = $iso19139Xml->xpath('//gmd:MD_Metadata/gmd:identificationInfo/'.$identifikationXPath.'/gmd:descriptiveKeywords/gmd:MD_Keywords/gmd:keyword/gco:CharacterString');
 			//get thesaurus name only for found keywords!
 			$iKeyword = 0;
 			foreach ($this->keywords as $keyword) {
-				$thesaurusName = $iso19139Xml->xpath('//gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:descriptiveKeywords[gmd:MD_Keywords/gmd:keyword/gco:CharacterString="'.$keyword.'"]/gmd:MD_Keywords/gmd:thesaurusName/gmd:CI_Citation/gmd:title/gco:CharacterString');
+				$thesaurusName = $iso19139Xml->xpath('//gmd:MD_Metadata/gmd:identificationInfo/'.$identifikationXPath.'/gmd:descriptiveKeywords[gmd:MD_Keywords/gmd:keyword/gco:CharacterString="'.$keyword.'"]/gmd:MD_Keywords/gmd:thesaurusName/gmd:CI_Citation/gmd:title/gco:CharacterString');
 				$this->keywordsThesaurusName[$iKeyword] = $thesaurusName[0];
 				//$e = new mb_exception("Keyword: ".$keyword);
 				//$e = new mb_exception("Thesaurus: ".$thesaurusName[0]);
@@ -388,7 +396,7 @@
 					$this->inspireActualCoverage = $this->inspireWholeArea;
 			}
 			$iKeyword = 0;
-			$this->isoCategoryKeys = $iso19139Xml->xpath('//gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:topicCategory/gmd:MD_TopicCategoryCode');
+			$this->isoCategoryKeys = $iso19139Xml->xpath('//gmd:MD_Metadata/gmd:identificationInfo/'.$identifikationXPath.'/gmd:topicCategory/gmd:MD_TopicCategoryCode');
 			//create mapbenders internal category objects
 			//first for topic categories
 			foreach ($this->isoCategoryKeys as $isoKey) {
@@ -424,7 +432,7 @@
 				$this->transferSize = null;
 			}	
 			//preview image
-			$this->previewImage = $iso19139Xml->xpath('//gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:graphicOverview/gmd:MD_BrowseGraphic/gmd:fileName/gco:CharacterString');
+			$this->previewImage = $iso19139Xml->xpath('//gmd:MD_Metadata/gmd:identificationInfo/'.$identifikationXPath.'/gmd:graphicOverview/gmd:MD_BrowseGraphic/gmd:fileName/gco:CharacterString');
 			if (is_array($this->previewImage) && $this->previewImage[0] !== '') {
 				$this->previewImage = $this->previewImage[0];
 			} else {
@@ -441,13 +449,13 @@
 			//esri
 			/*<gmd:extent><gmd:EX_Extent><gmd:geographicElement><gmd:EX_GeographicBoundingBox><gmd:westBoundLongitude><gco:Decimal>11.1414</gco:Decimal></gmd:westBoundLongitude><gmd:eastBoundLongitude><gco:Decimal>11.7284</gco:Decimal></gmd:eastBoundLongitude><gmd:southBoundLatitude><gco:Decimal>58.8838</gco:Decimal></gmd:southBoundLatitude><gmd:northBoundLatitude><gco:Decimal>59.2562</gco:Decimal></gmd:northBoundLatitude></gmd:EX_GeographicBoundingBox></gmd:geographicElement><gmd:temporalElement><gmd:EX_TemporalExtent><gmd:extent><gml:TimePeriod gml:id="idNummer1"><gml:beginPosition>1999-05-05</gml:beginPosition><gml:endPosition>2012-04-04</gml:endPosition></gml:TimePeriod></gmd:extent></gmd:EX_TemporalExtent></gmd:temporalElement></gmd:EX_Extent></gmd:extent>*/
 			//get bbox from xml:
-			$minx = $iso19139Xml->xpath('//gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:geographicElement/gmd:EX_GeographicBoundingBox/gmd:westBoundLongitude/gco:Decimal');
+			$minx = $iso19139Xml->xpath('//gmd:MD_Metadata/gmd:identificationInfo/'.$identifikationXPath.'/gmd:extent/gmd:EX_Extent/gmd:geographicElement/gmd:EX_GeographicBoundingBox/gmd:westBoundLongitude/gco:Decimal');
 			$minx = $minx[0];
-			$miny = $iso19139Xml->xpath('//gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:geographicElement/gmd:EX_GeographicBoundingBox/gmd:southBoundLatitude/gco:Decimal');
+			$miny = $iso19139Xml->xpath('//gmd:MD_Metadata/gmd:identificationInfo/'.$identifikationXPath.'/gmd:extent/gmd:EX_Extent/gmd:geographicElement/gmd:EX_GeographicBoundingBox/gmd:southBoundLatitude/gco:Decimal');
 			$miny = $miny[0];
-			$maxx = $iso19139Xml->xpath('//gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:geographicElement/gmd:EX_GeographicBoundingBox/gmd:eastBoundLongitude/gco:Decimal');
+			$maxx = $iso19139Xml->xpath('//gmd:MD_Metadata/gmd:identificationInfo/'.$identifikationXPath.'/gmd:extent/gmd:EX_Extent/gmd:geographicElement/gmd:EX_GeographicBoundingBox/gmd:eastBoundLongitude/gco:Decimal');
 			$maxx = $maxx[0];
-			$maxy = $iso19139Xml->xpath('//gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:geographicElement/gmd:EX_GeographicBoundingBox/gmd:northBoundLatitude/gco:Decimal');
+			$maxy = $iso19139Xml->xpath('//gmd:MD_Metadata/gmd:identificationInfo/'.$identifikationXPath.'/gmd:extent/gmd:EX_Extent/gmd:geographicElement/gmd:EX_GeographicBoundingBox/gmd:northBoundLatitude/gco:Decimal');
 			$maxy = $maxy[0];
 			$this->wgs84Bbox = array($minx,$miny,$maxx,$maxy); 
 			//more info: https://geo-ide.noaa.gov/wiki/index.php?title=ISO_Extents
@@ -454,36 +462,34 @@
 			//look for GML3 polygon as exterior ring in two alternative encodings (see: http://www.galdosinc.com/archives/191 - all coords are interpreted as given in EPSG:4326 for the moment!!!):
 			//allow multipolygons - multisurface objects
 			//test if single polygon or multipolygon is given
-			if ($iso19139Xml->xpath('//gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:geographicElement/gmd:EX_BoundingPolygon/gmd:polygon/gml:MultiSurface')) {
+			if ($iso19139Xml->xpath('//gmd:MD_Metadata/gmd:identificationInfo/'.$identifikationXPath.'/gmd:extent/gmd:EX_Extent/gmd:geographicElement/gmd:EX_BoundingPolygon/gmd:polygon/gml:MultiSurface')) {
 				//count surfaceMembers
 				$this->polygonalExtentExterior = array();
-				$numberOfSurfaces = count($iso19139Xml->xpath('//gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:geographicElement/gmd:EX_BoundingPolygon/gmd:polygon/gml:MultiSurface/gml:surfaceMember'));
+				$numberOfSurfaces = count($iso19139Xml->xpath('//gmd:MD_Metadata/gmd:identificationInfo/'.$identifikationXPath.'/gmd:extent/gmd:EX_Extent/gmd:geographicElement/gmd:EX_BoundingPolygon/gmd:polygon/gml:MultiSurface/gml:surfaceMember'));
 				//$e = new mb_exception("class_iso19139.php: found multisurface element");
 				for ($k = 0; $k < $numberOfSurfaces; $k++) {
-					$this->polygonalExtentExterior[] = $this->parsePolygon($iso19139Xml, '//gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:geographicElement/gmd:EX_BoundingPolygon/gmd:polygon/gml:MultiSurface/gml:surfaceMember['. (string)($k + 1) .']/');
+					$this->polygonalExtentExterior[] = $this->parsePolygon($iso19139Xml, '//gmd:MD_Metadata/gmd:identificationInfo/'.$identifikationXPath.'/gmd:extent/gmd:EX_Extent/gmd:geographicElement/gmd:EX_BoundingPolygon/gmd:polygon/gml:MultiSurface/gml:surfaceMember['. (string)($k + 1) .']/');
 				}
 			} else { 
-				if ($iso19139Xml->xpath('//gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:geographicElement/gmd:EX_BoundingPolygon/gmd:polygon/gml:Polygon')) {
+				if ($iso19139Xml->xpath('//gmd:MD_Metadata/gmd:identificationInfo/'.$identifikationXPath.'/gmd:extent/gmd:EX_Extent/gmd:geographicElement/gmd:EX_BoundingPolygon/gmd:polygon/gml:Polygon')) {
 					$this->polygonalExtentExterior = array();
-					$this->polygonalExtentExterior[0] = $this->parsePolygon($iso19139Xml, '//gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:geographicElement/gmd:EX_BoundingPolygon/gmd:polygon/');
+					$this->polygonalExtentExterior[0] = $this->parsePolygon($iso19139Xml, '//gmd:MD_Metadata/gmd:identificationInfo/'.$identifikationXPath.'/gmd:extent/gmd:EX_Extent/gmd:geographicElement/gmd:EX_BoundingPolygon/gmd:polygon/');
 				}
 			}
-			$this->hierachyLevel = $iso19139Xml->xpath('//gmd:MD_Metadata/gmd:hierarchyLevel/gmd:MD_ScopeCode');
-			$this->hierachyLevel = $this->hierachyLevel[0];
-			$this->tmpExtentBegin = $iso19139Xml->xpath('//gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:temporalElement/gmd:EX_TemporalExtent/gmd:extent/gml:TimePeriod/gml:beginPosition');
+			$this->tmpExtentBegin = $iso19139Xml->xpath('//gmd:MD_Metadata/gmd:identificationInfo/'.$identifikationXPath.'/gmd:extent/gmd:EX_Extent/gmd:temporalElement/gmd:EX_TemporalExtent/gmd:extent/gml:TimePeriod/gml:beginPosition');
 			$this->tmpExtentBegin = $this->tmpExtentBegin[0];
 			if ($this->tmpExtentBegin == "") {
 				$this->tmpExtentBegin = "1900-01-01";
 			}
-			$this->tmpExtentEnd = $iso19139Xml->xpath('//gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:temporalElement/gmd:EX_TemporalExtent/gmd:extent/gml:TimePeriod/gml:endPosition');		
+			$this->tmpExtentEnd = $iso19139Xml->xpath('//gmd:MD_Metadata/gmd:identificationInfo/'.$identifikationXPath.'/gmd:extent/gmd:EX_Extent/gmd:temporalElement/gmd:EX_TemporalExtent/gmd:extent/gml:TimePeriod/gml:endPosition');		
 			$this->tmpExtentEnd = $this->tmpExtentEnd[0];
 			if ($this->tmpExtentEnd == "") {
 				$this->tmpExtentEnd = "1900-01-01";
 			}
 			//spatial_res_type/spatial_res_value
-			$equivalentScale = $iso19139Xml->xpath('//gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:spatialResolution/gmd:MD_Resolution/gmd:equivalentScale/gmd:MD_RepresentativeFraction/gmd:denominator/gco:Integer');
+			$equivalentScale = $iso19139Xml->xpath('//gmd:MD_Metadata/gmd:identificationInfo/'.$identifikationXPath.'/gmd:spatialResolution/gmd:MD_Resolution/gmd:equivalentScale/gmd:MD_RepresentativeFraction/gmd:denominator/gco:Integer');
 			$equivalentScale = $equivalentScale[0];
-			$groundResolution = $iso19139Xml->xpath('//gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:spatialResolution/gmd:MD_Resolution/gmd:distance/gco:Distance');
+			$groundResolution = $iso19139Xml->xpath('//gmd:MD_Metadata/gmd:identificationInfo/'.$identifikationXPath.'/gmd:spatialResolution/gmd:MD_Resolution/gmd:distance/gco:Distance');
 			$groundResolution = $groundResolution[0];
 			if (isset($equivalentScale) && $equivalentScale != "") {
 				$this->spatialResValue = $equivalentScale;
@@ -550,12 +556,12 @@
 			$accessConstraints = $iso19139Xml->xpath('//gmd:MD_Metadata/gmd:identificationInfo//gmd:resourceConstraints/gmd:MD_LegalConstraints[gmd:accessConstraints/gmd:MD_RestrictionCode/@codeListValue="otherRestrictions"]/gmd:otherConstraints/gco:CharacterString');
 			$this->accessConstraints = $accessConstraints[0];
 			//$e = new mb_exception("accessConstraints: ".$accessConstraints[0]);
-			$this->resourceResponsibleParty = $iso19139Xml->xpath('//gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:pointOfContact/gmd:CI_ResponsibleParty/gmd:organisationName/gco:CharacterString');
+			$this->resourceResponsibleParty = $iso19139Xml->xpath('//gmd:MD_Metadata/gmd:identificationInfo/'.$identifikationXPath.'/gmd:pointOfContact/gmd:CI_ResponsibleParty/gmd:organisationName/gco:CharacterString');
 			$this->resourceResponsibleParty = $this->resourceResponsibleParty[0];
-			$this->resourceContactEmail = $iso19139Xml->xpath('//gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:pointOfContact/gmd:CI_ResponsibleParty/gmd:contactInfo/gmd:CI_Contact/gmd:address/gmd:CI_Address/gmd:electronicMailAddress/gco:CharacterString');
+			$this->resourceContactEmail = $iso19139Xml->xpath('//gmd:MD_Metadata/gmd:identificationInfo/'.$identifikationXPath.'/gmd:pointOfContact/gmd:CI_ResponsibleParty/gmd:contactInfo/gmd:CI_Contact/gmd:address/gmd:CI_Address/gmd:electronicMailAddress/gco:CharacterString');
 			$this->resourceContactEmail = $this->resourceContactEmail[0];
 			//parse extension for gmd:resourceMaintenance
-			$updateFrequency = $iso19139Xml->xpath('//gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:resourceMaintenance/gmd:MD_MaintenanceInformation/gmd:maintenanceAndUpdateFrequency/gmd:MD_MaintenanceFrequencyCode[@codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_MaintenanceFrequencyCode"]/@codeListValue');
+			$updateFrequency = $iso19139Xml->xpath('//gmd:MD_Metadata/gmd:identificationInfo/'.$identifikationXPath.'/gmd:resourceMaintenance/gmd:MD_MaintenanceInformation/gmd:maintenanceAndUpdateFrequency/gmd:MD_MaintenanceFrequencyCode[@codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_MaintenanceFrequencyCode"]/@codeListValue');
 			$updateFrequency = $updateFrequency[0];
 			//TODO: push codelists into conf files !
 			//http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_MaintenanceFrequencyCode
@@ -627,8 +633,8 @@
 
 	public function parsePolygon($iso19139Xml, $pathToPolygon) {
 		$polygonalExtentExterior = array();		
-		// //gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:geographicElement/gmd:EX_BoundingPolygon/gmd:polygon/
-		// or //gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:geographicElement/gmd:EX_BoundingPolygon/gmd:polygon/gml:MultiSurface/surfaceMember[1]/
+		// //gmd:MD_Metadata/gmd:identificationInfo/'.$identifikationXPath.'/gmd:extent/gmd:EX_Extent/gmd:geographicElement/gmd:EX_BoundingPolygon/gmd:polygon/
+		// or //gmd:MD_Metadata/gmd:identificationInfo/'.$identifikationXPath.'/gmd:extent/gmd:EX_Extent/gmd:geographicElement/gmd:EX_BoundingPolygon/gmd:polygon/gml:MultiSurface/surfaceMember[1]/
 		if ($iso19139Xml->xpath($pathToPolygon.'gml:Polygon/gml:exterior/gml:LinearRing/gml:posList')) {
 		//read posList
 			$exteriorRingPoints = $iso19139Xml->xpath($pathToPolygon.'gml:Polygon/gml:exterior/gml:LinearRing/gml:posList');

Modified: trunk/mapbender/http/php/mod_callCswMetadata.php
===================================================================
--- trunk/mapbender/http/php/mod_callCswMetadata.php	2019-01-22 07:50:21 UTC (rev 10036)
+++ trunk/mapbender/http/php/mod_callCswMetadata.php	2019-01-22 14:37:18 UTC (rev 10037)
@@ -57,8 +57,11 @@
 //$e = new mb_exception("mod_callMetadata.php: searchURL".$searchURL);
 //decode it !
 $searchURL = urldecode($searchURL);
+//list of possibly hierarchyLevels - iso 19115 MD_ScopeCode 
+$MD_ScopeCode = array("attribute","attributeType","collectionHardware","collectionSession","dataset","series","nonGeographicDataset","dimensionGroup","feature","featureType","propertyType","fieldSession","software","service","model","tile");
+$MD_ScopeCode[] = "application";
+#
 //control if some request variables are not set and set them explicit to NULL
-
 $checkForNullRequests = array("registratingDepartments","isoCategories","inspireThemes","customCategories","regTimeBegin","regTimeEnd","timeBegin","timeEnd","searchBbox","searchTypeBbox","searchResources","orderBy","hostName","resourceIds","restrictToOpenData");
 
 for($i=0; $i < count($checkForNullRequests); $i++){
@@ -355,16 +358,18 @@
 	$testMatch = $_REQUEST["searchResources"];
 	#$pattern = '/^(19|20)[0-9]{2}[-](0[1-9]|1[012])[-](0[1-9]|[12][0-9]|3[01])$/';
 	$countSR = count(explode(',',$testMatch));
- 	if (!($countSR >= 1 && $countSR <= 4)){ 
+ 	if (!($countSR >= 1 && $countSR <= 5)){ 
 		//echo 'searchResources: <b>'.$testMatch.'</b> count of requested resources out of sync.<br/>'; 
-		echo 'Parameter <b>searchResources</b> count of requested resources out of sync.<br/>'; 
+		echo 'Parameter <b>searchResources</b> count of requested resource types is more than 5.<br/>'; 
 		die(); 		
  	} else {
 		$testArray = explode(',',$testMatch);
 		for($i=0; $i<count($testArray);$i++){
-			if (!($testArray[$i] == 'dataset' or $testArray[$i] == 'service' or $testArray[$i] == 'application' or $testArray[$i] == 'nonGeographicDataset')) {
+			if (!in_array($testArray[$i], $MD_ScopeCode)) {
 			//echo 'searchResources: <b>'.$testMatch.'</b>at least one of them does not exists!<br/>'; 
-			echo 'Parameter <b>searchResources</b> at least one of them does not exists! (dataset, service, application, nonGeographicDataset)<br/>';
+			echo 'Parameter <b>searchResources</b> at least one of them does not exists!<br>';
+			echo implode(',',$MD_ScopeCode);
+			echo '<br/>';
 			die();
 			}
 		}
@@ -513,7 +518,8 @@
 //csw Id = catalogueId
 $csw = new csw();
 $csw->createCatObjFromDB($catalogueId);
-if ($csw == false) {
+
+if (is_null($csw->cat_id)) {
 	echo "Catalogue with id ".$catalogueId." not found in mapbender database!";
 	die();
 }
@@ -529,13 +535,18 @@
     $additionalFilter = false;
 }
 $recordType = $searchResources;
+
+//log start time for counting elements via csw
+//$countCswStartTime = microtime_float();
+
 //first count all hits for filter:
-$cswResponseObject = $cswClient->doRequest($cswClient->cswId, 'counthits', false, false, $recordType, false, false, $additionalFilter);
+//$cswResponseObject = $cswClient->doRequest($cswClient->cswId, 'counthits', false, false, $recordType, false, false, $additionalFilter);
 
-$e = new mb_exception("Number of type ".$recordType." datasets in portal CSW: ".$cswClient->operationResult);
-
-$maxRecords = (integer)$cswClient->operationResult;
-$pages = ceil($maxRecords / $maxResults);
+//$e = new mb_exception("Number of type ".$recordType." datasets in portal CSW: ".$cswClient->operationResult);
+//echo "Number of type ".$recordType." datasets in portal CSW: ".$cswClient->operationResult."<br>";
+//$usedCountCswTime = microtime_float() - $countCswStartTime;
+//$maxRecords = (integer)$cswClient->operationResult;
+//$pages = ceil($maxRecords / $maxResults);
 //$e = new mb_exception("pages: ".$pages);
 $metadataArray = array();
 $numberOfMetadataRecords = 0;
@@ -544,30 +555,102 @@
 
 //$e = new mb_exception("maxResults: ".$maxResults);
 
+//log start time of distributed metadatdata search via csw interface
+$searchCswStartTime = microtime_float();
 
-for ($i = 0; $i < 1 ; $i++) {
+//get the first page to also count the available records:
+$i = 0;
+$resultObject = new stdClass;
+foreach ($searchResourcesArray as $searchResource) {
+
+
+//echo $searchResource;
+//for ($i = 0; $i < 1 ; $i++) {
 //for ($i = 0; $i <= $pages-1 ; $i++) {
 	//$cswClient = new cswClient();
 	//$cswClient->cswId = $catalogueId;
-	$result = $cswClient->doRequest($cswClient->cswId, 'getrecordspaging', false, false, $recordType, $maxResults, ($i*$recordsPerPage)+1, $additionalFilter);
-	$page = $i + 1;
+	$result = $cswClient->doRequest($cswClient->cswId, 'getrecordspaging', false, false, $searchResource, $maxResults, $searchPages[$i]*$maxResults+1, $additionalFilter);
+	//$page = $i + 1;
 	//$e = new mb_exception("page: ".$page." (".$pages.")");
 	//$e = new mb_exception("result: ".json_encode($cswClient->operationSuccessful));
 	if ($cswClient->operationSuccessful == true) {
+		//extract number of records matched - for every request!
+		$numberOfRecords = $cswClient->operationResult->xpath('/csw:GetRecordsResponse/csw:SearchResults/@numberOfRecordsMatched');
+		$numberOfRecords = $numberOfRecords[0];
+		$maxRecords = (integer)$numberOfRecords;
+		$maxPages = ceil($maxRecords / $maxResults);
+		//$e = new mb_exception("number of records matched: ".$numberOfRecords);	
 		//$e = new mb_exception("operation successfull");	
 		//$e = new mb_exception(gettype($cswClient->operationResult));
 		$metadataRecord = $cswClient->operationResult->xpath('/csw:GetRecordsResponse/csw:SearchResults/gmd:MD_Metadata');
 		//$e = new mb_exception("number of records: ".count($metadataRecord));
 		//what is possible: keywords, categories?, spatial, ...
+	        $usedSearchCswTime = microtime_float() - $searchCswStartTime;
+
+		$resultObject->{$searchResource}->md->nresults = $maxRecords;
+		$resultObject->{$searchResource}->md->p = $searchPages[$i];
+		$resultObject->{$searchResource}->md->rpp = $maxResults;
+		$resultObject->{$searchResource}->md->genTime = $usedSearchCswTime;
+
+		$parsingMetadataStartTime = microtime_float();
+
 		for ($k = 1; $k <= count($metadataRecord) ; $k++) {
+			
 			$fileIdentifier = $cswClient->operationResult->xpath('/csw:GetRecordsResponse/csw:SearchResults/gmd:MD_Metadata['.$k.']/gmd:fileIdentifier/gco:CharacterString');
 			$fileIdentifier = (string)$fileIdentifier[0];
-			echo $fileIdentifier." - ";
+$resultObject->{$searchResource}->srv[$k-1]->id = $fileIdentifier;
 			$mdDateStamp = $cswClient->operationResult->xpath('/csw:GetRecordsResponse/csw:SearchResults/gmd:MD_Metadata['.$k.']/gmd:dateStamp/gco:Date');
 			$mdDateStamp = (string)$mdDateStamp[0];
-			echo $mdDateStamp."<br>";
-			$datasetIdentifier = $cswClient->operationResult->xpath('/csw:GetRecordsResponse/csw:SearchResults/gmd:MD_Metadata['.$k.']/gmd:identificationInfo/gmd:MD_DataIdentification/@uuid');
+$resultObject->{$searchResource}->srv[$k-1]->date = $mdDateStamp;
+			switch ($searchResource) {
+				case "service": 
+					$identifikationXPath = "srv:SV_ServiceIdentification";
+					break;
+				default:
+					$identifikationXPath = "gmd:MD_DataIdentification";
+					break;
+			}
+			$datasetIdentifier = $cswClient->operationResult->xpath('/csw:GetRecordsResponse/csw:SearchResults/gmd:MD_Metadata['.$k.']/gmd:identificationInfo/'.$identifikationXPath.'/@uuid');
 			$datasetidentifier = (string)$datasetidentifier[0];
+			//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');
+
+			if (is_array($previewImage) && $previewImage[0] !== '') {
+				$previewImage = (string)$previewImage[0];
+			} else {
+				$previewImage = null;
+			}
+
+$resultObject->{$searchResource}->srv[$k-1]->previewUrl = $previewImage;
+
+			//organization name
+			$resourceResponsibleParty = $cswClient->operationResult->xpath('/csw:GetRecordsResponse/csw:SearchResults/gmd:MD_Metadata['.$k.']/gmd:identificationInfo/'.$identifikationXPath.'/gmd:pointOfContact/gmd:CI_ResponsibleParty/gmd:organisationName/gco:CharacterString');
+			$resourceResponsibleParty = $resourceResponsibleParty[0];
+$resultObject->{$searchResource}->srv[$k-1]->respOrg = (string)$resourceResponsibleParty;
+			//box
+			//title
+			$title = $cswClient->operationResult->xpath('/csw:GetRecordsResponse/csw:SearchResults/gmd:MD_Metadata['.$k.']/gmd:identificationInfo/'.$identifikationXPath.'/gmd:citation/gmd:CI_Citation/gmd:title/gco:CharacterString');
+			$title = $title[0];
+$resultObject->{$searchResource}->srv[$k-1]->title = (string)$title;
+			//abstract
+			$abstract = $cswClient->operationResult->xpath('/csw:GetRecordsResponse/csw:SearchResults/gmd:MD_Metadata['.$k.']/gmd:identificationInfo/'.$identifikationXPath.'/gmd:abstract/gco:CharacterString');
+			$abstract = $abstract[0];
+$resultObject->{$searchResource}->srv[$k-1]->abstract = substr((string)$abstract,0,250);
+			//mdLink
+			//geturl for get recordbyid request
+			if (isset($csw->cat_op_values['getrecordbyid']['get'])) {
+				$resultObject->{$searchResource}->srv[$k-1]->mdLink = $csw->cat_op_values['getrecordbyid']['get']."?request=GetRecordById&service=CSW&version=2.0.2&Id=".$fileIdentifier."&ElementSetName=full&OUTPUTSCHEMA=http://www.isotc211.org/2005/gmd";
+			}
+			//html view
+			$resultObject->{$searchResource}->srv[$k-1]->htmlLink = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."/../mod_exportIso19139.php?".urlencode($resultObject->{$searchResource}->srv[$k-1]->mdLink);
+
+			//service urls if available 
+			//type of service
+			//inspire url for service
+			
+			
+
+			
 			$url =  $cswClient->operationResult->xpath('/csw:GetRecordsResponse/csw:SearchResults/gmd:MD_Metadata['.$k.']/gmd:distributionInfo/gmd:MD_Distribution/gmd:transferOptions/gmd:MD_DigitalTransferOptions/gmd:onLine/gmd:CI_OnlineResource/gmd:linkage/gmd:URL');
 			$url = (string)$url[0];
 			if (isset($url) && $url !=="") {
@@ -577,8 +660,15 @@
 				$numberOfMetadataRecords++;
 			}
 		}
+		$usedParsingMetadataTime = microtime_float() - $parsingMetadataStartTime;
+		//echo "Count time: ".$usedCountCswTime."<br>";
+		//echo "Search time: ".$usedSearchCswTime."<br>";
+		//echo "Parsing time: ".$usedParsingMetadataTime."<br>";
 	}
+        $i++;
 }
+echo json_encode($resultObject);
+//}
 //************************************************************************************
 //functions
 //************************************************************************************
@@ -692,5 +782,9 @@
 function isValidURL($url) {
 	return preg_match('|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $url);
 }
+function microtime_float() {
+    	list($usec, $sec) = explode(" ", microtime());
+    	return ((float)$usec + (float)$sec);
+}
 
 ?>



More information about the Mapbender_commits mailing list