Commit 6a4e4ada authored by Lefebvre, Jordan's avatar Lefebvre, Jordan
Browse files

Starting CoordinateConversion class.

parent 16cd6b04
Pipeline #12880 passed with stages
in 9 minutes and 42 seconds
...@@ -8,6 +8,7 @@ TRIBITS_PACKAGE_DEFINE_DEPENDENCIES( ...@@ -8,6 +8,7 @@ TRIBITS_PACKAGE_DEFINE_DEPENDENCIES(
para radixpara SS OPTIONAL para radixpara SS OPTIONAL
command radixcommand SS OPTIONAL command radixcommand SS OPTIONAL
math radixmath SS OPTIONAL math radixmath SS OPTIONAL
geo radixgeo SS OPTIONAL
glls radixglls SS OPTIONAL glls radixglls SS OPTIONAL
io radixio SS OPTIONAL io radixio SS OPTIONAL
geometry radixgeometry SS OPTIONAL geometry radixgeometry SS OPTIONAL
......
TRIBITS_PACKAGE_DEFINE_DEPENDENCIES( TRIBITS_PACKAGE_DEFINE_DEPENDENCIES(
LIB_REQUIRED_PACKAGES radixcore radixbug LIB_REQUIRED_PACKAGES radixcore radixbug
LIB_OPTIONAL_PACKAGES LIB_OPTIONAL_PACKAGES
TEST_REQUIRED_PACKAGES TEST_REQUIRED_PACKAGES testframework googletest
TEST_OPTIONAL_PACKAGES TEST_OPTIONAL_PACKAGES
LIB_REQUIRED_TPLS LIB_REQUIRED_TPLS
LIB_OPTIONAL_TPLS LIB_OPTIONAL_TPLS
......
#include "radixgeo/coordinateconversion.hh"
namespace radix
{
} // namespace radix
\ No newline at end of file
#ifndef RADIX_RADIXGEO_COORDINATECONVERSION_HH_
#define RADIX_RADIXGEO_COORDINATECONVERSION_HH_
#include "radixcore/visibility.hh"
#include <sstream>
#include <stdexcept>
namespace radix
{
class RADIX_PUBLIC CoordinateConversion
{
public:
static void validate(double latitude, double longitude)
{
if (latitude < -90.0 || latitude > 90.0 || longitude < -180.0 ||
longitude >= 180.0)
{
std::ostringstream oss;
oss << "Invalid coordinate [" << latitude << "," << longitude
<< "].\nLatitude must be [-90.,90.] and longitude must be "
"[-180,180).";
throw std::out_of_range(oss.str());
}
}
}; // class CoordinateConversion
} // namespace radix
#endif /** RADIX_RADIXGEO_COORDINATECONVERSION_HH_ */
\ No newline at end of file
#include "gtest/gtest.h"
#include "radixcore/system.hh"
#include "radixgeo/coordinateconversion.hh"
#include <unordered_map>
#include <fstream>
using namespace radix;
TEST(Radixgeo, CoordinateRange)
{
try
{
CoordinateConversion::validate(-91, -179);
}
catch (std::out_of_range e)
{
std::string error_message(e.what());
EXPECT_EQ(
"Invalid coordinate [-91,-179].\nLatitude must be [-90.,90.] and "
"longitude must be "
"[-180,180).",
error_message);
}
}
TEST(Radixgeo, CoordinateConversion) {}
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