5 * Copyright 2018 Andy Street <andy@street.me.uk>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
30 * @author Andy Street <andy@street.me.uk>
32 class TrackSegment implements Geographic
36 * A list of track points.
38 * @var TypedDoublyLinkedList (Point)
43 * A list of XML snippets describing unsupported data.
45 * @var TypedDoublyLinkedList (string)
47 protected $extensions;
50 * Fetch an ordered list of points that defines this track segment.
52 * @param boolean $create Create the list if it does not already exist.
53 * @return TypedDoublyLinkedList|null A list points.
55 public function getPoints(bool $create = true)
57 if ($create && $this->points === null)
58 $this->points = new TypedDoublyLinkedList('libgpx\Point');
63 * Fetch a list of XML strings that describe unsupported elements.
65 * @param boolean $create Create the list if it does not already exist.
66 * @return TypedDoublyLinkedList|null A list of XML strings.
68 public function getExtensions(bool $create = true)
70 if ($create && $this->extensions === null)
71 $this->extensions = new TypedDoublyLinkedList('string');
72 return $this->extensions;
76 * Fetch a bounding box that covers the feature.
78 * @return Bounds|null A bounding box covering the extent of the feature or
79 * null if not applicable.
81 public function getBounds()
84 if ($this->points !== null) {
85 foreach ($this->points as $point) {
86 $bounds = $point->getBounds();
87 $result = ($result === null ? $bounds : $result->extend($bounds));