Class GeographicCoordinates

java.lang.Object
  extended by GeographicCoordinates

public class GeographicCoordinates
extends java.lang.Object

The GeographicCoordinates class can be used to store and manipulate latitude and longitude data for geographical operations. Latitude and logitude are denoted by degrees and minutes to represent the North/South and East/West coordinates respectively of a geographic location on the surface of the earth. This class is to be used for HW4. For a complete description, of this assignment go to:

http://www.cs.stonybrook.edu/~cse114/hw/HW4.html

This class only performs very basic functions, allowing the altering and retrieving of integer variables that represent the degrees and minutes of a distance measurement for the surface of the earth, as well as a character variable that represents the direction of that measurement. In addition, a simple toString method is provided to get a String representation of this object in a neat form. Finally, some useful constants are provided for possible Latitudinal/Longitudinal calculations.

Author:
  Richard T. McKenna
  Instructor
  CSE 114 - Computer Science I - Fall 2009
  Stony Brook University


Field Summary
static int DEGREES_MIN
          The int constant representing the minimum possible value for degrees as used in latitude and longitude representations.
static int EARTH_RADIUS
          The int constant representing the radius of the earth in miles.
static int LAT_DEGREES_MAX
          The int constant representing the maximum possible value for degrees as used in latitude representations.
static int LONG_DEGREES_MAX
          The int constant representing the maximum possible value for degrees as used in longitude representations.
static int MINUTES_MAX
          The int constant representing the maximum possible value for minutes as used in latitude and longitude representations.
static int MINUTES_MIN
          The int constant representing the minimum possible value for minutes as used in latitude and longitude representations.
static double PI
          The double constant representing the ratio of the circumference to the diameter of a circle.
static double RADIAN_FACTOR
          The double constant used to convert numbers from degrees to radians.
 
Constructor Summary
GeographicCoordinates()
          Default Constructor for GeographicCoordinates, when called it initializes the degrees and minutes to 0, and the direction to '?'.

Preconditions: The GeographicCoordinates() constructor is called by a program and the result is assigned either to a variable of type GeographicCoordinates or is passed to another method as a parameter of type GeographicCoordinates.

Postconditions: A DistanceMeasurment object is constructed and memory is reserved for use for that object.
GeographicCoordinates(int initDegrees, int initMinutes, char initDirection)
          Second Constructor for GeographicCoordinates, when called it initializes the degrees, minutes, and direction instance variables to the values provided in the parameter list.

Preconditions: This constructor is called by a program and the result is assigned either to a variable of type GeographicCoordinates or is passed to another method as a parameter of type GeographicCoordinates.

Postconditions: A GeographicCoordinates object is constructed and memory is reserved for use for that object.
 
Method Summary
 int getDegrees()
          Accessor method that returns the degrees.

Preconditions: this GeographicCoordinates object must be constructed with instance variables properly initialized.

Postconditions: The degrees instance variable is returned.
 char getDirection()
          Accessor method that returns the direction.

Preconditions: this GeographicCoordinates object must be constructed with instance variables properly initialized.

Postconditions: The direction instance variable is returned.
 int getMinutes()
          Accessor method that returns the minutes.

Preconditions: this GeographicCoordinates object must be constructed with instance variables properly initialized.

Postconditions: The minutes instance variable is returned.
 void setDegrees(int changeDegrees)
          Mutator method that allows the programmer to change the degrees.

Preconditions: this GeographicCoordinates object must be constructed.

Postconditions: The degrees instance variable is assigned the value of changeDegrees.
 void setDirection(char changeDirection)
          Mutator method that allows the programmer to change the direction.

Preconditions: this GeographicCoordinates object must be constructed.

Postconditions: The direction instance variable is assigned the value of changeDirection.
 void setMinutes(int changeMinutes)
          Mutator method that allows the programmer to change the minutes.

Preconditions: this GeographicCoordinates object must be constructed.

Postconditions: The minutes instance variable is assigned the value of changeMinutes.
 java.lang.String toString()
          Method that returns a string that "textually represents" this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

EARTH_RADIUS

public static final int EARTH_RADIUS
The int constant representing the radius of the earth in miles.

See Also:
Constant Field Values

PI

public static final double PI
The double constant representing the ratio of the circumference to the diameter of a circle.

See Also:
Constant Field Values

RADIAN_FACTOR

public static final double RADIAN_FACTOR
The double constant used to convert numbers from degrees to radians.

See Also:
Constant Field Values

MINUTES_MIN

public static final int MINUTES_MIN
The int constant representing the minimum possible value for minutes as used in latitude and longitude representations.

See Also:
Constant Field Values

MINUTES_MAX

