CPSC220 Assignment 8 Extra Credit
Turn-by-turn Directions
Due on Friday, December 17th

Details

Extend your GUI Open Street Map program from assignment 8.75 to include turn-by-turn directions. The program should display a text area that when the user selects the start and end points displays a textual description of how to get from the start to the end point. The description should include a list of distances to travel before a direction to turn on a road. For example:

Proceed 54 ft. then turn left on Main St.
Procced 2 mi. then turn left on Market St.
...

In order to calculate the distance between two points use the equation:

d = acos(sin(lat1) * sin(lat2) + cos(lat1) * cos(lat2) * cos(lon2 − lon1)) * R
Where lat1 and lon1 is the first point, lat2 and lon2 is the second point, and R is the average radius of the earth (6371 km or 3959 mi). If the distance is less than a kilometer or less than a mile, convert the distance to meters or feet (1 km = 1000 m, 1 mi = 5280 ft). In order to determine if a turn is a left or a right turn you can use the following equation:

s = (lon2 - lon1) * (lat3 - lat1) - (lat2 - lat1) * (lon3 - lon1)

Where the line from point 1 to point 2 is the street being turned from, and point 2 to point 3 is the street being turned onto. The value s is between -1 and 1. If s is positive, then it is a left turn. If s is negative, then it is a right turn. Finally, in order to display the road names the way parser must check if a way represents a road (if it has a tag with a key of "highway") and if so store the name of the road (if it has a tag with a key of "name").

As usual, use good programming techniques. You should use good variable names, whitespace, comments, and follow the Java coding conventions. Make your code easy to read and understand by keeping lines of code and methods simple and short.

Submission: Tar your code and copy it to the directory ~bouchard/CPSC220/assign8extra on cs.roanoke.edu on Friday, December 17th.