Class: Dijskra

ol.graph. Dijskra

Compute the shortest paths between nodes in a graph source The source must only contains LinesString.

It uses a A* optimisation. You can overwrite methods to customize the result.


new Dijskra(options)

Parameters:
Name Type Description
options any
Properties
Name Type Argument Default Description
source ol/source/Vector

the source for the edges

maxIteration integer <optional>
20000

maximum iterations before a pause event is fired, default 20000

stepIteration integer <optional>
2000

number of iterations before a calculating event is fired, default 2000

epsilon number <optional>
1E-6

geometric precision (min distance beetween 2 points), default 1E-6

See:
Fires:
  • event:calculating
  • event:start
  • event:finish
  • event:pause

Methods


direction(feature)

Get the edge direction

  • 0 : the road is blocked
  • 1 : direct way
  • -1 : revers way
  • 2 : both way
Parameters:
Name Type Description
feature ol/Feature
Returns:

0: blocked, 1: direct way, -1: revers way, 2:both way

Type
Number

getBestWay()

Get the current 'best way'. This may be used to animate while calculating.

Returns:
Type
Array.<ol/Feature>

getEdges(coord)

Get all features at a coordinate

Parameters:
Name Type Description
coord ol/coordinate
Returns:
Type
Array.<ol/Feature>

getLength(geom)

Calculate the length of an edge

Parameters:
Name Type Description
geom ol/Feature | ol/geom/LineString
Returns:
Type
number

getNode(coord)

Get a node at a coordinate

Parameters:
Name Type Description
coord ol/coordinate
Returns:

the node

Type
ol/Feature

getNodeSource()

Get the nodes source concerned in the calculation

Returns:
Type
ol/source/Vector

path(start, end)

Calculate a path beetween 2 points

Parameters:
Name Type Description
start ol/coordinate
end ol/coordinate
Returns:

false if don't start (still running) or start and end nodes

Type
boolean | Array.<ol/coordinate>

pause()

Pause


resume()

Restart after pause


weight(feature)

Get the weighting of the edge, for example a speed factor The function returns a value beetween ]0,1]

  • 1 = no weighting
  • 0.5 = goes twice more faster on this road

If no feature is provided you must return the lower weighting you're using

Parameters:
Name Type Description
feature ol/Feature
Returns:

a number beetween 0-1

Type
number