Class Track

java.lang.Object
io.jenetics.jpx.Track
All Implemented Interfaces:
Serializable, Iterable<TrackSegment>

public final class Track extends Object implements Iterable<TrackSegment>, Serializable
Represents a GPX track - an ordered list of points describing a path.

Creating a Track object with one track-segment and 3 track-points:

final Track track = Track.builder() .name("Track 1") .description("Mountain bike tour.") .addSegment(segment -> segment .addPoint(p -> p.lat(48.2081743).lon(16.3738189).ele(160)) .addPoint(p -> p.lat(48.2081743).lon(16.3738189).ele(161)) .addPoint(p -> p.lat(48.2081743).lon(16.3738189).ele(162)))) .addSegment(segment -> segment .addPoint(p -> p.lat(46.2081743).lon(16.3738189).ele(160)) .addPoint(p -> p.lat(47.2081743).lon(16.3738189).ele(161)) .addPoint(p -> p.lat(49.2081743).lon(16.3738189).ele(162)))) .build();
Since:
1.0
Version:
1.5
See Also:
  • Method Details

    • getName

      public Optional<String> getName()
      Return the track name.
      Returns:
      the track name
    • getComment

      Return the GPS comment of the track.
      Returns:
      the GPS comment of the track
    • getDescription

      Return the text description of the track.
      Returns:
      the text description of the track
    • getSource

      Return the source of data. Included to give user some idea of reliability and accuracy of data.
      Returns:
      the source of data
    • getLinks

      public List<Link> getLinks()
      Return the links to external information about the track.
      Returns:
      the links to external information about the track
    • getNumber

      public Optional<UInt> getNumber()
      Return the GPS track number.
      Returns:
      the GPS track number
    • getType

      public Optional<String> getType()
      Return the type (classification) of the track.
      Returns:
      the type (classification) of the track
    • getExtensions

      Return the (cloned) extensions document. The root element of the returned document has the name extensions.
      <extensions> ... </extensions>
      Returns:
      the extensions document
      Throws:
      DOMException - if the document could not be cloned, because of an erroneous XML configuration
      Since:
      1.5
    • getSegments

      Return the sequence of route points.
      Returns:
      the sequence of route points
    • segments

      Return a stream of TrackSegment objects this track contains.
      Returns:
      a stream of TrackSegment objects this track contains
    • iterator

      Specified by:
      iterator in interface Iterable<TrackSegment>
    • toBuilder

      Convert the immutable track object into a mutable builder initialized with the current track values.
      Returns:
      a new track builder initialized with the values of this track
      Since:
      1.1
    • isEmpty

      public boolean isEmpty()
      Return true if all track properties are null or empty.
      Returns:
      true if all track properties are null or empty
    • nonEmpty

      public boolean nonEmpty()
      Return true if not all track properties are null or empty.
      Returns:
      true if not all track properties are null or empty
      Since:
      1.1
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • builder

      public static Track.Builder builder()
    • of

      public static Track of(String name, String comment, String description, String source, List<Link> links, UInt number, String type, Document extensions, List<TrackSegment> segments)
      Create a new Track with the given parameters.
      Parameters:
      name - the GPS name of the track
      comment - the GPS comment for the track
      description - user description of the track
      source - the source of data. Included to give user some idea of reliability and accuracy of data.
      links - the links to external information about track
      number - the GPS track number
      type - the type (classification) of track
      extensions - the extensions document
      segments - the track-segments holds a list of track-points which are logically connected in order. To represent a single GPS track where GPS reception was lost, or the GPS receiver was turned off, start a new track-segment for each continuous span of track data.
      Returns:
      a new Track with the given parameters
      Throws:
      NullPointerException - if the links or the segments sequence is null
      Since:
      1.5
    • of

      public static Track of(String name, String comment, String description, String source, List<Link> links, UInt number, String type, List<TrackSegment> segments)
      Create a new Track with the given parameters.
      Parameters:
      name - the GPS name of the track
      comment - the GPS comment for the track
      description - user description of the track
      source - the source of data. Included to give user some idea of reliability and accuracy of data.
      links - the links to external information about track
      number - the GPS track number
      type - the type (classification) of track
      segments - the track-segments holds a list of track-points which are logically connected in order. To represent a single GPS track where GPS reception was lost, or the GPS receiver was turned off, start a new track-segment for each continuous span of track data.
      Returns:
      a new Track with the given parameters
      Throws:
      NullPointerException - if the links or the segments sequence is null