geoflo.Routing

This module provides the routing functionality for the Geoflo application. It allows users to calculate routes between two points on the map using a PathFinder object.

Methods

static activate() → {void}

Activates the functionality by setting the 'enabled' property to true and enabling routing in the options.
Returns:
void

static deactivate() → {void}

This function deactivates the routing feature by setting the enabled flag to false, disabling routing in the options, and clearing the route data on the map.
Returns:
void

static getClosest() → {Object|boolean}

Calculates the closest point on a route based on the last click and the closest point to it.
Returns:
Object | boolean - Returns a GeoJSON LineString feature with routing property set to true if successful, otherwise false.

static getFeatures() → {Array}

Retrieves features of type 'LineString' from the mesh index.
Returns:
Array - An array of features of type 'LineString'.

static getMatch(coords) → {Promise.<Object>}

Retrieves a match for the given coordinates using the Exploring service. Sets the match as a starting point for routing.
Parameters:
Name Type Description
coords Object The coordinates for which to find a match.
Returns:
Promise.<Object> - The matched feature with routing property set to true.

static getRoute(fromPoint, toPoint) → {Array|boolean}

This function calculates a route between two points on a map using a PathFinder object. It checks if the routing feature is enabled and if the map is not currently moving. It then creates a feature collection from the existing features, initializes a PathFinder object, and finds a path between the two points. The path is validated and then added to the map with a 'routing.add' event.
Parameters:
Name Type Description
fromPoint Object The starting point for the route.
toPoint Object The destination point for the route.
Returns:
Array | boolean - The calculated route path as an array of points, or false if the route could not be calculated.