DistanceMeter Class |
Namespace: Telogis.GeoBase
The DistanceMeter type exposes the following members.
Name | Description | |
---|---|---|
DistanceMeter |
Construct a DistanceMeter with no starting point and zero distance already traveled.
| |
DistanceMeter(LatLon, Double) |
Construct a DistanceMeter with a start point and an initial distance (in radians) already
traveled.
|
Name | Description | |
---|---|---|
Miles |
Returns the current distance traveled between all points (as the crow flies) in miles.
|
Name | Description | |
---|---|---|
Add |
Add a new point. The distance from the previous point to this point (as the crow flies) is
calculated and added to the total distance traveled.
| |
AddPoints |
Add a list of points. Equivalent to calling Add for each point in the list.
| |
ClearDelta |
Zero the distance traveled, but retain the last point on the route.
| |
ClearFull |
Clears both the accumulated distance and the last point.
| |
Clone |
Returns a clone. Operations performed on the clone are independent.
| |
Distance |
Get total distance traveled (as the crow flies) from the starting point, through any
intermediate points, to the last point that was added.
| |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
This is useful for recording the total distance traveled along a route consisting of a number of LatLon points.
Consider using a RouteMatrix if you'd like to calculate the distance between stops on a route.
/* this example shows how to use a DistanceMeter with an IGps member (your GPS unit) */ IGps myGps = new ... // see "Tutorials -> Navigation -> The IGps Interface" for more info // start the DistanceMeter, with current GPS location and zero-distance DistanceMeter dm = new DistanceMeter(myGps.Position.location, 0); ... // suppose that this line of code gets called regularly, say once every 20 seconds dm.Add(myGps.Position.location); ... // whenever we want to get the as-the-crow-flies distance, we just need to call: double distanceTravelled = dm.Distance(DistanceUnit.Kilometers); ... // if we restart our journey we can call: dm.ClearDelta(); // ... this is like hitting 'reset' on your car odometer trip-counter. NOTE: If we // called dm.ClearAll() instead, we wouldn't start counting the distance until the // next dm.Add() - probably 20 seconds away (given our assumption about the rate // at which dd.Add() is called, above).