Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / August 2006

Tip: Looking for answers? Try searching our database.

Convert from HEX to decimal Latitude and Longitude

Thread view: 
sazykin@gmail.com - 14 Aug 2006 13:38 GMT
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
Roland de Ruiter - 14 Aug 2006 13:44 GMT
> I have a binary file with coordinates in Latitude and Longitude how can
> I convert then to degrees?
[quoted text clipped - 7 lines]
> Any help please.
> Thanx

Divide by 600000?
Signature

Regards,

Roland

sazykin@gmail.com - 14 Aug 2006 14:03 GMT
> > I have a binary file with coordinates in Latitude and Longitude how can
> > I convert then to degrees?
[quoted text clipped - 13 lines]
>
> 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????
sazykin@gmail.com - 14 Aug 2006 14:12 GMT
> > > I have a binary file with coordinates in Latitude and Longitude how can
> > > I convert then to degrees?
[quoted text clipped - 20 lines]
> 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
?????
Roland de Ruiter - 14 Aug 2006 14:17 GMT
>>> I have a binary file with coordinates in Latitude and Longitude how can
>>> I convert then to degrees?
[quoted text clipped - 20 lines]
> 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
Signature

Regards,

Roland

Luc The Perverse - 14 Aug 2006 14:20 GMT
>> > I have a binary file with coordinates in Latitude and Longitude how can
>> > I convert then to degrees?
[quoted text clipped - 20 lines]
> 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

:)


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.