mylket
mylket

Reputation: 147

Convert full location degree to java degree

I'm able to get some location degrees in a format like these:

N 7°7'23,2716"

E 6°19'16,72428"

But I'm not sure how I should convert it to the double value that represents a degree in java, apart from the fact that I should take the degree, the minutes and the seconds from my string and do something with them.

Upvotes: 0

Views: 55

Answers (1)

secret squirrel
secret squirrel

Reputation: 807

As @Berto99 said, convert everything into seconds. But you also need to add the degrees. So you have:

Decimal Degrees = degrees + (minutes/60) + (seconds/3600)

So in your examples, N 7°7'23,2716", E 6°19'16,72428"

N 7°7'23,2716" = 7 degrees + (7/60) + (23.2716/3600) = +7.123131

E 6°19'16,72428" = 6 degrees + (19/60) + (16.72428/3600) = +6.3213123

Beware of the minus sign If the N changes to an S, or the E changes to a W, then stick a minus sign in front of the decimal number.

Upvotes: 2

Related Questions