<?php
|
|
|
|
namespace OSM\Element\Member;
|
|
|
|
use OSM\Element\Member\Member;
|
|
use OSM\Point;
|
|
|
|
class Way extends Member {
|
|
|
|
public array $points = [];
|
|
|
|
public function completeFromArray(array $array): static
|
|
{
|
|
$hasGeometry = isset($array['geometry']);
|
|
if ($hasGeometry) {
|
|
$items = $array['geometry'];
|
|
foreach ($items as $item) {
|
|
$point = Point::createFromArray($item);
|
|
$this->points[] = $point;
|
|
}
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getFirstPoint(): Point {
|
|
return reset($this->points);
|
|
}
|
|
|
|
public function getLastPoint(): Point {
|
|
return end($this->points);
|
|
}
|
|
|
|
public function reversePoints(): static {
|
|
$this->points = array_reverse($this->points);
|
|
return $this;
|
|
}
|
|
}
|