# Traffic

REST API, Service version 1.0.0

> API reference: [`POST /traffic/1.0`](https://benomad.com/dev/doc/bemap-api/api/map-context/traffic.md)

To get the traffic information by country or an restricted area.

## Summary
1. Request
 1. Mandatory parameters
 2. Optional parameters
2. Response
 1. Details of fields
 2. Response samples

## Request
The request must be sent with the HTTP method `POST` and the HTTP header `Content-Type` set to `application/json`. 

Sample:
URI: `/bgis/service/traffic/1.0`

POST data:
```javascript
{
	"boundingBox" : {
		"minLon" : 2.24801,
		"minLat" : 48.80938,
		"maxLon" : 2.42045,
		"maxLat" : 48.90529
	},
	"outputLanguage" : "fr"
}
```

All coordinates are defined by longitude and latitude, see the [coordinate system](https://benomad.com/dev/doc/bemap-api/guides/reference/glossary-coordinate-system.md) glossary for more details.

### __Parameters__
The parameters `bbox` and `countryCode` can used alternately, but the presence of one of them in the request is mandatory.

- `geoserver` (string): Geoserver name.
- `swidx` (integer (int32), deprecated): Switch index.
- `countryCode` (string): Country ISO Code. Performs a data extract operation inside the specified Iso code filter.
- `timestamp` (integer (int64)): Time stamp in milliseconds.
- `boundingBox` (BoundingBox): The bounding box make a filter on an specific area.
  - `minLon` (number (double)): Minimum longitude, in degrees decimal ([WGS84](https://benomad.com/dev/doc/bemap-api/guides/reference/glossary-coordinate-system.md)).
  - `minLat` (number (double)): Minimum latitude, in degrees decimal ([WGS84](https://benomad.com/dev/doc/bemap-api/guides/reference/glossary-coordinate-system.md)).
  - `maxLon` (number (double)): Maximum longitude, in degrees decimal ([WGS84](https://benomad.com/dev/doc/bemap-api/guides/reference/glossary-coordinate-system.md)).
  - `maxLat` (number (double)): Maximum latitude, in degrees decimal ([WGS84](https://benomad.com/dev/doc/bemap-api/guides/reference/glossary-coordinate-system.md)).
- `elementId` (string): Traffic element ID.
- `reverseDirection` (boolean): Define the side of road will be used.
- `options` (enum[]): Options of traffic info service.
  - `STATS`: Enable the data outputs like jam factor, speed and other information.
  - `POLYLINE`: Enable the polyline geometry output.
  - `SYNC`
  - `ALERTC`: Enable the Alert-C outputs.
  - `OPENLR`: Enable the OpenLR outputs.
  - `TRAFFIC_PREDICTIVE`: Enable the predictive traffic information.
  - `TRAFFIC_HISTORICAL`: (Beta) Enable the historical traffic information.
  - `ONLY_BLOCKED_ROAD`: To get only the blocked roads (closed).
  - `EXCLUDE_BLOCKED_ROAD`: To exclude all blocked roads (closed).
- `previousUpdateTimestamp` (integer (int64), deprecated): The previous time stamp of update, can be used for synchronization mode.
- `outputLanguage` (string): Output language.

## Response

### Details of fields

- `countryInitialized` (boolean): Country initialized.
- `trafficResponseElements` (TrafficRespElement[]): Traffic response elements.
  - `trafficItem` (TrafficItem): Traffic Item.
    - `info` (TrafficElementInfo): Traffic information of element.
      - `id` (string)
      - `countryCode` (string)
      - `copyright` (string)
      - `releaseDate` (string (date-time))
      - `lastUpdateDate` (string (date-time))
    - `elementId` (string): Element ID.
    - `reverseDirection` (boolean): True for inverse road direction.
    - `boundingBox` (BoundingBox): Bounding box of geometry in WGS84.
      - `minLon` (number (double)): Minimum longitude, in degrees decimal ([WGS84](https://benomad.com/dev/doc/bemap-api/guides/reference/glossary-coordinate-system.md)).
      - `minLat` (number (double)): Minimum latitude, in degrees decimal ([WGS84](https://benomad.com/dev/doc/bemap-api/guides/reference/glossary-coordinate-system.md)).
      - `maxLon` (number (double)): Maximum longitude, in degrees decimal ([WGS84](https://benomad.com/dev/doc/bemap-api/guides/reference/glossary-coordinate-system.md)).
      - `maxLat` (number (double)): Maximum latitude, in degrees decimal ([WGS84](https://benomad.com/dev/doc/bemap-api/guides/reference/glossary-coordinate-system.md)).
    - `jamFactor` (number (float)): Percent (%) of traffic jam. Between 0.00 (free way) to 100.00 (full jam).
    - `reason` (enum): TrafficReason.
      - `NA`: Not available.
      - `CONGESTION`: traffic congestion (jam).
      - `CARRIAGEWAY_REDUCED`: Carriage-way reduced.
      - `ACCIDENT`: Accident.
      - `INCIDENT`: Incident.
      - `INFORMATION`: Information.
      - `NON_RECOMMANDED_ROAD`: Non re-commanded road.
      - `ROAD_CONDITION_DETERIORATED`: Road condition deteriorated.
      - `BLOCKED_ROAD`: Blocked road.
      - `ROAD_UNDER_CONTRUCTION`: Road under construction.
    - `reasonComments` (TrafficResComment[]): List of reason comments.
      - `language` (string)
      - `comment` (string)
    - `reasonCoordinate` (Coordinate): Coordinate of the reason event.
      - `lon` (number (double), required): Longitude in degrees decimal ([WGS84](https://benomad.com/dev/doc/bemap-api/guides/reference/glossary-coordinate-system.md)). Also accepted as `longitude`.
      - `lat` (number (double), required): Latitude in degrees decimal ([WGS84](https://benomad.com/dev/doc/bemap-api/guides/reference/glossary-coordinate-system.md)). Also accepted as `latitude`.
    - `polyline` (Coordinate[]): Polyline.
      - `lon` (number (double), required): Longitude in degrees decimal ([WGS84](https://benomad.com/dev/doc/bemap-api/guides/reference/glossary-coordinate-system.md)). Also accepted as `longitude`.
      - `lat` (number (double), required): Latitude in degrees decimal ([WGS84](https://benomad.com/dev/doc/bemap-api/guides/reference/glossary-coordinate-system.md)). Also accepted as `latitude`.
    - `segmentInfos` (TrafficSegInfo[]): Segment Info.
      - `id` (string): Unique identifier of road segment.
      - `reverseDirection` (boolean): The route travel is in opposite way of geometry.
    - `tmcInternalId` (integer (int64)): AlertcTrafficElement.
    - `alertcEbuCountryCode` (string): AlertcTrafficElement.
    - `alertcTableId` (integer (int64)): AlertcTrafficElement.
    - `alertcLocationId` (integer (int64)): AlertcTrafficElement.
    - `alertcExtend` (integer (int32)): AlertcTrafficElement.
    - `alertcCode` (integer (int32)): AlertcTrafficElement.
    - `openLrBase64` (string): OpenLrTrafficElement.

### Response samples
JSON Sample:
```javascript

```
