xni06 / JCoord

Easily convert between latitude/longitude, Universal Transverse Mercator (UTM) and Ordnance Survey (OSGB) references with Java using the Jcoord package.
http://www.jstott.me.uk/jcoord
12 stars 9 forks source link

Inconsistent conversions of LatLng and MGRS coordinates #9

Open BigBallard opened 4 years ago

BigBallard commented 4 years ago

I am having some troubles with conversations between LatLng and MGRS providing inconsistent and incorrect values for some geographic areas in different hemispheres and also within those hemispheres being inconsistent. To help verify I provided some the test points I used to check the validity of the conversions:

NW Hemisphere:

SW Hemisphere:

NE Hemisphere:

The code I am using the create and convert LatLng to MGRS:

double lat = 39.964463;
double lon = -99.820180;
LatLng ll = new LatLng(lat, lon);
MGRSRef mgrs = ll.toMGRSRef();

And then building off that, how I convert MGRS to LatLng by taking the string value of the MGRS, create a new MGRSRef , and convert that to LatLng:

MGRSRef mgrs = new MGRSRef("14SMK2995324135");
... = mgrs.toLatLng()
xni06 commented 4 years ago

Hi @DallasP9124 - I can't help sorry but feel free to add a PR or take a look at the forks to see whether anyone else has made sense of it at all.

I've just taken the author's source and made it available to the community