public static final int MINUTES_MAX
The int constant representing the maximum possible value for minutes as used in latitude and longitude representations.

See Also:
Constant Field Values

DEGREES_MIN

public static final int DEGREES_MIN
The int constant representing the minimum possible value for degrees as used in latitude and longitude representations. For latitude, 0 degrees represents the Equator. For longitude, 0 degrees represents the Prime Meridian, which goes through Greenwich, England.

See Also:
Constant Field Values

LAT_DEGREES_MAX

public static final int LAT_DEGREES_MAX
The int constant representing the maximum possible value for degrees as used in latitude representations. For latitude, the maximum degrees represents the North and South Pole, depending on the direction.

See Also:
Constant Field Values

LONG_DEGREES_MAX

public static final int LONG_DEGREES_MAX
The int constant representing the maximum possible value for degrees as used in longitude representations. For longitude, the maximum degrees represents the International Dateline in the Pacific ocean.

See Also:
Constant Field Values
Constructor Detail

GeographicCoordinates

public GeographicCoordinates()
Default Constructor for GeographicCoordinates, when called it initializes the degrees and minutes to 0, and the direction to '?'.

Preconditions: The GeographicCoordinates() constructor is called by a program and the result is assigned either to a variable of type GeographicCoordinates or is passed to another method as a parameter of type GeographicCoordinates.

Postconditions: A DistanceMeasurment object is constructed and memory is reserved for use for that object. The constructed object's values are initilized such that the degrees and minutes instance variables are set to 0, and the direction instance variable is set to '?'.


GeographicCoordinates

public GeographicCoordinates(int initDegrees,
                             int initMinutes,
                             char initDirection)
Second Constructor for GeographicCoordinates, when called it initializes the degrees, minutes, and direction instance variables to the values provided in the parameter list.

Preconditions: This constructor is called by a program and the result is assigned either to a variable of type GeographicCoordinates or is passed to another method as a parameter of type GeographicCoordinates.

Postconditions: A GeographicCoordinates object is constructed and memory is reserved for use for that object. The constructed object's degrees variable is initialized to the initDegrees value passed to the method, the minutes variable is initialized to the initMinutes value passed to the method, and the direction variable is initialized to the initDirection value passed to the method.

Parameters:
initDegrees - Used to initialize the degrees of the specified GeographicCoordinates
initMinutes - Used to initialize the minutes of the specified GeographicCoordinates
initDirection - Used to initialize the direction of the specified GeographicCoordinates
Method Detail

getDegrees

public int getDegrees()
Accessor method that returns the degrees.

Preconditions: this GeographicCoordinates object must be constructed with instance variables properly initialized.

Postconditions: The degrees instance variable is returned.

Returns:
the degrees for the specified GeographicCoordinates

getMinutes

public int getMinutes()
Accessor method that returns the minutes.

Preconditions: this GeographicCoordinates object must be constructed with instance variables properly initialized.

Postconditions: The minutes instance variable is returned.

Returns:
the minutes for the specified GeographicCoordinates

getDirection

public char getDirection()
Accessor method that returns the direction.

Preconditions: this GeographicCoordinates object must be constructed with instance variables properly initialized.

Postconditions: The direction instance variable is returned.

Returns:
the direction for the specified GeographicCoordinates

setDegrees

public void setDegrees(int changeDegrees)
Mutator method that allows the programmer to change the degrees.

Preconditions: this GeographicCoordinates object must be constructed.

Postconditions: The degrees instance variable is assigned the value of changeDegrees.

Parameters:
changeDegrees - the value to which the degrees value will be changed for the specified GeographicCoordinates

setMinutes

public void setMinutes(int changeMinutes)
Mutator method that allows the programmer to change the minutes.

Preconditions: this GeographicCoordinates object must be constructed.

Postconditions: The minutes instance variable is assigned the value of changeMinutes.

Parameters:
changeMinutes - the value to which the minutes value will be changed for the specified GeographicCoordinates object.

setDirection

public void setDirection(char changeDirection)
Mutator method that allows the programmer to change the direction.

Preconditions: this GeographicCoordinates object must be constructed.

Postconditions: The direction instance variable is assigned the value of changeDirection.

Parameters:
changeDirection - the value to which the direction value will be changed for the specified GeographicCoordinates object.

toString

public java.lang.String toString()
Method that returns a string that "textually represents" this object.
Preconditions: this GeographicCoordinates object must be constructed.

Postconditions: A String is returned that represents the values of the degrees, minutes, and direction separated by a spaces, where the degrees is followed by a degree symbol, and the minutes is followed by a tick mark symbol. This is how geographic coordinates are normally represented textually.

Overrides:
toString in class java.lang.Object
Returns:
a textual representation of the specified GeographicCoordinates