CoordToLineDistance()

Summary

Finds the nearest line feature to a point and returns information about it.

Syntax

dist = CoordToLineDistance(coord c, real search_threshold)

Argument Contents
c The location of the point
search_threshold The maximum size of the search area. Only line features that pass within search_threshold of the point are located and tested

Returns

An array with the following elements:

Element Type Contents
1 Integer The ID of the nearest line
2 Coord The coordinate of the nearest point on the line to c
3 Real The distance from c to the nearest part of the line
4 Array The integer ID of end node 1 and the real distance from c to end node 1
5 Array The integer ID of end node 2 and the real distance from c to end node 2

Notes

  • CoordToLineDistance() works only on a line layer in a standard geographic file.

  • The distance to the line is the length of the normal dropped from the point to the line.

Error Codes

Error Type Meaning
Error The current layer is the wrong type
NotFound There is no link within the given search_threshold

See Also

Function Summary
LocateNearestRecord() Finds the map feature nearest a point location
TagLayer() Fills a field in a layer with information about the nearest feature in another layer
GetEndpoints() Returns the IDs of the two endpoints of a link
GetLineDistance() Finds the distance from a coordinate to a line