You are here

public function LineString::isSimple in geoPHP 7

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

Overrides Collection::isSimple

1 call to LineString::isSimple()
LineString::isRing in geoPHP/lib/geometry/LineString.class.php

File

geoPHP/lib/geometry/LineString.class.php, line 139

Class

LineString
LineString. A collection of Points representing a line. A line can have more than one segment.

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;
}