getEastingFromChar static method Null safety
Given the first letter from a two-letter MGRS 100k zone, and given the MGRS table set for the zone number, figure out the easting value that should be added to the other, secondary easting value.
@private @param {string} e The first letter from a two-letter MGRS 100´k zone. @param {number} set The MGRS table set for the zone number. @return {number} The easting value for the given letter and set.
Implementation
static int getEastingFromChar(String e, int set) {
// colOrigin is the letter at the origin of the set for the
// column
var curCol = unicode.toRune(SET_ORIGIN_COLUMN_LETTERS[set - 1]);
var eastingValue = 100000;
var rewindMarker = false;
while (curCol != unicode.toRune(e[0])) {
curCol++;
if (curCol == I) {
curCol++;
}
if (curCol == O) {
curCol++;
}
if (curCol > Z) {
if (rewindMarker) {
throw Exception('Bad character: $e');
}
curCol = A;
rewindMarker = true;
}
eastingValue += 100000;
}
return eastingValue;
}