# 4. Trip details


<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

# Observations

- `tripid` attribute exists in vehicle trip details API but does not
  exist in route details API. Ex: `tripid = 71830930`

## Issue 1. Vehicle is assigned to more than one route

Vehicles on some occassions are assigned to more than one route. Ex:
Vehicle `KA57F5808` is assigned to two routes, `routeno = 210-NA` and
`routeno = D33-PPLO`.

``` json
"LiveLocation": [
    {
        "latitude": 12.909809,
        "longitude": 77.536422,
        "location": "Depot-33 Poornapragna layout (Towards Depot-33 (Poornapragna layout))",
        "lastrefreshon": "17-09-2025 23:19:34",
        "nextstop": null,
        "previousstop": "Arehalli (Towards Kengeri)",
        "vehicleid": 27211,
        "vehiclenumber": "KA57F5808",
        "routeno": "210-NA",
        "servicetypeid": 72,
        "servicetype": "Non AC/Ordinary",
        "heading": 210.18,
        "responsecode": 200,
        "trip_status": 1,
        "lastreceiveddatetimeflag": 1
    },
    {
        "latitude": 12.909809,
        "longitude": 77.536422,
        "location": "Depot-33 Poornapragna layout (Towards Depot-33 (Poornapragna layout))",
        "lastrefreshon": "17-09-2025 23:19:34",
        "nextstop": null,
        "previousstop": "Arehalli (Towards Kengeri)",
        "vehicleid": 27211,
        "vehiclenumber": "KA57F5808",
        "routeno": "D33-PPLO",
        "servicetypeid": 72,
        "servicetype": "Non AC/Ordinary",
        "heading": 210.18,
        "responsecode": 200,
        "trip_status": 1,
        "lastreceiveddatetimeflag": 1
    }
]
```

## Issue 2. Live location is missing

Live location was empty for about `2.5%` of vehicles (`185` out of
`7,247` vehicles) when run on `2025-09-17`. Ex: Vehicle ID `28622` with
registration number `KA01AR4181`.

``` json
{
    "RouteDetails": [],
    "LiveLocation": [],
    "Message": "No Records Found",
    "Issuccess": true,
    "exception": null,
    "RowCount": 0,
    "responsecode": 200
}
```

# Fetch

------------------------------------------------------------------------

<a
href="https://github.com/traffic-kowshik/traffic-data-bengaluru/blob/main/traffic_data_bengaluru/bmtc/trip_details.py#L36"
target="_blank" style="float:right; font-size:smaller">source</a>

### fetch_trip_details

>  fetch_trip_details (vehicle_id:int, sleep_duration:float=0.1)

*Fetch trip details for a given vehicle ID from the BMTC API.*

# Extract

## Dataset 1. Live Location

------------------------------------------------------------------------

<a
href="https://github.com/traffic-kowshik/traffic-data-bengaluru/blob/main/traffic_data_bengaluru/bmtc/trip_details.py#L57"
target="_blank" style="float:right; font-size:smaller">source</a>

### extract_live_location

>  extract_live_location (trip_details)

*Extract live location from trip details.*

------------------------------------------------------------------------

<a
href="https://github.com/traffic-kowshik/traffic-data-bengaluru/blob/main/traffic_data_bengaluru/bmtc/trip_details.py#L70"
target="_blank" style="float:right; font-size:smaller">source</a>

### get_live_locations

>  get_live_locations (directory:pathlib.Path)

*Extract live location for all trip details in a directory.*

## Dataset 2. Route Details

------------------------------------------------------------------------

<a
href="https://github.com/traffic-kowshik/traffic-data-bengaluru/blob/main/traffic_data_bengaluru/bmtc/trip_details.py#L83"
target="_blank" style="float:right; font-size:smaller">source</a>

### extract_route_detail

>  extract_route_detail (trip_detail)

# Task

------------------------------------------------------------------------

<a
href="https://github.com/traffic-kowshik/traffic-data-bengaluru/blob/main/traffic_data_bengaluru/bmtc/trip_details.py#L91"
target="_blank" style="float:right; font-size:smaller">source</a>

### task_fetch_trip_details

>  task_fetch_trip_details (data_directory:pathlib.Path)
