Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Convert from HEX to decimal Latitude and Longitude

Reply
Thread Tools

Convert from HEX to decimal Latitude and Longitude

 
 
sazykin@gmail.com
Guest
Posts: n/a
 
      08-14-2006
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

 
Reply With Quote
 
 
 
 
Roland de Ruiter
Guest
Posts: n/a
 
      08-14-2006
On 14-8-2006 14:38, wrote:
> 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
>

Divide by 600000?
--
Regards,

Roland
 
Reply With Quote
 
 
 
 
sazykin@gmail.com
Guest
Posts: n/a
 
      08-14-2006

Roland de Ruiter wrote:
> On 14-8-2006 14:38, wrote:
> > 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
> >

> Divide by 600000?
> --
> Regards,
>
> Roland



yeah!
but how to get integers when I use hex to integer :
System.out.println("Hex to Integer"+ Integer.valueOf("0fbe72",
16).intValue());
I'm getting - 1031794????
any ideas????

 
Reply With Quote
 
sazykin@gmail.com
Guest
Posts: n/a
 
      08-14-2006

wrote:
> Roland de Ruiter wrote:
> > On 14-8-2006 14:38, wrote:
> > > 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
> > >

> > Divide by 600000?
> > --
> > Regards,
> >
> > Roland

>
>
> yeah!
> but how to get integers when I use hex to integer :
> System.out.println("Hex to Integer"+ Integer.valueOf("0fbe72",
> 16).intValue());
> I'm getting - 1031794????
> any ideas????


or
String hexVal = "119C67";
System.out.println("Hex to Decimal. Hex = "+ hexVal + ",Decimal =
"+Integer.parseInt(hexVal,16));

I'm getting 1154151
?????

 
Reply With Quote
 
Roland de Ruiter
Guest
Posts: n/a
 
      08-14-2006
On 14-8-2006 15:03, wrote:
> Roland de Ruiter wrote:
>> On 14-8-2006 14:38, wrote:
>>> 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
>>>

>> Divide by 600000?
>> --
>> Regards,
>>
>> Roland

>
>
> yeah!
> but how to get integers when I use hex to integer :
> System.out.println("Hex to Integer"+ Integer.valueOf("0fbe72",
> 16).intValue());
> I'm getting - 1031794????
> any ideas????
>

Are you sure you got the bytes right?
decimal 16508674 = hex 00FBE702 00 FB E7 02
decimal 18418791 = hex 01190C67 01 19 0C 67
--
Regards,

Roland
 
Reply With Quote
 
Luc The Perverse
Guest
Posts: n/a
 
      08-14-2006
<> wrote in message
news: oups.com...
>
> Roland de Ruiter wrote:
>> On 14-8-2006 14:38, wrote:
>> > 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
>> >

>> Divide by 600000?
>> --
>> Regards,
>>
>> Roland

>
>
> yeah!
> but how to get integers when I use hex to integer :
> System.out.println("Hex to Integer"+ Integer.valueOf("0fbe72",
> 16).intValue());
> I'm getting - 1031794????
> any ideas????
>


See the example here.

http://mindprod.com/jgloss/hex.html

However - even if that functionality were not built in, parsing a hex number
should be trivial with a simple for loop. Perhaps you should write it for
practice.

Something like this perhaps (note - I have not compiled or tested this)

int parseHex(String x){
int ret = 0;
for(char c : x.toCharArray()){
ret*=16;
if(c>='a'&&c<='f')
ret+=c-'a'+10;
if(c>='A'&&c<='F')
ret+=c-'A'+10;
if(c>='0'&&c<='9')
ret+=c-'0';
else
return 0; //error handling?
}
return ret;
}

--
LTP




 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Convert Latitude, Longitude To TimeZone Roy Smith Python 0 03-31-2013 03:09 PM
Code to convert MGRS coordinates to latitude and longitude (degrees, clusardi2k Java 1 08-13-2012 06:36 PM
Code to convert MGRS coordinates to latitude and longitude (degrees,minutes, seconds) clusardi2k@aol.com Java 1 08-13-2012 04:46 PM
Initial guidance needed on mapping longitude and latitude to the x,y coordinates of an image. Penn Java 5 07-11-2007 03:26 PM
Fibonacci series and the exact longitude and latitude YS Sze C Programming 4 02-07-2004 12:53 AM



Advertisments