distanceTo

Returns the tree distance from the specified position to the start offset of the given horizon element.

The distance is strictly positive for elements in front of the position, i.e.:

  1. Elements on the position path in front of the position (the start offset of the element is greater than the position offset).

  2. Elements on sub-paths that the vehicle can reach by successively deviating to child paths.

The distance is strictly negative for elements behind the vehicle that the vehicle has moved past, i.e.:

  1. Elements on the position path that are completely behind the position or overlap the position, but start before the position (the start offset of the element is less than the position offset).

  2. Elements on sub-paths that the vehicle has deviated from at some point in the past.

The distance is 0 for elements that start at the position (the start offset of the element on the position path is the same as the position offset).

The distance is null if any of the following is true:

  1. The position does not have a valid path ID

  2. There is no path in the snapshot with the same ID as the one stored in the position

  3. The given element does not exist in the snapshot

  4. The given element is an element behind the position that the vehicle has not moved past, i.e., elements on sub-paths behind the vehicle that the vehicle has not taken.

Important: This is a Public Preview API. It may be changed or removed at any time.

Return

Tree distance to the given horizon element.

Parameters

element

Horizon element to compute the tree distance for.

position

Horizon position to compute the tree distance from.