Going Further on Programming Assignment 7
These questions/problems/tasks allow you to go further on
Programming Assignment 7. They are neither
required nor for extra credit. They will, however, help you gain a
deeper understanding of the material.
1 Sorting Multiple Results:
In the current application, when there are multiple segments that contain
the given address, they are presented to the user sorted by segment ID.
In many situations, it makes more sense to sort the results by distance
from a given longitude/latitude.
-
Learn how to calculate the "great circle distance" between two
points.
-
Implement an algorithm that can be used to calculate the
"great circle distance". Give careful thought to where this
code should be (i.e., in what class).
-
Modify your design so that the application can either sort by
segment ID or by distance from a given point. (Hint: You
should think about using classes that implement the
Comparator
interface.)
-
Modify your application so that the user can supply a longitude/latitude
pair (at run-time) that is used to sort the geocoded locations
when there are multiple segments for a single address. When such
a longitude/latitude pair is not provided, the application should sort
by segment ID.
2 Flexible Street Names:
In the current application, the user must enter the street name exactly.
Unfortunately, people often don't know the street "type" (e.g., whether
it is Elm St or Elm Dr). Modify your application so that, if it does not
find the street name as given, it ignores the street "type" (e.g., if
an appropriate segment is not found for 512 Elm St it then looks for
512 Elm Dr, 512 Elm Ave, etc...).