Select to view content in your preferred language

Unable to cast LocationDataSource.Location to NmeaDataSource.Location

764
3
08-07-2020 08:28 AM
by Anonymous User
Not applicable

When I try to cast LocationDataSource.Location to NmeaDataSource.Location I get the following error...

java.lang.ClassCastException: com.esri.arcgisruntime.location.LocationDataSource$Location cannot be cast to com.esri.arcgisruntime.location.NmeaDataSource$Location

I am wondering why this does not work?  I am using 100.8 and the documentation seems to indicate casting should be possible...

NmeaDataSource.Location (ArcGIS Runtime SDK for Android 100.8.0) 

It states the following there...

---------------------------------------------------------------------------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------------------------------------------------------------------------

Below is the code that I am using

lListener = new LocationDisplay.LocationChangedListener() {
   @Override
   public void onLocationChanged(LocationDisplay.LocationChangedEvent locationChangedEvent) {
      try { 
          NmeaDataSource.Location mLocation = (NmeaDataSource.Location) locationChangedEvent.getSource().getLocation();
0 Kudos
3 Replies
MarkBaird
Esri Regular Contributor

Hi Arron,

You need to tell me exactly what you are trying to do here.

The NMEALocationDataSource class is for internal use only at the moment.  This will become a new item of functionality on a future release for high accuracy GPS devices.

If you explain what you are trying to achieve, I can guide you.

Thanks

Mark

0 Kudos
by Anonymous User
Not applicable

Hi Mark,

Thanks for the response.  My main goal here is to be able to get the number of satellites and X/Y coordinates without having multiple location providers.  Right now I am able to grab the ESRI Location when it changes here as per the LocationDisplay.LocationChangedListener and then populate X/Y location in the widget.  However I end up getting number of satellites from Android location as you can see in the code below from the Android locationManager last known location.  I would prefer to get number of satellites from the same source via LocationDisplay.  Here is what I am currently doing and it does work just fine...

lListener = new LocationDisplay.LocationChangedListener() {
@Override
public void onLocationChanged(LocationDisplay.LocationChangedEvent locationChangedEvent) {

              double latitude = locationChangedEvent.getLocation().getPosition().getY();
              double longitude = locationChangedEvent.getLocation().getPosition().getX();
              Location androidLocation = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
              Integer sats = androidLocation.getExtras().getInt("satellites");

My thought process was that if I could cast this within the LocationChangedListener..

NmeaDataSource.Location loc = (NmeaDataSource.Location) locationChangedEvent.getSource().getLocation();

That I could then get the number of satellites as followed.

Integer sats = loc.getSatellites().size();


0 Kudos
by Anonymous User
Not applicable

Alright, am going to assume based on lack of response that what I would like to do is not possible with this version of the Runtime SDK.  Wondering if satellite information, and other GPS values will be possible to harvest in a future version of the Runtime SDK?  Really my main point is that I would like to avoid having to use both Android and ESRI location and associated listeners.  It adds unnecessary extra overhead.

0 Kudos