/**
  * Computes a new bounding box, bbox1 UNION bbox2
  */
 static function union($bboxArray)
 {
     if (count($bboxArray) == 1) {
         return array_pop($bboxArray);
     } elseif (count($bboxArray) >= 2) {
         $bbox1 = array_pop($bboxArray);
         $bbox2 = Mapbender_bbox::union($bboxArray);
         if (!($bbox1 != null && $bbox1->isValid()) && !($bbox2 != null && $bbox2->isValid())) {
             $e = new mb_exception("Mapbender_bbox: union: both parameters invalid!");
             return null;
         } elseif (!($bbox1 != null && $bbox1->isValid()) && ($bbox2 != null && $bbox2->isValid())) {
             $e = new mb_exception("Mapbender_bbox: union: first parameter invalid!");
             return $bbox2;
         } elseif ($bbox1 != null && $bbox1->isValid() && !($bbox2 != null && $bbox2->isValid())) {
             $e = new mb_exception("Mapbender_bbox: union: second parameter invalid!");
             return $bbox1;
         } else {
             if ($bbox1->epsg == $bbox2->epsg) {
                 $e = new mb_notice("Mapbender_bbox: union: bbox1 is: " . $bbox1);
                 $e = new mb_notice("Mapbender_bbox: union: bbox2 is: " . $bbox2);
                 $e = new mb_notice("Mapbender_bbox: union: merging bbox1 and bbox2...");
                 return new Mapbender_bbox(Mapbender_point::min($bbox1->min, $bbox2->min), Mapbender_point::max($bbox1->max, $bbox2->max), $bbox1->epsg);
             } else {
                 $e = new mb_exception("Mapbender_bbox: cannot process union with different EPSG codes");
             }
         }
     } else {
         $e = new mb_exception("Mapbender_bbox: Invalid parameter (Not an array)!");
     }
     return null;
 }