addPersistentRoadblockByCoordinates static method

(TrafficEvent?, GemError) addPersistentRoadblockByCoordinates({
  1. required List<Coordinates> coords,
  2. required DateTime startTime,
  3. required DateTime expireTime,
  4. required RouteTransportMode transportMode,
  5. 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

Also see:

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);
}