openlr.map.utils
Class PathUtils

java.lang.Object
  extended by openlr.map.utils.PathUtils

public final class PathUtils
extends Object

The Class RouteUtils.

OpenLR is a trade mark of TomTom International B.V.

email: software@openlr.org

Author:
TomTom International B.V.

Method Summary
static boolean checkPathConnection(List<Line> path)
          Checks if the path is connected properly.
static List<Line> constructPath(LineLinkedListElement dest)
          Constructs a path from information in the LineLinkedListElement.
static Line findCommonLineInPaths(List<? extends Line> location, LineLinkedListElement el)
          Compares the path of the location and the path indicated by the LineLinkedListElement el and returns the first line element which is part of both paths, starting from the end of the linked list path.
static LineLinkedListElement findElementInQueue(Queue<? extends LineLinkedListElement> pq, Line line)
          Returns the first LineLinkedListElement from the queue pq which contains the line l.
static int getLength(List<Line> path)
          Gets the total length of the path [in meter, rounded].
static int getLength(List<Line> path, Line start, Line end)
          Gets the length of the subpath of path between start and end.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getLength

public static int getLength(List<Line> path,
                            Line start,
                            Line end)
Gets the length of the subpath of path between start and end. The start and end line needs to be part of the route and the start line needs to be in the list prior to the end line. The returned length value includes the lengths of the start and end lines.

Parameters:
path - the complete path
start - start of the subpath
end - end of the subpath
Returns:
the length of the subpath including start and end line, if no subpath exists the method returns -1, if the path is empty the method returns 0

getLength

public static int getLength(List<Line> path)
Gets the total length of the path [in meter, rounded].

Parameters:
path - the path
Returns:
the total length or 0 if route is empty or null.

checkPathConnection

public static boolean checkPathConnection(List<Line> path)
Checks if the path is connected properly. For each line the subsequent line in the list also needs to be a direct successor of the line in the network.

Parameters:
path - the path to be checked
Returns:
true, if the path is connected, otherwise false

constructPath

public static List<Line> constructPath(LineLinkedListElement dest)
Constructs a path from information in the LineLinkedListElement. These elements store a pointer to its predecessor in a path and starting from the end of that path the method follows these pointers and stores the lines of the path until the path ends (indicated by an empty predecessor pointer). The returned path is directed from start to end. The path to be constructed shall not have any loops and if a loop is detected the method will return null.

Parameters:
dest - the end of the path
Returns:
the constructed path from start to dest or null if a loop is detected

findElementInQueue

public static LineLinkedListElement findElementInQueue(Queue<? extends LineLinkedListElement> pq,
                                                       Line line)
Returns the first LineLinkedListElement from the queue pq which contains the line l.

Parameters:
pq - a queue containing LineLinkedListElements
line - the line
Returns:
the LineLinkedListElement from pq containing l or null if it could not be found

findCommonLineInPaths

public static Line findCommonLineInPaths(List<? extends Line> location,
                                         LineLinkedListElement el)
Compares the path of the location and the path indicated by the LineLinkedListElement el and returns the first line element which is part of both paths, starting from the end of the linked list path. If no such line exists the method returns null.

Parameters:
location - the location path
el - LineLinkedListElement defining a second path
Returns:
the first line which is part of both paths, starting from the end of the paths


Copyright © 2013 TomTom International B.V.. All Rights Reserved.