You are here

public function Polygon::isSimple in geoPHP 8

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

Overrides Collection::isSimple

File

geoPHP/lib/geometry/Polygon.class.php, line 119

Class

Polygon
Polygon: A polygon is a plane figure that is bounded by a closed path, composed of a finite sequence of straight line segments

Code

public function isSimple() {
  if ($this
    ->geos()) {
    return $this
      ->geos()
      ->isSimple();
  }
  $segments = $this
    ->explode();
  foreach ($segments as $i => $segment) {
    foreach ($segments as $j => $check_segment) {
      if ($i != $j) {
        if ($segment
          ->lineSegmentIntersect($check_segment)) {
          return FALSE;
        }
      }
    }
  }
  return TRUE;
}