Nextbus in XML format (aka how to check buses and routes)

Started by NewFlyer9736BCT, October 19, 2010, 04:53:26 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

NewFlyer9736BCT

OK so (finally) here's a thread that will (hopefully) answer all your questions about this.


Short and simple answers here, compared to the complex XML explanation answers.


To check the route, just type this in the URL
Quotehttp://wmata.nextbus.com/s/COM.NextBus.Servlets.XMLFeed?command=vehicleLocations&a=wmata&r=X&t=0
with X being the route number.


Let's use route 36 as an example, replace the X in the link above with 36, and you get the list of buses on that route. If nothing shows up, then that usually means that there's no buses running on that route. Here's what shows up in http://wmata.nextbus.com/s/COM.NextBus.Servlets.XMLFeed?command=vehicleLocations&a=wmata&r=36&t=0

Quote<body copyright="All data copyright WMATA Washington 2010.">
<vehicle id="6594" routeTag="36" dirTag="36_36_0" lat="38.902931" lon="-77.0511779" secsSinceReport="16" predictable="true" heading="270" speedKmHr="0.0"/>
<vehicle id="2394" routeTag="36" dirTag="36_36v1_1" lat="38.921356" lon="-76.969452" secsSinceReport="197" predictable="true" heading="218" speedKmHr="0.0"/>
<vehicle id="9357" routeTag="36" dirTag="null" lat="38.897076" lon="-76.963676" secsSinceReport="191" predictable="false" heading="90" speedKmHr="41.832"/>
<vehicle id="6596" routeTag="36" dirTag="36_36_0" lat="38.947784" lon="-77.07946" secsSinceReport="106" predictable="true" heading="218" speedKmHr="0.0"/>
<vehicle id="5205" routeTag="36" dirTag="36_36_1" lat="38.870041" lon="-76.962318" secsSinceReport="40" predictable="true" heading="105" speedKmHr="22.5"/>
<vehicle id="2331" routeTag="36" dirTag="36_36v1_1" lat="38.900318" lon="-77.039665" secsSinceReport="46" predictable="true" heading="75" speedKmHr="25.74"/>
<vehicle id="2208" routeTag="36" dirTag="36_36_0" lat="38.884754" lon="-76.995949" secsSinceReport="15" predictable="true" heading="293" speedKmHr="0.0"/>
<vehicle id="6581" routeTag="32" dirTag="null" lat="38.961864" lon="-77.08625" secsSinceReport="16" predictable="false" heading="-4" speedKmHr="1.584"/>
<vehicle id="2218" routeTag="36" dirTag="36_36_1" lat="38.913906" lon="-77.066856" secsSinceReport="82" predictable="true" heading="150" speedKmHr="17.676"/>
<vehicle id="2046" routeTag="36" dirTag="null" lat="38.880108" lon="-76.9854809" secsSinceReport="70" predictable="false" heading="-4" speedKmHr="0.0"/>
<lastTime time="1287517970015"/>
</body>

As you can see here, it is a weekday and it's just about the start of rush hour, so we have some Western (as well as some Bladensburg) buses on this route at the time of this writing. Where it says "secsSinceReport=", that pretty much means what it sounds like (seconds since last report), so it makes a difference when you see a bus that has that number around 60 seconds or maybe 438154934 seconds (if you look at the Flxibles, you'll see that a lot of them have high numbers).



Now for the buses themselves. Here's the link to that
Quotehttp://wmata.nextbus.com/s/COM.NextBus.Servlets.XMLFeed?command=vehicleLocation&a=wmata&v=XXXX&t=0

again, where XXXX = bus number

so yeah, same concept with the route number.

