Click or drag to resize

DistanceMeter Class

Verizon Connect Logo
Print this page
Learn more about Verizon Connect GeoBase.
Get information about the latest release
Records the cumulative distance (as the crow-flies) traveled from a starting point through a number of other points.
Inheritance Hierarchy
SystemObject
  Telogis.GeoBaseDistanceMeter

Namespace:  Telogis.GeoBase
Assembly:  geobase.net (in geobase.net.dll) Version: 4.86.0.0
Syntax
public class DistanceMeter

The DistanceMeter type exposes the following members.

Constructors
  NameDescription
Public methodDistanceMeter
Construct a DistanceMeter with no starting point and zero distance already traveled.
Public methodDistanceMeter(LatLon, Double)
Construct a DistanceMeter with a start point and an initial distance (in radians) already traveled.
Top
Properties
  NameDescription
Public propertyMiles
Returns the current distance traveled between all points (as the crow flies) in miles.
Top
Methods
  NameDescription
Public methodAdd
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.
Public methodAddPoints
Add a list of points. Equivalent to calling Add for each point in the list.
Public methodClearDelta
Zero the distance traveled, but retain the last point on the route.
Public methodClearFull
Clears both the accumulated distance and the last point.
Public methodClone
Returns a clone. Operations performed on the clone are independent.
Public methodDistance
Get total distance traveled (as the crow flies) from the starting point, through any intermediate points, to the last point that was added.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Remarks

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.

Examples
C#
/* 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).
See Also