THIS SDK ISDEPRECATED.

We rolled out a new and better SDK for you.

Route avoids

Allow your users to plan a route that avoids toll roads, motorways, ferries, unpaved roads, carpool lanes, roads that they have already taken, vignettes, or even whole areas.

Sample use case: You plan a trip between the TomTom offices in Amsterdam and Oslo. You would like to check how much time you gain by taking a ferry and how much more time it will take to drive if you don’t use motorways so you can choose the best route.

Available routes to avoid:

1routeAvoid = Avoid.TOLL_ROADS
2routeAvoid = Avoid.MOTORWAYS
3routeAvoid = Avoid.FERRIES
4routeAvoid = Avoid.UNPAVED_ROADS
5routeAvoid = Avoid.CAR_POOLS
6routeAvoid = Avoid.ALREADY_USED_ROADS

To request a route for a specified route avoid:

1RouteDescriptor routeDescriptor = new RouteDescriptor.Builder()
2 .avoidType(avoidTypes)
3 .considerTraffic(false)
4 .build()
5
6RouteCalculationDescriptor routeCalculationDescriptor = new RouteCalculationDescriptor.Builder()
7 .routeDescription(routeDescriptor)
8 .maxAlternatives(0)
9 .reportType(ReportType.NONE)
10 .instructionType(InstructionsType.NONE)
11 .build();
12
13RouteSpecification routeSpecification = new RouteSpecification.Builder(
14 routeConfig.getOrigin(),
15 routeConfig.getDestination()
16)
17 .routeCalculationDescriptor(routeCalculationDescriptor)
18 .build();
1val routeDescriptor = RouteDescriptor.Builder()
2 .avoidType(listOf(avoidType))
3 .considerTraffic(false)
4 .build()
5
6val routeCalculationDescriptor = RouteCalculationDescriptor.Builder()
7 .routeDescription(routeDescriptor)
8 .maxAlternatives(MAX_ALTERNATIVES)
9 .reportType(ReportType.NONE)
10 .instructionType(InstructionsType.NONE)
11 .build()
12
13val routeSpecification = RouteSpecification.Builder(origin, destination)
14 .routeCalculationDescriptor(routeCalculationDescriptor)
15 .build()

image

Route avoid ferries

image

Route avoid motorways

image

Route avoid toll roads

Sample use case: You plan a trip from A to B and you know that on your way there are vignettes. Additionally, there is an area which has very high traffic. You want to avoid both vignettes and the specified area.

To avoid vignettes:

1List<String> avoidVignettesList = new ArrayList<>();
2avoidVignettesList.add("HUN");
3avoidVignettesList.add("CZE");
4avoidVignettesList.add("SVK");
5
6RouteSpecification routeSpecification = RouteSpecificationFactory.createRouteForAvoidsVignettesAndAreas(avoidVignettesList, routeConfig);
1 val listOfVignettes = listOf("HUN", "CZE", "SVK")
2val routeCalculationDescriptor = RouteCalculationDescriptor.Builder()
3 .routeDescription(createRouteDescriptor())
4 .maxAlternatives(MAX_ALTERNATIVES)
5 .reportType(ReportType.NONE)
6 .instructionType(InstructionsType.NONE)
7 .avoidVignettes(avoidVignettesList)
8 .build()
9
10val routeSpecification = RouteSpecification.Builder(routeConfig.origin, routeConfig.destination)
11 .routeCalculationDescriptor(routeCalculationDescriptor)
12 .build()

To avoid an area:

1BoundingBox boundingBox = new BoundingBox(ARAD_TOP_LEFT_NEIGHBORHOOD, ARAD_BOTTOM_RIGHT_NEIGHBORHOOD);
2
3List<BoundingBox> avoidAreas = new ArrayList<>();
4avoidAreas.add(boundingBox);
5
6RouteSpecification routeSpecification = RouteSpecificationFactory.createRouteForAvoidsArea(avoidAreas, routeConfig);
1 val boundingBox = BoundingBox(Locations.ARAD_TOP_LEFT_NEIGHBORHOOD, Locations.ARAD_BOTTOM_RIGHT_NEIGHBORHOOD)
2val routeCalculationDescriptor = RouteCalculationDescriptor.Builder()
3 .routeDescription(createRouteDescriptor())
4 .maxAlternatives(MAX_ALTERNATIVES)
5 .reportType(ReportType.NONE)
6 .instructionType(InstructionsType.NONE)
7 .avoidAreas(listOf(avoidArea))
8 .build()
9
10val routeSpecification = RouteSpecification.Builder(routeConfig.origin, routeConfig.destination)
11 .routeCalculationDescriptor(routeCalculationDescriptor)
12 .build()

image

Route without avoiding anything

image

Route avoiding a specified area

image

Route avoiding vignettes