Namespace: Algorithms

Algorithms

Contains functions for running and visualizing algorithms as well as helper methods for use in algorithms.

Source:

Members

(static) cachedRoutes

Source:

Methods

(static) drawRoute(id, path) → {void}

Draws a path on the map given an array of node IDs.

Parameters:
Name Type Description
id string

The ID of the map feature to be drawn. Drawing a feature with an ID corresponding to an existing feature will overwrite the previous one.

path Array.<number>

An array of node IDs forming a path.

Source:
Returns:
Type
void

(static) getDistance(n1, n2) → {number}

Gets the squared distance (in kilometers) between two nodes.

Parameters:
Name Type Description
n1 OSMNode

The first node.

n2 OSMNode

The second node.

Source:
Returns:

The distance in kilometers.

Type
number

(static) getNeighbors(node) → {Array.<number>}

Gets the neighbors of the current Node by traversing within and between Ways by moving between neighbors and Ways connected by the same Node.

Parameters:
Name Type Description
node OSMNode

The current Node.

Source:
Returns:

Array of Node IDs.

Type
Array.<number>

(static) getPath(cameFrom, start, node) → {Array.<number>}

Gets a path from one node to another given a dictionary storing ids of previous nodes.

Parameters:
Name Type Description
cameFrom Object.<number, number>

A dictionary of node IDs indexed by node IDs recording which node to move to from the current node.

start OSMNode

The target node. The path will terminate upon reaching this node.

node OSMNode

The first node to check. The path will traverse cameFrom backwards from this node.

Source:
Returns:

Array of Node IDs.

Type
Array.<number>

(static) getPathLength(cameFrom, start, node) → {Object}

Gets a path from one node to another and the length of the entire path given a dictionary storing ids of previous nodes.

Parameters:
Name Type Description
cameFrom Object.<number, number>

A dictionary of node IDs indexed by node IDs recording which node to move to from the current node.

start OSMNode

The target node. The path will terminate upon reaching this node.

node OSMNode

The first node to check. The path will traverse cameFrom backwards from this node.

Source:
Returns:

Object containing an array of Node IDs and the length of the path.

Type
Object

(static) getPathTime(dist) → {Object}

Calculates the time to walk the given path.

Walking through buildings (i.e. from one entrance to another) is assumed to be 1.41 times slower than walking the distance in a straight line directly between the entrance/exit nodes.

Parameters:
Name Type Description
dist number
Source:
Returns:

time: The time (in hours) to walk the given distance (in km) at a pace of 4.3km/h. dist: The actual distance.

Type
Object

(static) toggleFeature(id) → {bool|undefined}

Toggles the visiblity of the given Draw feature.

Parameters:
Name Type Description
id string

The map feature id.

Source:
Returns:

True if the feature is now visible, false if not. Undefined if the feature doesn't exist in either the cache or list of active features.

Type
bool | undefined

(static) toggleFeatureButton(self, id) → {void}

Toggles the given route as well as the text of the given button.

Parameters:
Name Type Description
self Element

The button to change the text of.

id string

The map feature id.

Source:
Returns:
Type
void