} else
throw new UnsupportedOperationException();
}
private void insertWithRoutingService(RoutingService routingService, int[] selectedRows) {
RouteConverter r = RouteConverter.getInstance();
List<NavigationPosition> selectedPositions = new ArrayList<NavigationPosition>();
for (int i = 0; i < selectedRows.length; i++)
selectedPositions.add(r.getPositionsModel().getPosition(i));
if (routingService.isDownload()) {
List<LongitudeAndLatitude> lal = new ArrayList<LongitudeAndLatitude>();
for (NavigationPosition position : selectedPositions) {
lal.add(asLongitudeAndLatitude(position));
}
routingService.downloadRoutingDataFor(lal);
}
TravelMode travelMode = r.getRoutingServiceFacade().getTravelMode();
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);
for (int j = 0; j < positions.size(); j++) {
int[] rows = new int[]{insertRow + j};
r.getBatchPositionAugmenter().addData(rows, false, true, true);
}
}
}
}