Reputation: 23
I have a GPS device(gt003) which sends data to my server, I need to convert the 01E0598A 0869058A values that the device sends into latitude and longitude.
Latitude
Occupy 4 bytes, representing the latitude value.
Number range is from 0 to 162000000, which represents the range form 0°to 90°. Unit: 1/500 second Conversion method:
A) Convert the latitude (degrees, minutes) data from GPS module into a new form which represents the value only in minutes;
B Multiply the converted value by 30000, and then transform the result to hexadecimal number
For example22°32.7658′,(22×60+32.7658)×30000=40582974, then convert it to hexadecimal number 0x02 0x6B 0x3F 0x3E
Longitude
Occupy 4 bytes, representing the longitude value of location data. Number ranges from 0 to 324000000, representing the range form 0°to 180°.Unit: 1/500 seconds, Conversion method is the same as latitude’s.
Expected output close to 17°29'20.2"N 78°23'21.7"E
Upvotes: 2
Views: 2730
Reputation: 609
01E0598A(16) = 31480202(10).
Divide by 30000 -> 31480202 / 30000 = 1049.34006666. As you mentioned, it is value in minutes.
So: 1049.34006666/60 = 17.489001°(If you need decimal of degrees - that is it). What is 17°.
0.489001° -> 0.489001 * 60 = 29.34". So 29". 0.34 least. 0.34 * 60 = 20.4'.
Result = 17°29"20.4'.
The same for 0869058A:
0869058A(16) = 141100426(10).
141100426 / 30000 = 4703.347533333333".
4703.347533333333 / 60 = 78.38912555555556° -> 78°
0.38912555555556 * 60 = 23.3475333333336" -> 23"
0.3475333333336 * 60 = 20.852000000016' -> 20.85'
Result: 78°23"20.85' = 78.38912555555556°
Upvotes: 3