Inspiration

One of the members on our team makes a long drive nearly twice a day. Google maps provides the information needed to find the fastest route, but taking such a long drive multiple times a day is not only harsh on your wallet, but also the environment. Our team agreed that there should be a way to understand which route would be the best to take, regardless of if it took longer, as long as it used less gasoline.

What it does

EcoRoute gives the user data about fuel consumption on any given driving route. The user is allowed to choose from a selection of varying vehicles with drastically different fuel efficiencies. After selecting a starting point and an ending point, the map draws your route, and gives a pop up message as to how much fuel you will use on that route by comparing hundreds of points of elevation data. This gives the ability to compare alternate routes, and their efficiencies in order to find a route that avoids unnecessary fuel consumption. In our examples, we found that the earlier mentioned team member was able to find a route that cut over half a gallon of gas per trip! That saves hundreds of gallons a year, based off of a single use of the program!

How we built it

We began by creating a web page, and used the Google Maps API to populate the page with a map. Our next step was to understand how to input starting and ending points, and have the Google Directions API set a route for us. Next, we dove deep into the directions we received, 6 levels to be exact, and found latitude and longitude data for every little turn on the route. We used that data to ping the Google Elevation API, and receive hundreds of points of elevation data. Still further, we found the distance between each of the points, and the differences in elevation between those points. We used this information to create an array of slopes, one for each stretch of road. After getting the slopes, we sent each of them into a function based in trigonometry that uses the slope data to return a number we should multiply our fuel consumption by. After adding up all of those values, and doing a large amount of conversion, we created a marker at the beginning of the route displaying total estimated fuel consumption. It was difficult, but we got it!

Challenges we ran into

No one on our team was very familiar with JavaScript, and this entire program was built using that language. We had very little experience with JSON files, and those were also integral to our development. So our first challenge was attempting to slightly understand two file formats we were inexperienced in. After some youtube videos, and a few helpful blogs, we began to figure things out. At one point, we could not figure out why our arrays were coming up empty! We spent well over an hour playing with our debugger, bouncing ideas off one another, and angrily smashing our hands onto the keyboard. Luckily, a kind Google employee came to our rescue and told us of a concept called asynchronization! It turns out, our arrays were being filled, just in a very weird order. So we moved code around and got over the fact that our code didn't run top-to-bottom like we are used to. The final challenge we faced was a severe lack of sleep. But we were able to get over that, and plug away at a few little loose ends after some well deserved rest.

Accomplishments that we're proud of

First and foremost, we all made some great friends! We were not all familiar with one another before this hackathon, but now we know eachother very well. We are also proud that we were not just able to meet our initial goal of getting fuel consumption data, but we were finished so early that we could use the Shine API and allow users to choose from a selection of vehicles! We had a wonderful time, and we are extremely proud of the results of our hard work. Every single member of our team made significant contributions to the end product. In no way was 1 person pulling the weight, and no one was 'free loading.' We all worked extremely hard, slept very little, kept our cool, and made a product that can have a very positive impact on the well being of our planet.

What we learned

JavaScript. Really though, we came into this with no knowledge of the language, and now we have a fully fleshed out program written in something we had never used literally less than 24 hours ago. We also learned to always pay attention to API calls and make sure that they are synchronous with your other code! If not, make sure to place the proper code inside that function. We were also impressed with just how much work three strangers can put into a project in only a few hours! We started off with no knowledge of ANY of the software we were using, and we divvied up work appropriately and managed our time well. Now we have something we are all incredibly proud of, and friends to go along with it.

What's next for ecoRoute

Our data could still be more accurate. We want to add stop sign locations, as well as stop lights. These stops add a significant amount of fuel consumption, and would be very useful for increasing the accuracy of our fuel emission estimations. Another one of our next steps would be to add speed limit data, because the speed of a driver affects fuel emission significantly. There are plenty of other factors we could add, including a better algorithm modeling the correlation between elevation and fuel emissions. Our end goal is to use these factors to find the most fuel efficient path from one place to another. Hopefully people will begin using the most economic route for travel rather than simply the fastest. Our planet cannot handle the emissions we are currently producing, and in order to give people in the future an equal chance that we have, we must find ways to preserve this beautiful planet we live on. If everyone saved just half a gallon of gas per day, we would be cutting down fuel consumption by billions, if not trillions of gallons per year.

Share this project:
×

Updates