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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Wed Feb 27 05:20:16 PST 2013


Author: verenadiewald
Date: 2013-02-27 05:20:16 -0800 (Wed, 27 Feb 2013)
New Revision: 8577

Modified:
   trunk/mapbender/http/classes/class_gml_multipolygon.php
Log:
return correct bbox for multipolygons

Modified: trunk/mapbender/http/classes/class_gml_multipolygon.php
===================================================================
--- trunk/mapbender/http/classes/class_gml_multipolygon.php	2013-02-27 13:19:02 UTC (rev 8576)
+++ trunk/mapbender/http/classes/class_gml_multipolygon.php	2013-02-27 13:20:16 UTC (rev 8577)
@@ -182,20 +182,41 @@
 		return $str;
 	}
 	
-	public function getBbox () {
-		$bboxArray = array();
-        for ($i = 0; $i < count($this->polygonArray); $i++) {
-        	if($this->polygonArray[$i]["x"] && $this->polygonArray[$i]["y"]) {
-            	$p = new Mapbender_point(
-                	$this->polygonArray[$i]["x"],
-                    $this->polygonArray[$i]["y"],
-                    $this->srs
-                );
-                $bboxArray[]= new Mapbender_bbox($p, $p, $this->srs);
-           	}
-     	}
-        return Mapbender_bbox::union($bboxArray);
-   	}
+		public function getBbox () {
+                $bboxArray = array();
+                $numberPolygonArray = count($this->polygonArray);
+                if ($numberPolygonArray > 0) {
+                        for ($cnt =0; $cnt < $numberPolygonArray; $cnt++){
+                                for ($i=0; $i < count($this->polygonArray[$cnt]); $i++) {
+                                        if($this->polygonArray[$cnt][$i]["x"] && $this->polygonArray[$cnt][$i]["y"]) {
+                                                $p = new Mapbender_point(
+                                                                $this->polygonArray[$cnt][$i]["x"],
+                                                                $this->polygonArray[$cnt][$i]["y"],
+                                                                $this->srs
+                                                );
+                                                $bboxArray[]= new Mapbender_bbox($p, $p, $this->srs);
+                                        }       
+                                }
+                                
+                                for ($i=0; $i < count($this->innerRingArray[$cnt]); $i++) {
+                                        for ($j=0; $j < count($this->innerRingArray[$cnt][$i]); $j++) {
+                                                if($this->innerRingArray[$cnt][$i][$j]["x"] && $this->innerRingArray[$cnt][$i][$j]["y"]) {
+                                                        $p = new Mapbender_point(
+                                                                        $this->innerRingArray[$cnt][$i][$j]["x"],
+                                                                        $this->innerRingArray[$cnt][$i][$j]["y"],
+                                                                        $this->srs
+                                                        );
+                                                        $bboxArray[]= new Mapbender_bbox($p, $p, $this->srs);
+                                                }
+                                        }
+                                }
+                        }
+                        return Mapbender_bbox::union($bboxArray);
+                }
+                else {
+                        $e = new mb_exception("GMLMultiPolygon: getBbox: this multiPolygon is null.");
+                }
+        }
 	
 }
 ?>



More information about the Mapbender_commits mailing list