You are here

public function Geometry::union in geoPHP 8

Same name and namespace in other branches
  1. 7 geoPHP/lib/geometry/Geometry.class.php \Geometry::union()

File

geoPHP/lib/geometry/Geometry.class.php, line 222

Class

Geometry
Geometry abstract class

Code

public function union(Geometry $geometry) {
  if ($this
    ->geos()) {
    if (is_array($geometry)) {
      $geom = $this
        ->geos();
      foreach ($geometry as $item) {
        $geom = $geom
          ->union($item
          ->geos());
      }
      return geoPHP::geosToGeometry($geos);
    }
    else {
      return geoPHP::geosToGeometry($this
        ->geos()
        ->union($geometry
        ->geos()));
    }
  }
}