Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
LEFEBVREJP email
radix
Commits
118aa0ec
Commit
118aa0ec
authored
Apr 09, 2018
by
LEFEBVREJP email
Browse files
Adding UTM latitude zone hemisphere conversion.
parent
1c135f49
Changes
3
Hide whitespace changes
Inline
Side-by-side
radixgeo/coordinateconversion.cc
View file @
118aa0ec
#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
radixgeo/coordinateconversion.hh
View file @
118aa0ec
...
...
@@ -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
...
...
radixgeo/tests/tstCoordinateConversion.cc
View file @
118aa0ec
...
...
@@ -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'
));
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment