Class NmeaLocationDataSource
- java.lang.Object
-
- com.esri.arcgisruntime.location.LocationDataSource
-
- com.esri.arcgisruntime.location.NmeaLocationDataSource
-
public final class NmeaLocationDataSource extends LocationDataSource
This object will parse specific NMEA messages pushed into it. Valid GGA, GSA, GST, GSV, RMC, VTG messages are parsed and, depending upon the message type and contents, and aLocationDataSource.LocationChangedEvent
orNmeaLocationDataSource.SatellitesChangedEvent
may be raised. TheLocationDataSource.LocationChangedEvent
will return aNmeaLocationDataSource.NmeaLocation
object. TheNmeaLocationDataSource.LocationChangedEvent
will return an array ofNmeaSatelliteInfo
objects. This data source is based on NMEA version 4.11 (November 2018).- Since:
- 100.10.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
NmeaLocationDataSource.NmeaLocation
An NMEA location object.static class
NmeaLocationDataSource.SatellitesChangedEvent
An event representing a change of satellite information.static interface
NmeaLocationDataSource.SatellitesChangedListener
The listener interface for receiving satellite changed events.-
Nested classes/interfaces inherited from class com.esri.arcgisruntime.location.LocationDataSource
LocationDataSource.ErrorChangedEvent, LocationDataSource.ErrorChangedListener, LocationDataSource.HeadingChangedEvent, LocationDataSource.HeadingChangedListener, LocationDataSource.Location, LocationDataSource.LocationChangedEvent, LocationDataSource.LocationChangedListener, LocationDataSource.Status, LocationDataSource.StatusChangedEvent, LocationDataSource.StatusChangedListener
-
-
Constructor Summary
Constructors Constructor Description NmeaLocationDataSource()
Creates an NMEA location data source object.NmeaLocationDataSource(SpatialReference receiverSpatialReference)
Creates an NMEA location data source object.NmeaLocationDataSource(SpatialReference receiverSpatialReference, SpatialReference outputSpatialReference)
Creates an NMEA location data source object.NmeaLocationDataSource(SpatialReference receiverSpatialReference, SpatialReference outputSpatialReference, DatumTransformation outputDatumTransformation)
Creates an NMEA location data source object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addSatellitesChangedListener(NmeaLocationDataSource.SatellitesChangedListener listener)
Registers the given listener to be called when satellites have changed.DatumTransformation
getOutputDatumTransformation()
Gets theDatumTransformation
to be used in the project operation.SpatialReference
getOutputSpatialReference()
Gets the output spatial reference.SpatialReference
getReceiverSpatialReference()
Gets theSpatialReference
to be assigned to the outputNmeaLocationDataSource.NmeaLocation
; the default is WGS84.protected void
onStart()
Called fromLocationDataSource.startAsync()
.protected void
onStop()
Called from theLocationDataSource.stopAsync()
orLocationDataSource.stop()
method, subclasses should perform any necessary clean-up in this method; for example, stop streaming the location data, release resources, and so on.void
pushData(byte[] data)
Reads the input NMEA data creating anNmeaLocationDataSource.NmeaLocation
.boolean
removeSatellitesChangedListener(NmeaLocationDataSource.SatellitesChangedListener listener)
Unregisters the given listener that was previously added usingaddSatellitesChangedListener(SatellitesChangedListener)
.-
Methods inherited from class com.esri.arcgisruntime.location.LocationDataSource
addErrorChangedListener, addHeadingChangedListener, addLocationChangedListener, addStartedListener, addStatusChangedListener, getError, getStatus, isStarted, onStartCompleted, removeErrorChangedListener, removeHeadingChangedListener, removeLocationChangedListener, removeStartedListener, removeStatusChangedListener, setLastKnownLocation, startAsync, stop, stopAsync, updateHeading, updateLocation
-
-
-
-
Constructor Detail
-
NmeaLocationDataSource
public NmeaLocationDataSource()
Creates an NMEA location data source object. Locations created from this data source will have aSpatialReference
of WGS84.- Since:
- 100.10.0
-
NmeaLocationDataSource
public NmeaLocationDataSource(SpatialReference receiverSpatialReference, SpatialReference outputSpatialReference, DatumTransformation outputDatumTransformation)
Creates an NMEA location data source object. Locations from this data source will be projected from theSpatialReference
defined by thereceiverSpatialReference
parameter to the spatial reference defined by theoutputSpatialReference
parameter using the datum transformation defined byoutputDatumTransformation
. If theoutputSpatialReference
is null, the locations will not be projected and the locations will be in thereceiverSpatialReference
, ignoring theoutputDatumTransformation
.This constructor can be be used when a receiver is outputting locations in a
SpatialReference
other than WGS84, such as when using a reference base station, and/or the application requires the output locations to be projected to a differentSpatialReference
using aDatumTransformation
.- Parameters:
receiverSpatialReference
- the spatial reference of incoming NMEA receiver dataoutputSpatialReference
- the spatial reference to project theNmeaLocationDataSource.NmeaLocation
tooutputDatumTransformation
- theDatumTransformation
to use when projecting theNmeaLocationDataSource.NmeaLocation
- Throws:
java.lang.IllegalArgumentException
- if receiverSpatialReference is null- Since:
- 100.10.0
-
NmeaLocationDataSource
public NmeaLocationDataSource(SpatialReference receiverSpatialReference, SpatialReference outputSpatialReference)
Creates an NMEA location data source object. Locations from this data source will be projected from theSpatialReference
defined by thereceiverSpatialReference
parameter to the spatial reference defined by theoutputSpatialReference
parameter. If theoutputSpatialReference
parameter is null, the locations will not be projected and the locations will be in thereceiverSpatialReference
.This constructor can be be used when a receiver is outputting locations in a
SpatialReference
other than WGS84, such as when using a reference base station, and/or the application requires the output locations to be projected to a differentSpatialReference
.- Parameters:
receiverSpatialReference
- the spatial reference of incoming NMEA receiver dataoutputSpatialReference
- the spatial reference to project theNmeaLocationDataSource.NmeaLocation
to- Throws:
java.lang.IllegalArgumentException
- if receiverSpatialReference is null- Since:
- 100.10.0
-
NmeaLocationDataSource
public NmeaLocationDataSource(SpatialReference receiverSpatialReference)
Creates an NMEA location data source object. Locations from this data source will have aSpatialReference
defined by thereceiverSpatialReference
parameter.This constructor can be used when a receiver is outputting locations in a
SpatialReference
other than WGS84, such as when using a reference base station.- Parameters:
receiverSpatialReference
- the spatial reference of incoming NMEA receiver data- Throws:
java.lang.IllegalArgumentException
- if receiverSpatialReference is null- Since:
- 100.10.0
-
-
Method Detail
-
getOutputDatumTransformation
public DatumTransformation getOutputDatumTransformation()
Gets theDatumTransformation
to be used in the project operation. If set, this property will be used as theDatumTransformation
in the call toGeometryEngine.project(Geometry, SpatialReference, DatumTransformation)
. For this property to be used, theoutputSpatialReference
property also has to be set.- Returns:
- the datum transformation to be used in the project operation
- Since:
- 100.10.0
-
getOutputSpatialReference
public SpatialReference getOutputSpatialReference()
Gets the output spatial reference. The projected point will be stored inLocationDataSource.Location.getPosition()
. If this property is null, the position will contain the original incoming x, y, and z values from the NMEA data sentence and thegetReceiverSpatialReference()
.- Returns:
- the output spatial reference
- Since:
- 100.10.0
-
getReceiverSpatialReference
public SpatialReference getReceiverSpatialReference()
Gets theSpatialReference
to be assigned to the outputNmeaLocationDataSource.NmeaLocation
; the default is WGS84. By default, this will be WGS84 for its horizontal (WKID=4326) and vertical reference systems (WKID=115700). This can be set to a different spatial reference if a receiver returns locations in a different reference system.- Returns:
- the spatial reference to be assigned to the output location, the default is WGS84
- Since:
- 100.10.0
-
addSatellitesChangedListener
public void addSatellitesChangedListener(NmeaLocationDataSource.SatellitesChangedListener listener)
Registers the given listener to be called when satellites have changed.This listener will be invoked on the UI thread if it is added from the UI thread, otherwise it is not guaranteed on which thread the listener is invoked.
- Parameters:
listener
- a listener to be called when the satellites have changed- Throws:
java.lang.IllegalArgumentException
- if listener is null- Since:
- 100.10.0
- See Also:
removeSatellitesChangedListener(SatellitesChangedListener)
-
removeSatellitesChangedListener
public boolean removeSatellitesChangedListener(NmeaLocationDataSource.SatellitesChangedListener listener)
Unregisters the given listener that was previously added usingaddSatellitesChangedListener(SatellitesChangedListener)
.- Parameters:
listener
- the listener to unregister- Returns:
- true if the listener was removed successfully; false otherwise
- Since:
- 100.10.0
- See Also:
addSatellitesChangedListener(SatellitesChangedListener)
-
pushData
public void pushData(byte[] data)
Reads the input NMEA data creating anNmeaLocationDataSource.NmeaLocation
. The NMEA location data source needs to be started before calling this method.When pushing data:
- Each sentence needs to begins with a '$'.
- Each sentence needs to end with carriage return/line feed sequence.
- Single or multiple sentences can be pushed at one time, all strings in the buffer will be parsed.
- There is no explicit limit on the amount of data that can pushed at one time.
- If a partial sentences are pushed the data source accumulates (and concatenates) the pushed data until a carriage return/line feed sequence is reached.
- The data source parses these messages types: GGA, GSA, GST, GSV, RMC, VTG.
- Each sentence's checksum is validated.
- Unknown/bad/incorrect sentences are ignored (They do not produce any location, satellite updates etc.).
- Sentences support up to 256 characters (This is beyond the NMEA spec's 82 character limit to support receiver's that output longer sentences).
- Messages should be of the form: "$XXYYY,[data]*[checksum]\r\n"
See https://www.nmea.org/ for more information on the NMEA standard.<String>$GPGGA,092750.000,5321.6802,N,00630.3372,W,1,8,1.03,61.7,M,55.2,M,,*76 $GPGSA,A,3,10,07,05,02,29,04,08,13,,,,,1.72,1.03,1.38*0A $GPGSV,3,1,11,10,63,137,17,07,61,098,15,05,59,290,20,08,54,157,30*70
- Parameters:
data
- the data buffer that contains NMEA data- Since:
- 100.10.0
-
onStart
protected void onStart()
Description copied from class:LocationDataSource
Called fromLocationDataSource.startAsync()
. Subclasses should implement this method to prepare for starting the data source. TheLocationDataSource.onStartCompleted(Throwable)
method must be called by the subclass once the location data source has finished its starting process.- Specified by:
onStart
in classLocationDataSource
-
onStop
protected void onStop()
Description copied from class:LocationDataSource
Called from theLocationDataSource.stopAsync()
orLocationDataSource.stop()
method, subclasses should perform any necessary clean-up in this method; for example, stop streaming the location data, release resources, and so on.- Specified by:
onStop
in classLocationDataSource
-
-