mirror of
https://gitlab.ibr.cs.tu-bs.de/tschuber/ns-3-leo.git
synced 2025-06-08 01:53:58 +02:00
Add lat long conversion
This commit is contained in:
parent
b7f459e36a
commit
70c70a19ce
8 changed files with 171 additions and 16 deletions
|
@ -1,5 +1,7 @@
|
|||
#include <fstream>
|
||||
|
||||
#include "math.h"
|
||||
|
||||
#include "ns3/log.h"
|
||||
#include "ns3/config.h"
|
||||
#include "ns3/waypoint.h"
|
||||
|
@ -52,4 +54,39 @@ LeoGndNodeHelper::Install (const std::string &wpFile)
|
|||
return nodes;
|
||||
}
|
||||
|
||||
Vector3D
|
||||
LeoGndNodeHelper::GetEarthPosition (const LeoLatLong &loc)
|
||||
{
|
||||
double lat = loc.latitude * (M_PI / 90);
|
||||
double lon = loc.longitude * (M_PI / 180);
|
||||
Vector3D pos = Vector3D (LEO_GND_RAD_EARTH * sin (lat) * cos (lon),
|
||||
LEO_GND_RAD_EARTH * sin (lat) * sin (lon),
|
||||
LEO_GND_RAD_EARTH * cos (lat));
|
||||
return pos;
|
||||
}
|
||||
|
||||
NodeContainer
|
||||
LeoGndNodeHelper::Install (const LeoLatLong &location1,
|
||||
const LeoLatLong &location2)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << location1 << location2);
|
||||
|
||||
NodeContainer nodes;
|
||||
|
||||
for (const LeoLatLong loc : { location1, location2 })
|
||||
{
|
||||
Vector pos = GetEarthPosition (loc);
|
||||
Ptr<ConstantPositionMobilityModel> mob = CreateObject<ConstantPositionMobilityModel> ();
|
||||
mob->SetPosition (pos);
|
||||
Ptr<Node> node = m_gndNodeFactory.Create<Node> ();
|
||||
node->AggregateObject (mob);
|
||||
nodes.Add (node);
|
||||
NS_LOG_INFO ("Added ground node at " << pos);
|
||||
}
|
||||
|
||||
NS_LOG_INFO ("Added " << nodes.GetN () << " ground nodes");
|
||||
|
||||
return nodes;
|
||||
}
|
||||
|
||||
}; // namespace ns3
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue