I have some db records that I am trying to extract. I've hit a stumbling block with the lat/long fields. This might sound computer-y so far but it's going to end in a maths question, I promise. I am not a mathematician, not mathematically inclined, so please don't laugh too hard at me
The only info I have is (some guesswork from a previous explorer of this issue) that the lat/long is converted to a decimal by:
s + (m * 3) + (h * 3 * 60)
The seconds are stored only in 3 values: 00, 20, 40
E/W is indicated by a flag elsewhere.
Looking at my first record, I have:
Longitude 108.45.0 W -> apply magic formula -> expect to find 19575
Actual extracted data: 19575 (hurrah, it matches!)
Across the W Longs it seems happy and consistent... but then I hit some records with E Longs...
Longitude 27.28.0 E -> apply magic formula -> expect to find 4944
Actual extracted data: 27824 (hmm, that's not good)
But wait... there's more. That vast majority of records have their second set to 0. I've found one record so far that shows seconds.
Latitude 44.38.20 N -> apply magic formula -> expect to find 8054
Actual extracted data: 8035
This last one, however, I think I can explain. (m * 3) + (h * 3 * 60) would be 8034. The difference between expected and found is 1 -> seconds are 1 * 20 = 20 seconds. If the difference had been 2, the second would have been 2 * 20 = 40. This approach has been used elsewhere in the database. Unfortunately. I've not found any records with 40 seconds to confirm this but heyho, it seems to work. Because the vast majority of records have 0 seconds, it doesn't crop up as a problem very often.
My questions
Does anybody recognise what the hell is going on with this conversion? Perhaps it's a standard way to wedge DMS into 15 bits that everyone else in the world already knows about
Even if I confirm how the DMS is being turned into a decimal (well, integer it appears) how do I turn the extracted data back into DMS?
Any suggestions or pointers are welcome, this is really starting to bug me...
Sample Data to show what I'm working (or "failing") with
Longitude 108 45 0 W -> db says 19575
Longitude 105 20 0 W -> db says 18960
Longitude 79 28 0 W -> db says 14304
Longitude 126 54 0 E -> db says 9926 (expected 22842)
Longitude 125 54 0 E -> db says 10106 (expected 22662)
Longitude 27 28 0 E -> db says 27824 (expected 27824)
Latitude 39 2 0 N -> db says 7026
Latitude 44 38 20 N -> db says 8035 (expected 8054)
Latitude 46 13 0 N -> db says 8319
Latitude 12 11 20 S -> db says 30574 (expected 2213)
Latitude 11 40 20 S -> db says 30667 (expected 2120)