Given the second letter from a two-letter MGRS 100k zone, and given the * MGRS table set for the zone number, figure out the northing value that * should be added to the other, secondary northing value. You have to * remember that Northings are determined from the equator, and the vertical * cycle of letters mean a 2000000 additional northing meters. This happens * approx. every 18 degrees of
| 335 | * additional northings. You have to figure out how many 2000000 meters need |
| 336 | * to be added for the zone letter of the MGRS coordinate. */ |
| 337 | int SquareCharToNorthing(char n, int set) |
| 338 | { |
| 339 | if (n > 'V') |
| 340 | return kInvalidEastingNorthing; |
| 341 | |
| 342 | int curRow = kSetOriginRowLetters[set]; |
| 343 | int northingValue = 0; |
| 344 | bool rewindMarker = false; |
| 345 | |
| 346 | while (curRow != n) |
| 347 | { |
| 348 | curRow++; |
| 349 | if (curRow == 'I') |
| 350 | curRow++; |
| 351 | if (curRow == 'O') |
| 352 | curRow++; |
| 353 | if (curRow > 'V') |
| 354 | { |
| 355 | if (rewindMarker) // Making sure that this loop ends even if n has invalid value. |
| 356 | return kInvalidEastingNorthing; |
| 357 | curRow = 'A'; |
| 358 | rewindMarker = true; |
| 359 | } |
| 360 | northingValue += 100000; |
| 361 | } |
| 362 | |
| 363 | return northingValue; |
| 364 | } |
| 365 | |
| 366 | // Get minimum northing value of a MGRS zone. |
| 367 | int ZoneToMinNorthing(char zoneLetter) |