About GPS ToolKit.NET
Introduction
Purchasing GPS ToolKit.NET
Redistributing GPS ToolKit.NET
License Agreement
Support
Getting Started
Getting Started
Setting up the GPS
Basic Concepts
GPS ToolKit Sample Projects
About GPS ToolKit Errors
Reference
GPSToolKit Class
Properties
BaudRate
ExtendedFixData
IsGPSConnected
IsPortOpen
LastPositionUpdateTime
NavigationData
PortName
Protocol
Position
Satellites
Speed
TrueCourse
Methods
AddRoute
AddTrack
AddWaypoint
AutoDetectGPS
Close
GetAvailableSystemPorts
GetGPSInfo
GetRoutes
GetSystemPorts
GetTracks
GetWaypoints
Open
ShutOffGPS
WriteRawBinaryToGPS
WriteRawToGPS
Events
FileComplete
GPSConnected
GPSDisconnected
NavigationUpdate
PositionUpdate
RawDataReceived
SatelliteUpdate
Supporting Classes
Altitude
Angle
Distance
ExtendedFixData
Properties
DGPSRefStationID
EstimatedHorizontalError
EstimatedPositionError
EstimatedVerticalError
FixMode
GeoidHeightAboveWGS84
HDOP
MagneticVariation
NumSatellitesInView
PDOP
TimeSinceLastDGPSUpdate
VDOP
GPSInfo
Latitude
Methods
ToDecimalDegreesString
ToDegreesMinutesString
ToDegreesMinutesSecondsString
Longitude
Methods
ToDecimalDegreesString
ToDegreesMinutesString
ToDegreesMinutesSecondsString
NavData
Properties
ActiveRoute
ArrivedAtDest
CrossTrackError
DestWptName
DestWptPosition
IsValid
MagBearingFromOriginToDest
OriginWptName
TrueBearingFromOriginToDest
TrueBearingToDestWpt
VelocityTowardDestWpt
Position
Methods
BearingFrom
BearingTo
DistanceTo
Route
Properties
Name
Waypoints
Satellite
Speed
Track
Properties
Color
DisplayTrack
Name
TrackPoints
TrackPoint
Waypoint
Collections
RouteCollection
SatelliteCollection
TrackCollection
TrackPointCollection
WaypointCollection

GPS ToolKit.NET Basics

With GPS ToolKit.NET, it is simple to get GPS position, speed, and direction data. Once you have confirmed that GPS ToolKit can "see" the GPS by using one of the included sample applications, we can begin communicating. For the following examples, you may want to ensure that the GPS has an active satellite lock or is in "demo" mode.

Getting the current position directly

The current position is reported through the GPSToolKit.Position property. This property returns a Position object which contains the latitude, longitude, and altitude, if available, of the current fix. For example:

[Visual Basic]

Imports SciCom.GPSToolKit
[...]
myGPSToolKit.AutoDetectGPS()

' Give GPS ToolKit time to receive first set of position data
System.Threading.Thread.Sleep(2000)

' Get current lat/lon in degrees
Dim pos As Position
Dim lat, lon as Double

pos = myGPSToolKit.Position

If pos.IsValid = True Then
   lat = pos.Latitude.ValueInDegrees
   lon = pos.Longitude.ValueInDegrees
End If


[C#]
using SciCom.GPSToolKit;
[...]
myGPSToolKit.AutoDetectGPS();

// Give GPS ToolKit time to receive first set of position data
System.Threading.Thread.Sleep(2000);

// Get current lat/lon in degrees
double lat, lon;

Position pos = myGPSToolKit.Position;

if(pos.IsValid == true)
{
   lat = pos.Latitude.ValueInDegrees;
   lon = pos.Longitude.ValueInDegrees;
}


[C++]
using namespace SciCom::GPSToolKit;
[...]
myGPSToolKit->AutoDetectGPS();

// Give GPS ToolKit time to receive first set of position data
System::Threading::Thread::Sleep(2000);

// Get current lat/lon in degrees
double lat, lon;

Position *pos = myGPSToolKit->Position;

if(pos->IsValid == true)
{
   lat = pos->Latitude->ValueInDegrees;
   lon = pos->Longitude->ValueInDegrees;
}

In practice, this method is not very useful because it only reads the position once. A more useful implementation would use a loop to read the data every few seconds and perform some processing with each new point. Managing this loop can be cumbersome, however, since it causes high CPU usage and will lock up the application's UI unless special care is taken.

Getting position updates through events

A better method to continuously read GPS position is to handle the PositionUpdate event, which is fired every time GPS position data is updated. By providing a handler function for this event, GPS ToolKit will call the function everytime position data is updated, eliminating the need to continuously poll for new data:

[Visual Basic]

Imports SciCom.GPSToolKit
[...]

Private Sub myGPSToolKit_PositionUpdate(ByVal sender As Object, ByVal e As SciCom.GPSToolKit.PositionUpdateEventArgs) Handles myGPSToolKit.PositionUpdate
    Dim pos As Position
    Dim lat, lon As Double

    pos = e.Position

    If pos.IsValid = True Then
        lat = pos.Latitude.ValueInDegrees
        lon = pos.Longitude.ValueInDegrees
    End If
End Sub


[C#]
using SciCom.GPSToolKit;
[...]

private void myGPSToolKit_PositionUpdate(object sender, SciCom.GPSToolKit.PositionUpdateEventArgs e)
{
    // Get current lat/lon in degrees
    double lat, lon;

    Position pos = e.Position;

    if(pos.IsValid == true)
    {
        lat = pos.Latitude.ValueInDegrees;
        lon = pos.Longitude.ValueInDegrees;
    }
}


[C++]
using namespace SciCom::GPSToolKit;
[...]

private: System::Void myGPSToolKit_PositionUpdate(System::Object *  sender, SciCom::GPSToolKit::PositionUpdateEventArgs *  e)
{
    // Get current lat/lon in degrees
    double lat, lon;

    Position *pos = myGPSToolKit->Position;

    if(pos->IsValid == true)
    {
        lat = pos->Latitude->ValueInDegrees;
        lon = pos->Longitude->ValueInDegrees;
    }
}

Getting speed, direction, or other data can be done in a similar manner. To view a working example of the above methods, please see the Simple GPS sample application.

See Also

Adding GPS ToolKit to your project