20 #include <ns3/geographic-positions.h>
77 double originLongitude,
80 double maxDistFromOrigin,
85 void DoRun()
override;
93 static std::string
Name(
double originLatitude,
94 double originLongitude,
95 double maxDistFromOrigin);
106 double originLongitude,
107 double maxDistFromOrigin)
109 std::ostringstream oss;
110 oss <<
"origin latitude = " << originLatitude <<
" degrees, "
111 <<
"origin longitude = " << originLongitude <<
" degrees, "
112 <<
"max distance from origin = " << maxDistFromOrigin;
117 double originLongitude,
120 double maxDistFromOrigin,
122 :
TestCase(
Name(originLatitude, originLongitude, maxDistFromOrigin)),
123 m_originLatitude(originLatitude),
124 m_originLongitude(originLongitude),
125 m_maxAltitude(maxAltitude),
126 m_numPoints(numPoints),
127 m_maxDistFromOrigin(maxDistFromOrigin),
139 std::list<Vector> points =
140 GeographicPositions::RandCartesianPointsAroundGeographicPoint(
m_originLatitude,
150 GeographicPositions::SPHERE);
152 while (!points.empty())
154 randPoint = points.front();
158 double straightDistFromOrigin =
159 sqrt(pow(randPoint.x - origin.x, 2) + pow(randPoint.y - origin.y, 2) +
160 pow(randPoint.z - origin.z, 2));
163 double arcDistFromOrigin =
168 "random point (" << randPoint.x <<
", " << randPoint.y <<
", "
170 <<
") is outside of max radius from origin");
186 :
TestSuite(
"rand-cart-around-geo", UNIT)
188 NS_LOG_INFO(
"creating RandCartAroundGeoTestSuite");
191 for (
double originLatitude = -89.9; originLatitude <= 89.9; originLatitude += 35.96)
193 for (
double originLongitude = 0; originLongitude <= 360; originLongitude += 72)
195 for (
double maxDistFromOrigin = 1000; maxDistFromOrigin <= 1000000;
196 maxDistFromOrigin *= 10)
Rand Cart Around Geo Test Case.
double m_maxAltitude
maximum altitude
void DoRun() override
Implementation to actually run this TestCase.
double m_originLongitude
origin longitude
double m_originLatitude
origin latitude
~RandCartAroundGeoTestCase() override
static std::string Name(double originLatitude, double originLongitude, double maxDistFromOrigin)
name function
RandCartAroundGeoTestCase(double originLatitude, double originLongitude, double maxAltitude, int numPoints, double maxDistFromOrigin, Ptr< UniformRandomVariable > uniRand)
Constructor.
int m_numPoints
number of points
double m_maxDistFromOrigin
maximum distance from origin
Ptr< UniformRandomVariable > m_uniRand
random number
Rand Cart Around Geo Test Suite.
RandCartAroundGeoTestSuite()
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
static RandCartAroundGeoTestSuite g_RandCartAroundGeoTestSuite
Static variable for test initialization.
#define NS_TEST_ASSERT_MSG_LT(actual, limit, msg)
Test that an actual value is less than a limit and report and abort if not.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static constexpr double EARTH_RADIUS
Earth's radius in meters if modeled as a perfect sphere.
static const double TOLERANCE
Tolerance used to check reciprocal of two numbers.
static const double EARTH_RADIUS
earth's radius in meters if modeled as a perfect sphere
const double TOLERANCE
0.1 meter tolerance for testing, which is very small compared to the maximum distances from origin be...
static std::string Name(std::string str, uint32_t totalStreamSize, uint32_t sourceWriteSize, uint32_t serverReadSize, uint32_t serverWriteSize, uint32_t sourceReadSize, bool useIpv6)