The Afternoon Special about Trusting but Verifying – BART Edition

system-mapI got my database seeded with my beautiful data from several APIs and I worked out all the kinks…. as I was working on figuring out what data structure I want to use for my user’s stop_list (a list of stops from my user to their destination). Thats when I realize that my API for BART routes gives me all the stops for a route versus giving me different routes with their own stops (i.e. Daly City has all the stops from Richmond, Fremont, Pittsburg, etc., instead of Fremont – Daly City and only having the stops for that route).

dalycity

I was getting these route information from my 511 API, which I wanted to since this is the API I am going to use to find the real time data, so this information is needed, but isn’t enough information for me to display to users. So I looked at the BART API that I am using to get the lat and lon of the stops. So I found that it provides route names and their stops in order! Nice!

I spent some time figuring out how the route name was modeled – which is”FROM – TO”.  Once I figured that out then I had to match which BART routes match to 511 routes so I can connect the organized and wonderfully name routes to the act real time data api.

organized

Now that I have way to connect the two, I started working on getting the two calls connected – which entailed reformatting my 511 BART data structure to change from the ‘route name’ being the key, to having the ‘route_code’ as the key, so I can iterate over the NEW Bart dictionary and index into the 511 Bart dictionary using ‘route_code’ and connect the data from the 511 Bart dictionary to the NEW Bart dictionary.

Since the NEW Bart dictionary has more information (it contains the old and new – which I wasn’t 100% sure if I wanted to remove any of the old, just in case), I needed to change my MUNI and Caltrain attribute names of the list of stops to be consistent. So I changed the attribute ‘stops’ to ‘stop_list’ so its reflects that this is an ordered list of stops that this route uses.

route

Learn from my mistake:

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s