X-Git-Url: http://gitweb.fperrin.net/?p=GpsPrune.git;a=blobdiff_plain;f=src%2Ftim%2Fprune%2Ffunction%2Fcompress%2FDuplicatePointAlgorithm.java;fp=src%2Ftim%2Fprune%2Ffunction%2Fcompress%2FDuplicatePointAlgorithm.java;h=ce3f5977abfe59dd11c50689130ef62bcdab44ce;hp=0000000000000000000000000000000000000000;hb=ce6f2161b8596f7018d6a76bff79bc9e571f35fd;hpb=2d8cb72e84d5cc1089ce77baf1e34ea3ea2f8465 diff --git a/src/tim/prune/function/compress/DuplicatePointAlgorithm.java b/src/tim/prune/function/compress/DuplicatePointAlgorithm.java new file mode 100644 index 0000000..ce3f597 --- /dev/null +++ b/src/tim/prune/function/compress/DuplicatePointAlgorithm.java @@ -0,0 +1,82 @@ +package tim.prune.function.compress; + +import java.awt.Component; +import java.awt.event.ActionListener; + +import tim.prune.data.DataPoint; +import tim.prune.data.Track; + +/** + * Algorithm for detecting duplicate points to compress + */ +public class DuplicatePointAlgorithm extends CompressionAlgorithm +{ + /** Number of points before this one to consider as duplicates */ + private static final int NUM_POINTS_TO_BACKTRACK = 20; + + /** + * Constructor + * @param inTrack track object + * @param inDetails track details object + * @param inListener listener to attach to activation control + */ + public DuplicatePointAlgorithm(Track inTrack, TrackDetails inDetails, ActionListener inListener) + { + super(inTrack, inDetails, inListener); + } + + /** + * Perform the compression and work out which points should be deleted + * @param inFlags deletion flags from previous algorithms + * @return number of points deleted + */ + protected int compress(boolean[] inFlags) + { + int numPoints = _track.getNumPoints(); + int numDeleted = 0; + // Loop over all points looking for duplicates + for (int i=1; i