Class Filters

java.lang.Object
io.jenetics.jpx.Filters

public final class Filters extends Object
Some commonly usable way-point filter methods.
Since:
1.1
Version:
1.1
  • Method Details

    • mergeSegments

      public static List<TrackSegment> mergeSegments(List<TrackSegment> segments)
      Merges the given segments into one segment containing all way-points. The order of the way-points is preserved.
      final GPX merged = gpx.toBuilder() .trackFilter() .map(track -> track.toBuilder() .listMap(Filters::mergeSegments) .filter(TrackSegment::nonEmpty) .build()) .build() .build();
      Parameters:
      segments - the segment list to merge
      Returns:
      a list with one segment, containing all way-points of the original segments
      Throws:
      NullPointerException - if the given segment list is null
    • mergeTracks

      public static List<Track> mergeTracks(List<Track> tracks)
      Merges the given tracks into one track containing all segments. The order of the segments is preserved.
      final GPX merged = gpx.toBuilder() .trackFilter() .listMap(Filters::mergeTracks) .filter(Track::nonEmpty) .build()) .build();
      Parameters:
      tracks - the track list to merge
      Returns:
      a list with one track, containing all segments
      Throws:
      NullPointerException - if the given track list is null
    • fullyMergeTracks

      public static List<Track> fullyMergeTracks(List<Track> tracks)
      Merges all way-points of all segments of the given track list into one track with one segment, containing all way-points. The order of the way-points is preserved.
      final GPX merged = gpx.toBuilder() .trackFilter() .listMap(Filters::fullyMergeTracks) .build()) .build();
      Parameters:
      tracks - the track list to merge
      Returns:
      a list with one track, containing one segment with all way-points
      Throws:
      NullPointerException - if the given track list is null
    • nonEmptyGPX

      public static GPX nonEmptyGPX(GPX gpx)
      Return a new GPX object with all empty elements (tracks, track-segments, routes and metadata) removed. This method can be used to clean up the GPX object before writing it to file.
      final GPX gpx = ...; final GPX.write(Filters.nonEmptyGPX(gpx), "tracks.gpx", " ");
      Parameters:
      gpx - the GPX object to clean up
      Returns:
      a new GPX object with all empty elements removed
      Throws:
      NullPointerException - if the given gpx object is null
    • nonEmptyRoutes

      public static List<Route> nonEmptyRoutes(List<Route> routes)
      Return a new route list with all empty routes removed.
      Parameters:
      routes - the route list to clean up
      Returns:
      a new route list with all empty routes removed
      Throws:
      NullPointerException - if the given argument is null
    • nonEmptyTracks

      public static List<Track> nonEmptyTracks(List<Track> tracks)
      Return a new track list with all empty tracks removed.
      Parameters:
      tracks - the track list to clean up
      Returns:
      a new track list with all empty tracks removed
      Throws:
      NullPointerException - if the given argument is null
    • nonEmptySegments

      public static List<TrackSegment> nonEmptySegments(List<TrackSegment> segments)
      Return a new segment list with all empty segments removed.
      Parameters:
      segments - the segment list to clean up
      Returns:
      a new segment list with all empty segments removed
      Throws:
      NullPointerException - if the given argument is null