A service that I'm consuming requires that I pass it the lat/lon for an address as integers. Currently, my lat/lon's are stored as doubles:
double lat = 38.898748;
double lon = -77.037684;
I've exhausted my Google-fu and can't find a method for converting lat/lon to an integer representation. Any help would be appreciated.
Sometimes it is simple, just multiply by 1 million.
Multiply by .000001 to convert back.
Granted this assumes you only want precision to the 6th decimal.
You need to know what Geodetic System you're using and what the API expects. E.g. WGS84, NAD83, OSGB36, ED50... (Example: Google Earth uses WGS84)
If they need an integer then they're probably using something different from Google and other providers. Chances are that rounding a a double or some other integer conversion will not work. You need the Geodetic System information and then make the conversion between the two values.
The only way I can see this happening is if you shift the decimal point.
int lat = (int)(38.898748 * 1000000.0);
int lon = (int)(-77.037684 * 1000000.0);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With