Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show bus position on map, either simulated or using real-time data #176

Closed
barbeau opened this issue Sep 18, 2014 · 5 comments
Closed

Show bus position on map, either simulated or using real-time data #176

barbeau opened this issue Sep 18, 2014 · 5 comments

Comments

@barbeau
Copy link
Member

barbeau commented Sep 18, 2014

I just opened this ticket on iPhone as well (https://github.com/OneBusAway/onebusaway-iphone/issues/320), but I wanted to mirror here so we have a reference specific to Android as well.

This was something that @caitbonnar and @jrharshath discussed the other day, and I wanted to capture some info/links related to this.

We have all the data we need to simulate the bus position based on a particular trip and schedule (from GTFS / OBA REST APIs) as well as the current time. If we have shapes.txt in GTFS we can simulate precise position, if not position simulation will be rougher.

Real-time vehicle position is a little harder - from what I can tell the OBA REST APIs don't have a way to pull back vehicle positions related to a single route/trip (See additional comments below - OBA REST API trips-for-route returns all active trips per route, which include a status element that has real-time and interpolated vehicle position information). However, the OBA SIRI APIs that MTA deployed in NYC do. So, going forward, it would probably make sense to do real-time vehicle position based on the SIRI APIs. I don't believe the SIRI APIs are plug-and-play yet with the rest of the OBA core app modules server-side, but hopefully that will happen soon.

Related items:

  • The Transit App shows simulated bus position based on schedule data (on Android, at least - haven't checked iPhone):

thetransitapp-simulatedbusposition

  • Transit Map is an open-source web application that shows simulated bus position based on GTFS data
  • TRAVIC and Trajserver together apparently do something similar, although I haven't looked at them in detail yet (they were sent to me). They are both apparently related to this Master's Thesis on "Real-time Movement Visualization of Public Transit Data".

This issue is also related to showing route flow lines (https://github.com/OneBusAway/onebusaway-iphone/issues/319), since a moving vehicle on the map would also indicate direction of flow.

@barbeau
Copy link
Member Author

barbeau commented Aug 14, 2015

@barbeau barbeau added this to the v2.1 milestone Sep 24, 2015
barbeau added a commit that referenced this issue Oct 5, 2015
* See docs at http://developer.onebusaway.org/modules/onebusaway-application-modules/current/api/where/methods/trips-for-route.html
* This allows us to get active information about all current trips for a route, including status information, which includes vehicle position (towards #176)
* Also add unit test for API
* This also fixes a bug in ObaTripStatus that was preventing vehicle position from being correctly populated from the JSON response.  More unit tests have been added to check that vehicle position is being parsed correctly in both ArrivalsAndDeparturesForStop and TripsForRoute API responses.
barbeau added a commit that referenced this issue Oct 12, 2015
…n route mode

TODO:
* Vehicle map icon (including orientation of vehicle and popup balloon contents
* Cleanup of code related to icons
* Keep animation movement of buses?  Can be strange when bus moves off a road and cuts corners - should we snap it to the route line, if that is possible?
@barbeau
Copy link
Member Author

barbeau commented Oct 14, 2015

Arrow icon by Zlatko Najdenovski, MK (https://thenounproject.com/icon/63549/), marker icon by Housin Aziz, SE (https://thenounproject.com/term/map-marker/37239/), bus icon from Google Material Design (https://github.com/google/material-design-icons/blob/master/maps/svg/production/ic_directions_bus_48px.svg).

@barbeau barbeau modified the milestones: Public v2.0.x release, v2.1 Oct 16, 2015
@barbeau
Copy link
Member Author

barbeau commented Oct 16, 2015

I've been working on showing vehicle positions in the "routes" view in my spare time. Progress is in this branch:
https://github.com/OneBusAway/onebusaway-android/tree/176-vehicles

...and it currently looks like this:
image

Tapping on the vehicle icon will open a marker balloon that has the route/headsign info, the status (e.g., "3 min delay"), and how recently the information was updated.

barbeau added a commit that referenced this issue Oct 20, 2015
* Show real-time vehicle position information (when its available in route map mode, and show interpolated vehicle position based on schedule data when real-time data isn't available
* Uses trips-for-route OBA REST API endpoint - status.lastKnownLocation is used for real-time position, and status.position is used for interpolated position based on schedule data
* Black PNG vehicle icons are included in the project, and then colored dynamically for each status (early/ontime/late/schedule) and direction, and then cached in VehicleOverlay
* Only animate the movement of the vehicle icon if the new position is withina threshold of another - otherwise, just snap icon to new position
* ActiveTripIds are used to track active vehicle markers on the map - we can't use vehicleId in overlay HashMaps to keep track of vehicles because we want to show an interpolated position (based on schedule data) for trips without real-time data, and those statuses do not have vehicleIds associated with them, but do have activeTripIds
@barbeau
Copy link
Member Author

barbeau commented Oct 20, 2015

Fixed in develop via 81aa529 - real-time vehicles locations are now visible in the "Route mode" - i.e., viewing the route on the map.

Here's what the vehicle markers and popup balloons look like for real-time data (left) and schedule data (right):

image

Markers on map are color-coded according to early/ontime/late/schedule colors. Currently polling rate for trips-for-routes API in route mode is 10 seconds, and that's when the marker positions and balloon contents are updated.

Tapping on the marker balloon takes you to the TripDetailsActivity for that vehicle/trip, and scrolls to the stop that the bus is currently at:

image

For schedule-based positions, it turns out that OBA already interpolates a position based on schedule data, and this information is available in the trip status element returned by the API. status.lastKnownLocation is used for real-time position, and status.position is used for interpolated position based on schedule data.

Future work should focus on making the "route mode" more easily discoverable - primarily:

  1. Adding it to the "Bus Options" menu when tapping on any arrival
  2. Showing route favorites in a list, similar to starred stops

Future work could also add a thread to continuously update the "Data updated X min/seconds ago" text in the marker balloon every second, so it ticks up in real-time.

@barbeau barbeau closed this as completed Oct 20, 2015
@barbeau
Copy link
Member Author

barbeau commented Oct 27, 2015

I just added the source SVG files for the marker icons to the /icons/vehicle_markers folder via 99e3380.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant