Easily convert between latitude/longitude, Universal Transverse Mercator (UTM) and Ordnance Survey (OSGB) references with Java using the Jcoord package.
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:
Kansas USA (Consistent):
Lat Lng: 39.964463, -99.820180 -> MGRS: 14SMK2995324135
MGRS: 14SMK2995324135 -> Lat Lng: 39.964460, -99.820180
SW Hemisphere:
Rio De Janeiro Brazil (Inconsistent)
Lat Lng: -22.938733, -43.503667 -> MGRS: 23KPQ5342862481
MGRS: 23KPQ5342862481 -> Lat Lng: -76.724974 -35.068682
NE Hemisphere:
Leipzig Germany (Consistent)
Lat Lng: 51.349262, 12.365591 -> MGRS: 33UUS1655091960
MGRS: 33UUS1655091960 -> Lat Lng: 51.349262, 12.365591
Kassel Germany (Inconsistent)
Lat Lng: 51.310206, 9.536331 -> MGRS: 32UNB3738384458
MGRS: 32UNB3738284458 -> Lat Lng: 65.679762, 9.813488
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()
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:
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: