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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Fri May 10 04:05:44 PDT 2019


Author: armin11
Date: 2019-05-10 04:05:44 -0700 (Fri, 10 May 2019)
New Revision: 10118

Modified:
   trunk/mapbender/http/classes/class_crs.php
   trunk/mapbender/http/classes/class_iso19139.php
Log:
Fix for wrong date fields in iso metadata - set them default to 1900-01-01 if they are wrong. Fix for parsing crs - if version of registry is not given in urn notation.

Modified: trunk/mapbender/http/classes/class_crs.php
===================================================================
--- trunk/mapbender/http/classes/class_crs.php	2019-05-09 09:43:10 UTC (rev 10117)
+++ trunk/mapbender/http/classes/class_crs.php	2019-05-10 11:05:44 UTC (rev 10118)
@@ -90,7 +90,15 @@
 				$identifierNew = str_replace('URN:OGC:DEF:CRS:EPSG:','',strtoupper($identifier));			
 				$this->identifier = $identifier;
 				$this->identifierType = 'urn';
-				$this->identifierCode = explode(':',$identifierNew)[1];			
+				if (substr($identifierNew, 0, 1 ) === ":") {
+				    $this->identifierCode = ltrim($identifierNew, ':');
+				} else {
+				    if (strpos($identifierNew, ":") !== false) {
+				    	$this->identifierCode = explode(':',$identifierNew)[1];
+				    } else {
+					$this->identifierCode = $identifierNew;
+				    }
+				}			
 				return;
 			} else {
 				//case urn:x-ogc:def:crs:EPSG:25832?? - geoserver

Modified: trunk/mapbender/http/classes/class_iso19139.php
===================================================================
--- trunk/mapbender/http/classes/class_iso19139.php	2019-05-09 09:43:10 UTC (rev 10117)
+++ trunk/mapbender/http/classes/class_iso19139.php	2019-05-10 11:05:44 UTC (rev 10118)
@@ -631,6 +631,19 @@
 		/*if (count($this->{$objectPrefix."Categories"}) && $this->{$objectPrefix."Categories"}[0] == 0) {
 			$this->{$objectPrefix."Categories"} = array();
 		}*/
+		//qualify date date/time fields
+		$dateFields = array("createDate", "changeDate", "tmpExtentBegin", "tmpExtentEnd");
+		foreach ($dateFields as $dateField) {
+			$valueToCheck = $this->{$dateField};
+			//validate to iso date format YYYY-MM-DD
+			$testMatch = $valueToCheck;
+			$pattern = '/^(19|20)[0-9]{2}[-](0[1-9]|1[012])[-](0[1-9]|[12][0-9]|3[01])$/';		
+ 			if (!preg_match($pattern,$testMatch)){ 
+				$e = new mb_exception("classes/class_iso19139.php: invalid date format for attribute ".$dateField." - found: ".$valueToCheck.". Set it to 1900-01-01!");
+				$this->{$dateField} = "1900-01-01";
+				$this->harvestException = $this->harvestException."\nInvalid date format for attribute ".$dateField." - found: ".$valueToCheck.". Set it to 1900-01-01!";	
+ 			}
+		}
 	}
 
 	public function parsePolygon($iso19139Xml, $pathToPolygon) {
@@ -2437,8 +2450,8 @@
 				'f',
 				$this->randomId,
 				$this->owner,
-				$this->harvestresult,
-				$this->harvestexception
+				$this->harvestResult,
+				$this->harvestException
 			);
 			$t = array('s','s','s','s','b','s','i','i','s');
 		}	



More information about the Mapbender_commits mailing list