java.lang.Object
io.jenetics.jpx.Filters
Some commonly usable way-point filter methods.
- Since:
- 1.1
- Version:
- 1.1
-
Method Summary
Modifier and TypeMethodDescriptionfullyMergeTracks(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.static List<TrackSegment>mergeSegments(List<TrackSegment> segments) Merges the given segments into one segment containing all way-points.mergeTracks(List<Track> tracks) Merges the given tracks into one track containing all segments.static GPXnonEmptyGPX(GPX gpx) Return a newGPXobject with all empty elements (tracks, track-segments, routes and metadata) removed.nonEmptyRoutes(List<Route> routes) Return a new route list with all empty routes removed.static List<TrackSegment>nonEmptySegments(List<TrackSegment> segments) Return a new segment list with all empty segments removed.nonEmptyTracks(List<Track> tracks) Return a new track list with all empty tracks removed.
-
Method Details
-
mergeSegments
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 isnull
-
mergeTracks
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 isnull
-
fullyMergeTracks
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 isnull
-
nonEmptyGPX
Return a newGPXobject 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
GPXobject with all empty elements removed - Throws:
NullPointerException- if the givengpxobject isnull
-
nonEmptyRoutes
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 isnull
-
nonEmptyTracks
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 isnull
-
nonEmptySegments
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 isnull
-