MCPcopy Create free account
hub / github.com/comaps/comaps / SquareCharToEasting

Function SquareCharToEasting

libs/platform/utm_mgrs_utils.cpp:302–327  ·  view source on GitHub ↗

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.

Source from the content-addressed store, hash-verified

300// MGRS table set for the zone number, figure out the easting value that
301// should be added to the other, secondary easting value.
302int SquareCharToEasting(char e, size_t set)
303{
304 ASSERT_LESS(set, kSetOriginColumnLetters.size(), ());
305 int curCol = kSetOriginColumnLetters[set];
306 int eastingValue = 100000;
307 bool rewindMarker = false;
308
309 while (curCol != e)
310 {
311 curCol++;
312 if (curCol == 'I')
313 curCol++;
314 if (curCol == 'O')
315 curCol++;
316 if (curCol > 'Z')
317 {
318 if (rewindMarker)
319 return kInvalidEastingNorthing;
320 curCol = 'A';
321 rewindMarker = true;
322 }
323 eastingValue += 100000;
324 }
325
326 return eastingValue;
327}
328
329/* Given the second letter from a two-letter MGRS 100k zone, and given the
330 * MGRS table set for the zone number, figure out the northing value that

Callers 1

MGRStoLatLonFunction · 0.85

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected