addPersistentRoadblockByArea static method
(TrafficEvent?, GemError)
addPersistentRoadblockByArea({
- required GeographicArea area,
- required DateTime startTime,
- required DateTime expireTime,
- required RouteTransportMode transportMode,
- required String id,
Adds a user-defined persistent roadblock covering a geographic area.
Parameters
area: The GeographicArea affected by the roadblock.startTime: The UTC start time for the roadblock.expireTime: The UTC expiry time for the roadblock.transportMode: The RouteTransportMode affected by the roadblock.id: A unique identifier for the user roadblock.
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.
Also see:
- addAntiPersistentRoadblockByArea to create an anti-area roadblock that whitelists an area instead of blocking it.
- addPersistentRoadblockByCoordinates to create roadblocks defined by coordinates.
Implementation
static (TrafficEvent?, GemError) addPersistentRoadblockByArea({
required GeographicArea area,
required DateTime startTime,
required DateTime expireTime,
required RouteTransportMode transportMode,
required String id,
}) {
final OperationResult resultString = staticMethod(
'TrafficService',
'addPersistentRoadblockArea',
args: <String, dynamic>{
'area': area,
'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);
}