Skip to content

#1990 Ignores GPS positions with 0/0 latitude and longitude values. #1991

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions src/main/java/io/github/dsheirer/map/PlottableEntityHistory.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,20 @@ public IdentifierCollection getIdentifierCollection()
*/
public void add(PlottableDecodeEvent event)
{
TimestampedGeoPosition mostRecentPosition = getLatestPosition();
TimestampedGeoPosition latest = new TimestampedGeoPosition(event.getLocation(), event.getTimeStart());

if(isUnique(latest, mostRecentPosition))
if(event.isValidLocation())
{
mCurrentEvent = event;
mLocationHistory.add(0, latest);
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);
}
}
}
}
Expand Down
61 changes: 32 additions & 29 deletions src/main/java/io/github/dsheirer/map/PlottableEntityModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,42 +101,45 @@ public void delete(List<PlottableEntityHistory> tracksToDelete)
@Override
public void receive(PlottableDecodeEvent plottableDecodeEvent)
{
//Add or update the event on the swing event thread
EventQueue.invokeLater(() -> {
Identifier from = plottableDecodeEvent.getIdentifierCollection().getFromIdentifier();
if(plottableDecodeEvent.isValidLocation())
{
//Add or update the event on the swing event thread
EventQueue.invokeLater(() -> {
Identifier from = plottableDecodeEvent.getIdentifierCollection().getFromIdentifier();

if(from != null && from.getForm() != Form.LOCATION)
{
AliasListConfigurationIdentifier aliasList = plottableDecodeEvent.getIdentifierCollection().getAliasListConfiguration();
String key = (aliasList != null ? aliasList.toString() : KEY_NO_ALIAS_LIST) + from;
if(from != null && from.getForm() != Form.LOCATION)
{
AliasListConfigurationIdentifier aliasList = plottableDecodeEvent.getIdentifierCollection().getAliasListConfiguration();
String key = (aliasList != null ? aliasList.toString() : KEY_NO_ALIAS_LIST) + from;

PlottableEntityHistory entityHistory = mEntityHistoryMap.get(key);
PlottableEntityHistory entityHistory = mEntityHistoryMap.get(key);

if(entityHistory == null)
{
entityHistory = new PlottableEntityHistory(from, plottableDecodeEvent);
mEntityHistories.add(entityHistory);
mEntityHistoryMap.put(key, entityHistory);
int index = mEntityHistories.indexOf(entityHistory);
fireTableRowsInserted(index, index);
if(entityHistory == null)
{
entityHistory = new PlottableEntityHistory(from, plottableDecodeEvent);
mEntityHistories.add(entityHistory);
mEntityHistoryMap.put(key, entityHistory);
int index = mEntityHistories.indexOf(entityHistory);
fireTableRowsInserted(index, index);
}
else
{
entityHistory.add(plottableDecodeEvent);
int index = mEntityHistories.indexOf(entityHistory);
fireTableRowsUpdated(index, index);
}

for(IPlottableUpdateListener listener : mPlottableUpdateListeners)
{
listener.addPlottableEntity(entityHistory);
}
}
else
{
entityHistory.add(plottableDecodeEvent);
int index = mEntityHistories.indexOf(entityHistory);
fireTableRowsUpdated(index, index);
}

for(IPlottableUpdateListener listener : mPlottableUpdateListeners)
{
listener.addPlottableEntity(entityHistory);
LOGGER.warn("Received plottable decode event that does not contain a FROM identifier - cannot plot");
}
}
else
{
LOGGER.warn("Received plottable decode event that does not contain a FROM identifier - cannot plot");
}
});
});
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ public GeoPosition getLocation()
return mGeoPosition;
}

/**
* Indicates if the location is non-null and either latitude or longitude is not at the zero axis. If the location
* coordinates are zero or both are very small values close to zero, then the location is flagged as invalid.
*/
public boolean isValidLocation()
{
return mGeoPosition != null &&
((Math.abs(mGeoPosition.getLatitude()) > 0.01) || (Math.abs(mGeoPosition.getLongitude()) > 0.01));
}

/**
* Sets the heading for the mobile plottable event
* @param heading
Expand Down
Loading