Convert from HEX to decimal Latitude and Longitude

  • Follow


I have a binary file with coordinates in Latitude and Longitude how can
I convert then to degrees?

Byte 180-183 (Latitude)
   Hex 119c67   integer 18418791
Byte 184-187 (Longitude)
   Hex 0fbe72   integer 16508674
Decoded Decimal:   Latitude     30.697985
                             Longitude    27.514457
Any help please.
Thanx

0
Reply sazykin (9) 8/14/2006 12:42:19 PM

<sazykin@gmail.com> wrote...
>I have a binary file with coordinates in Latitude and Longitude
> how can I convert then to degrees?

First you should understand your data...
It's very simple arithmetics.


> 
> Byte 180-183 (Latitude)
>   Hex 119c67   integer 18418791

WRONG! You've lost a zero. Dec 18418791 = Hex 1190c67.



> Byte 184-187 (Longitude)
>   Hex 0fbe72   integer 16508674

WRONG! You've lost a zero. Dec 16508674 = Hex fbe702.



> Decoded Decimal:
>   Latitude     30.697985
>   Longitude    27.514457

In the first angle there is the '6' digit at the first
decimal place, so I suppose values are a simple decimal
fractions rather than a degree-minute-second notation.

Divide your known coordinate values by file-values
to calculate the encoding scale, i.e. what angle
is coded as a unit of your data:

lat: 30.697985/18418791 = 1.666667e-6 = 1/600000
lon: 27.514457/16508674 = 1.666667e-6 = 1/600000

So your coordinates are simply stored as integers,
expressed in 600000'ths of a degree. You need to decode
4 bytes as an integer and divide it by 600000.0 to get
a value in degrees.

However the sample you gave is too short to discover
encoding for different hemispheres. If your data span
both sides of the equator or the Greenwich meridian,
they will probably be stored as positive and negative
integers, for N/S and for E/W hemispheres, respectively
-- but that should be verified.


Maciek
0
Reply Maciek 8/14/2006 1:50:43 PM


sazykin@gmail.com writes:

> I have a binary file with coordinates in Latitude and Longitude how can
> I convert then to degrees?
> 
> Byte 180-183 (Latitude)
>    Hex 119c67   integer 18418791
> Byte 184-187 (Longitude)
>    Hex 0fbe72   integer 16508674
> Decoded Decimal:   Latitude     30.697985
>                              Longitude    27.514457

Try dividing the integer result by 600000.0

-- 
Thomas A. Russ,  USC/Information Sciences Institute
0
Reply tar 8/14/2006 9:08:52 PM

2 Replies
502 Views

(page loaded in 0.047 seconds)

Similiar Articles:













7/21/2012 11:19:15 PM


Reply: