]> git.street.me.uk Git - andy/gpx.git/blobdiff - src/libgpx/gpx.php
Add extensions for GPX type
[andy/gpx.git] / src / libgpx / gpx.php
index 3d45b6f8adaf6ab258502bedeecc07b8d689cfe8..61e9e58db098aeb26e4636026bd387a88b1b2624 100644 (file)
@@ -113,6 +113,20 @@ class GPX implements Geographic
    */
   protected $routes;
 
+  /**
+   * A list of tracks.
+   *
+   * @var TypedDoublyLinkedList (Track)
+   */
+  protected $tracks;
+
+  /**
+   * A list of XML snippets describing unsupported elements.
+   *
+   * @var TypedDoublyLinkedList (string)
+   */
+  protected $extensions;
+
   /**
    * Fetch the name of the program that created the GPX file.
    *
@@ -303,6 +317,32 @@ class GPX implements Geographic
     return $this->routes;
   }
 
+  /**
+   * Fetch a list of tracks.
+   *
+   * @param boolean $create Create the list if it does not already exist.
+   * @return TypedDoublyLinkedList A list of tracks.
+   */
+  public function getTracks(bool $create = true)
+  {
+    if ($create && $this->tracks === null)
+      $this->tracks = new TypedDoublyLinkedList('libgpx\Track');
+    return $this->tracks;
+  }
+
+  /**
+   * Fetch a list of protocol extensions as raw XML.
+   *
+   * @param boolean $create Create the list if it does not already exist.
+   * @return TypedDoublyLinkedList A list of protocol extensions.
+   */
+  public function getExtensions(bool $create = true)
+  {
+    if ($create && $this->extensions === null)
+      $this->extensions = new TypedDoublyLinkedList('string');
+    return $this->extensions;
+  }
+
   /**
    * Fetch a bounding box that covers the feature.
    *
@@ -314,7 +354,8 @@ class GPX implements Geographic
     $result = null;
     $lists = [
       $this->waypoints,
-      $this->routes
+      $this->routes,
+      $this->tracks
     ];
     foreach ($lists as $list) {
       if ($list === null) continue;