Click or drag to resize

LineDistanceTo Method

Verizon Connect Logo
Print this page
Learn more about Verizon Connect GeoBase.
Get information about the latest release
Calculates the shortest distance from the given point to this Line.

Namespace:  Telogis.GeoBase
Assembly:  geobase.net (in geobase.net.dll) Version: 4.99.0.0
Syntax
public override double DistanceTo(
	LatLon location,
	DistanceUnit units
)

Parameters

location
Type: Telogis.GeoBaseLatLon
The given point, as a LatLon
units
Type: Telogis.GeoBaseDistanceUnit
Unit that measurement is returned in.

Return Value

Type: Double
Distance in units.
Remarks
This distance is calculated using an arc, as opposed to the (longer) straight-line distance. The use of an arc returns the true shortest distance, taking into account the curvature of the earth's surface.
Examples
C#
// Create a line
Telogis.GeoBase.Line lineExample = new Telogis.GeoBase.Line(
    new Telogis.GeoBase.Geometry.LineString[] {
        new Telogis.GeoBase.Geometry.LineString(
        new LatLon(33.458781,-117.673489),
        new LatLon(33.453646,-117.665022))
    }
);

// Create a point
LatLon pointExample = new LatLon(33.471842, -117.657561);

// Print the shortest distance between the line and the point
Console.WriteLine("Shortest distance from line to point is {0} miles", 
    lineExample.DistanceTo(pointExample, DistanceUnit.MILES).ToString("0.0"));
// 'Shortest distance from line to point is 1.3 miles'
See Also