@Test public void mergeSegments() { final GPX gpx = nextGPX(new Random(1)); final GPX merged = gpx.toBuilder() .trackFilter() .map(track -> track.toBuilder() .listMap(Filters::mergeSegments) .filter(TrackSegment::nonEmpty) .build()) .build() .build(); for (Track track : merged.getTracks()) { Assert.assertEquals(track.getSegments().size(), 1); } }
public static List<TrackSegment> mergeSegments( final List<TrackSegment> segments ) { final List<WayPoint> points = segments.stream() .flatMap(TrackSegment::points) .collect(toUnmodifiableList()); return List.of(TrackSegment.of(points)); }
Filters { public static List<TrackSegment> mergeSegments( final List<TrackSegment> segments ) { final List<WayPoint> points = segments.stream() .flatMap(TrackSegment::points) .collect(toUnmodifiableList()); return List.of(TrackSegment.of(points)); } }
Filters { public static List<TrackSegment> mergeSegments( final List<TrackSegment> segments ) { final List<WayPoint> points = segments.stream() .flatMap(TrackSegment::points) .collect(toUnmodifiableList()); return List.of(TrackSegment.of(points)); } private  Filters(); }
Filters { public static List<TrackSegment> mergeSegments( final List<TrackSegment> segments ) { final List<WayPoint> points = segments.stream() .flatMap(TrackSegment::points) .collect(toUnmodifiableList()); return List.of(TrackSegment.of(points)); } private  Filters(); static List<TrackSegment> mergeSegments(
		final List<TrackSegment> segments
	); static List<Track> mergeTracks(final List<Track> tracks); static List<Track> fullyMergeTracks(final List<Track> tracks); static GPX nonEmptyGPX(final GPX gpx); static List<Route> nonEmptyRoutes(final List<Route> routes); static List<Track> nonEmptyTracks(final List<Track> tracks); static List<TrackSegment> nonEmptySegments(
		final List<TrackSegment> segments
	); }
Filters { public static List<TrackSegment> mergeSegments( final List<TrackSegment> segments ) { final List<WayPoint> points = segments.stream() .flatMap(TrackSegment::points) .collect(toUnmodifiableList()); return List.of(TrackSegment.of(points)); } private  Filters(); static List<TrackSegment> mergeSegments(
		final List<TrackSegment> segments
	); static List<Track> mergeTracks(final List<Track> tracks); static List<Track> fullyMergeTracks(final List<Track> tracks); static GPX nonEmptyGPX(final GPX gpx); static List<Route> nonEmptyRoutes(final List<Route> routes); static List<Track> nonEmptyTracks(final List<Track> tracks); static List<TrackSegment> nonEmptySegments(
		final List<TrackSegment> segments
	);  }