THIS SDK ISDEPRECATED.

We rolled out a new and better SDK for you.

Reachable range

The Reachable Range component calculates a set of locations that can be reached from the origin point. It optimizes routes with a given route-type (e.g., fastest, eco, etc.) but limits the range for the given budget and consumption parameters. It uses the Calculate Reachable Range API so you can find all details in the service documentation.

Sample use case: You are preparing for a trip and you would like to check how far you can drive on your battery or tank, or within a specific time limit so you can plan your journey.

The following example shows a number of points that are reachable based on one of a specified model for: * Combustion engine * Electric engine * Time-2h limit on an electric car (time budget model is available for both electric and combustion engines)

Use the following code sample to implement a similar use case.

To request a reachable range, create a ReachableRangeSpecification:

Creating ReachableRangeSpecification for a combustion vehicle can be done in the following manner:

1return new ReachableRangeSpecification.Builder(Locations.AMSTERDAM_CENTER_LOCATION)
2 .reachableRangeBudgetDescriptor(reachableRangeBudgetDescriptor)
3 .combustionVehicleDescriptor(combustionVehicleDescriptor)
4 .build()
1return ReachableRangeSpecification.Builder(Locations.AMSTERDAM_CENTER)
2 .reachableRangeBudgetDescriptor(reachableRangeBudgetDescriptor)
3 .combustionVehicleDescriptor(createCombustionVehicleDescriptor())
4 .build()

Creating ReachableRangeSpecification for the electric vehicle can be done in the following manner:

1return new ReachableRangeSpecification.Builder(Locations.AMSTERDAM_CENTER_LOCATION)
2 .reachableRangeBudgetDescriptor(reachableRangeBudgetDescriptor)
3 .electricVehicleDescriptor(electricVehicleDescriptor)
4 .build();
1return ReachableRangeSpecification.Builder(Locations.AMSTERDAM_CENTER)
2 .reachableRangeBudgetDescriptor(reachableRangeBudgetDescriptor)
3 .electricVehicleDescriptor(createElectricVehicleDescriptor())
4 .build()

and pass it to the Routing API:

1routingApi.planReachableRange(
2 reachableRangeSpecificationFactory.createReachableRangeSpecificationForCombustion(),
3 reachableAreaCallback);
routingApi.planReachableRange(reachableRangeSpecification, reachableAreaCallback)

Setup of the common parameters of the ReachableRangeSpecification for a combustion engine:

1ReachableRangeBudgetDescriptor reachableRangeBudgetDescriptor =
2 new ReachableRangeBudgetDescriptor.Builder()
3 .fuelBudgetInLiters(5.0)
4 .build();
5
6Map<Double, Double> consumptionMap = new HashMap<>();
7consumptionMap.put(50.0, 6.3);
8
9CombustionVehicleConsumption combustionVehicleConsumption = new CombustionVehicleConsumption(
10 43.0, 1.7, 34.2, consumptionMap
11);
12
13CombustionVehicleDescriptor combustionVehicleDescriptor = new CombustionVehicleDescriptor.Builder()
14 .vehicleConsumption(combustionVehicleConsumption)
15 .vehicleDimensions(new VehicleDimensions.Builder()
16 .vehicleWeightInKg(1600)
17 .build())
18 .vehicleEfficiency(new VehicleEfficiency.Builder()
19 .uphillEfficiency(0.33)
20 .downhillEfficiency(0.33)
21 .decelerationEfficiency(0.33)
22 .accelerationEfficiency(0.33)
23 .build())
24 .build();
1val consumption = mapOf(Pair(SPEED, CONSUMPTION_AT_SPEED))
2val combustionVehicleConsumption = CombustionVehicleConsumption(
3 VEHICLE_CURRENT_FUEL, VEHICLE_AUXILIARY_POWER, FUEL_ENERGY_DENSITY, consumption
4)
5
6return CombustionVehicleDescriptor.Builder()
7 .vehicleConsumption(combustionVehicleConsumption)
8 .vehicleEfficiency(createVehicleEfficiency())
9 .vehicleDimensions(createVehicleDimensions())
10 .build()

Setup of the common parameters of the ReachableRangeSpecification for an electric vehicle:

1ReachableRangeBudgetDescriptor reachableRangeBudgetDescriptor =
2 new ReachableRangeBudgetDescriptor.Builder()
3 .energyBudgetInKWh(5.0)
4 .build();
5Map<Double, Double> consumptionMap = new HashMap<>();
6consumptionMap.put(50.0, 6.3);
7
8ElectricVehicleConsumption electricVehicleConsumption =
9 new ElectricVehicleConsumption(85.0, 43.0, 1.7, consumptionMap);
10
11ElectricVehicleDescriptor electricVehicleDescriptor = new ElectricVehicleDescriptor.Builder(electricVehicleConsumption)
12 .vehicleDimensions(new VehicleDimensions.Builder()
13 .vehicleWeightInKg(1600)
14 .build())
15 .vehicleEfficiency(new VehicleEfficiency.Builder()
16 .uphillEfficiency(0.33)
17 .downhillEfficiency(0.33)
18 .decelerationEfficiency(0.33)
19 .accelerationEfficiency(0.33)
20 .build())
21 .build();
1val consumption = mapOf(Pair(SPEED, CONSUMPTION_AT_SPEED))
2val electricVehicleConsumption = ElectricVehicleConsumption(
3 VEHICLE_MAX_CHARGE, VEHICLE_CURRENT_CHARGE, VEHICLE_AUXILIARY_POWER, consumption
4)
5
6return ElectricVehicleDescriptor.Builder(electricVehicleConsumption)
7 .vehicleEfficiency(createVehicleEfficiency())
8 .vehicleDimensions(createVehicleDimensions())
9 .build()

The result can be observed with ReachableAreaCallback:

1protected ReachableAreaCallback reachableAreaCallback = new ReachableAreaCallback() {
2 @Override
3 public void onSuccess(@NonNull ReachableRangeArea reachableArea) {
4 doActionOnReachableRangeResponse(reachableArea);
5 }
6
7 @Override
8 public void onError(@NonNull RoutingException error) {
9 doActionOnReachableRangeError();
10 }
11};
1private val reachableAreaCallback = object : ReachableAreaCallback {
2 override fun onSuccess(reachableArea: ReachableRangeArea) {
3 reachableRangeArea.value = Resource.success(reachableArea)
4 }
5
6 override fun onError(error: RoutingException) {
7 reachableRangeArea.value = Resource.error(null, Error(error.message))
8 }
9}

image

Fuel budget: 5 liters

image

Energy budget: 5 kWh

image

Time budget: 2h

You can use the output of the returned set of locations for other interacting use cases e.g., searching for places on the route to one (many) reachable point(s) with Search along the route or within the polygon boundaries with the Geometry search features of the Maps SDK.