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:
  1. 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.
  2. 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.
  3. 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.
  4. 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.

This sounds really nice, Kerm! I bet hundreds of other people could use this app. What will you be writing it in?

Also, one thing: will you be making this for apple as well? Or only for Android?


And why only ten second intervals? Why not 5-second, or maybe even 1-second?
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).
Even with the simplest regression or machine learning technique, estimates could easily improve in accuracy over those of Amtrak.
Yes, machine learning should be used everywhere. I'm biased though.

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)
How is this coming along? Have you started writing the app yet, Kerm? And if so, could you post some code?
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.

Heh, no one told me that Amtrak WiFi had stymied the upload of that previous screenshot! I find that moderately amusing. In other news, here's a little progress on another portion of this project:

*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.

If you wanted to add tracking for municipal trains, I'd be happy to see my local MBTA make it in. It seems they have various APIs: https://www.mbta.com/developers
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.


This is really cool. It reminds me of this site.
Looks really cool! Since I'm on a computer, scrolling is a bit hard, so it'd be cool (better) if we could scroll like on a normal website. (two fingers up/down and right/left)
Would it be possible to get better contrast on the train numbers in Amtracker Web?
Runer112 wrote:
If you wanted to add tracking for municipal trains, I'd be happy to see my local MBTA make it in. It seems they have various APIs: https://www.mbta.com/developers
I'd like to do so. To add to that, the NYC MTA has APIs for commuter rail (and probably subways too).
jonbush wrote:
This is really cool. It reminds me of this site.
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.
This sounds really cool, I hope it turns out! Very Happy
Thanks, Legoman! Updates: routes are now shown, and they're properly loaded from CartoDB whenever the daemon is restarted (then cached on the server), so they should always be up-to-date:

I think it's great the progress you've made these last few days. Any ETA on the legend?

KermMartian wrote:
temporary or permanent home


"There's nothing more permanent than a temporary fix." -Mark Twain. -Michael Scott.
No ETA on the legend, but I'll continue to try to add it soon.

A few notes to self (and question for you all, I suppose): PhoneGap looks like one reasonable option to make an app work easily on both iOS and Android devices; any alternatives that you guys have used and liked? Plugins that I found that should be useful:
https://github.com/mapsplugin/cordova-plugin-googlemaps
https://github.com/hoerresb/WifiWizard
  
Register to Join the Conversation
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.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement