RouteData API

RouteData object stores the information about transporter's route as a list of movement tasks. The tasks are executed consequently in the order of listing. Each task describes transporter's movement along a single segment of the route. The segment ends when the type of movement changes. The movements can be of the following types:

RouteData object provides the following functions:
General

Function

Description

boolean isEmpty()

Returns true if the RouteData object contains information about a transporter's route. Otherwise, returns false.

int size()

Returns the amount of movement tasks in the RouteData object.

RouteData findShortestRoute(Collection<RouteData> collection,
LengthUnits units)

Returns the shortest route from the collection of RouteData objects in the specified length units.

Parameters:
collection - a collection of RouteData objects
units - a constant defining the length units.


Route information

Function

Description

IRouteLocation getSourceLocation()

Returns the source location of the route described by the RouteData object.

IRouteLocation getTargetLocation()

Returns the target location of the route described by the RouteData object.

double distance(LengthUnits units)

Returns the distance of the route described in the RouteData object in specified length units.

Parameter:
units - a constant defining the length units.

boolean contains(INode node)

Checks whether the route described in the RouteData object contains the given node.

Parameter:
node
- a given network node.

boolean contains(IPath path)

Checks whether the route described in the RouteData object contains the given path.

Parameter:
path
- a given network path.


Movement tasks information

Function

Description

IMovement getMovement(int index)

Returns a movement task with a specified index from the RouteData object.

Parameter:
index
- a given index of a movement task

IMovement getFirstMovement()

Returns the first movement task. If the RouteData object is empty, this function returns null.

IMovement getLastMovement()

Returns the last movement task. If the RouteData object is empty, this function returns null.

List<IMovement> getMovements()

Returns the unmodifiable list of all movement tasks.


Creating movement tasks

Function

Description

IMovement createPlainMovement(INetworkMarkupElement networkElement, Point source, Point target)

Creates a movement task of PLAIN type within a given network node.

Parameters:
networkElement - a network node where the movement must take place
source - a point in the node where the movement must begin (the point is taken in the absolute coordinate system)
target - a point in the node where the movement must end (the point is taken in the absolute coordinate system)

IMovement createPathMovement(IPath path,
boolean forward)

Creates a movement task of PATH type along the given path in the specified direction.

Parameters:
path - network path where the movement must take place
forward - if true, the movement begins from the starting point of the path; if false - from the ending point of the path

IMovement createPathMovement(IPath path, double sourceOffset,
double targetOffset, LengthUnits units)

Creates a movement task of PATH type. The movement takes place within a single path, begins at the given offset from the starting point of the path and ends at the given offset from the starting point of the path. The offset is given in the specified length units.

Parameters:
path - network path where the movement must take place
sourceOffset - distance from the starting point of the path to the starting point of the movement
targetOffset - distance from the starting point of the path to the ending point of the movement
units - a constant defining the length units

IMovement createPortMovement(MarkupPort source,
MarkupPort target)

Creates a movement task of PORT type between the two given network ports.

Parameters:
source - network port where the movement must begin
target - network port where the movement must end

IMovement createNodeTransferMovement(INode node,
IPath sourcePath, IPath targetPath)

Creates a movement task of either PATH type or PLAIN type between the two given paths within a given network node. In case of polygonal and rectangular nodes it will be a PLAIN type, and in case of point node - a PATH type.

Parameters:
node - network node where the movement must take place
sourcePath - network path where the movement must begin
targetPath - network path where the movement must end


Adding movement tasks

Function

Description

addMovement(IMovement movement)

Adds a given movement task to the RouteData object. This task is placed at the end of the existing list of movement tasks.

Parameter:
movement - the given movement task

addMovement(int index, IMovement movement)

Adds a given movement task to the RouteData object and inserts it in the existing list of movement tasks by the specified index.

Parameters:
index - the index where the movement task must be inserted
movement - the given movement task

addMovements(IMovement... movements)

Adds movement tasks to the RouteData object. These movements are placed at the end of the existing list of movement tasks in the same order as the arguments passed.

Parameter:
movements - the movement tasks

addMovements(Collection<? extends IMovement> movements)

Adds a collection of movement tasks to the RouteData object. These movements are placed at the end of the existing list of movement tasks in the same order as they are in the collection.

Parameter:
movements - the collection of movement tasks

addPlainMovement(INetworkMarkupElement networkElement, Point source, Point target)

Adds a movement task of PLAIN type within a given network node.

Parameters:
networkElement - a network node where the movement must take place
source - a point in the node where the movement must begin (the point is taken in the absolute coordinate system)
target - a point in the node where the movement must end (the point is taken in the absolute coordinate system)

addPathMovement(IPath path, boolean isForward)

Adds a movement task of PATH type along the given path in the specified direction to the RouteData object.

Parameters:
path - network path where the movement must take place.
forward - if true, the movement begins from the starting point of the path; if false - from the ending point of the path

addPathMovement(IPath path, double sourceOffset,
double targetOffset, LengthUnits units)

Adds a movement task of PATH type to the RouteData object. The movement takes place within one path, begins at the given offset from the starting point of the path and ends at the given offset from the starting point of the path. The offset is given in the specified length units.

Parameters:
path - network path where the movement must take place
sourceOffset - distance from the starting point of the path to the starting point of the movement
targetOffset - distance from the starting point of the path to the ending point of the movement
units - a constant defining the length units

addNodeTransferMovement(INode node,
IPath sourcePath, IPath targetPath)

Adds a movement task of either PATH type or PLAIN type from one given path to another within a given network node to the RouteData object. In case of polygonal and rectangular nodes it will be a PLAIN type, and in case of point node - a PATH type.

Parameters:
node - network node where the movement must take place
sourcePath - network path where the movement must begin
targetPath - network path where the movement must end

addPortMovement(MarkupPort source,
MarkupPort target)

Adds a movement task of PORT type between the two given network ports to the RouteData object.

Parameters:
source - network port where the movement must begin
target - network port where the movement must end


Removing movement tasks

Function

Description

boolean removeMovement(IMovement movement)

Removes the given movement task from the RouteData object. If the function returns true, the task was found in the object and successfully removed. If the function returns false, the task wasn't found.

Parameter:
movement
- the given movement task

removeMovement(int index)

Removes a movement task with a given index from the RouteData object.

Parameter:
index
- the given index of the movement task

removeFirstMovement()

Removes the first movement task from the RouteData object.

removeLastMovement()

Removes the last movement task from the RouteData object.


Related topics

Creating a custom route programmatically

Transporters

Transporter API

Path-guided navigation