Creates an empty graph; cellSize should be about the typical segment length.
ReadonlycellSpatial hash cell size, metres.
ReadonlyedgesAll edges, by id.
ReadonlynodesAll nodes, by id.
Adds an edge between existing nodes. Returns its id, or −1 (and changes nothing) if it would break planarity, duplicate an edge, or have zero length.
Adds a node and returns its id.
True if segment a→b (between nodes na and nb, which may be −1) would touch any edge not
sharing one of those nodes. skipEdge is ignored (the edge about to be split at b).
Edge id connecting nodes a and b, or −1.
Ids of edges that may overlap the box (a superset: check the geometry).
First edge crossed by segment a→b (nearest to a), ignoring edges at node skipNode. distance is the parameter along a→b.
Length of edge e, metres.
Nearest point on any edge within radius of (x, z), skipping edges for which skip is true.
Optionalskip: (id: number) => booleanNearest node within radius of (x, z), skipping ids in skip; −1 if none.
Optionalskip: (id: number) => booleanThe other end of edge e seen from node n.
Shortest route between two nodes along the roads (A*). Returns node ids from from to to,
or an empty array if they are not connected. cost can weight edges (default: length).
Splits edge e at (x, z) (projected onto it) with a new node; returns the node id.
Plain-data copy (nodes and edges), e.g. to send to a worker or save.
Total road length, metres (optionally only one class).
Optionaltype: RoadType
A planar road graph: every crossing of two roads is a node. RoadGraph.addEdge refuses edges that would cross or touch another edge away from a shared node, so the graph stays planar by construction. Spatially hashed for fast snapping and crossing queries, and plain data (
toJSON) so crowds and vehicles can navigate it.