TrafficEngine (API Reference)
Class TrafficEngine
Use the TrafficEngine to get information about current traffic flow and incidents in an area
specified by GeoBox, GeoCircle, or GeoCorridor.
Provides optional parameters given in TrafficIncidentsQueryOptions and TrafficFlowQueryOptions to filter the result.
By default, incidents are localized based on their geographical location. You can override that behavior by specifying the desired language that should be used for the incidents description and summary.
The resulting traffic data contains information on incident types such as congestion, construction for road works, road hazard, road closure, weather updates for road condition, lane restriction and others.
Traffic data is fetched online to get the most precise and freshest data available.
In offline mode, live traffic data can be fetched using the traffic pass-through features.
See SDKNativeEngine.getPassThroughFeatures()
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance of this class.TrafficEngine(SDKNativeEngine sdkEngine) Creates a new instance of this class. -
Method Summary
Modifier and TypeMethodDescriptionlookupIncident(String originalId, TrafficIncidentLookupOptions lookupOptions, TrafficIncidentLookupCallback callback) Asynchronously queries for traffic incident by the original id.queryForFlow(GeoBox boxArea, TrafficFlowQueryOptions queryOptions, TrafficFlowQueryCallback callback) Asynchronously queries for traffic flow using a bounding box as a filter.queryForFlow(GeoCircle circleArea, TrafficFlowQueryOptions queryOptions, TrafficFlowQueryCallback callback) Asynchronously queries for traffic flow using a circle as a filter.queryForFlow(GeoCorridor corridorArea, TrafficFlowQueryOptions queryOptions, TrafficFlowQueryCallback callback) Asynchronously queries for traffic flow by a corridor as a filter.queryForIncidents(GeoBox boxArea, TrafficIncidentsQueryOptions queryOptions, TrafficIncidentsQueryCallback callback) Asynchronously queries for traffic incidents using a bounding box as a filter.queryForIncidents(GeoCircle circleArea, TrafficIncidentsQueryOptions queryOptions, TrafficIncidentsQueryCallback callback) Asynchronously queries for traffic incidents using a circle as a filter.queryForIncidents(GeoCorridor corridorArea, TrafficIncidentsQueryOptions queryOptions, TrafficIncidentsQueryCallback callback) Asynchronously queries for traffic incidents by a corridor as a filter.
-
Constructor Details
-
TrafficEngine
Creates a new instance of this class.
- Throws:
InstantiationErrorException-Indicates what went wrong when the instantiation was attempted.
-
TrafficEngine
Creates a new instance of this class.
- Parameters:
sdkEngine-An SDKEngine instance.
- Throws:
InstantiationErrorException-Indicates what went wrong when the instantiation was attempted.
-
-
Method Details
-
queryForIncidents
@NonNull public TaskHandle queryForIncidents(@NonNull GeoBox boxArea, @NonNull TrafficIncidentsQueryOptions queryOptions, @NonNull TrafficIncidentsQueryCallback callback) Asynchronously queries for traffic incidents using a bounding box as a filter.
- Parameters:
boxArea-The bounding box area to search for traffic incidents. The maximum width and height for a bounding box filter is 1 degree.
queryOptions-The options which are specific for incidents query.
callback-It is always invoked on the main thread.
- Returns:
Handle that will be used to manipulate the execution of the task.
-
queryForIncidents
@NonNull public TaskHandle queryForIncidents(@NonNull GeoCircle circleArea, @NonNull TrafficIncidentsQueryOptions queryOptions, @NonNull TrafficIncidentsQueryCallback callback) Asynchronously queries for traffic incidents using a circle as a filter.
- Parameters:
circleArea-The circle area to search for traffic incidents. The maximum radius of the circle filter is 50000 meters.
queryOptions-The options which are specific for incidents query.
callback-It is always invoked on the main thread.
- Returns:
Handle that will be used to manipulate the execution of the task.
-
queryForIncidents
@NonNull public TaskHandle queryForIncidents(@NonNull GeoCorridor corridorArea, @NonNull TrafficIncidentsQueryOptions queryOptions, @NonNull TrafficIncidentsQueryCallback callback) Asynchronously queries for traffic incidents by a corridor as a filter.
- Parameters:
corridorArea-The corridor box to search for traffic incidents. The maximum length for the corridor is 500000 meters and the maximum
GeoCorridor.half_width_in_metersis 5000 meters. If the number of points in corridor is greater than 300 then request is split into smaller ones and results are aggregated into single response, this will result in multiple requests to the backend. This process does not change a shape of the corridor.To reduce number of points in the corridor use
PolylineSimplifier.If no
GeoCorridor.half_width_in_metersis specified, the default value is used. The default value is 30 meters.queryOptions-The options which are specific for incidents query.
callback-It is always invoked on the main thread.
- Returns:
Handle that will be used to manipulate the execution of the task.
-
lookupIncident
@NonNull public TaskHandle lookupIncident(@NonNull String originalId, @NonNull TrafficIncidentLookupOptions lookupOptions, @NonNull TrafficIncidentLookupCallback callback) Asynchronously queries for traffic incident by the original id. See
TrafficIncident.getOriginalId()for more information.- Parameters:
originalId-The requested incident original id.
lookupOptions-The options which are specific for the incident lookup query.
callback-The callback object that will be invoked after the incident lookup query. It is always invoked on the main thread.
- Returns:
Handle that will be used to manipulate the execution of the task.
-
queryForFlow
@NonNull public TaskHandle queryForFlow(@NonNull GeoBox boxArea, @NonNull TrafficFlowQueryOptions queryOptions, @NonNull TrafficFlowQueryCallback callback) Asynchronously queries for traffic flow using a bounding box as a filter.
Note: This is a beta release of this feature, so there could be a few bugs and unexpected behaviors. Related APIs may change for new releases without a deprecation process.
- Parameters:
boxArea-The bounding box area to search for traffic flow.
queryOptions-The options which are specific for flow query.
callback-It is always invoked on the main thread.
- Returns:
Handle that will be used to manipulate the execution of the task.
-
queryForFlow
@NonNull public TaskHandle queryForFlow(@NonNull GeoCircle circleArea, @NonNull TrafficFlowQueryOptions queryOptions, @NonNull TrafficFlowQueryCallback callback) Asynchronously queries for traffic flow using a circle as a filter.
Note: This is a beta release of this feature, so there could be a few bugs and unexpected behaviors. Related APIs may change for new releases without a deprecation process.
- Parameters:
circleArea-The circle area to search for traffic flow. The maximum radius of the circle filter is 50000 meters.
queryOptions-The options which are specific for flow query.
callback-It is always invoked on the main thread.
- Returns:
Handle that will be used to manipulate the execution of the task.
-
queryForFlow
@NonNull public TaskHandle queryForFlow(@NonNull GeoCorridor corridorArea, @NonNull TrafficFlowQueryOptions queryOptions, @NonNull TrafficFlowQueryCallback callback) Asynchronously queries for traffic flow by a corridor as a filter.
Note: This is a beta release of this feature, so there could be a few bugs and unexpected behaviors. Related APIs may change for new releases without a deprecation process.
- Parameters:
corridorArea-The corridor box to search for traffic flow. The maximum length for the corridor is 500000 meters and the maximum
GeoCorridor.half_width_in_metersis 5000 meters.Maximum number of points in the corridor is 300.
To reduce number of points in the corridor use
PolylineSimplifier.If no
GeoCorridor.half_width_in_metersis specified, the default value is used. The default value is 30 meters.queryOptions-The options which are specific for flow query.
callback-It is always invoked on the main thread.
- Returns:
Handle that will be used to manipulate the execution of the task.
-