[Mapbender-commits] r9647 - trunk/mapbender/http/classes

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Thu Jan 12 01:33:13 PST 2017


Author: armin11
Date: 2017-01-12 01:33:13 -0800 (Thu, 12 Jan 2017)
New Revision: 9647

Modified:
   trunk/mapbender/http/classes/class_iso19139.php
Log:
New possibility to test the conformancy declarations in metadata again a inspire legislation conf file (json based)

Modified: trunk/mapbender/http/classes/class_iso19139.php
===================================================================
--- trunk/mapbender/http/classes/class_iso19139.php	2017-01-12 09:31:37 UTC (rev 9646)
+++ trunk/mapbender/http/classes/class_iso19139.php	2017-01-12 09:33:13 UTC (rev 9647)
@@ -58,6 +58,7 @@
 	var $lineage;
 	var $inspireTopConsistence; //db bool, 't' or 'f'
 	var $inspireInteroperability; //db bool, 't' or 'f' - declaration if the provided data should be compliant with the interoperablity implementing rule
+	var $inspireResulations; //array of actual inspire regulations which are relevant for this metadata representation (dataset/service) 
 	var $spatialResType;
 	var $spatialResValue;
 	var $export2Csw; //db bool, 't' or 'f'
@@ -142,11 +143,54 @@
 		$this->resourceContactEmail = null;
 		$this->previewImage = null;
 		$this->codeListUpdateFrequencyArray = $codeListUpdateFrequencyArray;
-		//read inspire legislation info from json file
-		//$e = new mb_exception(__FILE__ ."/../../conf/inspire_legislation.json");
-		//$this->inspireLegislation = json_decode(file_get_contents(__FILE__ ."/../../../conf/inspire_legislation.json"), true);
-		//$e = new mb_exception(json_encode($this->inspireLegislation));
+		//read inspire legislation info from json file - enhancement for INSPIRE - maybe to be defined as an extension of the class in further developments!
+		//source: http://inspire.ec.europa.eu/inspire-legislation/
+		$inspireLegislationConf = realpath(dirname(__FILE__) ."/../../conf/inspire_legislation.json");
+		$this->inspireLegislation = json_decode(file_get_contents($inspireLegislationConf));
+		$this->inspireRegulations = $this->getRelevantInspireRegulations();
 	}
