Skip to content
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

#1924 GPS Positions Listed as User Identifiers In Map Panel #1925

Merged
merged 1 commit into from
May 26, 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
2 changes: 1 addition & 1 deletion src/main/java/io/github/dsheirer/map/MapPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ private JTable getPlottedTracksTable()
if(mPlottedTracksTable == null)
{
mPlottedTracksTable = new JTable(mMapService.getPlottableEntityModel());

mPlottedTracksTable.setAutoCreateRowSorter(true);
mMapService.getPlottableEntityModel().addTableModelListener(e ->
{
//Update the followed entity for DELETE/UPDATE operations
Expand Down
38 changes: 34 additions & 4 deletions src/main/java/io/github/dsheirer/map/PlottableEntityHistory.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,42 @@ public IdentifierCollection getIdentifierCollection()
*/
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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import io.github.dsheirer.alias.Alias;
import io.github.dsheirer.alias.AliasList;
import io.github.dsheirer.alias.AliasModel;
import io.github.dsheirer.identifier.Form;
import io.github.dsheirer.identifier.Identifier;
import io.github.dsheirer.identifier.configuration.AliasListConfigurationIdentifier;
import io.github.dsheirer.module.decode.event.PlottableDecodeEvent;
Expand Down Expand Up @@ -104,7 +105,7 @@ public void receive(PlottableDecodeEvent plottableDecodeEvent)
EventQueue.invokeLater(() -> {
Identifier from = plottableDecodeEvent.getIdentifierCollection().getFromIdentifier();

if(from != null)
if(from != null && from.getForm() != Form.LOCATION)
{
AliasListConfigurationIdentifier aliasList = plottableDecodeEvent.getIdentifierCollection().getAliasListConfiguration();
String key = (aliasList != null ? aliasList.toString() : KEY_NO_ALIAS_LIST) + from;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import io.github.dsheirer.log.LoggingSuppressor;
import io.github.dsheirer.message.IMessage;
import io.github.dsheirer.module.decode.DecoderType;
import io.github.dsheirer.module.decode.event.DecodeEvent;
import io.github.dsheirer.module.decode.event.DecodeEventType;
import io.github.dsheirer.module.decode.event.PlottableDecodeEvent;
import io.github.dsheirer.module.decode.p25.IServiceOptionsProvider;
Expand Down Expand Up @@ -1523,13 +1524,14 @@ private void processGPS(MacMessage message, MacStructure structure)
collection.update(fromRadio);
}

broadcast(PlottableDecodeEvent.plottableBuilder(DecodeEventType.GPS, message.getTimestamp())
DecodeEvent decodeEvent = PlottableDecodeEvent.plottableBuilder(DecodeEventType.GPS, message.getTimestamp())
.protocol(Protocol.APCO25)
.location(gps.getGeoPosition()).channel(getCurrentChannel()).details("LOCATION: " +
gps.getLocation().toString())
.identifiers(collection)
.build());

.build();
broadcast(decodeEvent);
mTrafficChannelManager.broadcast(decodeEvent);
mTrafficChannelManager.processP2CurrentUser(getCurrentFrequency(), getTimeslot(), gps.getLocation(),
message.getTimestamp());
}
Expand Down
Loading