terra-route-graph
    Preparing search index...

    Class TerraRouteGraph

    Represents a graph constructed from a GeoJSON FeatureCollection of LineString features. This class provides methods to analyze the graph, including connected components, node and edge counts, and shortest paths. Coordinates in the LineStrings are considered connected if they share identical coordinates.

    Index

    Constructors

    Methods

    • Gets the average length of all edges in the graph based on the length of the LineString. If no edges exist, it returns -1.

      Returns number

      The average length of all edges in meters, or -1 if no edges exist.

    • Gets the count of connected components in the graph.

      Returns number

      The number of connected components in the graph.

    • Gets the connected components of the graph.

      Returns FeatureCollection<LineString, GeoJsonProperties>[]

      An array of FeatureCollection representing the connected components.

    • Gets the count of unique edges in the graph.

      Returns number

      The number of unique edges in the graph.

    • Gets the unique edges of the graph as a FeatureCollection of LineString features. Each edge is represented as a LineString. This method ensures that each edge is unique, meaning that edges are not duplicated in the collection. Each linestring only two coordinates, representing the start and end points of the edge.

      Returns FeatureCollection<LineString>

      A FeatureCollection containing the unique edges of the graph.

    • Gets the leaf edges of the graph. A leaf edge is defined as an edge whose start or end node has a degree of 1. Here an edge is defined as a LineString with two coordinates, representing the start and end points.

      Returns FeatureCollection<LineString>

      A FeatureCollection containing only the leaf edges of the graph.

    • Gets the longest edge in the graph based on the length of the LineString.

      Returns null | Feature<LineString, GeoJsonProperties>

      The longest edge as a Feature or null if no edges exist.

    • Gets the length of the longest edge in the graph based on the length of the LineString. If no edges exist, it returns -1.

      Returns number

      The length of the longest edge in meters, or 0 if no edges exist.

    • Gets the current network of the graph.

      Returns FeatureCollection<LineString>

      A GeoJSON FeatureCollection of LineString features representing the network.

    • Gets a filtered network containing only LineStrings that are completely within the specified bounding box.

      Parameters

      • boundingBox: BoundingBox

        A bounding box array in the format [minLng, minLat, maxLng, maxLat]

      Returns FeatureCollection<LineString>

      A GeoJSON FeatureCollection of LineString features representing the network filtered by the bounding box.

    • Gets the network without duplicate or subsection lines. This method processes the network to remove any duplicate lines or lines that are subsections of other lines.

      Returns FeatureCollection<LineString, GeoJsonProperties>

      A FeatureCollection representing the network without duplicate or subsection lines.

    • Gets the count of unique nodes and edges in the graph.

      Returns { edgeCount: number; nodeCount: number }

      An object containing the counts of nodes and edges.

    • Gets the count of unique nodes in the graph.

      Returns number

      The number of unique nodes in the graph.

    • Gets the degree of each node in the graph.

      Returns Record<string, number>

      A Map where the key is a coordinate string "lng,lat" and the value is the degree.

    • Gets summary statistics for node degrees (min, max, average).

      Returns { avg: number; max: number; min: number }

    • Gets the unique nodes of the graph as a FeatureCollection of Point features.

      Returns FeatureCollection<Point>

      A FeatureCollection containing the nodes of the graph.

    • Returns the pruned network, which is the network without the leaf edges. i.e. This method removes all leaf edges from the network, leaving only the non-leaf edges

      Parameters

      • Optionaldepth: number

      Returns FeatureCollection<LineString>

      A FeatureCollection representing the pruned network without leaf edges.

    • Gets the length of a specific route.

      Parameters

      • line: Feature<LineString>

        A GeoJSON Feature of type LineString

      Returns number

      The length of the route in meters

    • Gets the shortest edge in the graph based on the length of the LineString.

      Returns null | Feature<LineString, GeoJsonProperties>

      The shortest edge as a Feature or null if no edges exist.

    • Gets the length of the shortest edge in the graph based on the length of the LineString. If no edges exist, it returns -1.

      Returns number

      The length of the shortest edge in meters, or 0 if no edges exist.

    • Returns the network where all nodes that are with n meters of each other are unified. The function will avoid unifying coordinates in the same linestring.

      Parameters

      • toleranceMeters: number

        the tolerance for unifying nodes in meters.

      Returns FeatureCollection<LineString, GeoJsonProperties>

    • Sets the network for the graph. This method replaces the current network with a new one.

      Parameters

      • network: FeatureCollection<LineString>

        A GeoJSON FeatureCollection of LineString features representing the network.

      Returns void