+
+ /**
+ * Check whether the time difference between P1 and P2 is sufficiently large
+ * @param inP1 earlier point
+ * @param inP2 later point
+ * @return true if we can stop looking now, found a point early/late enough
+ */
+ private static boolean hasSufficientTimeDifference(DataPoint inP1, DataPoint inP2)
+ {
+ if (inP1 == null || inP2 == null)
+ return true; // we have to give up now
+ if (!inP1.hasTimestamp() || !inP2.hasTimestamp())
+ return false; // keep looking
+ final long MIN_TIME_DIFFERENCE_MS = 1000L;
+ return inP2.getTimestamp().getMillisecondsSince(inP1.getTimestamp()) >= MIN_TIME_DIFFERENCE_MS;
+ }