algorithm - Convert GPS data to latitude and longitude c# -
i have gps device(gt003) sends data server, need convert 01e0598a 0869058a values device sends latitude , longitude.
latitude
occupy 4 bytes, representing latitude value.
number range 0 162000000, represents range form 0°to 90°. unit: 1/500 second conversion method:
a) convert latitude (degrees, minutes) data gps module new form represents value in minutes;
b multiply converted value 30000, , transform result hexadecimal number
for example22°32.7658′,(22×60+32.7658)×30000=40582974, convert hexadecimal number 0x02 0x6b 0x3f 0x3e
longitude
occupy 4 bytes, representing longitude value of location data. number ranges 0 324000000, representing range form 0°to 180°.unit: 1/500 seconds, conversion method same latitude’s.
expected output close 17°29'20.2"n 78°23'21.7"e
01e0598a(16) = 31480202(10).
divide 30000 -> 31480202 / 30000 = 1049.34006666. mentioned, value in minutes.
so: 1049.34006666/60 = 17.489001°(if need decimal of degrees - it). 17°.
0.489001° -> 0.489001 * 60 = 29.34". 29". 0.34 least. 0.34 * 60 = 20.4'.
result = 17°29"20.4'.
the same 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°
Comments
Post a Comment