Commit 48629f4a by LEFEBVREJP email

Starting on UTMZones.

parent d25fe342
Pipeline #12887 failed with stages
in 4 minutes and 13 seconds
 #include "radixgeo/coordinateconversion.hh" #include namespace radix { const std::array CoordinateConversion::UTMZones::letters = { 'A', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Z'}; const std::array CoordinateConversion::UTMZones::degrees = { -90, -84, -72, -64, -56, -48, -40, -32, -24, -16, -8, 0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 84}; const std::array CoordinateConversion::UTMZones::neg_letters = { 'A', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M'}; const std::array CoordinateConversion::UTMZones::neg_degrees = { -90, -84, -72, -64, -56, -48, -40, -32, -24, -16, -8}; const std::array CoordinateConversion::UTMZones::pos_letters = { 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Z'}; const std::array CoordinateConversion::UTMZones::pos_degrees = { 0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 84}; short CoordinateConversion::UTMZones::latZoneDegree(char letter) { auto itr = std::find(letters.begin(), letters.end(), letter); if (itr == letters.end()) return -100; return *itr; } short CoordinateConversion::UTMZones::lonZone(double longitude) { double longZone = 0; if (longitude < 0.0) { longZone = ((180.0 + longitude) / 6) + 1; } else { longZone = (longitude / 6) + 31; } return short(longZone); } char CoordinateConversion::UTMZones::latZone(double latitude) { short latIndex = -2; short lat = short(latitude); if (lat >= 0) { size_t len = pos_letters.size(); for (size_t i = 0; i < len; i++) { if (lat == pos_degrees[i]) { latIndex = i; break; } if (lat > pos_degrees[i]) { continue; } else { latIndex = i - 1; break; } } } else { size_t len = neg_letters.size(); for (size_t i = 0; i < len; i++) { if (lat == neg_degrees[i]) { latIndex = i; break; } if (lat < neg_degrees[i]) { latIndex = i - 1; break; } else { continue; } } } if (latIndex == -1) { latIndex = 0; } if (lat >= 0) { if (latIndex == -2) { latIndex = pos_letters.size() - 1; } return pos_letters[latIndex]; } else { if (latIndex == -2) { latIndex = neg_letters.size() - 1; } return neg_letters[latIndex]; } } // UTMZones::latZone } // namespace radix \ No newline at end of file