int waySelection) {
List<Position> result = new ArrayList<Position>();
try {
MapWayFilter wayFilter = createMapWayFilter(mapData, waySelection);
boolean ignoreOneways = (waySelection == 0);
MapNode fromRNode = mapData.getNearestWayNode(new Position(locs
.get(0)), wayFilter);
result.add(new Position(fromRNode.getLat(), fromRNode.getLon()));
for (int i = 1; i < locs.size()
&& !CancelableThread.currIsCanceled(); i++) {
MapNode toRNode = mapData.getNearestWayNode(new Position(locs
.get(i)), wayFilter);
HeuristicFunction hf = createHeuristicFunction(toRNode,
waySelection);
Problem problem = createProblem(fromRNode, toRNode, mapData,
wayFilter, ignoreOneways, waySelection);
Search search = new AStarSearch(new GraphSearch(), hf);
List<Action> actions = search.search(problem);
if (actions.isEmpty())
break;
for (Object action : actions) {
if (action instanceof OsmMoveAction) {
OsmMoveAction a = (OsmMoveAction) action;
for (MapNode node : a.getNodes())
if (!node.equals(a.getFrom()))
result.add(new Position(node.getLat(), node
.getLon()));
}
}
fromRNode = toRNode;
}