I'm making an MGRS overlay plugin for leaflet. To help with this, I've been using some of the leaflet mosue coordinate plugins. But they have occasional math errors. So I want to write some unit tests for their conversion code. The first step is having test data.
I ran Geotrans 3.7 on a set of test Lat/Lng data to get UTM, MGRS, and USNG. Following the basic file processing section of the user guide: running the GUI, file open, open the Gold Data
map_proj/WGS84/Lat_Lon.csv, and selecting the output coordinate system, and saving.
I ran a diff on the MGRS and USNG data, and it showed a difference.
$ diff mgrs.dat usng.dat 1c1 < COORDINATES: Military Grid Reference System (MGRS) --- > COORDINATES: United States National Grid (USNG) 100c100 < 40REU0000018785 --- > 40RDU9999918785 208c208 < 31XDP6500529005 --- > ZAA0000033272 258c258 < 41XMP6500529005 --- > ZHD7740366636
In Geotrans, I can convert
40RDU9999918785 USNG -> Lng/Lat(57E, 30N) -> USNG, and it results in
40REU0000018785, which is 10 meters away. (It's also the coordinate given for MGRS)
ZAA0000033272 USNG -> Lng/Lat(0E 84N) -> USNG results in the same thing, but
31XDP6500529005 MGRS -> Lng/Lat is
84 0 0.0N 0 0 0.1W
So GeoTrans seems to be using different algorithms for MGRS and USNG, which is odd, as with WGS 84, they're identical.
So where should I go for example data I can trust, so I can evaluate/fix existing converters, or worst case write my own?
github.com/proj4js/mgrs(Can someone else edit this to be a link, "You need at least 10 reputation to post more than 2 links") looks reasonable, but it doesn't support the UPS part.
So using GeographicLibs
GeoConvert (version 1.45, which was in the debian repos)
$ tail -n +13 Lat_Lon.csv | GeoConvert -m > mgrs.dat $ tail -n +13 Lat_Lon.csv | GeoConvert -u > utm.dat
Differences between Geotrans and GeographicLib MGRS are as follows:
$ diff mgrs.dat mgrsGEOTRANS.dat 203c203 < ZAA0000033272 --- > 31XDP6500529005 253c253 < ZHD7740366636 --- > 41XMP6500529005
So for the first point, which is 84,0, converting back(with
GeoConvert: 84.00000 0.00004 GeoTrans: 84.00000 0.00001
Second point is 84,60;
GeoConvert: 84.00000 60.00004 GeoTrans: 84.00000 60.00001
GeoConvert will do UTM/UPS at once, while Geotrans just gives
Error: Output Universal Transverse Mercator (UTM): Latitude out of range, so I didn't compare those.
So my question becomes, can I just trust the
GeoConvert values as perfect and correct, or should I use the two values from GeoTrans?