calculateIsolines method
- required IsolineThresholds thresholds,
- IsolineAllowOptions? allow,
- String? arrivalTime,
- IsolineAvoidanceOptions? avoid,
- bool? departNow,
- String? departureTime,
- List<
double> ? destination, - IsolineDestinationOptions? destinationOptions,
- GeometryFormat? isolineGeometryFormat,
- IsolineGranularityOptions? isolineGranularity,
- String? key,
- IsolineOptimizationObjective? optimizeIsolineFor,
- RoutingObjective? optimizeRoutingFor,
- List<
double> ? origin, - IsolineOriginOptions? originOptions,
- IsolineTrafficOptions? traffic,
- IsolineTravelMode? travelMode,
- IsolineTravelModeOptions? travelModeOptions,
Calculates areas that can be reached within specified time or distance thresholds from a given point. For example, you can use this operation to determine the area within a 30-minute drive of a store location, find neighborhoods within walking distance of a school, or identify delivery zones based on drive time.
Isolines (also known as isochrones for time-based calculations) are useful for various applications including:
- Service area visualization - Show customers the area you can serve within promised delivery times
- Site selection - Analyze potential business locations based on population within travel distance
- Site selection - Determine areas that can be reached within specified response times
May throw AccessDeniedException.
May throw InternalServerException.
May throw ThrottlingException.
May throw ValidationException.
Parameter thresholds :
The distance or time thresholds used to determine reachable areas. You can
specify up to five thresholds (which all must be the same type) to
calculate multiple isolines in a single request. For example, to determine
the areas that are reachable within 10 and 20 minutes of the origin,
specify time thresholds of 600 and 1200 seconds.
You incur a calculation charge for each threshold. Using a large number of thresholds in a request can lead to unexpected charges. For more information, see Routes pricing in the Amazon Location Service Developer Guide.
Parameter allow :
Enables special road types or features that should be considered for
routing even if they might be restricted by default for the selected
travel mode. These include high-occupancy vehicle and toll lanes.
Parameter arrivalTime :
Determine areas from which Destination can be reached by this
time, taking into account predicted traffic conditions and working
backward to account for congestion patterns. This attribute cannot be used
together with DepartureTime or DepartNow.
Specified as an ISO-8601 timestamp with timezone offset.
Time format: YYYY-MM-DDThh:mm:ss.sssZ |
YYYY-MM-DDThh:mm:ss.sss+hh:mm
Examples:
2020-04-22T17:57:24Z
2020-04-22T17:57:24+02:00
Parameter avoid :
Specifies road types, features, or areas to avoid (if possible) when
calculating reachable areas. These are treated as preferences rather than
strict constraints—if a route cannot be calculated without using an
avoided feature, that avoidance preference may be ignored.
Parameter departNow :
When true, uses the current time as the departure time and takes current
traffic conditions into account. This attribute cannot be used together
with DepartureTime or ArrivalTime.
Parameter departureTime :
Determine areas that can be reached when departing at this time, taking
into account predicted traffic conditions. This attribute cannot be used
together with ArrivalTime or DepartNow.
Specified as an ISO-8601 timestamp with timezone offset.
Time format:YYYY-MM-DDThh:mm:ss.sssZ |
YYYY-MM-DDThh:mm:ss.sss+hh:mm
Examples:
2020-04-22T17:57:24Z
2020-04-22T17:57:24+02:00
Parameter destination :
An optional destination point, specified as [longitude,
latitude] coordinates. When provided, the service calculates areas
from which this destination can be reached within the specified
thresholds. This reverses the usual isoline calculation to show areas that
could reach your location, rather than areas you could reach from your
location. Either Origin or Destination must be
provided.
Parameter destinationOptions :
Options that control how the destination point is matched to the road
network and how routes can approach it. These options help improve travel
time accuracy by accounting for real-world access to the destination.
Parameter isolineGeometryFormat :
The format of the returned IsolineGeometry.
Default value:FlexiblePolyline
Parameter isolineGranularity :
Controls the detail level of the generated isolines. Higher granularity
produces smoother shapes but requires more processing time and results in
larger responses.
Parameter key :
An Amazon Location Service API Key with access to this action. If omitted,
the request must be signed using Signature Version 4.
Parameter optimizeIsolineFor :
Controls the trade-off between calculation speed and isoline precision.
Choose FastCalculation for quicker results with less detail,
AccurateCalculation for more precise results, or
BalancedCalculation for a middle ground.
Default value: BalancedCalculation
Parameter optimizeRoutingFor :
Determines whether routes prioritize shortest travel time
(FastestRoute) or shortest physical distance
(ShortestRoute) when calculating reachable areas.
Default value: FastestRoute
Parameter origin :
The starting point for isoline calculations, specified as
[longitude, latitude] coordinates. For example, this could
be a store location, service center, or any point from which you want to
calculate reachable areas. Either Origin or
Destination must be provided.
Parameter originOptions :
Options that control how the origin point is matched to the road network
and how routes can depart from it. These options help improve travel time
accuracy by accounting for real-world access from the origin.
Parameter traffic :
Configures how real-time and historical traffic data affects isoline
calculations. Traffic patterns can significantly impact reachable areas,
especially during peak hours.
Parameter travelMode :
The mode of transportation to use for calculations. This affects which
road types or features can be used, estimated speed, and the traffic
levels that are applied.
-
Car—Standard passenger vehicle routing using roads accessible to cars -
Pedestrian—Walking routes using pedestrian paths, sidewalks, and crossings -
Scooter—Light two-wheeled vehicle routing using roads and paths accessible to scooters -
Truck—Commercial truck routing considering vehicle dimensions, weight restrictions, and hazardous material regulations
Car
Parameter travelModeOptions :
Additional attributes that refine how reachable areas are calculated based
on specific vehicle characteristics. These options help produce more
accurate results by accounting for real-world constraints and
capabilities.
For example:
-
For trucks (
Truck), specify dimensions, weight limits, and hazardous cargo restrictions to ensure isolines only include roads that can physically and legally accommodate the vehicle -
For cars (
Car), set maximum speed capabilities or indicate high-occupancy vehicle eligibility to better estimate reachable areas -
For scooters (
Scooter), specify engine type and speed limitations to more accurately model their travel capabilities
Implementation
Future<CalculateIsolinesResponse> calculateIsolines({
required IsolineThresholds thresholds,
IsolineAllowOptions? allow,
String? arrivalTime,
IsolineAvoidanceOptions? avoid,
bool? departNow,
String? departureTime,
List<double>? destination,
IsolineDestinationOptions? destinationOptions,
GeometryFormat? isolineGeometryFormat,
IsolineGranularityOptions? isolineGranularity,
String? key,
IsolineOptimizationObjective? optimizeIsolineFor,
RoutingObjective? optimizeRoutingFor,
List<double>? origin,
IsolineOriginOptions? originOptions,
IsolineTrafficOptions? traffic,
IsolineTravelMode? travelMode,
IsolineTravelModeOptions? travelModeOptions,
}) async {
final $query = <String, List<String>>{
if (key != null) 'key': [key],
};
final $payload = <String, dynamic>{
'Thresholds': thresholds,
if (allow != null) 'Allow': allow,
if (arrivalTime != null) 'ArrivalTime': arrivalTime,
if (avoid != null) 'Avoid': avoid,
if (departNow != null) 'DepartNow': departNow,
if (departureTime != null) 'DepartureTime': departureTime,
if (destination != null)
'Destination': destination.map(_s.encodeJsonDouble).toList(),
if (destinationOptions != null) 'DestinationOptions': destinationOptions,
if (isolineGeometryFormat != null)
'IsolineGeometryFormat': isolineGeometryFormat.value,
if (isolineGranularity != null) 'IsolineGranularity': isolineGranularity,
if (optimizeIsolineFor != null)
'OptimizeIsolineFor': optimizeIsolineFor.value,
if (optimizeRoutingFor != null)
'OptimizeRoutingFor': optimizeRoutingFor.value,
if (origin != null) 'Origin': origin.map(_s.encodeJsonDouble).toList(),
if (originOptions != null) 'OriginOptions': originOptions,
if (traffic != null) 'Traffic': traffic,
if (travelMode != null) 'TravelMode': travelMode.value,
if (travelModeOptions != null) 'TravelModeOptions': travelModeOptions,
};
final response = await _protocol.sendRaw(
payload: $payload,
method: 'POST',
requestUri: '/v2/isolines',
queryParams: $query,
exceptionFnMap: _exceptionFns,
);
final $json = await _s.jsonFromResponse(response);
return CalculateIsolinesResponse(
isolineGeometryFormat: GeometryFormat.fromString(
($json['IsolineGeometryFormat'] as String?) ?? ''),
isolines: (($json['Isolines'] as List?) ?? const [])
.nonNulls
.map((e) => Isoline.fromJson(e as Map<String, dynamic>))
.toList(),
arrivalTime: $json['ArrivalTime'] as String?,
departureTime: $json['DepartureTime'] as String?,
snappedDestination: ($json['SnappedDestination'] as List?)
?.nonNulls
.map((e) => _s.parseJsonDouble(e)!)
.toList(),
snappedOrigin: ($json['SnappedOrigin'] as List?)
?.nonNulls
.map((e) => _s.parseJsonDouble(e)!)
.toList(),
pricingBucket: _s.extractHeaderStringValue(
response.headers, 'x-amz-geo-pricing-bucket')!,
);
}