I have a list of areas which are made up of multiple "boxes" (or avoidance areas). I am trying to add these boxes to the avoidance options when calculating the route, but the route seems to just ignore avoidance areas and create a route going through the avoidance areas.
I tried adding the areas to the avoidance options by creating GeoBox
objects using GeoCoordinates
.
CarOptions carOptions = new CarOptions();
for (Area area : closest100Areas) {
for (Box box : area.getBoxes()) {
GeoCoordinates northEast = new GeoCoordinates(box.northEast.latitude, box.northEast.longitude);
GeoCoordinates southWest = new GeoCoordinates(box.southWest.latitude, box.southWest.longitude);
carOptions.avoidanceOptions.avoidAreas.add(new GeoBox(southWest, northEast));
}
}
routingEngine.calculateRoute(waypoints, carOptions, new CalculateRouteCallback() {
@Override
public void onRouteCalculated(@Nullable RoutingError routingError, @Nullable List<Route> routes) {
if (routingError == null) {
Route route = routes.get(0);
showRouteDetails(route);
showRouteOnMap(route);
getManeuverInstructions(route);
logRouteViolations(route);
} else {
Log.e("Error while calculating a route:", routingError.toString());
}
}
});
The attached image shows a highlighted avoidance area which seems to be ignored. I also am not sure as to why there is a noticeable notch, but that is a separate issue.