@Test public void testSegmenter1000mil() throws IOException { assertEquals( 1, Segmenters .floatingDistance( DefaultDistance.of(1000, DistanceUnit.MILES)) .segment(loadTrack()).getSegments().size()); }
public Track segment(Track track) { List<? extends LinkedTrackPoint> trkpts = track.getTrackpoints(); List<Segment> result = Lists.newArrayList(); T actValue = this.zero; int start = 0; int end = 0; int maxEnd = trkpts.size() - 1; for (LinkedTrackPoint trkpt : trkpts) { end++; if (trkpt.getLink() != null) { T next = this.dataFunc.apply(trkpt); actValue = actValue.add(next); if (actValue.compareTo(this.targetValue) >= 0 && end > start + 1 && end < maxEnd) { List<? extends LinkedTrackPoint> ntrkpt = trkpts.subList( start, end); result.add(new DefaultSegment(ntrkpt, DefaultStatistics .ofWaypoints(ntrkpt))); actValue = actValue.subtract(this.targetValue); start = end; } } } if (end > start) { List<? extends LinkedTrackPoint> ntrkpts = trkpts.subList(start, end); result.add(new DefaultSegment(ntrkpts, DefaultStatistics .ofWaypoints(ntrkpts))); } return new DefaultTrack(track.getId(), track.getMetadata(), track.getWaypoints(), result, track.getStatistics()); }
MathObjectSegmenter implements Segmenter { public Track segment(Track track) { List<? extends LinkedTrackPoint> trkpts = track.getTrackpoints(); List<Segment> result = Lists.newArrayList(); T actValue = this.zero; int start = 0; int end = 0; int maxEnd = trkpts.size() - 1; for (LinkedTrackPoint trkpt : trkpts) { end++; if (trkpt.getLink() != null) { T next = this.dataFunc.apply(trkpt); actValue = actValue.add(next); if (actValue.compareTo(this.targetValue) >= 0 && end > start + 1 && end < maxEnd) { List<? extends LinkedTrackPoint> ntrkpt = trkpts.subList( start, end); result.add(new DefaultSegment(ntrkpt, DefaultStatistics .ofWaypoints(ntrkpt))); actValue = actValue.subtract(this.targetValue); start = end; } } } if (end > start) { List<? extends LinkedTrackPoint> ntrkpts = trkpts.subList(start, end); result.add(new DefaultSegment(ntrkpts, DefaultStatistics .ofWaypoints(ntrkpts))); } return new DefaultTrack(track.getId(), track.getMetadata(), track.getWaypoints(), result, track.getStatistics()); } }
MathObjectSegmenter implements Segmenter { public Track segment(Track track) { List<? extends LinkedTrackPoint> trkpts = track.getTrackpoints(); List<Segment> result = Lists.newArrayList(); T actValue = this.zero; int start = 0; int end = 0; int maxEnd = trkpts.size() - 1; for (LinkedTrackPoint trkpt : trkpts) { end++; if (trkpt.getLink() != null) { T next = this.dataFunc.apply(trkpt); actValue = actValue.add(next); if (actValue.compareTo(this.targetValue) >= 0 && end > start + 1 && end < maxEnd) { List<? extends LinkedTrackPoint> ntrkpt = trkpts.subList( start, end); result.add(new DefaultSegment(ntrkpt, DefaultStatistics .ofWaypoints(ntrkpt))); actValue = actValue.subtract(this.targetValue); start = end; } } } if (end > start) { List<? extends LinkedTrackPoint> ntrkpts = trkpts.subList(start, end); result.add(new DefaultSegment(ntrkpts, DefaultStatistics .ofWaypoints(ntrkpts))); } return new DefaultTrack(track.getId(), track.getMetadata(), track.getWaypoints(), result, track.getStatistics()); } MathObjectSegmenter(T targetValue, T zero,
			Function<LinkedTrackPoint, T> dataFunc); }
MathObjectSegmenter implements Segmenter { public Track segment(Track track) { List<? extends LinkedTrackPoint> trkpts = track.getTrackpoints(); List<Segment> result = Lists.newArrayList(); T actValue = this.zero; int start = 0; int end = 0; int maxEnd = trkpts.size() - 1; for (LinkedTrackPoint trkpt : trkpts) { end++; if (trkpt.getLink() != null) { T next = this.dataFunc.apply(trkpt); actValue = actValue.add(next); if (actValue.compareTo(this.targetValue) >= 0 && end > start + 1 && end < maxEnd) { List<? extends LinkedTrackPoint> ntrkpt = trkpts.subList( start, end); result.add(new DefaultSegment(ntrkpt, DefaultStatistics .ofWaypoints(ntrkpt))); actValue = actValue.subtract(this.targetValue); start = end; } } } if (end > start) { List<? extends LinkedTrackPoint> ntrkpts = trkpts.subList(start, end); result.add(new DefaultSegment(ntrkpts, DefaultStatistics .ofWaypoints(ntrkpts))); } return new DefaultTrack(track.getId(), track.getMetadata(), track.getWaypoints(), result, track.getStatistics()); } MathObjectSegmenter(T targetValue, T zero,
			Function<LinkedTrackPoint, T> dataFunc); Track segment(Track track); }
MathObjectSegmenter implements Segmenter { public Track segment(Track track) { List<? extends LinkedTrackPoint> trkpts = track.getTrackpoints(); List<Segment> result = Lists.newArrayList(); T actValue = this.zero; int start = 0; int end = 0; int maxEnd = trkpts.size() - 1; for (LinkedTrackPoint trkpt : trkpts) { end++; if (trkpt.getLink() != null) { T next = this.dataFunc.apply(trkpt); actValue = actValue.add(next); if (actValue.compareTo(this.targetValue) >= 0 && end > start + 1 && end < maxEnd) { List<? extends LinkedTrackPoint> ntrkpt = trkpts.subList( start, end); result.add(new DefaultSegment(ntrkpt, DefaultStatistics .ofWaypoints(ntrkpt))); actValue = actValue.subtract(this.targetValue); start = end; } } } if (end > start) { List<? extends LinkedTrackPoint> ntrkpts = trkpts.subList(start, end); result.add(new DefaultSegment(ntrkpts, DefaultStatistics .ofWaypoints(ntrkpts))); } return new DefaultTrack(track.getId(), track.getMetadata(), track.getWaypoints(), result, track.getStatistics()); } MathObjectSegmenter(T targetValue, T zero,
			Function<LinkedTrackPoint, T> dataFunc); Track segment(Track track);  }