main
Class CityFinder
java.lang.Object
main.CityFinder
public class CityFinder
- extends java.lang.Object
The CityFinder
class stores all of the cities that are
available and finds the closest city to a given latitude/longitude pair.
Constructor Summary |
CityFinder(java.lang.String fileName)
Constructs a new CityFinder with the cities specified in
the file referenced by filename that is passed in. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
cities
private java.util.ArrayList<City> cities
DIMENSION_2
private static final int DIMENSION_2
- See Also:
- Constant Field Values
DIMENSION_3
private static final int DIMENSION_3
- See Also:
- Constant Field Values
CityFinder
public CityFinder(java.lang.String fileName)
throws java.io.IOException,
java.io.FileNotFoundException,
java.text.ParseException
- Constructs a new
CityFinder
with the cities specified in
the file referenced by filename that is passed in.
- Parameters:
fileName
- a String
- Throws:
java.io.IOException
- if there's an error opening or reading the file
java.io.FileNotFoundException
- if the file is not found
java.text.ParseException
- if a parse error occurs
parseInput
private void parseInput(java.io.BufferedReader fin)
throws java.io.IOException,
java.io.FileNotFoundException,
java.text.ParseException
- Throws:
java.io.IOException
java.io.FileNotFoundException
java.text.ParseException
returnClosestCity3d
public City returnClosestCity3d(Position position)
- Given a position, returns the closest city to it in space
- Parameters:
position
- a Position
- Returns:
- the closest city
returnClosestCity2d
public City returnClosestCity2d(Position position)
- Given a position, returns the closest city to it in flattened space
- Parameters:
position
- a Position
- Returns:
- the closest city
returnClosestCity
private City returnClosestCity(Position position,
int dimension)