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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Fri Sep 19 05:53:09 PDT 2014


Author: armin11
Date: 2014-09-19 05:53:09 -0700 (Fri, 19 Sep 2014)
New Revision: 9079

Modified:
   trunk/mapbender/http/classes/class_iso19139.php
Log:
Bugfix for parsing polygons

Modified: trunk/mapbender/http/classes/class_iso19139.php
===================================================================
--- trunk/mapbender/http/classes/class_iso19139.php	2014-09-19 12:52:51 UTC (rev 9078)
+++ trunk/mapbender/http/classes/class_iso19139.php	2014-09-19 12:53:09 UTC (rev 9079)
@@ -75,7 +75,7 @@
 		$this->changeDate = "1900-01-01";
 		$this->metadata = "";
 		$this->wgs84Bbox = array(-180.0,-90.0,180.0,90.0); //minx, miny, maxx, maxy in EPSG:4326
-		$this->polygonalExtentExterior = array(); //initialize empty array
+		$this->polygonalExtentExterior = null; //initialize as null, cause it may be empty
 		$this->datasetId = "";
 		$this->datasetIdCodeSpace = "";	
 		$this->keywords = array();
@@ -303,14 +303,17 @@
 			//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')) {
 				//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'));
-				$e = new mb_exception("class_iso19139.php: found multisurface element");
+				//$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/');
+					$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) .']/');
 				}
 			} else { 
-				$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/');
-
+				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')) {
+					$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->hierachyLevel = $iso19139Xml->xpath('//gmd:MD_Metadata/gmd:hierarchyLevel/gmd:MD_ScopeCode');
 			$this->hierachyLevel = $this->hierachyLevel[0];
@@ -878,13 +881,17 @@
 				if ($gml3 !== false) {
 					//check count of polygons
 					if ($gml3->xpath('//gml:MultiSurface')) {
+						$this->polygonalExtentExterior = array();
 						//count surfaceMembers
 						$numberOfSurfaces = count($gml3->xpath('//gml:MultiSurface/gml:surfaceMember'));
 						for ($k = 0; $k < $numberOfSurfaces; $k++) {
 							$this->polygonalExtentExterior[] = $this->parsePolygon($gml3, '//gml:MultiSurface/gml:surfaceMember/');
 						}
 					} else { 
-						$this->polygonalExtentExterior[0] = $this->parsePolygon($gml3, '/');
+						if($gml3->xpath('//gml:Polygon')) {
+							$this->polygonalExtentExterior = array();
+							$this->polygonalExtentExterior[0] = $this->parsePolygon($gml3, '/');
+						}
 					}
 				}
 			}
@@ -1252,6 +1259,7 @@
 				$postGisPolygon .= "))";
 			}
 		}
+		//$e = new mb_exception("class_Iso19139.php: wkt: ".$postGisPolygon);
 		return $postGisPolygon;
 	}
 



More information about the Mapbender_commits mailing list