The Latitude and Longitude are embedded in the Payload (Payload HEX)
Latitude: Byte[8]-Byte[10], for instance: 4a0d76
Longitude: Byte[11]-Byte[13], for instance: 031845
To convert the HEX values into usable coordinates you can use the following calculation:
Convert HEX to Decimal.
LAT: 4a0d76 => 4853110
LONG: 031845 => 202821
To convert the decimal value into a usable coordinate you can use the following calculations for the Latitude and Longitude
Latitude: LAT * (90 / 2^23)
For instance: 4853110 * ( 90 / 2^23) = 52,068221569066 =/= 52,068222
Longitude: LONG * (180 / 2^23)
For instance: 202821 * (180 / 2^23) = 4,3520665168762 =/= 4,352067
Now you have the coordinates, which can be used by for instance Google Maps.
Beste antwoord door Remco_Dekkinga
To also support negative coordinates, an extra step is needed between the conversion from HEX to Decimal and the coordinate calculation.
When the decimal coordinate (after converting from HEX) is larger than 2^23, substract 2^24 from the decimal coordinate to make it a negative coordinate.
For instance:
2^23 = 8388608
LAT: B62C45 => 11938885
1193885 is larger than 8388608, which means we need to substract 16777216 from 11938885.
11938885 - 16777216 = -4838331
-4838331 will become -51.909660 using the coordinate calculation.
-4838331 * ( 90 / 2^23) = -51,9096601009368896484375 =/= -51,909660
Bekijk origineel
When the decimal coordinate (after converting from HEX) is larger than 2^23, substract 2^24 from the decimal coordinate to make it a negative coordinate.
For instance:
2^23 = 8388608
LAT: B62C45 => 11938885
1193885 is larger than 8388608, which means we need to substract 16777216 from 11938885.
11938885 - 16777216 = -4838331
-4838331 will become -51.909660 using the coordinate calculation.
-4838331 * ( 90 / 2^23) = -51,9096601009368896484375 =/= -51,909660