Developing with GPS data and devices

GPS library in the Runtime SDK for Windows Mobile

The GPS library reads and parses GPS positions from a connected COM port. The COM port can be a physical serial port, a virtual COM port bound to a GPS receiver via Bluetooth or USB, or a program COM port attached to a GPS intermediate driver on Windows Mobile devices. Note that the GPS intermediate driver is available on Windows Mobile 5.0 and newer systems and allows more than one application to access the GPS at the same time. For additional information on the intermediate driver, see GPS Intermediate Driver Reference.

It is also important to note that the ArcGIS Runtime SDK for Windows Mobile GPS library only supports NMEA protocol. To support the use of GPS receivers that do not output GPS positions in NMEA format, developers need to use third-party tools (such as Trimble GPS Controllerfor Trimble GPS receivers).

Ensure that your GPS receiver is correctly configured, and you know what COM port you want to use before starting your application and opening a connection to the GPS receiver.

GPS components in the IDE toolbox

The ArcGIS Runtime SDK for Windows Mobile provides three .NET components as part of the toolbox for designing and building mobile applications:

Each component performs the heavy lifting in managing the connection to a GPS receiver, parsing NMEA GPS sentences, displaying GPS on the map, and providing an interface for leveraging GPS sentences elsewhere in your application.

SerialPortGpsConnection

The SerialPortGpsConnection manages the communication between a GPS device and your application. After establishing a connection to a GPS device, SerialPortGpsConnection decodes received positional information, packages it, and broadcasts the decoded information to the mobile application inside meaningful event arguments. To use this component, specify the baud rate and the port name with which the GPS device has been paired.

FileGpsConnection

The FileGpsConnection component simulates a GPS by reading an input file that contains positional information previously gathered from a GPS device. As the information is read, at an interval specified by the user, the FileGpsConnection decodes the positional information, packages it and broadcasts the decoded information to the mobile application inside meaningful event arguments. When the SentenceReceived event is fired, the NMEASentenceEventArgs can be used to access the GPS information. The GPSDisplay component automatically gets the GPS information if it is properly linked to the GPSFileConnection. To use this component, specify a valid file name containing the NMEA sentence positional information.

GpsDisplay

The GpsDisplay component synchronizes the information decoded by the GpsConnection and displays it within a map. To use this component, specify the active GpsConnection (SerialPortGpsConnection or FileGpsConnection) and the map to use. This component contains all the properties and settings used to control how the GPS positional information displays. See the object reference for complete details on each of the properties.

Getting started with GPS development

The first step in working with GPS, and perhaps the hardest, is to establish a connection between a COM port on your device and a GPS receiver. For mobile devices that have a built-in receiver or for GPS receivers physically connected to your machine via a cable, this is usually not a problem. However, Bluetooth connections can be problematic due to the various hardware and software configurations. In either case, follow the manufacturer's installation guide for your environment, and establish a GPS connection to the COM port on your device.

To start using GPS information in your application, add the SerialPortGpsConnection component from the ArcGIS Mobile Controls tab in Visual Studio to your project. The properties on this component configure the communication properties between your device and the receiver, and include items such as the COM port, baud rate, and so on. The common practice is to leave the default values and set the COM port to a value established above. To receive GPS information from the receiver, call SerialPortGpsConnection.Open within your code, which is usually called from an appropriate control such as a button or check box on your UI. To stop receiving information, call the corresponding Close method.

Working with GpsDisplay

The GPS location can display on your map via the GpsDisplay component. Add this component to your project from the ArcGIS Mobile Controls tab in Visual Studio and set the GpsConnection property to the SerialPortGpsConnection that you previously added. When you run your application and open the GpsConnection, the map centers on the GPS location and displays the position with a marker.

Working with GPS information

In addition to displaying the GPS position on the map, you can also obtain the GPS information received from the connection. Each time a GPS sentence is received by the GpsConnection, a GpsChanged event fires. You can listen to this event and return a GpsEventArgs class. Due to the multi-threaded architecture of the components, include the appropriate code to handle thread pools as shown in the following example.

private void serialPortGpsConnection1_GpsChanged(object sender, GpsEventArgs e)
{
  if (InvokeRequired) 
    {
      Invoke(new GpsChangedEventHandler(serialPortGpsConnection1_GpsChanged),sender, e);
      return;
    }

  MessageBox.Show(e.Altitude); 
}

You can use the Latitude and Longitude properties on the GpsEventArgs class to get a GPS position and display this on your map, as an alternative to the GpsDisplay component, or to create geometry in new features. If your map is not in WGS84 coordinates, use the SpatialReference.FromWGS84ToCoodinate method to project the returned coordinate.

GPS sample application

The Getting started with GPS development topic illustrates how to read and visualize GPS data in a Windows application.

1/7/2015