Now...for both, you will notice the routeTag, dirTag, lat, and lon. the routeTag is the most recent route that the bus was set to. the dirTag is the direction tag (36_36_0 could mean route 36 to Friendship Heights and 36_36_1 could mean route 36 to Naylor Road Station, or the other way around, but you get the point). notice that the Bladensburg runs have 36_36v1_1, the "v" means variation. Considering the fact that the 30s has many variation, you might see something like v2_2 or something different. There's also sometimes things like 36_36c2_2 but I don't know what the c means, this is something to ask Ken (79MetroExtraMD), he knows a lot more about this than I do.


The lat and lon simply means the latitude and longitude coordinates. This is how you can tell where the bus is. Let's use 4355 as an example:
Quote<body copyright="All data copyright WMATA Washington 2010.">
<vehicle id="4355" routeTag="10B" dirTag="null" lat="39.046783" lon="-77.108406" secsSinceReport="31089" predictable="false" heading="-4" speedKmHr="0.0"/>
</body>

plug in the lat and lon coords in Google Maps or something, and you will see that the coordinates of 4355 shows that it is at the Montgomery Division as of 31089 seconds ago (and counting). seeing from the routeTag saying "10B", you can tell that this bus just recently moved to Montgomery from Royal. It's a matter of time before we see this bus on Montgomery routes.


Here's a brief list of estimated coordinate ranges where each bus division is located:

Annex: lat = 38.872-38.873 | lon = 76.932-76.933
Bladensburg: lat = 38.920-38.923 | lon = 76.969-76.971
Carmen E Turner: lat = 38.940-38.941 | lon = 76.877-76.878
Four Mile Run: lat = 38.841-38.844 | lon = 77.053-77.054
Landover: lat = 38.935-38.937 | lon = 76.873-76.877
Montgomery: lat = 39.045-39.046 | lon = 77.107-77.109
Northern: lat = 38.946-38.948 | lon = 77.031-77.032
Royal: lat = 38.810-38.812 | lon = 77.042
Western: lat = 38.957-38.959 | lon = 77.084-77.085
West Ox: lat = 38.848-38.849 | lon = 77.377-77.378

Pentagon: lat = 38.867-38.869 | lon = 77.052-77.053
Ballston Station: lat = 38.881-38.882 | lon = 77.110-77.111
Rosslyn Station: lat = 38.896 | lon = 77.071
Silver Spring Station: lat = 38.993-38.994 | lon = 77.027-77.028
Shady Grove Station (west): lat = 39.118 | lon = 77.166-77.167
Bethesda Station: lat = 38.984 | lon = 77.096



Once again, for more info or questions, Ken (79MetroExtraMD) is the guy to ask since he showed me all of this.
Route Q2. Destination: Silver Spring Station

WMATAGMOAGH

George,

Thank you for finally posting this "how-to" after many requests and rebuffs from other posters in response to those requests.

79MetroExtraMD

I'm still going through most of the commands and such. Right now, I'm trying to get a feel for Los Angeles's feeds. I have a guide I made but Nextbus is making some changes to the feed so I'll update the instructions when they become available.
"Route 79, Limited Stop, destination: Archives"
Follow me on Twitter: @kencon06

OrionFlyer

Blue Line Shuttle to Franconia-Springfield.



Want me to make a destination sign for you? Just send me a PM and I'll have it made in no time.

79MetroExtraMD

Quote from: OrionFlyer on October 19, 2010, 10:52:37 PM
Is there any way you can track blocks?
You can only get the block information from the predicitions for the stops.
"Route 79, Limited Stop, destination: Archives"
Follow me on Twitter: @kencon06

RideOn5905


Tristan

I wonder if we could roll up a quick "app" where you only have to punch in the route number.  If I get 10 minutes, I'll work on something.

79MetroExtraMD

Quote from: Tristan on October 27, 2010, 02:23:02 PM
I wonder if we could roll up a quick "app" where you only have to punch in the route number.  If I get 10 minutes, I'll work on something.
There's much more to it than doing it by route number. It'd be best to do it by stop number.
"Route 79, Limited Stop, destination: Archives"
Follow me on Twitter: @kencon06