Click or drag to resize

Implementing an IGps Member

Verizon Connect Logo
Print this page
Learn more about Verizon Connect GeoBase.
Get information about the latest release
Overview

GPS units play an important role in Navigation tasks. This topic describes how to effectively implement your own IGps member.

An IGps member can be passed to a Navigator or NavigationManager to assist the user with routing and navigation.

Fields

Each IGps member should have a Position object. The Position object should have the following fields populated:

These fields are used internally by Telogis.GeoBase.Navigation classes to provide navigation services. Other fields are present for completeness.

Note Note

To ensure correct operation of other Telogis.GeoBase.Navigation classes, the time field should always work with Coordinated Universal Time (UTC) values. If your device provides time stamps in a local time zone, you must convert these to UTC values before populating this field.

Example

Suppose we wish to implement a new IGps member, which will interface with a laptop that has an attached GPS receiver. We are given an interface to the laptop, with the methods to return a heading, location and speed (conveniently in the required units). The following code example shows how an IGps member could be implemented.

C#
public class LaptopGps : IGps {

  bool power = false;
  Position pos = new Position();
  int count = 0;

  // interface to laptop:
  //  mGpsReceiver.getLoc() returns LatLon
  //  mGpsReceiver.getHeading() returns double
  //  mGpsReceiver.getSpeed() returns double (meters/sec)
  //  mGpsReceiver.getNumSats()
  GpsReceiver mGpsReceiver = new GpsReceiver();


#region IGps Members

  // 'Power up' the GPS
  public void PowerUp() {
  pos.quality.Mode = GpsFixType.FixType3d;
  pos.quality.numSats = mGpsReceiver.getNumSats();
  pos.units = SpeedUnit.MetersPerSecond;
  power = true;
  }

  // 'Power down' the GPS
  public void PowerDown() {
  pos.quality.Mode = GpsFixType.FixNone;
  power = false;
  }

  // Get whether the unit is powered up
  public bool PoweredUp {
  get { return power; }
  }

  // Get the position of this unit
  public Position Position {
  get {
      // talk to the laptop...
      pos.speed = mGpsReceiver.getSpeed();
      pos.location = mGpsReceiver.getLoc();
      pos.heading = mGpsReceiver.getHeading();

      // update pos number and time...
      pos.PositionNumber = count++;
      pos.time = DateTime.UtcNow;
      pos.TickCount = System.Environment.TickCount;

      return pos;
  }
  }

#endregion

}