diff --git a/src/main/java/io/github/dsheirer/module/decode/dmr/DMRDecoderState.java b/src/main/java/io/github/dsheirer/module/decode/dmr/DMRDecoderState.java index 6d1fdf3cd..2994c3544 100644 --- a/src/main/java/io/github/dsheirer/module/decode/dmr/DMRDecoderState.java +++ b/src/main/java/io/github/dsheirer/module/decode/dmr/DMRDecoderState.java @@ -424,18 +424,19 @@ else if(packet.getPacket() instanceof XCMPPacket xcmp) broadcast(packetEvent); - GeoPosition geoPosition = PacketUtil.extractGeoPosition(packet.getPacket()); + } - if (geoPosition != null) { - PlottableDecodeEvent plottableDecodeEvent = PlottableDecodeEvent.plottableBuilder(DecodeEventType.GPS, packet.getTimestamp()) - .channel(getCurrentChannel()) - .identifiers(new IdentifierCollection(packet.getIdentifiers())) - .protocol(Protocol.LRRP) - .location(geoPosition) - .build(); + GeoPosition geoPosition = PacketUtil.extractGeoPosition(packet.getPacket()); - broadcast(plottableDecodeEvent); - } + if (geoPosition != null) { + PlottableDecodeEvent plottableDecodeEvent = PlottableDecodeEvent.plottableBuilder(DecodeEventType.GPS, packet.getTimestamp()) + .channel(getCurrentChannel()) + .identifiers(new IdentifierCollection(packet.getIdentifiers())) + .protocol(Protocol.LRRP) + .location(geoPosition) + .build(); + + broadcast(plottableDecodeEvent); } } @@ -1209,19 +1210,17 @@ private void processLinkControl(LCMessage message, boolean isTerminator) } break; case FULL_STANDARD_GPS_INFO: - if(message instanceof GPSInformation) + if(message instanceof GPSInformation gpsInformation) { - GPSInformation gpsInformation = (GPSInformation)message; - MutableIdentifierCollection ic = new MutableIdentifierCollection(getIdentifierCollection().getIdentifiers()); - ic.update(gpsInformation.getGPSLocation()); - - DecodeEvent gpsEvent = DMRDecodeEvent.builder(DecodeEventType.GPS, message.getTimestamp()) - .identifiers(ic) - .timeslot(getTimeslot()) - .details("LOCATION:" + gpsInformation.getGPSLocation()) - .build(); - - broadcast(gpsEvent); + PlottableDecodeEvent plottableGPS = PlottableDecodeEvent.plottableBuilder(DecodeEventType.GPS, message.getTimestamp()) + .channel(getCurrentChannel()) + .details("LOCATION:" + gpsInformation.getGPSLocation()) + .identifiers(new IdentifierCollection(getIdentifierCollection().getIdentifiers())) + .protocol(Protocol.DMR) + .location(gpsInformation.getPosition()) + .build(); + + broadcast(plottableGPS); } break; case FULL_STANDARD_TALKER_ALIAS_COMPLETE: diff --git a/src/main/java/io/github/dsheirer/module/decode/dmr/message/data/lc/full/GPSInformation.java b/src/main/java/io/github/dsheirer/module/decode/dmr/message/data/lc/full/GPSInformation.java index c9d7d06bd..823aee981 100644 --- a/src/main/java/io/github/dsheirer/module/decode/dmr/message/data/lc/full/GPSInformation.java +++ b/src/main/java/io/github/dsheirer/module/decode/dmr/message/data/lc/full/GPSInformation.java @@ -1,6 +1,6 @@ /* * ***************************************************************************** - * Copyright (C) 2014-2020 Dennis Sheirer + * Copyright (C) 2014-2023 Dennis Sheirer * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,10 +24,10 @@ import io.github.dsheirer.identifier.location.LocationIdentifier; import io.github.dsheirer.module.decode.dmr.identifier.DMRLocation; import io.github.dsheirer.module.decode.dmr.message.type.PositionError; -import org.apache.commons.math3.util.FastMath; - import java.util.ArrayList; import java.util.List; +import org.apache.commons.math3.util.FastMath; +import org.jdesktop.swingx.mapviewer.GeoPosition; /** * GPS Information @@ -81,16 +81,30 @@ public PositionError getPositionError() return PositionError.fromValue(getMessage().getInt(POSITION_ERROR)); } + /** + * Latitude in decimal degrees + */ public double getLatitude() { return getMessage().getTwosComplement(LATITUDE_START, LATITUDE_END) * LATITUDE_UNITS; } + /** + * Longitude in decimal degrees + */ public double getLongitude() { return getMessage().getTwosComplement(LONGITUDE_START, LONGITUDE_END) * LONGITUDE_UNITS; } + /** + * Geo-position for the lat/lon + */ + public GeoPosition getPosition() + { + return new GeoPosition(getLatitude(), getLongitude()); + } + /** * GPS location as an identifier */