codice / usng.js

A javascript library for converting LL, UTM, USNG, and MGRS
Other
24 stars 33 forks source link

Incorrect grid zone letter for UPS at the south pole #51

Open Skhmt opened 7 months ago

Skhmt commented 7 months ago

At the south pole, any longitude > -90 and < 90 (i.e. towards the prime meridian) gives the zone letter B, while longitudes > 90 but < -90 (i.e. towards the anti-meridian) gives the zone letter A. In other words, the zone letter at the south pole is being determined by the northing. This is incorrect.

DMA TM 8358,1 B-3.2:

If the easting is less than 2,000,000 meters the Grid Zone Designation will be Y or A depending on whether the point is in the North or South Polar region. If the easting is greater than 2,000,000 meters the Grid Zone Designation will be Z or B.

See also the wikipedia example.

I had an open PR but since the repo hasn't been touched in years, I just closed it. This is more to let anyone else know to not trust the grid zone letter for UPS at the south pole.

ryanc16 commented 2 months ago

Just confirming this is still an issue. I actually ran into this while writing unit tests in my own application and cross verifying using a different online coordinate conversion tool.

Issue is in two places in the code: https://github.com/codice/usng.js/blob/64420822d95ec8fa40c83718dc5d75fcbe0c0137/src/usng.ts#L355 https://github.com/codice/usng.js/blob/64420822d95ec8fa40c83718dc5d75fcbe0c0137/src/usng.ts#L572

Results below for longitudes -179 through 179 in the southern pole using the LLtoUTMUPS(lat, lon) method.

