I have a device reporting its position to me in a format they describe as 'ddmm.mmmm'
it looks like this:
Latitude: 5108.5837 N Longitude: 00052.6334 E
Anyone have an idea how I can convert this to a normal decimal number that I can use with RGeo?
Ok, I've worked it out, for anyone that may come across the same format, its simpler than I thought it was..
Latitude: 5108.5812 N
Longitude: 00052.6289 E
degrees is anything before the last 2 digits before the decimal point (e.g. 51 or 000)
minutes is the rest, seconds are expressed as fractional minutes so you just have to do:
51.0 + (8.5812 / 60.0) = 51.14302
0.0 + (52.6289 / 60.0) = 0.8771483333
if the latitude is S, negate it
if the longitude is W, negate it
For reference, if you have seconds too, you'd do:
degrees + (minutes.to_f / 60) + (seconds.to_f / 3600)
There are some degrees, 60 minutes is 1 degree, 60 seconds is 1 minute (60*60 = 3600)