calculateRange

abstract fun calculateRange(rangeCalculationOptions: RangeCalculationOptions): Result<Range, RoutingFailure>

Synchronously calculates a range using the provided RangeCalculationOptions.

Return

A Range if the call succeeds, a RoutingFailure if it fails.

** Usage example: **

val rangeCalculator: RangeCalculator = ...
val rangeCalculationOptions: RangeCalculationOption = ...
when (val calculateRangeResult = rangeCalculator.calculateRange(rangeCalculationOptions)) {
is Result.Success -> {
val rangeResult = calculateRangeResult.value()
// YOUR CODE GOES HERE
}
is Result.Failure -> {
val rangeFailure = calculateRangeResult.failure()
// YOUR CODE GOES HERE
}
}

Parameters

rangeCalculationOptions

Determines origin, budget, and other parameters.


abstract fun calculateRange(rangeCalculationOptions: RangeCalculationOptions, callback: Callback<Range, RoutingFailure>): Cancellable

Asynchronously calculates a range using the provided RangeCalculationOptions object. If the operation succeeds, Callback.onSuccess is called for the callback with a Range. Otherwise, Callback.onFailure is called with a RoutingFailure.

Return

A cancellable operation.

** Usage example: **

val rangeCalculator: RangeCalculator = ...
val rangeCalculationOptions: RangeCalculationOptions = ...
rangeCalculator.calculateRange(
rangeCalculationOptions,
object : Callback<Range, RoutingFailure> {
override fun onSuccess(result: Range) {
// YOUR CODE GOES HERE
}
override fun onFailure(failure: RoutingFailure) {
// YOUR CODE GOES HERE
}
},
)

Parameters

rangeCalculationOptions

Determines origin, budget, and other parameters.

callback

The Callback invoked when the operation has finished, either successfully or with an error. The callback will be executed in the main thread.