Click to expand Lat: -80.1 Lon: -179 to 179 ``` [-80.1,-179] -> A 1980772mE 898404mN [-80.1,-178] -> A 1961549mE 898907mN [-80.1,-177] -> A 1942338mE 899746mN [-80.1,-176] -> A 1923145mE 900920mN [-80.1,-175] -> A 1903975mE 902428mN [-80.1,-174] -> A 1884834mE 904271mN [-80.1,-173] -> A 1865729mE 906448mN [-80.1,-172] -> A 1846664mE 908958mN [-80.1,-171] -> A 1827646mE 911800mN [-80.1,-170] -> A 1808681mE 914974mN [-80.1,-169] -> A 1789773mE 918478mN [-80.1,-168] -> A 1770930mE 922312mN [-80.1,-167] -> A 1752157mE 926474mN [-80.1,-166] -> A 1733459mE 930963mN [-80.1,-165] -> A 1714842mE 935777mN [-80.1,-164] -> A 1696313mE 940916mN [-80.1,-163] -> A 1677875mE 946378mN [-80.1,-162] -> A 1659536mE 952160mN [-80.1,-161] -> A 1641301mE 958261mN [-80.1,-160] -> A 1623174mE 964680mN [-80.1,-159] -> A 1605163mE 971414mN [-80.1,-158] -> A 1587272mE 978462mN [-80.1,-157] -> A 1569506mE 985821mN [-80.1,-156] -> A 1551872mE 993488mN [-80.1,-155] -> A 1534374mE 1001463mN [-80.1,-154] -> A 1517018mE 1009741mN [-80.1,-153] -> A 1499810mE 1018321mN [-80.1,-152] -> A 1482753mE 1027200mN [-80.1,-151] -> A 1465854mE 1036375mN [-80.1,-150] -> A 1449118mE 1045844mN [-80.1,-149] -> A 1432549mE 1055604mN [-80.1,-148] -> A 1416154mE 1065651mN [-80.1,-147] -> A 1399936mE 1075983mN [-80.1,-146] -> A 1383901mE 1086596mN [-80.1,-145] -> A 1368054mE 1097488mN [-80.1,-144] -> A 1352399mE 1108654mN [-80.1,-143] -> A 1336942mE 1120092mN [-80.1,-142] -> A 1321686mE 1131798mN [-80.1,-141] -> A 1306637mE 1143768mN [-80.1,-140] -> A 1291800mE 1156000mN [-80.1,-139] -> A 1277178mE 1168488mN [-80.1,-138] -> A 1262776mE 1181230mN [-80.1,-137] -> A 1248599mE 1194221mN [-80.1,-136] -> A 1234650mE 1207457mN [-80.1,-135] -> A 1220935mE 1220935mN [-80.1,-134] -> A 1207457mE 1234650mN [-80.1,-133] -> A 1194221mE 1248599mN [-80.1,-132] -> A 1181230mE 1262776mN [-80.1,-131] -> A 1168488mE 1277178mN [-80.1,-130] -> A 1156000mE 1291800mN [-80.1,-129] -> A 1143768mE 1306637mN [-80.1,-128] -> A 1131798mE 1321686mN [-80.1,-127] -> A 1120092mE 1336942mN [-80.1,-126] -> A 1108654mE 1352399mN [-80.1,-125] -> A 1097488mE 1368054mN [-80.1,-124] -> A 1086596mE 1383901mN [-80.1,-123] -> A 1075983mE 1399936mN [-80.1,-122] -> A 1065651mE 1416154mN [-80.1,-121] -> A 1055604mE 1432549mN [-80.1,-120] -> A 1045844mE 1449118mN [-80.1,-119] -> A 1036375mE 1465854mN [-80.1,-118] -> A 1027200mE 1482753mN [-80.1,-117] -> A 1018321mE 1499810mN [-80.1,-116] -> A 1009741mE 1517018mN [-80.1,-115] -> A 1001463mE 1534374mN [-80.1,-114] -> A 993488mE 1551872mN [-80.1,-113] -> A 985821mE 1569506mN [-80.1,-112] -> A 978462mE 1587272mN [-80.1,-111] -> A 971414mE 1605163mN [-80.1,-110] -> A 964680mE 1623174mN [-80.1,-109] -> A 958261mE 1641301mN [-80.1,-108] -> A 952160mE 1659536mN [-80.1,-107] -> A 946378mE 1677875mN [-80.1,-106] -> A 940916mE 1696313mN [-80.1,-105] -> A 935777mE 1714842mN [-80.1,-104] -> A 930963mE 1733459mN [-80.1,-103] -> A 926474mE 1752157mN [-80.1,-102] -> A 922312mE 1770930mN [-80.1,-101] -> A 918478mE 1789773mN [-80.1,-100] -> A 914974mE 1808681mN [-80.1, -99] -> A 911800mE 1827646mN [-80.1, -98] -> A 908958mE 1846664mN [-80.1, -97] -> A 906448mE 1865729mN [-80.1, -96] -> A 904271mE 1884834mN [-80.1, -95] -> A 902428mE 1903975mN [-80.1, -94] -> A 900920mE 1923145mN [-80.1, -93] -> A 899746mE 1942338mN [-80.1, -92] -> A 898907mE 1961549mN [-80.1, -91] -> A 898404mE 1980772mN [-80.1, -90] -> B 898236mE 2000000mN [-80.1, -89] -> B 898404mE 2019228mN [-80.1, -88] -> B 898907mE 2038451mN [-80.1, -87] -> B 899746mE 2057662mN [-80.1, -86] -> B 900920mE 2076855mN [-80.1, -85] -> B 902428mE 2096025mN [-80.1, -84] -> B 904271mE 2115166mN [-80.1, -83] -> B 906448mE 2134271mN [-80.1, -82] -> B 908958mE 2153336mN [-80.1, -81] -> B 911800mE 2172354mN [-80.1, -80] -> B 914974mE 2191319mN [-80.1, -79] -> B 918478mE 2210227mN [-80.1, -78] -> B 922312mE 2229070mN [-80.1, -77] -> B 926474mE 2247843mN [-80.1, -76] -> B 930963mE 2266541mN [-80.1, -75] -> B 935777mE 2285158mN [-80.1, -74] -> B 940916mE 2303687mN [-80.1, -73] -> B 946378mE 2322125mN [-80.1, -72] -> B 952160mE 2340464mN [-80.1, -71] -> B 958261mE 2358699mN [-80.1, -70] -> B 964680mE 2376826mN [-80.1, -69] -> B 971414mE 2394837mN [-80.1, -68] -> B 978462mE 2412728mN [-80.1, -67] -> B 985821mE 2430494mN [-80.1, -66] -> B 993488mE 2448128mN [-80.1, -65] -> B 1001463mE 2465626mN [-80.1, -64] -> B 1009741mE 2482982mN [-80.1, -63] -> B 1018321mE 2500190mN [-80.1, -62] -> B 1027200mE 2517247mN [-80.1, -61] -> B 1036375mE 2534146mN [-80.1, -60] -> B 1045844mE 2550882mN [-80.1, -59] -> B 1055604mE 2567451mN [-80.1, -58] -> B 1065651mE 2583846mN [-80.1, -57] -> B 1075983mE 2600064mN [-80.1, -56] -> B 1086596mE 2616099mN [-80.1, -55] -> B 1097488mE 2631946mN [-80.1, -54] -> B 1108654mE 2647601mN [-80.1, -53] -> B 1120092mE 2663058mN [-80.1, -52] -> B 1131798mE 2678314mN [-80.1, -51] -> B 1143768mE 2693363mN [-80.1, -50] -> B 1156000mE 2708200mN [-80.1, -49] -> B 1168488mE 2722822mN [-80.1, -48] -> B 1181230mE 2737224mN [-80.1, -47] -> B 1194221mE 2751401mN [-80.1, -46] -> B 1207457mE 2765350mN [-80.1, -45] -> B 1220935mE 2779065mN [-80.1, -44] -> B 1234650mE 2792543mN [-80.1, -43] -> B 1248599mE 2805779mN [-80.1, -42] -> B 1262776mE 2818770mN [-80.1, -41] -> B 1277178mE 2831512mN [-80.1, -40] -> B 1291800mE 2844000mN [-80.1, -39] -> B 1306637mE 2856232mN [-80.1, -38] -> B 1321686mE 2868202mN [-80.1, -37] -> B 1336942mE 2879908mN [-80.1, -36] -> B 1352399mE 2891346mN [-80.1, -35] -> B 1368054mE 2902512mN [-80.1, -34] -> B 1383901mE 2913404mN [-80.1, -33] -> B 1399936mE 2924017mN [-80.1, -32] -> B 1416154mE 2934349mN [-80.1, -31] -> B 1432549mE 2944396mN [-80.1, -30] -> B 1449118mE 2954156mN [-80.1, -29] -> B 1465854mE 2963625mN [-80.1, -28] -> B 1482753mE 2972800mN [-80.1, -27] -> B 1499810mE 2981679mN [-80.1, -26] -> B 1517018mE 2990259mN [-80.1, -25] -> B 1534374mE 2998537mN [-80.1, -24] -> B 1551872mE 3006512mN [-80.1, -23] -> B 1569506mE 3014179mN [-80.1, -22] -> B 1587272mE 3021538mN [-80.1, -21] -> B 1605163mE 3028586mN [-80.1, -20] -> B 1623174mE 3035320mN [-80.1, -19] -> B 1641301mE 3041739mN [-80.1, -18] -> B 1659536mE 3047840mN [-80.1, -17] -> B 1677875mE 3053622mN [-80.1, -16] -> B 1696313mE 3059084mN [-80.1, -15] -> B 1714842mE 3064223mN [-80.1, -14] -> B 1733459mE 3069037mN [-80.1, -13] -> B 1752157mE 3073526mN [-80.1, -12] -> B 1770930mE 3077688mN [-80.1, -11] -> B 1789773mE 3081522mN [-80.1, -10] -> B 1808681mE 3085026mN [-80.1, -9] -> B 1827646mE 3088200mN [-80.1, -8] -> B 1846664mE 3091042mN [-80.1, -7] -> B 1865729mE 3093552mN [-80.1, -6] -> B 1884834mE 3095729mN [-80.1, -5] -> B 1903975mE 3097572mN [-80.1, -4] -> B 1923145mE 3099080mN [-80.1, -3] -> B 1942338mE 3100254mN [-80.1, -2] -> B 1961549mE 3101093mN [-80.1, -1] -> B 1980772mE 3101596mN [-80.1, 0] -> B 2000000mE 3101764mN [-80.1, 1] -> B 2019228mE 3101596mN [-80.1, 2] -> B 2038451mE 3101093mN [-80.1, 3] -> B 2057662mE 3100254mN [-80.1, 4] -> B 2076855mE 3099080mN [-80.1, 5] -> B 2096025mE 3097572mN [-80.1, 6] -> B 2115166mE 3095729mN [-80.1, 7] -> B 2134271mE 3093552mN [-80.1, 8] -> B 2153336mE 3091042mN [-80.1, 9] -> B 2172354mE 3088200mN [-80.1, 10] -> B 2191319mE 3085026mN [-80.1, 11] -> B 2210227mE 3081522mN [-80.1, 12] -> B 2229070mE 3077688mN [-80.1, 13] -> B 2247843mE 3073526mN [-80.1, 14] -> B 2266541mE 3069037mN [-80.1, 15] -> B 2285158mE 3064223mN [-80.1, 16] -> B 2303687mE 3059084mN [-80.1, 17] -> B 2322125mE 3053622mN [-80.1, 18] -> B 2340464mE 3047840mN [-80.1, 19] -> B 2358699mE 3041739mN [-80.1, 20] -> B 2376826mE 3035320mN [-80.1, 21] -> B 2394837mE 3028586mN [-80.1, 22] -> B 2412728mE 3021538mN [-80.1, 23] -> B 2430494mE 3014179mN [-80.1, 24] -> B 2448128mE 3006512mN [-80.1, 25] -> B 2465626mE 2998537mN [-80.1, 26] -> B 2482982mE 2990259mN [-80.1, 27] -> B 2500190mE 2981679mN [-80.1, 28] -> B 2517247mE 2972800mN [-80.1, 29] -> B 2534146mE 2963625mN [-80.1, 30] -> B 2550882mE 2954156mN [-80.1, 31] -> B 2567451mE 2944396mN [-80.1, 32] -> B 2583846mE 2934349mN [-80.1, 33] -> B 2600064mE 2924017mN [-80.1, 34] -> B 2616099mE 2913404mN [-80.1, 35] -> B 2631946mE 2902512mN [-80.1, 36] -> B 2647601mE 2891346mN [-80.1, 37] -> B 2663058mE 2879908mN [-80.1, 38] -> B 2678314mE 2868202mN [-80.1, 39] -> B 2693363mE 2856232mN [-80.1, 40] -> B 2708200mE 2844000mN [-80.1, 41] -> B 2722822mE 2831512mN [-80.1, 42] -> B 2737224mE 2818770mN [-80.1, 43] -> B 2751401mE 2805779mN [-80.1, 44] -> B 2765350mE 2792543mN [-80.1, 45] -> B 2779065mE 2779065mN [-80.1, 46] -> B 2792543mE 2765350mN [-80.1, 47] -> B 2805779mE 2751401mN [-80.1, 48] -> B 2818770mE 2737224mN [-80.1, 49] -> B 2831512mE 2722822mN [-80.1, 50] -> B 2844000mE 2708200mN [-80.1, 51] -> B 2856232mE 2693363mN [-80.1, 52] -> B 2868202mE 2678314mN [-80.1, 53] -> B 2879908mE 2663058mN [-80.1, 54] -> B 2891346mE 2647601mN [-80.1, 55] -> B 2902512mE 2631946mN [-80.1, 56] -> B 2913404mE 2616099mN [-80.1, 57] -> B 2924017mE 2600064mN [-80.1, 58] -> B 2934349mE 2583846mN [-80.1, 59] -> B 2944396mE 2567451mN [-80.1, 60] -> B 2954156mE 2550882mN [-80.1, 61] -> B 2963625mE 2534146mN [-80.1, 62] -> B 2972800mE 2517247mN [-80.1, 63] -> B 2981679mE 2500190mN [-80.1, 64] -> B 2990259mE 2482982mN [-80.1, 65] -> B 2998537mE 2465626mN [-80.1, 66] -> B 3006512mE 2448128mN [-80.1, 67] -> B 3014179mE 2430494mN [-80.1, 68] -> B 3021538mE 2412728mN [-80.1, 69] -> B 3028586mE 2394837mN [-80.1, 70] -> B 3035320mE 2376826mN [-80.1, 71] -> B 3041739mE 2358699mN [-80.1, 72] -> B 3047840mE 2340464mN [-80.1, 73] -> B 3053622mE 2322125mN [-80.1, 74] -> B 3059084mE 2303687mN [-80.1, 75] -> B 3064223mE 2285158mN [-80.1, 76] -> B 3069037mE 2266541mN [-80.1, 77] -> B 3073526mE 2247843mN [-80.1, 78] -> B 3077688mE 2229070mN [-80.1, 79] -> B 3081522mE 2210227mN [-80.1, 80] -> B 3085026mE 2191319mN [-80.1, 81] -> B 3088200mE 2172354mN [-80.1, 82] -> B 3091042mE 2153336mN [-80.1, 83] -> B 3093552mE 2134271mN [-80.1, 84] -> B 3095729mE 2115166mN [-80.1, 85] -> B 3097572mE 2096025mN [-80.1, 86] -> B 3099080mE 2076855mN [-80.1, 87] -> B 3100254mE 2057662mN [-80.1, 88] -> B 3101093mE 2038451mN [-80.1, 89] -> B 3101596mE 2019228mN [-80.1, 90] -> B 3101764mE 2000000mN [-80.1, 91] -> A 3101596mE 1980772mN [-80.1, 92] -> A 3101093mE 1961549mN [-80.1, 93] -> A 3100254mE 1942338mN [-80.1, 94] -> A 3099080mE 1923145mN [-80.1, 95] -> A 3097572mE 1903975mN [-80.1, 96] -> A 3095729mE 1884834mN [-80.1, 97] -> A 3093552mE 1865729mN [-80.1, 98] -> A 3091042mE 1846664mN [-80.1, 99] -> A 3088200mE 1827646mN [-80.1, 100] -> A 3085026mE 1808681mN [-80.1, 101] -> A 3081522mE 1789773mN [-80.1, 102] -> A 3077688mE 1770930mN [-80.1, 103] -> A 3073526mE 1752157mN [-80.1, 104] -> A 3069037mE 1733459mN [-80.1, 105] -> A 3064223mE 1714842mN [-80.1, 106] -> A 3059084mE 1696313mN [-80.1, 107] -> A 3053622mE 1677875mN [-80.1, 108] -> A 3047840mE 1659536mN [-80.1, 109] -> A 3041739mE 1641301mN [-80.1, 110] -> A 3035320mE 1623174mN [-80.1, 111] -> A 3028586mE 1605163mN [-80.1, 112] -> A 3021538mE 1587272mN [-80.1, 113] -> A 3014179mE 1569506mN [-80.1, 114] -> A 3006512mE 1551872mN [-80.1, 115] -> A 2998537mE 1534374mN [-80.1, 116] -> A 2990259mE 1517018mN [-80.1, 117] -> A 2981679mE 1499810mN [-80.1, 118] -> A 2972800mE 1482753mN [-80.1, 119] -> A 2963625mE 1465854mN [-80.1, 120] -> A 2954156mE 1449118mN [-80.1, 121] -> A 2944396mE 1432549mN [-80.1, 122] -> A 2934349mE 1416154mN [-80.1, 123] -> A 2924017mE 1399936mN [-80.1, 124] -> A 2913404mE 1383901mN [-80.1, 125] -> A 2902512mE 1368054mN [-80.1, 126] -> A 2891346mE 1352399mN [-80.1, 127] -> A 2879908mE 1336942mN [-80.1, 128] -> A 2868202mE 1321686mN [-80.1, 129] -> A 2856232mE 1306637mN [-80.1, 130] -> A 2844000mE 1291800mN [-80.1, 131] -> A 2831512mE 1277178mN [-80.1, 132] -> A 2818770mE 1262776mN [-80.1, 133] -> A 2805779mE 1248599mN [-80.1, 134] -> A 2792543mE 1234650mN [-80.1, 135] -> A 2779065mE 1220935mN [-80.1, 136] -> A 2765350mE 1207457mN [-80.1, 137] -> A 2751401mE 1194221mN [-80.1, 138] -> A 2737224mE 1181230mN [-80.1, 139] -> A 2722822mE 1168488mN [-80.1, 140] -> A 2708200mE 1156000mN [-80.1, 141] -> A 2693363mE 1143768mN [-80.1, 142] -> A 2678314mE 1131798mN [-80.1, 143] -> A 2663058mE 1120092mN [-80.1, 144] -> A 2647601mE 1108654mN [-80.1, 145] -> A 2631946mE 1097488mN [-80.1, 146] -> A 2616099mE 1086596mN [-80.1, 147] -> A 2600064mE 1075983mN [-80.1, 148] -> A 2583846mE 1065651mN [-80.1, 149] -> A 2567451mE 1055604mN [-80.1, 150] -> A 2550882mE 1045844mN [-80.1, 151] -> A 2534146mE 1036375mN [-80.1, 152] -> A 2517247mE 1027200mN [-80.1, 153] -> A 2500190mE 1018321mN [-80.1, 154] -> A 2482982mE 1009741mN [-80.1, 155] -> A 2465626mE 1001463mN [-80.1, 156] -> A 2448128mE 993488mN [-80.1, 157] -> A 2430494mE 985821mN [-80.1, 158] -> A 2412728mE 978462mN [-80.1, 159] -> A 2394837mE 971414mN [-80.1, 160] -> A 2376826mE 964680mN [-80.1, 161] -> A 2358699mE 958261mN [-80.1, 162] -> A 2340464mE 952160mN [-80.1, 163] -> A 2322125mE 946378mN [-80.1, 164] -> A 2303687mE 940916mN [-80.1, 165] -> A 2285158mE 935777mN [-80.1, 166] -> A 2266541mE 930963mN [-80.1, 167] -> A 2247843mE 926474mN [-80.1, 168] -> A 2229070mE 922312mN [-80.1, 169] -> A 2210227mE 918478mN [-80.1, 170] -> A 2191319mE 914974mN [-80.1, 171] -> A 2172354mE 911800mN [-80.1, 172] -> A 2153336mE 908958mN [-80.1, 173] -> A 2134271mE 906448mN [-80.1, 174] -> A 2115166mE 904271mN [-80.1, 175] -> A 2096025mE 902428mN [-80.1, 176] -> A 2076855mE 900920mN [-80.1, 177] -> A 2057662mE 899746mN [-80.1, 178] -> A 2038451mE 898907mN [-80.1, 179] -> A 2019228mE 898404mN ```