terra-route
    Preparing search index...

    Class TerraRoute

    TerraRoute is a routing utility for finding the shortest path between two geographic points over a given GeoJSON LineString network.

    The class builds an internal graph structure based on the provided network, then applies A* algorithm to compute the shortest route.

    Index

    Constructors

    • Creates a new instance of TerraRoute.

      Parameters

      • OptionaldistanceMeasurement: (positionA: Position, positionB: Position) => number

        Optional custom distance measurement function (defaults to haversine distance).

      Returns TerraRoute

    Methods

    • Builds the internal graph representation (adjacency list) from the input network. Each LineString segment is translated into bidirectional graph edges with associated distances. Assumes that the network is a connected graph of LineStrings with shared coordinates. Calling this method with a new network overwrite any existing network and reset all internal data structures.

      Parameters

      • network: FeatureCollection<LineString>

        A GeoJSON FeatureCollection of LineStrings representing the road network.

      Returns void

    • Computes the shortest route between two points in the network using A* algorithm.

      Parameters

      • start: Feature<Point>

        A GeoJSON Point Feature representing the start location.

      • end: Feature<Point>

        A GeoJSON Point Feature representing the end location.

      Returns null | Feature<LineString, GeoJsonProperties>

      A GeoJSON LineString Feature representing the shortest path, or null if no path is found.

      Error if the network has not been built yet with buildRouteGraph(network).