Extensions are added to a PathSearch to influence the search process.
Remarks
An extension contains several callback methods that are used by the PathSearch to, e.g., calculate the costs for the next possible steps (i.e., entering the next partition cell) and to decide when the target is reached.
The PathSearch uses the callbacks in the following order:
- initialize
- initializeEdges
- initializeCurrentEdge
- initializeCurrentPathRequest
- appendStartEntrances
- calculateStartEntranceCost
- calculateCosts
- calculateHeuristicCosts
- isValidTargetEntrance
- finalizePath or cancelCurrentPathRequest
- finalizeCurrentEdge or cancelCurrentEdge
- finalizeEdges
- finalizePathSearchResult
- cleanUp
Type Details
- yfiles module
- router-polyline
- yfiles-umd modules
- layout-area, layout-multipage, layout-orthogonal-compact, layout, router-bus, router-polyline
- Legacy UMD name
- yfiles.router.PathSearchExtension
See Also
Constructors
Creates a new instance of PathSearchExtension.
Properties
Gets the configuration used for the path search.
Remarks
Gets the current context of the path search.
Remarks
Methods
Appends additional start entrances for the path search of the current edge to the given list of all previously generated entrances.
Remarks
Parameters
A map of options to pass to the method.
- allStartEntrances - IList<Object>
- a list of all previously generated entrances
calculateCosts
(currentEntrance: CellEntrance, enteredCell: PartitionCell, enterInterval: OrthogonalInterval, edgeCellInfo: EdgeCellInfo, maxAllowedCosts: number) : numberCalculates the costs for entering the given PartitionCell via the given enter OrthogonalInterval.
Remarks
The given EdgeCellInfo describes how the partition cell that has been entered by the current entrance would be traversed if this enter interval to the neighboring cell would be chosen.
The maxAllowedCosts
describe the maximum costs that entering the neighboring cell via the given enter interval may induce. If the maximum cost is exceeded, calculations that may further increase its cost may be skipped because this interval won't be chosen anyway.
This implementation doesn't add any costs. It may be overridden to add costs, e.g., if entering through the given interval would create a bend.
Parameters
A map of options to pass to the method.
- currentEntrance - CellEntrance
- the entrance that was used for entering the current cell
- enteredCell - PartitionCell
- the neighboring cell that shall be entered
- enterInterval - OrthogonalInterval
- the interval that shall be used for entering the neighboring cell
- edgeCellInfo - EdgeCellInfo
- the information about how the current cell would be traversed if the neighboring cell would be entered by this enter interval
- maxAllowedCosts - number
- the maximum allowed costs for this enter interval
Returns
- ↪number
- the costs for entering the neighboring cell via the enter interval
Calculates the heuristic costs for the given CellEntrance that describe the minimal costs that will arise to finish the path if the given cell entrance is used as next step.
Remarks
After evaluating the costs for each enter interval to a neighboring cell, this method is called for each of the resulting CellEntrances.
This implementation doesn't add any costs. It may be overridden to add some heuristic costs, e.g., if the edge would have to bend to reach the target node from the given CellEntrance.
Parameters
A map of options to pass to the method.
- entrance - CellEntrance
- the entrance to calculate the heuristic costs for the rest of the path
Returns
- ↪number
- the minimal costs that will arise to finish the path if the given cell entrance is used as next step
Returns the cost for starting the path in the given entrance.
Remarks
This method is called for each start entrance of the current edge.
The current implementation doesn't add any costs for the given CellEntrance. It may be overridden to make start entrances with less specific intervals more expensive. For example, intervals that allow more than just the PortConstraint location to connect to the source node become more expensive.
Parameters
A map of options to pass to the method.
- startEntrance - CellEntrance
- the start entrance for which the cost is calculated
Returns
- ↪number
- the cost for starting the path in the given entrance
Handles the cancellation of the path search for the current edge.
Remarks
This callback notifies the extension when the path search for the current edge is canceled. Then, the path search will proceed with altering the penalties of the current edge and reinitializing it again.
This implementation does nothing. It may be overridden to reset some edge specific information, e.g., removing previously added listeners.
Parameters
A map of options to pass to the method.
- context - PathSearchContext
- the context containing the current edge for which the path search has been canceled
See Also
Handles the cancellation of the path search for the current PathRequest.
Remarks
This callback notifies the extension when the path search for the current request is canceled. In case that not all requests of an edge are successful, then also the path search for that edge will be canceled.
This implementation does nothing. It may be overridden to process or reset PathRequest-specific data like e.g., previously registered listeners.
Parameters
A map of options to pass to the method.
- context - PathSearchContext
- the context containing the request for which the path search has been canceled
See Also
Cleans up the extension from the path searches with the current configuration and context.
Handles the completion of the path search for the current edge.
Remarks
This callback notifies the extension when enough paths are found for the current edge. After that, the path search either proceeds with initializing the next current edge in the context's edge list or calls finalizeEdges if all edges in this list have been handled.
This implementation does nothing. It may be overridden to add/reset some edge specific information, e.g., removing previously added listeners or adding new start entrances.
Parameters
A map of options to pass to the method.
- context - PathSearchContext
- the context containing the current edge for which the path search has been finished
See Also
Handles the completion of all marked edges.
Remarks
Parameters
A map of options to pass to the method.
- context - PathSearchContext
- the context containing the list of edges for which paths have been found
See Also
After finding a valid target entrance and creating a EdgeRouterPath, the extension is notified of the found path.
Remarks
If the path search is configured to calculate several possible paths for an edge, the path search proceeds with choosing another unhandled CellEntrance.
This implementation does nothing. It may be overridden to collect some information about the given path that may influence the path search of later edges.
Parameters
A map of options to pass to the method.
- path - EdgeRouterPath
- the path found for the current edge in the context
See Also
Completes the path search result.
Remarks
This callback notifies the extensions of the paths chosen for the edges in the current context. After calling finalizeEdges, the PathSearch decides, which of the found paths to use for each edge and adds them to the PathSearchResult.
With this callback, the registered extensions are notified of this result before the path search either initializes the next list of edges to route or ends the path search by calling cleanUp. This implementation does nothing.
Parameters
A map of options to pass to the method.
- pathSearchResult - PathSearchResult
- the path search result for the edge in the current context's edge list
See Also
Initializes this extension for path searches using the given configuration.
Remarks
Parameters
A map of options to pass to the method.
- configuration - PathSearchConfiguration
- the configuration to use for the following path searches
Initializes this extension with the current edge set in the given context.
Remarks
This method is called for each edge of the context. Each call will be balanced by a call to either finalizeCurrentEdge or cancelCurrentEdge.
It may be overridden to initialize/reset the settings for the current edge (e.g. minimum distances).
Parameters
A map of options to pass to the method.
- context - PathSearchContext
- the context containing the current edge
See Also
Initializes this extension with the current PathRequest set in the given context.
Remarks
This method is called for each request of the context's current edge. Each call will be balanced by a call to either finalizePath or cancelCurrentPathRequest.
This method may be overridden to modify settings and data that should be individual for each PathRequest.
Parameters
A map of options to pass to the method.
- context - PathSearchContext
- the context containing the current path request
See Also
Initializes this extension with the context that contains the list of edges for which paths are calculated.
Remarks
This method may be called several times during a path search. Each call will be balanced by calls to finalizeEdges and finalizePathSearchResult.
It may be overridden to initialize/reset the settings for the routed edges (e.g. minimum distances).
Parameters
A map of options to pass to the method.
- context - PathSearchContext
- the context containing the list of edges for which paths shall be found
See Also
Determines whether or not this extension considers the given CellEntrance as a valid target entrance, i.e., the path may end with the given entrance.
Remarks
Each time a CellEntrance is chosen as next step, all registered extensions are asked if this entrance is a valid target entrance. Only if none of the extensions returns false
, a EdgeRouterPath is created.
This implementation accepts all CellEntrances as valid targets. It may be overridden to only activate the target if the route fulfills a certain condition.
Parameters
A map of options to pass to the method.
- entrance - CellEntrance
- the entrance to decide if it is a valid target entrance
Returns
- ↪boolean
true
if the path may end with this entrance,false
otherwise