for (int i = 0; i < selectedPositions.size(); i++) {
// skip the very last position without successor
if (i == r.getPositionsModel().getRowCount() - 1 || i == selectedPositions.size() - 1)
continue;
RoutingResult result = routingService.getRouteBetween(selectedPositions.get(i), selectedPositions.get(i + 1), travelMode);
if (result != null) {
List<BaseNavigationPosition> positions = new ArrayList<BaseNavigationPosition>();
for (NavigationPosition position : result.getPositions()) {
positions.add(r.getPositionsModel().getRoute().createPosition(position.getLongitude(), position.getLatitude(), position.getElevation(), null, null, null));
}
int insertRow = r.getPositionsModel().getIndex(selectedPositions.get(i)) + 1;
r.getPositionsModel().add(insertRow, positions);