A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ns3::GeographicPositions Class Reference

Consists of methods dealing with Earth geographic coordinates and locations. More...

#include "geographic-positions.h"

+ Collaboration diagram for ns3::GeographicPositions:

Public Types

enum  EarthSpheroidType { SPHERE , GRS80 , WGS84 }
 The possible Earth spheroid models. . More...
 

Static Public Member Functions

static Vector CartesianToGeographicCoordinates (Vector pos, EarthSpheroidType sphType)
 Inverse of GeographicToCartesianCoordinates using [1].
 
static Vector GeographicToCartesianCoordinates (double latitude, double longitude, double altitude, EarthSpheroidType sphType)
 Converts earth geographic/geodetic coordinates (latitude and longitude in degrees) with a given altitude above earth's surface (in meters) to Earth Centered Earth Fixed (ECEF) Cartesian coordinates (x, y, z in meters), where origin (0, 0, 0) is the center of the earth.
 
static Vector GeographicToTopocentricCoordinates (Vector pos, Vector refPoint, EarthSpheroidType sphType)
 Conversion from geographic to topocentric coordinates.
 
static std::tuple< double, double, doubleGetRadiusEccentFlat (EarthSpheroidType type)
 
static std::list< Vector > RandCartesianPointsAroundGeographicPoint (double originLatitude, double originLongitude, double maxAltitude, int numPoints, double maxDistFromOrigin, Ptr< UniformRandomVariable > uniRand)
 Generates uniformly distributed random points (in ECEF Cartesian coordinates) within a given altitude above earth's surface centered around a given origin point (on earth's surface, in geographic/geodetic coordinates) within a given distance radius (using arc length of earth's surface, not pythagorean distance).
 
static Vector TopocentricToGeographicCoordinates (Vector pos, Vector refPoint, EarthSpheroidType sphType)
 Conversion from topocentric to geographic.
 

Static Public Attributes

static constexpr double EARTH_GRS80_ECCENTRICITY = 0.0818191910428158
 Earth's first eccentricity as defined by GRS80 https://en.wikipedia.org/wiki/Geodetic_Reference_System_1980.
 
static constexpr double EARTH_GRS80_FLATTENING = 0.003352810681183637418
 Earth's first flattening as defined by GRS80 https://en.wikipedia.org/wiki/Geodetic_Reference_System_1980.
 
static constexpr double EARTH_SEMIMAJOR_AXIS = 6378137
 <Earth's semi-major axis in meters as defined by both GRS80 and WGS84 https://en.wikipedia.org/wiki/World_Geodetic_System
 
static constexpr double EARTH_SPHERE_ECCENTRICITY = 0
 Earth's eccentricity if modeled as a perfect sphere.
 
static constexpr double EARTH_SPHERE_FLATTENING = 0
 Earth's flattening if modeled as a perfect sphere.
 
static constexpr double EARTH_SPHERE_RADIUS = 6371e3
 Spheroid model to use for earth: perfect sphere (SPHERE), Geodetic Reference System 1980 (GRS80), or World Geodetic System 1984 (WGS84)
 
static constexpr double EARTH_WGS84_ECCENTRICITY = 0.0818191908426215
 Earth's first eccentricity as defined by https://en.wikipedia.org/wiki/World_Geodetic_System#WGS84.
 
static constexpr double EARTH_WGS84_FLATTENING = 0.00335281
 Earth's first flattening as defined by WGS84 https://en.wikipedia.org/wiki/World_Geodetic_System#WGS84.
 

Detailed Description

Consists of methods dealing with Earth geographic coordinates and locations.

Definition at line 34 of file geographic-positions.h.

Member Enumeration Documentation

◆ EarthSpheroidType

The possible Earth spheroid models. .

Enumerator
SPHERE 
GRS80 
WGS84 

Definition at line 79 of file geographic-positions.h.

Member Function Documentation

◆ CartesianToGeographicCoordinates()

Vector ns3::GeographicPositions::CartesianToGeographicCoordinates ( Vector  pos,
EarthSpheroidType  sphType 
)
static

Inverse of GeographicToCartesianCoordinates using [1].

This function iteratively converts cartesian (ECEF) coordinates to geographic coordinates. The residual delta is 1 m, which is approximately 1 / 30 arc seconds or 9.26e-6 deg.

Parameters
posa vector representing the Cartesian coordinates (x, y, z referenced in meters) of the point (origin (0, 0, 0) is center of earth)
sphTypeearth spheroid model to use for conversion
Returns
Vector position where x = latitude (deg), y = longitude (deg), z = altitude above the ellipsoid (m)

[1] "Ellipsoidal and Cartesian Coordinates Conversion", Navipedia, European Space Agency, Jul 8, 2019. https://gssc.esa.int/navipedia/index.php/Ellipsoidal_and_Cartesian_Coordinates_Conversion

Definition at line 73 of file geographic-positions.cc.

References ns3::CalculateDistance(), ns3::DegreesToRadians(), GetRadiusEccentFlat(), NS_ASSERT_MSG, NS_LOG_FUNCTION, and ns3::RadiansToDegrees().

Referenced by CartesianToGeoTestCase::DoRun(), and ns3::GeocentricConstantPositionMobilityModel::DoSetGeocentricPosition().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GeographicToCartesianCoordinates()

Vector ns3::GeographicPositions::GeographicToCartesianCoordinates ( double  latitude,
double  longitude,
double  altitude,
EarthSpheroidType  sphType 
)
static

Converts earth geographic/geodetic coordinates (latitude and longitude in degrees) with a given altitude above earth's surface (in meters) to Earth Centered Earth Fixed (ECEF) Cartesian coordinates (x, y, z in meters), where origin (0, 0, 0) is the center of the earth.

Parameters
latitudeearth-referenced latitude (in degrees) of the point
longitudeearth-referenced longitude (in degrees) of the point
altitudeheight of the point (in meters) above earth's surface
sphTypeearth spheroid model to use for conversion
Returns
a vector representing the Cartesian coordinates (x, y, z referenced in meters) of the point (origin (0, 0, 0) is center of earth)

Definition at line 52 of file geographic-positions.cc.

References ns3::DegreesToRadians(), GetRadiusEccentFlat(), and NS_LOG_FUNCTION_NOARGS.

Referenced by ns3::GeocentricConstantPositionMobilityModel::DoGetDistanceFrom(), ns3::GeocentricConstantPositionMobilityModel::DoGetGeocentricPosition(), GeoToCartesianTestCase::DoRun(), CartesianToGeoTestCase::DoRun(), RandCartAroundGeoTestCase::DoRun(), and RandCartesianPointsAroundGeographicPoint().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GeographicToTopocentricCoordinates()

Vector ns3::GeographicPositions::GeographicToTopocentricCoordinates ( Vector  pos,
Vector  refPoint,
EarthSpheroidType  sphType 
)
static

Conversion from geographic to topocentric coordinates.

Conversion formulas taken from [1, Sec. 4.1.3 "Geographic/topocentric conversions"]. [1] IOGP. Geomatics guidance note 7, part 2: coordinate conversions & transformations including formulas. IOGP Publication 373-7-2, International Association For Oil And Gas Producers, Sep. 2019 https://www.iogp.org/bookstore/product/coordinate-conversions-and-transformation-including-formulas/

Parameters
posa vector representing the Geographic coordinates (latitude, longitude, altitude) in degrees (lat/lon) and meters (altitude).
refPointa vector representing the reference point (latitude, longitude, altitude) in degrees (lat/lon) and meters (altitude). Default is (0,0,0)
sphTypeearth spheroid model to use for conversion
Returns
Vector position in meters and using planar Cartesian coordinates, i.e., ns-3's defaults

Definition at line 130 of file geographic-positions.cc.

References ns3::DegreesToRadians(), GetRadiusEccentFlat(), and NS_LOG_FUNCTION.

Referenced by ns3::GeocentricConstantPositionMobilityModel::DoGetPosition(), and GeoToAndFromTopocentricTestCase::TestReferencePoint().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetRadiusEccentFlat()

std::tuple< double, double, double > ns3::GeographicPositions::GetRadiusEccentFlat ( EarthSpheroidType  type)
static
Parameters
typethe type of model which is used to model the Earth
Returns
the corresponding radius (in meters), first eccentricity and first flattening values

Definition at line 299 of file geographic-positions.cc.

References EARTH_GRS80_ECCENTRICITY, EARTH_GRS80_FLATTENING, EARTH_SEMIMAJOR_AXIS, EARTH_SPHERE_ECCENTRICITY, EARTH_SPHERE_FLATTENING, EARTH_SPHERE_RADIUS, EARTH_WGS84_ECCENTRICITY, EARTH_WGS84_FLATTENING, GRS80, NS_FATAL_ERROR, SPHERE, and WGS84.

Referenced by CartesianToGeographicCoordinates(), GeographicToCartesianCoordinates(), GeographicToTopocentricCoordinates(), and TopocentricToGeographicCoordinates().

+ Here is the caller graph for this function:

◆ RandCartesianPointsAroundGeographicPoint()

std::list< Vector > ns3::GeographicPositions::RandCartesianPointsAroundGeographicPoint ( double  originLatitude,
double  originLongitude,
double  maxAltitude,
int  numPoints,
double  maxDistFromOrigin,
Ptr< UniformRandomVariable uniRand 
)
static

Generates uniformly distributed random points (in ECEF Cartesian coordinates) within a given altitude above earth's surface centered around a given origin point (on earth's surface, in geographic/geodetic coordinates) within a given distance radius (using arc length of earth's surface, not pythagorean distance).

Distance radius is measured as if all generated points are on earth's surface (with altitude = 0). Assumes earth is a perfect sphere.

Parameters
originLatitudeorigin point latitude in degrees
originLongitudeorigin point longitude in degrees
maxAltitudemaximum altitude in meters above earth's surface with which random points can be generated
numPointsnumber of points to generate
maxDistFromOriginmax distance in meters from origin with which random transmitters can be generated (all transmitters are less than or equal to this distance from the origin, relative to points being on earth's surface)
uniRandpointer to the uniform random variable to use for random location and altitude generation
Returns
a list containing the vectors (x, y, z location referenced in meters from origin at center of earth) of each point generated

Definition at line 208 of file geographic-positions.cc.

References ns3::DegreesToRadians(), EARTH_SPHERE_RADIUS, GeographicToCartesianCoordinates(), NS_LOG_FUNCTION_NOARGS, NS_LOG_WARN, ns3::RadiansToDegrees(), and SPHERE.

Referenced by ns3::TvSpectrumTransmitterHelper::CreateRegionalTvTransmitters(), and RandCartAroundGeoTestCase::DoRun().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ TopocentricToGeographicCoordinates()

Vector ns3::GeographicPositions::TopocentricToGeographicCoordinates ( Vector  pos,
Vector  refPoint,
EarthSpheroidType  sphType 
)
static

Conversion from topocentric to geographic.

Conversion formulas taken from [1, Sec. 4.1.3 "Geographic/topocentric conversions"]. [1] IOGP. Geomatics guidance note 7, part 2: coordinate conversions & transformations including formulas. IOGP Publication 373-7-2, International Association For Oil And Gas Producers, Sep. 2019 https://www.iogp.org/bookstore/product/coordinate-conversions-and-transformation-including-formulas/

Parameters
posa vector representing the topocentric coordinates (u, v, w) in meters, which represent the cartesian coordinates along the xEast, yNorth and zUp axes, respectively..
refPointa vector representing the reference point (latitude, longitude, altitude) in degrees (lat/lon) and meters (altitude). Default is (0,0,0)
sphTypeearth spheroid model to use for conversion
Returns
Vector position (latitude, longitude, altitude) in degrees (lat/lon) and meters (altitude) converted to geographic coordinates

Definition at line 162 of file geographic-positions.cc.

References ns3::DegreesToRadians(), epsilon, GetRadiusEccentFlat(), NS_LOG_FUNCTION, and ns3::RadiansToDegrees().

Referenced by ns3::GeocentricConstantPositionMobilityModel::DoSetPosition(), and GeoToAndFromTopocentricTestCase::TestReferencePoint().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ EARTH_GRS80_ECCENTRICITY

constexpr double ns3::GeographicPositions::EARTH_GRS80_ECCENTRICITY = 0.0818191910428158
staticconstexpr

Earth's first eccentricity as defined by GRS80 https://en.wikipedia.org/wiki/Geodetic_Reference_System_1980.

Definition at line 64 of file geographic-positions.h.

Referenced by GetRadiusEccentFlat().

◆ EARTH_GRS80_FLATTENING

constexpr double ns3::GeographicPositions::EARTH_GRS80_FLATTENING = 0.003352810681183637418
staticconstexpr

Earth's first flattening as defined by GRS80 https://en.wikipedia.org/wiki/Geodetic_Reference_System_1980.

Definition at line 68 of file geographic-positions.h.

Referenced by GetRadiusEccentFlat().

◆ EARTH_SEMIMAJOR_AXIS

constexpr double ns3::GeographicPositions::EARTH_SEMIMAJOR_AXIS = 6378137
staticconstexpr

<Earth's semi-major axis in meters as defined by both GRS80 and WGS84 https://en.wikipedia.org/wiki/World_Geodetic_System

Definition at line 60 of file geographic-positions.h.

Referenced by GetRadiusEccentFlat().

◆ EARTH_SPHERE_ECCENTRICITY

constexpr double ns3::GeographicPositions::EARTH_SPHERE_ECCENTRICITY = 0
staticconstexpr

Earth's eccentricity if modeled as a perfect sphere.

Definition at line 53 of file geographic-positions.h.

Referenced by GetRadiusEccentFlat().

◆ EARTH_SPHERE_FLATTENING

constexpr double ns3::GeographicPositions::EARTH_SPHERE_FLATTENING = 0
staticconstexpr

Earth's flattening if modeled as a perfect sphere.

Definition at line 56 of file geographic-positions.h.

Referenced by GetRadiusEccentFlat().

◆ EARTH_SPHERE_RADIUS

constexpr double ns3::GeographicPositions::EARTH_SPHERE_RADIUS = 6371e3
staticconstexpr

Spheroid model to use for earth: perfect sphere (SPHERE), Geodetic Reference System 1980 (GRS80), or World Geodetic System 1984 (WGS84)

Moritz, H. "Geodetic Reference System 1980." GEODETIC REFERENCE SYSTEM 1980. https://web.archive.org/web/20170712034716/http://www.gfy.ku.dk/~iag/HB2000/part4/grs80_corr.htm.

"Department of Defense World Geodetic System 1984." National Imagery and Mapping Agency, 1 Jan. 2000. https://web.archive.org/web/20200729203634/https://earth-info.nga.mil/GandG/publications/tr8350.2/wgs84fin.pdf. Earth's radius in meters if modeled as a perfect sphere

Definition at line 50 of file geographic-positions.h.

Referenced by GetRadiusEccentFlat(), and RandCartesianPointsAroundGeographicPoint().

◆ EARTH_WGS84_ECCENTRICITY

constexpr double ns3::GeographicPositions::EARTH_WGS84_ECCENTRICITY = 0.0818191908426215
staticconstexpr

Earth's first eccentricity as defined by https://en.wikipedia.org/wiki/World_Geodetic_System#WGS84.

Definition at line 72 of file geographic-positions.h.

Referenced by GetRadiusEccentFlat().

◆ EARTH_WGS84_FLATTENING

constexpr double ns3::GeographicPositions::EARTH_WGS84_FLATTENING = 0.00335281
staticconstexpr

Earth's first flattening as defined by WGS84 https://en.wikipedia.org/wiki/World_Geodetic_System#WGS84.

Definition at line 76 of file geographic-positions.h.

Referenced by GetRadiusEccentFlat().


The documentation for this class was generated from the following files: