Commit 118aa0ec authored by Lefebvre, Jordan's avatar Lefebvre, Jordan
Browse files

Adding UTM latitude zone hemisphere conversion.

parent 1c135f49
#include "radixgeo/coordinateconversion.hh"
#include <algorithm>
namespace radix
{
const std::array<char, 22> 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'};
{'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<short, 22> 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};
{-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<char, 11> CoordinateConversion::UTMZones::neg_letters = {
'A', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M'};
{'A', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M'}};
const std::array<short, 11> CoordinateConversion::UTMZones::neg_degrees = {
-90, -84, -72, -64, -56, -48, -40, -32, -24, -16, -8};
{-90, -84, -72, -64, -56, -48, -40, -32, -24, -16, -8}};
const std::array<char, 11> CoordinateConversion::UTMZones::pos_letters = {
'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Z'};
{'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Z'}};
const std::array<short, 11> CoordinateConversion::UTMZones::pos_degrees = {
0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 84};
{0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 84}};
const std::array<char, 11>
CoordinateConversion::UTM2LatLon::southern_hemisphere = {
{'A', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'L', 'L', 'M'}};
short CoordinateConversion::UTMZones::latZoneDegree(char letter)
{
auto itr = std::find(letters.begin(), letters.end(), letter);
......@@ -221,5 +224,20 @@ void CoordinateConversion::validate(double latitude, double longitude)
throw std::out_of_range(oss.str());
}
}
char CoordinateConversion::UTM2LatLon::hemisphere(char latitude_zone)
{
auto it = std::find(std::begin(southern_hemisphere),
std::end(southern_hemisphere), latitude_zone);
if (it == southern_hemisphere.end())
{
return 'N';
}
else
{
return 'S';
}
}
// UTMZones::latZone
} // namespace radix
\ No newline at end of file
......@@ -150,6 +150,14 @@ class RADIX_PUBLIC CoordinateConversion
UTMCoordinate toUTM(double latitude, double longitude);
}; // class LatLon2UTM
class RADIX_PUBLIC UTM2LatLon
{
private:
public:
static const std::array<char, 11> southern_hemisphere;
static char hemisphere(char latitude_zone);
}; // class UTM2LatLon
/**
* @brief validate Validates coordinate
* @param latitude latitude coordinate
......
......@@ -223,4 +223,13 @@ TEST(Radixgeo, LatLon2UTM)
EXPECT_EQ('S', utm.lattitude_zone);
EXPECT_EQ(585322, utm.easting);
EXPECT_EQ(4109888, utm.northing);
CoordinateConversion::UTMZones::latZoneDegree(utm.lattitude_zone);
}
TEST(Radixgeo, UTM2LatLon)
{
EXPECT_EQ('S', CoordinateConversion::UTM2LatLon::hemisphere('A'));
EXPECT_EQ('S', CoordinateConversion::UTM2LatLon::hemisphere('M'));
EXPECT_EQ('N', CoordinateConversion::UTM2LatLon::hemisphere('N'));
EXPECT_EQ('N', CoordinateConversion::UTM2LatLon::hemisphere('Z'));
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment