You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
808 B

1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
  1. <?php
  2. namespace OSM\Element\Member;
  3. use OSM\Point;
  4. class Way extends Member
  5. {
  6. public array $points = [];
  7. public function completeFromArray(array $array): static
  8. {
  9. $hasGeometry = isset($array['geometry']);
  10. if ($hasGeometry) {
  11. $items = $array['geometry'];
  12. foreach ($items as $item) {
  13. $point = Point::createFromArray($item);
  14. $this->points[] = $point;
  15. }
  16. }
  17. return $this;
  18. }
  19. public function getFirstPoint(): Point
  20. {
  21. return reset($this->points);
  22. }
  23. public function getLastPoint(): Point
  24. {
  25. return end($this->points);
  26. }
  27. public function reversePoints(): static
  28. {
  29. $this->points = array_reverse($this->points);
  30. return $this;
  31. }
  32. }