new EvSmartRoutingResponse(options)
BeNomad BeMap JavaScript API - EvSmartRoutingResponse (v1.5)
Strongly-typed response parser. `fromJson()` accepts both the REST **v1.0**
shape (single `journey` + `route`) and the REST **v2.0.0** shape (`journeys[]`
of `{summary, events[]}`), exposing both through the same getters.
Wire shapes mirror `EvSmartRoutingResponse` server-side
(`bemap_idea/.../service/{v1_0_0,v2_0_0}/model/evSmartRouting/response/EvSmartRoutingResponse.java`):
{
logTag,
journey: { distance, duration, batteryLevel, consumed, chargingTime,
chargingCost, departureTime, arrivalTime, vehicle,
savedCo2Emissions },
inputInfo,
boundingBox,
route: { stepPoints, polyline?, encodedPolyline?, events?, timeSlotWarns? }
}
Parameters:
| Name | Type | Description |
|---|---|---|
options |
Object | Parsed JSON response from the server. |
Methods
(static) fromJson(json) → {bemap.EvSmartRoutingResponse}
Parse the raw JSON response into a `bemap.EvSmartRoutingResponse`.
Parameters:
| Name | Type | Description |
|---|---|---|
json |
Object |
Returns:
getArrivalBatteryLevel() → {Number}
Remaining battery level (percent, 0-100) at the end of the trip.
Returns:
- Type
- Number
getBoundingBox() → {bemap.BoundingBox|null}
`bemap.BoundingBox` covering the whole journey, or `null` when absent.
`fromJson` already lifts `{topLeft, bottomRight}` to a `bemap.BoundingBox`,
so under normal conditions this returns a `bemap.BoundingBox`. If the
BoundingBox lift failed (e.g. malformed payload), the raw JSON object is
returned so callers can still inspect it.
Returns:
- Type
- bemap.BoundingBox | null
getChargingCost()
getChargingTime() → {Number}
Total time spent charging across all stops, in seconds.
Returns:
- Type
- Number
getConsumed() → {Number}
Total energy consumed across the whole journey, in kWh.
Returns:
- Type
- Number
getDistance() → {Number}
Distance of the whole journey, in metres.
Returns:
`0` when the journey is missing.
- Type
- Number
getDuration() → {Number}
Duration of the whole journey, in seconds (including charging stops).
Returns:
`0` when the journey is missing.
- Type
- Number
getEncodedPolyline() → {String|Array.<String>|null}
Google-encoded polyline. On a **v1** response this is a single `String`; on a
**v2** response it is an `Array.` — one encoded string per ROUTE
segment, since v2 splits the geometry across ROUTE events. `null` when absent.
Returns:
- Type
- String | Array.<String> | null
getEvents()
getJourneys()
getPolyline() → {Array.<bemap.Coordinate>}
Route polyline as an Array of `bemap.Coordinate`, or empty when the
server omitted the polyline (e.g. `pl=false` in the request).
Returns:
- Type
- Array.<bemap.Coordinate>
getRouteConsumptions()
getSavedCo2Emissions() → {Number|null}
Saved CO2 emissions (kg), when `co2Emissions` was set in the request.
Returns:
- Type
- Number | null
getStepPoints() → {Array.<bemap.EvStepPoint>}
Charging stops in order along the journey, parsed into `EvStepPoint`.
Returns:
- Type
- Array.<bemap.EvStepPoint>