terra-route
Version:
A library for routing along GeoJSON LineString networks
84 lines (83 loc) • 3.67 kB
TypeScript
import { Feature, FeatureCollection, LineString, Point } from "geojson";
/**
* 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.
*/
export declare class LineStringGraph {
constructor(network: FeatureCollection<LineString>);
private network;
/**
* Sets the network for the graph.
* This method replaces the current network with a new one.
* @param network A GeoJSON FeatureCollection of LineString features representing the network.
*/
setNetwork(network: FeatureCollection<LineString>): void;
/**
* Gets the current network of the graph.
* @returns A GeoJSON FeatureCollection of LineString features representing the network.
*/
getNetwork(): FeatureCollection<LineString>;
/**
* Gets the connected components of the graph.
* @returns An array of FeatureCollection<LineString> representing the connected components.
*/
getConnectedComponents(): FeatureCollection<LineString>[];
/**
* Gets the count of connected components in the graph.
* @returns The number of connected components in the graph.
*/
getConnectedComponentCount(): number;
/**
* Gets the count of unique nodes and edges in the graph.
* @returns An object containing the counts of nodes and edges.
*/
getNodeAndEdgeCount(): {
nodeCount: number;
edgeCount: number;
};
/**
* Gets the unique nodes of the graph as a FeatureCollection of Point features.
* @returns A FeatureCollection<Point> containing the nodes of the graph.
*/
getNodes(): FeatureCollection<Point>;
/**
* Gets the count of unique nodes in the graph.
* @returns The number of unique nodes in the graph.
*/
getNodeCount(): number;
/**
* 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 A FeatureCollection<LineString> containing the unique edges of the graph.
*/
getEdges(): FeatureCollection<LineString>;
/**
* 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 The length of the longest edge in meters, or 0 if no edges exist.
*/
getLongestEdgeLength(): number;
/**
* 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 The length of the shortest edge in meters, or 0 if no edges exist.
*/
getShortestEdgeLength(): number;
/**
* Gets the longest edge in the graph based on the length of the LineString.
* @returns The longest edge as a Feature<LineString> or null if no edges exist.
*/
getLongestEdge(): Feature<LineString> | null;
/**
* Gets the shortest edge in the graph based on the length of the LineString.
* @returns The shortest edge as a Feature<LineString> or null if no edges exist.
*/
getShortestEdge(): Feature<LineString> | null;
/**
* Gets the count of unique edges in the graph.
* @returns The number of unique edges in the graph.
*/
getEdgeCount(): number;
}