How to use external gps location data

13368
34
Jump to solution
05-03-2018 10:02 PM
ShiminCai
Occasional Contributor III

Hi All,

I have a new requirement for our apps to use external gps location updates (Bad Elf GPS Unit) besides the default Apple location service updates. I understood that I need to create a custom location display data source class that conforms to the protocol <AGSLocationDisplayDataSource> and replace the mapVidw.locationDisplay.dataSource. My question is that: how do I implement the start method in the  protocol of <AGSLocationDisplayDataSource>? I'm currently still on 10.2.5 and later will look at the 100.2.1 as well. Can anyone please shed any light on this or have any working code to share? Many thanks for your help.

Cheers,

Shimin

1 Solution

Accepted Solutions
Nicholas-Furness
Esri Regular Contributor

HI Shimin Cai,

If you're still looking to implement your own data source, look at the reference doc here.

Here's what you need to do.

Implement a class that inherits from AGSLocationDataSource. The key functions you need to implement are doStart() and doStop(). These are the entry points to your class.

<< Runtime communicating to your custom location data source:

  • doStart() will be called by the Runtime when you call AGSMapView.locationDisplay.startWithCompletion().
  • doStop() will be called by the Runtime when you call AGSMapView.locationDisplay.stop().

>> Providing feedback to Runtime during startup/shutdown:

  • Starting your external device - When Runtime calls your doStart() function, you need to tell Runtime once the external device has started up. Call self.didStartOrFailWithError:() from within your doStart() function to let the Runtime know your external device has started or that it failed to start.
  • Stopping your external device - When Runtime calls your doStop() function, you need to tell Runtime once the external device has stopped. Call didStop() from within your doStop() function to let the Runtime know your external GPS device has stopped.

>> Providing location updates to Runtime:

  • Getting a new location - Whenever your external device's API gives you a new location, construct a new AGSLocation object and pass it to self.didUpdateLocation:().
  • Getting a new heading - If you get a new heading only (and not a completely new location), call self.didUpdateHeading:() with the new heading to let the Runtime know.

Hope this helps.

Cheers,

Nick.

View solution in original post

34 Replies
DiveshGoyal
Esri Regular Contributor

You do not necessarily need to implement a custom location datasource.

If you successfully pair your external GPS receiver with the device, then iOS should start using the location feed coming from the receiver instead of the in-built sensor. That location feed will come through to all apps using the standard Apple location manager apis, which is what the default 

AGSCLLocationDataSource uses, so you don't need to build a custom location datasource.

You really only need a custom datasource if you want to use special apis/sdk that the manufacturer provides for pulling extended or proprietary information from the receiver, or if you want to add additional intelligence in the datasource for dealing with location updates 

0 Kudos
ShiminCai
Occasional Contributor III

Hi Divesh,

Thank you very much for your reply. I'm getting a Bad Elf GPS Unit and will be testing that out.

The Bad Elf GPS has its own sdk/api to pull so much info from the receiver. I think soon or later I will be asked to read other extended infos from the receiver and in this case I will have to implement a custom location datasource as you suggested. 

I think I also have another use case of custom location datasource: location feed from drones. One of our projects looks at getting drone location and drone status (pitch, roll, yaw and gimbal) using the drone api. It was proposed that the project/app transmit the location data obtained from drones to an ad-hoc peer to peer wireless connected device using the Apple's MultiPeer Connectivity framework. Thus our apps will need to use the location feeds from drones and that's why I'm thinking the custom location datasource class... Any advises on this as well please?  

So any advises on how to implement a custom location datasource or directions leading to any documentation about it would be much appreciated, and everyone please?

 

Cheers,

Shimin

0 Kudos
ShiminCai
Occasional Contributor III

Hi Divesh,

Just found out that our users have already tried what you suggested pairing Bad Elf GPS receivers and their devices and had the problem of iOS switching location feeds from external GPS receiver and the in-built sensor randomly. They want to be able to control the source of location feeds. Looks like the custom location datasource is the way for me to go...

 

Cheers,

Shimin

0 Kudos
ManasaParida
New Contributor III

Hi Divesh Goyal‌,

What is the actual process to test the Navigation in either device or simulator when we are in development mode using ArcGIS Runtime SDK, like it is not possible to debug when we only really travel to get new AGSLocation Data so rather than doing that, is there any options to test the static points like Source to Destination with realtime Testing and Debugging when we are developing the app. Would be appreciate if you could suggest me on this. Meanwhile the question is how to test and debug the app in Device/Simulator on realtime without traveling and it was not so feasible to debug when we are traveling  . So basically we can set the Source and Destination Route Stops in a JSON file format or something like that once the map loaded it will start navigating the app based on the JSON Route stops so that we can able to test for the re-routing and realtime navigation to found dead code or faulty/bugs to fix it rather than a Real Test.

0 Kudos
Nicholas-Furness
Esri Regular Contributor

You could record a journey to a GPX file using GPS tracking software of your choice and then test your Runtime app using the AGSGPXLocationDataSource. Create a new instance of that pointing at your GPX file, then set your mapView.locationDisplay.dataSource to this new instance.

ManasaParida
New Contributor III

@Nicholas Furness  Ignore my previous reply, i found the solution to work, thanks

0 Kudos
Nicholas-Furness
Esri Regular Contributor

HI Shimin Cai,

If you're still looking to implement your own data source, look at the reference doc here.

Here's what you need to do.

Implement a class that inherits from AGSLocationDataSource. The key functions you need to implement are doStart() and doStop(). These are the entry points to your class.

<< Runtime communicating to your custom location data source:

  • doStart() will be called by the Runtime when you call AGSMapView.locationDisplay.startWithCompletion().
  • doStop() will be called by the Runtime when you call AGSMapView.locationDisplay.stop().

>> Providing feedback to Runtime during startup/shutdown:

  • Starting your external device - When Runtime calls your doStart() function, you need to tell Runtime once the external device has started up. Call self.didStartOrFailWithError:() from within your doStart() function to let the Runtime know your external device has started or that it failed to start.
  • Stopping your external device - When Runtime calls your doStop() function, you need to tell Runtime once the external device has stopped. Call didStop() from within your doStop() function to let the Runtime know your external GPS device has stopped.

>> Providing location updates to Runtime:

  • Getting a new location - Whenever your external device's API gives you a new location, construct a new AGSLocation object and pass it to self.didUpdateLocation:().
  • Getting a new heading - If you get a new heading only (and not a completely new location), call self.didUpdateHeading:() with the new heading to let the Runtime know.

Hope this helps.

Cheers,

Nick.

ShiminCai
Occasional Contributor III

Hi Nick,

Thanks a lot for your reply. Yes I will be implementing the custom location display datasource. I figured out what to do after reading the relevant docs in the 100.2.1 which provide clearer explanations about the custom datasource than that in the 10.2.5. Your instructions here verified what I'm thinking to do and are much appreciated.

I also had a look at the external gps receiver support of the Collector app. Basically we would like to achieve the similar functionalities in our apps. Did Collector implement the support in a similar way or do you have any suggestion?

I'm currently looking at the gps hexadecimal string data/NMEA sentences. I haven't found a complete NMEA parser in Swift in the net and had the feeling I have to write it myself... Any advises please?

Thanks,

Shimin

0 Kudos
Nicholas-Furness
Esri Regular Contributor

Hey Shimin Cai,

Collector does indeed take a similar approach.

For inspiration you could look at this C# NMEA Parser. You would have to translate from C# to Swift but there might be some useful info for you there in building your Location Data Source.

Cheers,

Nick.

0 Kudos