These are projects posted by the students of Dr. Gove Allen at Brigham Young University. These students have taken one semester-long course on VBA and generally have had no prior programming experience

Thursday, December 10, 2015

Map a Run!

Darian Boehme
12/10/15
Final Project Executive Summary
Description

                For my project, I decided to solve a personal problem that I have. I like to run every morning before I start my day, and often I travel around to different places where I don’t know a route to run. What I end up doing is just going running and estimating my distance and sometimes getting lost. So, my code is meant to solve this problem by allowing me to enter in an address anywhere in the world as well as a desired distance to run and a mapped route will be developed. The routes that are developed vary, but they all start and end in the same place.

Implementation

                In order to accomplish this task, I decided to break the solution up into several parts. The first part is a banner ribbon called Run Finder and a button the user clicks to run the program. This opens a userform that collects the address and distance desired. The next part of the code converts the address into latitude and longitude so that it can be manipulated easily. Following this, the code performs an algorithm to convert the desired distance from miles into latitude and longitude lengths. Then the code communicates with Google maps to start mapping a route by using the latitude and longitude coordinates. The route is randomized every time the code runs, so the adjustments to the latitude and longitude numbers are added or subtracted to produce a destination that is input in Google maps.
                While the code is producing a route, the total distance is checked every time a new destination is added. Ideally, if all roads are in straight lines, then the route will make a perfect square with each side being a quarter of the total distance given by the user. Unfortunately, most roads are not straight lines and the results are higher or lower distances than anticipated. So, if the distance is getting too long on any particular leg, then the code will set the destination back to the start. This allows for more precise measurement of the routes. After a potential route has been mapped, then the code will compare the actual route distance with the desired distance given by the user and if the distance is not within a close range, the route will be discarded. The code then makes an adjustment to the calculation of the latitude and longitude destination calculations depending on if the actual distance was shorter or longer than the desired distance. Another route will then be mapped using these adjustment factors to shorten or lengthen the route. This loop will be run until a route is found that is not more than .6 miles longer or .1 mile shorter than the desired route.
                Once a suitable route is found, the URL is saved and information is written to a table on the spreadsheet. The table saves the date, the starting address of the route, the desired distance, the actual distance, and the URL link to the route on Google maps. This table is a history of all routes mapped using this tool.

Difficulties encountered

                I encountered a few difficulties in this project. First was that I had no idea how to interface with the Google maps site and there were a few hiccups trying to figure out how to write my code. I received some assistance with this part which I will discuss later. The most difficult part of the project, however, was figuring out how to write the algorithm that was sufficiently precise enough to produce a route that was within the acceptable range without taking 10 minutes to loop through the program. Often, the routes would be too long or too short. This fine-tuning of the algorithm allowed me to find a route within 4-5 loops through the program usually. I found that the shorter the run, the easier to get precision, but I often go on runs that are 12-18 miles and I needed a tool that would allow me to get precision. I also had trouble with presenting the data in a way that would be useful to the user. I couldn’t get the map to embed into Excel, so I decided to create a table that would record the historical data including the URL so that the user could get access to the map.

Assistance


                I worked on the entire project by myself with no help from other people or other people’s code with the exception of one part. I was having trouble understanding the Google maps html and how to access it and I went in to talk to Professor Allen. He helped me design this part of my code and allowed me to understand how to continue.


URL's

http://files.gove.net/shares/files/15f/djboehme/Final_Project.xlsm
http://files.gove.net/shares/files/15f/djboehme/Executive_Summary.pdf




1 comment:

  1. If you want your ex-girlfriend or ex-boyfriend to come crawling back to you on their knees (even if they're dating somebody else now) you got to watch this video
    right away...

    (VIDEO) Why your ex will NEVER get back...

    ReplyDelete

Blog Archive