This is a basically gps application where i am getting the latitude information from the meta data of a picture in this format 28"41'44.13597 .
My need is to convert the same information into decimal and the out will show data in decimal format like 28.705450.
Please help through code or any references
Thanks in advance
There are 60 minutes in one degree and 3600 seconds in one degree. To convert minutes and seconds to decimal degrees, divide minutes by 60, divide seconds by 3600, and then add the results to obtain the decimal equivalent.
/** answer=hour+minutes/60+seconds/3600 */
public double convertHourToDecimal(String degree) {
if(!degree.matches("(-)?[0-6][0-9]\"[0-6][0-9]\'[0-6][0-9](.[0-9]{1,5})?")
throw new IllegalArgumentException();
String[] strArray=degree.split("[\"']");
return Double.parseDouble(strArray[0])+Double.parseDouble(strArray[1])/60+Double.parseDouble(strArray[2])/3600;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With