convert wgs 84 to lat/long

Kenneth Brodersen picture Kenneth Brodersen · Apr 11, 2011 · Viewed 7.9k times · Source

Hi I am having a little trouble figuring out how to convert between types of coordinates. I have a list of coordinate sets with the following description

"Coordinates are always in the WGS84 system. All coordinates a represented as integer values x and y where the coordinate value is multiplied with 1,000,000."

An example: 559262 6319512

Well, I need to convert these to long/lat (and back) so i can use these in google maps (android). But this is not as easy as it seams. I have been searching around and did find some code to do this, but it does not seam to work properly. Anyone who can provide some code for doing this? If possible, I would like to avoid a big geo framework (it has to be used in an android application).

thanks.

best regards, kenneth

EDIT: I did find a solution on my own. I downloaded the class described here: http://www.ibm.com/developerworks/java/library/j-coordconvert/

And it works fine. Hope someone can find it useful.

I am sorry for posting before having done my homework decently. Thanks to everyone who posted

Answer

azharb picture azharb · Apr 11, 2011

If you're getting the location from the GPS on android, you will get a Location object that holds Lat/Long as doubles. In order to display a point on Google Maps, you need to turn these double values into a GeoPoint object using:

GeoPoint location = new GeoPoint(
            (int) (mLocation.getLatitude()) * 1E6), 
            (int) (mLocation.getLongitude()) * 1E6)
                     );

Hope thats helpful.