Day 9 – Project Transit Notifier

To do:Work on my website so I can use the stops from Nextbus to link my user to the transit stop and then find the vehicle that way. I'm going to be taking on a whole different approach.What I did: Today was all about truly debugging my code. I got it to work about 80% of the time, but my sorting function was off. It wasn't always selecting a vehicle, but it was processing for the latitude and longitude though. Some times it worked, other times it didn't. I knew there was a large underlining issue. I peppered my code with print statement to see what is happening and that when I figured out that it wasn't actually grabbing what I thought it should. I couldn't figure out why its able to get any information from a variable with no value.

>> This one won! 1465      <-------- this one worked! But if it wasn't working this line wasn't showing up

Thats when I asked for support from Meggie and she noticed that I was using the same variable name before and thats how it had a valid vehicle id (this wasn't an issue for my function, but for my scratch document).  I was able to have it work through the sorting function, but there are times when the vehicles are not always 100% available from firebase so it cannot compare a vehicle if its not in both list. So I dealt with it by defaulting the vehicle to the first one if it cannot validate the sort. This is not the ideal situation, but it was the best logical solution that I can think of at the moment. I want to have my program be correct all the time, but since my data from Firebase through Muni can be a little off, I'll have to settle with this for now.Since I was fixing my sorting function I cleaned it up so that its a nested for loop that compares each vehicle of a list with each vehicle of the other list. I wasn't sure how to break out of this nested for loop without having a conditional while loop flag. So I looked onto the internets and I found the try and expect and I have a "class BreakIt(Exception): pass" condition, so when it reaches where the vehicle has found itself in the other list and the distance is smaller (getting closer to my user) to break out of the whole thing. If it doesn't match and the distance is not getting smaller, I'm setting it to the closest vehicle for now (since it works about 80% of the time). For my next sprint, I am thinking that if that happens, I should grab 3 vehicles and keep track of the three in the queue and then I can check all three of them and which ever get to my destination first would be the correct one.Now that my scratch file is up and running and was working on my pretty functions (the same information from my scratch file, but much prettier). My main function (that processes the other functions) was returning an empty list :( So I tested each function indvidually and my

def validates_bound_direction_of_vehicles_in_line(dic_vehicles_for_line, bound_dir):"""From a dictionary of vehicles in a line, it'll filter for the ones going the correct bound direction,O = Outbound, I = Inbound"""available_vehicle_with_direction = []bound = bound_dirfor vehicle in dic_vehicles_for_line:vehicle_id = vehicletry:print "hi"vehicle_dirTag = firebase.get("sf-muni/vehicles/" + vehicle_id, "dirTag")if vehicle_dirTag:if vehicle_dirTag.find(bound) != -1:available_vehicle_with_direction.append(vehicle)except AttributeError:passreturn available_vehicle_with_direction****the spacing isn't showing up because wordpress doesn't support tags and additional spacing

It was returning an empty list. I tried it without the try/except but it didn't work since sometimes my vehicles disappear for a moment. I copied pasted the section of my scratch file that were the base for my function and I couldn't figure out what was different. Until my mentor Tim came and he asked, what is the difference between firebase and transit_firebase. I forgot to include the transit part, so it was pulling from a blank firebase, hehe:

vehicle_dirTag = transit_firebase.get("sf-muni/vehicles/" + vehicle_id, "dirTag")

To do Tomorrow:  Work on Jquery calls so I can use the transit stops for my user, and work on pulling the information from a web~form.


My Thoughts/Process: Today I got frustrated :( I worked the majority of the day without having much success. I tried working on a problem until I felt tried and then moved to another problem until I gelt tired and then started another hard portion. I am defiantly not taking my own advise of making sure I'm portioning my work, but I'm feeling behind. I'm starting to feel as though I my progress has stop as of late last week. I didn't give up though. I just tried another thing. I do know that I was going to met with Tom this evening, so I struggled. I read this morning an article about how deep learning happens when students struggle with concepts at first before giving them the answer: "The best way to learn math is to learn how to fail productively". Tom helped me so much and he was super supportive. I am very grateful to have him as my mentor.

~~~~~No photos today because wordpress isn't feeling it today ~~~~~~~~~

Previous
Previous

Day 10 – Project Transit Notifier

Next
Next

Day 8 – Project Transit Notifier