addPersistentRoadblockByCoordinates static method
(TrafficEvent?, GemError)
addPersistentRoadblockByCoordinates({
- required List<
Coordinates> coords, - required DateTime startTime,
- required DateTime expireTime,
- required RouteTransportMode transportMode,
- required String id,
Adds a user-defined persistent roadblock using a list of coordinates.
If coords contains a single coordinate a point roadblock is defined,
which may create two roadblock records (one per direction) when matched
to bidirectional roads.
If coords contains multiple points a path
roadblock is created covering the route from the first to the last
coordinate.
Parameters
coords: A list of Coordinates defining the roadblock geometry.startTime: The UTC start time when the roadblock becomes active.expireTime: The UTC expiry time when the roadblock is removed.transportMode: The RouteTransportMode affected by the roadblock.id: A unique identifier for the user roadblock. This id can later be used to retrieve or delete the roadblock via TrafficEvent.description.
Returns
- A tuple
([TrafficEvent]?, [GemError])where the first element is the created TrafficEvent on success, and the second element is a GemError code. On failure the event will benulland the error explains the cause. Possible error codes include:- GemError.activation: Roadblocks are disabled in TrafficPreferences.
- GemError.exist: A roadblock with the same id already exists.
- GemError.invalidInput: One or more parameters are invalid.
- GemError.notFound: No suitable street match or map data missing.
- GemError.inUse: The provided id is already in use.
- GemError.noRoute: The coordinates cannot define a valid route.
Also see:
- addAntiPersistentRoadblockByArea to create an anti-area roadblock that whitelists an area instead of blocking it.
- addPersistentRoadblockByArea to create roadblocks defined by geographic areas.
Implementation
static (TrafficEvent?, GemError) addPersistentRoadblockByCoordinates({
required List<Coordinates> coords,
required DateTime startTime,
required DateTime expireTime,
required RouteTransportMode transportMode,
required String id,
}) {
final OperationResult resultString = staticMethod(
'TrafficService',
'addPersistentRoadblockCoords',
args: <String, dynamic>{
'coord': coords,
'startUTC': startTime.millisecondsSinceEpoch,
'expireUTC': expireTime.millisecondsSinceEpoch,
'transportMode': transportMode.id,
'id': id,
},
);
final GemError error = GemErrorExtension.fromCode(
resultString['result']['second'],
);
if (error != GemError.success) {
return (null, error);
}
return (TrafficEvent.init(resultString['result']['first']), error);
}