Last edited by KermMartian on 19 Jan 2018 07:00:46 pm; edited 2 times in total

Many of you know that I like and ride Amtrak a great deal. I find it to be by far the most comfortable and pleasant way to travel, from the legroom to the scenery to the ease of just walking to my local Amtrak station and getting on the train. Unfortunately, one of the most frustrating parts of traveling on Amtrak is that they largely run on other people's tracks, and even when they're running on their own tracks in the Northeast Corridor, they sharing those tracks with other railroads. The upshot is that Amtrak trains are frequently delayed, but Amtrak routinely underestimates those delays and/or doesn't announce them until it's almost the train's scheduled departure time, even if those delays could have been anticipated simply from the location of the train. Amtrak provides a very rough set of data that clever enthusiasts have scraped into an online map via a scraping API, but train locations are only update every 7-10 minutes on this map, and there's currently no easy way to get an estimate of whether your train will be late without consulting that map.

A few months ago, I started formulating an idea to create an app that will make it easy for Amtrak passengers to see when their trains will actually arrive. I'm envisioning engineering this in a couple of steps:

First, take advantage of the fact that when you're riding Amtrak and you're connected to your train's WiFi, there's a JSON API available that will give you your train's location and estimated station arrivals at 10 second intervals. With this data, I can create a simple app that shows you where your train is and when you're likely to get to your destination.

Using the existing (coarse) train location APIs, use historical data and simple machine learning to estimate when all trains will actually get to their destination.

Have each instance of the app run by a current passenger send finer-grained location data to a server that will allow it to make more precise estimates of train arrival.

Scrape relevant keywords from news and social media to try to correlate news events with train delays to notice and predict otherwise exceptional and unpredictable delays.

So far, I've been gradually working on (1). I have built an Android app that can track your train's location using the on-board API, or simply track your phone's location via GPS when you're not connected to Amtrak WiFi. I'll gradually work on making this spiffier, including letting you set your destination and reminding you to connect to Amtrak WiFi before unleashing this on the general public. Do you take Amtrak? Would something like this help you? Let me know how I can develop this to be the most useful possible tool to make train travel even better.

Thanks, Caleb! I'm most familiar with app programming for Android, so that's where I'll start, but I'd be curious what the easiest way to port it to iOS would be. The train's API provides information at 10-second intervals simply because there's no good reason for it to give information any faster (and that's plenty precise for a passenger to track their train traveling at ~60-80mph anyway).

I think this app will be very useful. While recently planning an Amtrak trip that involves connecting to another train in Chicago, I was able to use historical data to calculate the likelihood that I would miss my connection (16%). However, my analysis does not account for more subtle factors and patterns that could be predicted with machine learning.

I can imagine that an app like this would help prevent situations where a station gets overloaded with people waiting for a train that is guaranteed to be delayed. This kind of analysis could also help railroads identify and eliminate behaviors that lead to cascading delays (I would not be surprised if it is already employed).

This looks awesome, and in my opinion, the easiest way to port it to iOS is to learn Swift and whatever else they want you to use. A mac is usually a good option for that, in regards to iOS development (xCode)

Caleb_J: Oh yes, those screenshots in the first post were from the actual app; they weren't mockups.

For various life reasons, I haven't had the motivation or time (or Amtrak-riding opportunities) to work on the Amtracker app lately (by the way, I tentatively changed the name from "Amtrakker" to "Amtracker" because concerns about trademarks). This past weekend, I took a long set of overnight trains to and from Milwaukee, Wisconsin, and I added three features:

Extracts the train name and number from available information, and displays that in the app, when possible.

Has a button you can click to zoom into your train's position. I need to make this button toggle between locking the camera position to focusing on the train, and allowing it to freely move.

Grabs the route polygon as expose by the train's API, and uses that in the displayed map. Eventually I'd like to collect the relevant polygons and have them embedded in the app, so it can also show all of Amtrak's routes for context.

I wish I had more time to work on this project! I recently completed a separate component of this general idea that is not an Android app, and I'm pleased with how it's coming along, but that's a discussion for another day. Today, I fixed one issue and added one feature. The issue I fixed is that high-frequency position updates were not being shown because of a change in the source JSON. The feature I added is the train's current velocity shown as a snippet on the train's position marker; I learned how to force the Google Maps API to re-draw snippets so that it updates live every ~30 seconds or so if you have the marker shown.

*bumpity bump* Those interested are welcome to play with http://at.cemetech.net, my temporary or permanent home for the web-based portion of Amtracker. This is a live map of all of the Amtrak services en route right now, and I'm actively poking at features of it. Up soon include clearer markers, route polylines, and display of current speed and lateness.

Last edited by jonbush on 19 Jan 2018 04:54:37 pm; edited 1 time in total

KermMartian wrote:

*bumpity bump* Those interested are welcome to play with http://at.cemetech.net, my temporary or permanent home for the web-based portion of Amtracker. This is a live map of all of the Amtrak services en route right now, and I'm actively poking at features of it. Up soon include clearer markers, route polylines, and display of current speed and lateness.

That's something I've used before. I want to go beyond that; I now show headings, which they don't, but I also want to start getting the machine learning to extract meaning from historical data going soon. For which I need to start tracking historical data.

CVSoft wrote:

Would it be possible to get better contrast on the train numbers in Amtracker Web?

Ask and you shall receive.

Some new updates. In no particular order, using Spiderfier to fan out overlapping services to make them easier to click on, showing train information and velocity, then new label styling thanks to MarkerWithLabel, with a more complete info window showing train information that includes lateness information.

Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.