+	
+	public function getRelevantInspireRegulations($withAmendmentAndCorrigendum = true) {
+		//use $this->hierachyLevel and give back all relevant regulations (only the newest of each type) with their dates in the requested language
+		$language = $this->inspireLegislation->default_language;
+		$countInspireRegulations = 0;
+		$regulations = array();
+		if ($withAmendmentAndCorrigendum == true) {
+			//$legislationTypeArray = array("legislation","legislation_amendment","legislation_corrigendum");
+			$legislationTypeArray = array("legislation","legislation_amendment");
+		} else {
+			$legislationTypeArray = array("legislation");
+		}
+		//iterate over object and array !
+		foreach ($this->inspireLegislation as $inspire_rules) {
+			foreach ($inspire_rules as $regulation) { 
+				if (in_array($regulation->type, $legislationTypeArray) && in_array($regulation->group, array("data_specifications","metadata","network_services"))) {
+					if (in_array($this->hierachyLevel, $regulation->subject)) {
+						//check if already a regulation with this name exists in the array - if it is already there, check if the date is newer or older!
+						$keyInArray = array_search($regulation->label->{$language}, array_column($regulations, 'name'));//TODO []
+						if ($keyInArray !== false) {
+							$newDateTime = new dateTime($regulation->date);
+							if ($newDateTime < $regulations[$keyInArray]['date']) {
+								$regulations[$keyInArray]['date'] = $newDateTime;
+							}
+						} else {
+							$regulations[$countInspireRegulations]['date'] = new dateTime($regulation->date);
+							$regulations[$countInspireRegulations]['name'] = $regulation->label->{$language};
+							$regulations[$countInspireRegulations]['type'] = $regulation->group;
+							$countInspireRegulations++;
+						}
+					}
+				}
+			}
+		}
+		//debug output
+		/*foreach ($regulations as $reg) {
+			$e = new mb_exception("regulation date: ".$reg['date']->format('Y-m-d'));
+			$e = new mb_exception("regulation: ".$reg['name']);
+			$e = new mb_exception("regulation type: ".$reg['type']);
+		}*/
+		return $regulations;
+	}
 
 	public function removeGetRecordTag ($xml) {
 		$regex = "#<csw:GetRecordByIdResponse .*?>#";
@@ -470,6 +514,39 @@
 			if (in_array($updateFrequency, $codeListUpdateFrequencyArray)) {
 				$this->updateFrequency = $updateFrequency;
 			}
+			//check declaration of inspire conformity - only true if true for all relevant regulations is declared!
+			$this->inspireInteroperability = 't';
+			$interoperabilityArray = array();
+			$countInteroperabilityArray = 0;
+			foreach ($this->inspireRegulations as $regulation) {
+				$interoperabilityArray[$countInteroperabilityArray]['name'] = $regulation['name'];
+				$interoperabilityArray[$countInteroperabilityArray]['date'] = $regulation['date']->format('Y-m-d');
+				$interoperabilityArray[$countInteroperabilityArray]['pass'] = null;
+				//get boolean from metadata
+				//string(//gmd:MD_Metadata/gmd:dataQualityInfo/gmd:DQ_DataQuality/gmd:report/gmd:DQ_DomainConsistency/gmd:result/gmd:DQ_ConformanceResult[gmd:specification/gmd:CI_Citation/gmd:title/gco:CharacterString="Verordnung (EG) Nr. 1205/2008 der Kommission vom 3. Dezember 2008 zur Durchführung der Richtlinie 2007/2/EG des Europäischen Parlaments und des Rates hinsichtlich Metadaten" and gmd:specification/gmd:CI_Citation/gmd:date/gmd:CI_Date/gmd:date/gco:Date="2008-12-03"]/gmd:pass/gco:Boolean)
+				$conformanceStatement = $iso19139Xml->xpath('//gmd:MD_Metadata/gmd:dataQualityInfo/gmd:DQ_DataQuality/gmd:report/gmd:DQ_DomainConsistency/gmd:result/gmd:DQ_ConformanceResult[gmd:specification/gmd:CI_Citation/gmd:title/gco:CharacterString="'.$regulation['name'].'" and gmd:specification/gmd:CI_Citation/gmd:date/gmd:CI_Date/gmd:date/gco:Date="'.$regulation['date']->format('Y-m-d').'"]/gmd:pass/gco:Boolean');
+				//problem: xpath extract this element strange - the first entry is a string object 
+				$conformanceStatement = (string)$conformanceStatement[0];
+				switch ($conformanceStatement) {
+					case "true":
+						$interoperabilityArray[$countInteroperabilityArray]['pass'] = "true";
+   						break;
+					case "false":
+						$interoperabilityArray[$countInteroperabilityArray]['pass'] = "false";
+						$this->inspireInteroperability = 'f';
+					default:
+						$interoperabilityArray[$countInteroperabilityArray]['pass'] = "not declared";
+						$this->inspireInteroperability = 'f';
+						break;
+				}
+				$countInteroperabilityArray++;
+			}
+			//for debugging purposes
+			foreach ($interoperabilityArray as $declaredSpec) {
+				$e = new mb_exception("classes/class_iso19139.php: check conformance declaration: name: ".$declaredSpec['name']. " - date: ".$declaredSpec['date']." - pass: ".$declaredSpec['pass']);
+				
+			}
+			$e = new mb_notice("classes/class_iso19139.php: sufficient declared inspire conformity: ".$this->inspireInteroperability);
 			$this->qualifyMetadata();
 			return $this;
 		} else {



More information about the Mapbender_commits mailing list