UNPKG

terra-route

Version:

A library for routing along GeoJSON LineString networks

51 lines (50 loc) 2.49 kB
import { Position, Feature, Point, LineString, FeatureCollection } from "geojson"; /** * Calculates the total length of a LineString route in meters. * * @param line - A GeoJSON Feature<LineString> representing the route * @returns The total length of the route in meters */ export declare function routeLength(line: Feature<LineString>): number; /** * Extracts unique coordinates from a FeatureCollection of LineStrings. * * @param collection - A GeoJSON FeatureCollection of LineStrings * @returns An array of unique Position coordinates */ export declare function getUniqueCoordinatesFromLineStrings(collection: FeatureCollection<LineString>): Position[]; /** * Validates a GeoJSON Feature<LineString> route. * * @param route - The GeoJSON feature to validate * @returns A boolean indicating if it is a valid LineString route */ export declare function getReasonIfLineStringInvalid(route: Feature<LineString> | null | undefined): string | undefined; /** * Checks if the start and end coordinates of a LineString match the given start and end points. * * @param line - The LineString feature to check * @param start - The start point feature * @param end - The end point feature * @return True if the start and end coordinates match, false otherwise * */ export declare function startAndEndAreCorrect(line: Feature<LineString>, start: Feature<Point>, end: Feature<Point>): boolean; /** * Checks if the route represented by a LineString is longer than the direct path. * In theory, a route should always longer than the direct path if it has more than two points. * @param line - The LineString feature representing the route * @param start - The start point feature * @param end - The end point feature * @returns - True if the route is longer than the direct path, false otherwise */ export declare function routeIsLongerThanDirectPath(line: Feature<LineString>, start: Feature<Point>, end: Feature<Point>): boolean; /** * Modifies a FeatureCollection of LineStrings to break connections * between lines that share coordinates, by adjusting one of the shared * coordinates within a given tolerance. * * @param collection - The input FeatureCollection of LineStrings * @param tolerance - The amount by which to offset shared coordinates (in degrees) * @returns A new FeatureCollection with modified coordinates */ export declare function disconnectLineStrings(collection: FeatureCollection<LineString>, tolerance: number): FeatureCollection<LineString>;