Class DMSCoordinate
Object
DMSCoordinate
Class which contains the Degrees, Minutes, and Seconds for each coordinate of DMS format
For simplicity, we will not be including the cardinal direction associated with latitude
and longitude.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) int(package private) int(package private) int(package private) int(package private) int(package private) int -
Constructor Summary
ConstructorsConstructorDescriptionDefault Constructor which initializes each value to 0.DMSCoordinate(int degreesLat, int minutesLat, int secondsLat, int degreesLong, int minutesLong, int secondsLong) Overloaded constructor, for the case that each degrees, minute, and second is seperate already.DMSCoordinate(String latAndLong) Overloaded constructor in the case that the Latitude and Longitude were not split before creating DMSCoordinate Object. -
Method Summary
Modifier and TypeMethodDescriptionintGets Latitudinal Degrees value.intGets Longitudinal Degrees value.Converts latitude DMS to a readable formatConverts longitude DMS to a readable formatintGets Latitudinal Minutes value.intGets Longitudinal Minutes value.intGets Latitudinal Seconds value.intGets Longitudinal Seconds value.voidsetLatitude(String latitude) Takes in a String and assigns the latitude class variables based upon their position in the String.voidsetLongitude(String longitude) Takes in a String and assigns the longitude class variables based upon their position in the String.toString()Converts both latitude and longitude to their String formats and appends them to eachother with a space in between then returns full String.
-
Field Details
-
degreesLat
int degreesLat -
minutesLat
int minutesLat -
secondsLat
int secondsLat -
degreesLong
int degreesLong -
minutesLong
int minutesLong -
secondsLong
int secondsLong
-
-
Constructor Details
-
DMSCoordinate
public DMSCoordinate()Default Constructor which initializes each value to 0. -
DMSCoordinate
Overloaded constructor in the case that the Latitude and Longitude were not split before creating DMSCoordinate Object. The provided String must be split into a latitude and longitude String using substring(). After being split, each is sent tosetLatitude(String)orsetLongitude(String).- Parameters:
latAndLong- Both Latitude and Longitude, should be seperated by a space, "LATITUDE LONGITUDE"
-
DMSCoordinate
public DMSCoordinate(int degreesLat, int minutesLat, int secondsLat, int degreesLong, int minutesLong, int secondsLong) Overloaded constructor, for the case that each degrees, minute, and second is seperate already.
-
-
Method Details
-
getDegreesLat
public int getDegreesLat()Gets Latitudinal Degrees value.- Returns:
- Degrees in Latitude
-
getMinutesLat
public int getMinutesLat()Gets Latitudinal Minutes value.- Returns:
- Minutes in Latitude
-
getSecondsLat
public int getSecondsLat()Gets Latitudinal Seconds value.- Returns:
- Seconds in Latitude
-
getDegreesLong
public int getDegreesLong()Gets Longitudinal Degrees value.- Returns:
- Degrees in Longitude
-
getMinutesLong
public int getMinutesLong()Gets Longitudinal Minutes value.- Returns:
- Minutes in Longitude
-
getSecondsLong
public int getSecondsLong()Gets Longitudinal Seconds value.- Returns:
- Seconds in Longitude
-
getLatitude
Converts latitude DMS to a readable format- Returns:
- String should follow the format ex. 38°53'12", DEGREES°MINUTES'SECONDS"
-
getLongitude
Converts longitude DMS to a readable format- Returns:
- String should follow the format 38°53'12", DEGREES°MINUTES'SECONDS"
-
setLatitude
Takes in a String and assigns the latitude class variables based upon their position in the String.After each number is parsed, they must all be checked to be in the range of 0 to 60. If any are not in this range of 0-60, all latitude values are set to 0, and a String is printed to indicate an error has occurred. Given they are in this range, each value is set accordingly.
- Parameters:
latitude- - String in the format 38°53'12", DEGREES°MINUTES'SECONDS"
-
setLongitude
Takes in a String and assigns the longitude class variables based upon their position in the String.After each number is parsed, they must all be checked to be in the range of 0 to 60. If any are not in this range of 0-60, all longitude values are set to 0, and a String is printed to indicate an error has occurred. Given they are in this range, each value is set accordingly.
- Parameters:
longitude- - String in the format 38°53'12"
-
toString
Converts both latitude and longitude to their String formats and appends them to eachother with a space in between then returns full String. ex: "LATITUDE LONGITUDE"
-