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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Thu Nov 15 03:10:45 PST 2018


Author: armin11
Date: 2018-11-15 03:10:44 -0800 (Thu, 15 Nov 2018)
New Revision: 9999

Modified:
   trunk/mapbender/http/php/mod_dataISOMetadata.php
Log:
Enhancement when exporting dataset iso metadata from metador - also when only simple polygons are given

Modified: trunk/mapbender/http/php/mod_dataISOMetadata.php
===================================================================
--- trunk/mapbender/http/php/mod_dataISOMetadata.php	2018-11-14 20:40:13 UTC (rev 9998)
+++ trunk/mapbender/http/php/mod_dataISOMetadata.php	2018-11-15 11:10:44 UTC (rev 9999)
@@ -113,6 +113,7 @@
 	$mb_metadata = $row;
 
 	//parse polygon to add needed gml:id attributes for metadata validation
+	$mb_metadata['boundingGmlMultiPolygon'] = false;
 	if (isset($row['bounding_polygon']) && $row['bounding_polygon'] != '') {
 		//extract coordinates from gml
 		//push them into array
@@ -126,14 +127,14 @@
 			$gml3 = simplexml_load_string($gml3FromPostgis);
 			if ($gml3 === false) {
 				foreach(libxml_get_errors() as $error) {
-        				$err = new mb_exception("class_Iso19139:".$error->message);
+        				$err = new mb_exception("php/mod_dataISOMetadata.php:".$error->message);
     				}
-				throw new Exception("class_Iso19139:".'Cannot parse Metadata XML!');
+				throw new Exception("php/mod_dataISOMetadata.php:".'Cannot parse Metadata XML!');
 				return false;
 			}
 		}
 		catch (Exception $e) {
-    			$err = new mb_exception("class_Iso19139:".$e->getMessage());
+    			$err = new mb_exception("php/mod_dataISOMetadata.php:".$e->getMessage());
 			return false;
 		}			
 		//if parsing was successful
@@ -153,13 +154,12 @@
 					$polygon = $polygon[0];
 					$polygon->addAttribute('gml:gml:id', md5($polygon->asXML()));
 				}
+				$mb_metadata['boundingGmlMultiPolygon'] = true;
 			} else { 
-				$e = new mb_notice("php/mod_dataISOMetadata.php: no MultiSurface found!");
+				$e = new mb_notice("php/mod_dataISOMetadata.php: no MultiSurface found - search for polygon!");
 				if($gml3->xpath('//gml:Polygon')) {
 					$e = new mb_notice("php/mod_dataISOMetadata.php: number of polygons: 1");
-					$polygon = $gml3->xpath('//gml:Polygon');
-					$polygon = $polygon[0];
-					$polygon->addAttribute('gml:gml:id', md5($polygon->asXML()));
+					$gml3->addAttribute('gml:gml:id', md5($gml3->asXML()));
 				}
 			}
 		}
@@ -1480,7 +1480,11 @@
 		$gmlDoc = new DOMDocument();
 		$gmlDoc->loadXML($mb_metadata['boundingPolygonGml']);
 		$xpathGml = new DOMXpath($gmlDoc);
-		$gmlNodeList = $xpathGml->query('/gml:MultiSurface');
+		if ($mb_metadata['boundingGmlMultiPolygon'] == true) {
+			$gmlNodeList = $xpathGml->query('/gml:MultiSurface');
+		} else {
+			$gmlNodeList = $xpathGml->query('/gml:Polygon');
+		}
 		for ($i = ($gmlNodeList->length)-1; $i >= 0; $i--) {
 			$polygon->appendChild($iso19139->importNode($gmlNodeList->item($i), true));
 		}



More information about the Mapbender_commits mailing list