# EV reachable area

`POST https://bemap.benomad.com/bgis/service/evreachablearea/1.0`

Part of [EV reachable area](https://benomad.com/dev/doc/bemap-api/electric-mobility/ev-reachable-area.md).

> **Show how far an electric vehicle can go.** The area an electric vehicle can reach from its start point with the charge it has, as a shape to draw on a map. Use it to show a driver which destinations are within range before a trip, or which places a fleet can serve without charging.

Perform a calculation of reachable area dedicated to electrical vehicle. This service return a geometry of area.

Provisioned per account: without it, BeMap answers `400 Access Denied`.

## Request body

JSON, `Content-Type: application/json`. Schema `EvReachableAreaRequest`.

- `vehicle` (string, required): Vehicle model (UUID key).
- `temperature` (integer (int32), required): Temperature in Celsius.
- `startLon` (number (double), required): Departure longitude in decimal degrees (WGS84). Also accepted as `longitude`.
- `startLat` (number (double), required): Departure latitude in decimal degrees (WGS84). Also accepted as `latitude`.
- `geoserver` (string): Geoserver name.
- `swidx` (integer (int32), deprecated): Switch index.
- `initBatLvl` (number (double)): Initial battery level in percent. Available value 0 to 100. 100% if not defined.
- `weather` (boolean): Enable the weather information.
- `wp` (string): Enable the weather information.
- `payload` (integer (int32)): Vehicle's extra load (consumables or passengers weight for example) (in kg). 75kg by default.
- `extraPayload` (integer (int32), deprecated): Additional load weight in kg (like passengers, luggage or tools). Deprecated and not supported anymore, use the `payload` field. Also accepted as `extraPayLoad`.
- `criterias` (enum[]): This field is a list of criteria used by the routing calculator, e.g.: "`AVOID_MOTORWAYS`", "`AVOID_TOLLS`".
  - `AVOID_FERRIES`: Find a route with no ferry.
  - `AVOID_MOTORWAYS`: Find a route without motorways.
  - `AVOID_TOLLS`: Find a route with no toll.
  - `AVOID_UNPAVED`: Find a route with no unpaved roads.
  - `AVOID_CROSSING_BORDER`: Find a route without country border crossing (makes sence only when the start and stop points are in the same country).
  - `LESS_EXPENSIVE`: Find the less expensive charging stations. Only with algorithm v2. Deprecated.
  - `TRAFFIC`: Use traffic info for route calculation.
- `stopLon` (number (double)): Arrival longitude in decimal degrees (WGS84).
- `stopLat` (number (double)): Arrival latitude in decimal degrees (WGS84).
- `geo` (boolean): Set to `true` to enable the geometry of the reachable area's polygon. By default `true`.
- `egeo` (boolean): Set to `true` to enable the encoded geometry of the reachable area's polygon. By default `false`. See `Google Encoded Polyline Algorithm Format` in glossary.

## Response

`200`, schema `EvReachableAreaResponse`.

- `boundingBox` (BoundingBox): The bounding box of the returned polygon geometry.
  - `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)).
- `geometry` (Coordinate[]): The reachable area's polygon geometry defined as a list of WGGS84 coordinates.
  - `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`.
- `encodedGeometry` (string): The reachable area's polygon geometry encoded with Google Algorithm.

## Errors

- `400`: Bad Request
- `302`: no credentials were sent. Do not follow the redirect.
- `401`: the account or the API key is wrong.

How to read each one: [Errors](https://benomad.com/dev/doc/bemap-api/getting-started/errors.md).

## Example

```bash
curl -X POST 'https://bemap.benomad.com/bgis/service/evreachablearea/1.0' \
  -u 'YOUR_ACCOUNT:YOUR_API_KEY' \
  --fail-with-body \
  -H 'Content-Type: application/json' \
  -d '{
  "vehicle": "29b8cbcd-a75e-48db-a29f-c26745013d20",
  "startLat": 48.8606,
  "startLon": 2.3376,
  "initBatLvl": 60,
  "temperature": 15,
  "geo": true,
  "criterias": [
    "AVOID_TOLLS"
  ]
}'
```

Response captured from production, long arrays and strings shortened:

```json
{
  "boundingBox": {
    "minLon": -0.29192,
    "minLat": 47.36367,
    "maxLon": 4.81493,
    "maxLat": 51.04861
  },
  "geometry": [
    {
      "lon": 0.03853,
      "lat": 50.76823
    },
    {
      "lon": -0.28914,
      "lat": 50.8278
    }
  ]
}
```

## Reference pages

- [EV reachable area](https://benomad.com/dev/doc/bemap-api/guides/services/evreachablearea.md)
