mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 08:37:25 -05:00
Co-authored-by: sheirerd <sheirerd@ainfosec.com>
This commit is contained in:
@@ -87,12 +87,42 @@ public class PlottableEntityHistory
|
||||
*/
|
||||
public void add(PlottableDecodeEvent event)
|
||||
{
|
||||
mCurrentEvent = event;
|
||||
mLocationHistory.add(0, new TimestampedGeoPosition(event.getLocation(), event.getTimeStart()));
|
||||
TimestampedGeoPosition mostRecentPosition = getLatestPosition();
|
||||
TimestampedGeoPosition latest = new TimestampedGeoPosition(event.getLocation(), event.getTimeStart());
|
||||
|
||||
while(mLocationHistory.size() > MAX_LOCATION_HISTORY)
|
||||
if(isUnique(latest, mostRecentPosition))
|
||||
{
|
||||
mLocationHistory.remove(mLocationHistory.size() - 1);
|
||||
mCurrentEvent = event;
|
||||
mLocationHistory.add(0, latest);
|
||||
|
||||
while(mLocationHistory.size() > MAX_LOCATION_HISTORY)
|
||||
{
|
||||
mLocationHistory.remove(mLocationHistory.size() - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if the latest time and position is at least 30 seconds newer than the previous position and either the
|
||||
* latitude or longitude differs by at least 0.00001 degrees.
|
||||
* @param latest location
|
||||
* @param previous location
|
||||
* @return indication of uniqueness.
|
||||
*/
|
||||
private boolean isUnique(TimestampedGeoPosition latest, TimestampedGeoPosition previous)
|
||||
{
|
||||
if(latest != null && previous == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if(latest != null && previous != null)
|
||||
{
|
||||
return latest.getTimestamp() > (previous.getTimestamp() + 30_000) ||
|
||||
Math.abs(latest.getLatitude() - previous.getLatitude()) > 0.00001 ||
|
||||
Math.abs(latest.getLongitude() - previous.getLongitude()) > 0.00001;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user