You are here

public function LineString::explode in geoPHP 8

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

Overrides Collection::explode

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

File

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

Class

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

Code

public function explode() {
  $parts = array();
  $points = $this
    ->getPoints();
  foreach ($points as $i => $point) {
    if (isset($points[$i + 1])) {
      $parts[] = new LineString(array(
        $point,
        $points[$i + 1],
      ));
    }
  }
  return $parts;
}