WSF
wsf::Terrain Class Reference

#include <WsfTerrain.hpp>

Classes

struct  Post

Public Types

enum  ElevationType { cINVALID , cTERRAIN , cVEGETATION , cBATHYMETRY }

Public Member Functions

 Terrain (TerrainInterface *aInterfacePtr)
 Terrain (const Terrain &aSrc)
Terrainoperator= (const Terrain &aRhs)=delete
 ~Terrain ()
bool Initialize (TerrainInterface *aInterfacePtr)
bool Initialize (WsfSimulation &aSimulation)
int GetElevApprox (double aLat, double aLon, float &aElev)
int GetElevApprox (const double aWCS[3], float &aElev)
int GetElevInterp (double aLat, double aLon, float &aElev)
int GetElevInterp (const double aWCS[3], float &aElev)
int GetVegElevApprox (double aLat, double aLon, float &aElev)
int GetVegElevInterp (double aLat, double aLon, float &aElev)
int GetBathymetryElevApprox (double aLat, double aLon, float &aElev)
int GetBathymetryElevInterp (double aLat, double aLon, float &aElev)
void GetNormalNED (double aLat, double aLon, double aNormal[3])
void GetNormalENU (double aLat, double aLon, double aNormal[3])
bool TerrainHitAlongLOS (const double aEyepointWCS[3], double aTerminusWCS[3])
bool IsEnabled ()
bool IsVegetationEnabled ()
bool IsBathymetryEnabled ()
bool MaskedByTerrain (double aLat1, double aLon1, double aAlt1, double aLat2, double aLon2, double aAlt2, double aMaxRange, double aRadiusScale=1.0)
bool MaskedByTerrainFast (double aLat1, double aLon1, double aAlt1, double aLat2, double aLon2, double aAlt2, double aMaxRange)
bool MaskedByVegetation (double aLat1, double aLon1, double aAlt1, double aLat2, double aLon2, double aAlt2, double aMaxRange, double aRadiusScale=1.0)
bool MaskedByVegetationFast (double aLat1, double aLon1, double aAlt1, double aLat2, double aLon2, double aAlt2, double aMaxRange)
bool GetHeightExtremaIn (WsfSimulation &aSimulation, WsfZone *aZonePtr, Post &aMin, Post &aMax)
bool GetHeightExtremaIn (WsfSimulation &aSimulation, double aLatSouth, double aLonWest, double aLatNorth, double aLonEast, Post &aMin, Post &aMax, WsfZone *aZonePtr=nullptr)
bool IsGeodeticDatabase ()
bool DTEDTypeDatabase ()

Protected Member Functions

GeoElevationTile * GetTilePtr ()
GeoElevationTileManager & GetManager ()
bool LoadTile (double aLat, double aLon)
bool ComputeTerrainImpactP (double aLocationWCS_1[3], double aLocationWCS_2[3], bool aFirstPass=false)

Friends

class TerrainInterface

Detailed Description

Implements the terrain database and query operations.

This class provides the following major functions:

  • To get the height of the terrain at a location.
  • To get the unit normal vector to the terrain at a location.
  • To get vegetation information over a particular location.
  • To determine if the line of sight between two objects is masked by the terrain.
  • To determine height extrema (min, max) within a (LatA, LatB, LonA, LonB) rectangle.

An instance of a Terrain object provides the context in which to perform the first two operations. The object maintains a concept of a 'current tile', which represents the tile that contains the latitude and longitude involved in the last query operation. When a query is performed the object will determine if the current tile is the correct tile and if not, load the correct tile and then perform the requested query. Typically a simulation object (mover, sensor, etc) instantiates a Terrain object and makes queries on the object as it moves along. Therefore, the Terrain object only needs to switch tiles when the owning object crosses a tile boundary.

The terrain masking and height extrema checks are static methods.

The class maintains static data that represents the terrain database. The query methods reference this database to get their terrain data. Note that tiles are shared between Terrain objects through a reference counting mechanism. Thus, only a single instance of a specific tile will actually exist in memory.

Member Enumeration Documentation

◆ ElevationType

Enumerator
cINVALID 
cTERRAIN 
cVEGETATION 
cBATHYMETRY 

Constructor & Destructor Documentation

◆ Terrain() [1/2]

wsf::Terrain::Terrain ( TerrainInterface * aInterfacePtr)

References TerrainInterface.

Referenced by operator=(), and Terrain().

◆ Terrain() [2/2]

wsf::Terrain::Terrain ( const Terrain & aSrc)

Copy constructor. If the source object has a tile loaded then the new object will load the same tile.

References Terrain().

◆ ~Terrain()

wsf::Terrain::~Terrain ( )

Delete a terrain object.

The current tile (if any) is unloaded.

Member Function Documentation

◆ ComputeTerrainImpactP()

bool wsf::Terrain::ComputeTerrainImpactP ( double aLocationWCS_1[3],
double aLocationWCS_2[3],
bool aFirstPass = false )
protected

Computes terrain impact between two LOS points (Recursive).

Parameters
aLocationWCS_1WCS location of point 1
aLocationWCS_2WCS location of point 2
aFirstPassSet to true if first pass (default = false)
Returns
'true' if image center calculation is complete or 'false' if not.

References ComputeTerrainImpactP(), and MaskedByTerrain().

Referenced by ComputeTerrainImpactP(), and TerrainHitAlongLOS().

◆ DTEDTypeDatabase()

bool wsf::Terrain::DTEDTypeDatabase ( )
inline

◆ GetBathymetryElevApprox()

int wsf::Terrain::GetBathymetryElevApprox ( double aLat,
double aLon,
float & aElev )

Get the bathymetry depth at the closest sample point.

Parameters
aLatLatitude in the range [-90, 90]
aLonLongitude in the range [-180, 180]
aElev[output] The terrain elevation at the point. This will be 0 if there is no terrain in for the requested point or if terrain processing has been disabled. Positive is up.
Returns
0 if the requested location is in the current tile (or if there is no terrain) or non-zero if a tile switch was required.

Referenced by operator=(), and UT_DEFINE_SCRIPT_METHOD().

◆ GetBathymetryElevInterp()

int wsf::Terrain::GetBathymetryElevInterp ( double aLat,
double aLon,
float & aElev )

Get the bathymetry depth by interpolating from the bounding sample points.

The terrain height is determined by performing bi-linear interpolation using the four corner points of the cell that contains the requested point.

Parameters
aLatLatitude in the range [-90, 90]
aLonLongitude in the range [-180, 180]
aElev[output] The terrain elevation at the point. This will be 0 if there is no terrain in for the requested point or if terrain processing has been disabled (or if at sea level). Positive is up.
Returns
0 if the requested location is in the current tile (or if there is no terrain) or non-zero if a tile switch was required.

Referenced by wsf::TerrainInterface::MaskedByTerrainP(), and operator=().

◆ GetElevApprox() [1/2]

int wsf::Terrain::GetElevApprox ( const double aWCS[3],
float & aElev )

Get the terrain height at the closest sample point.

Parameters
aWCSWCS location of the point
aElev[output] The terrain height at the point. This will be 0 if there is no terrain in for the requested point or if terrain processing has been disabled.
Returns
0 if the requested location is in the current tile (or if there is no terrain) or non-zero if a tile switch was required.

References GetElevApprox().

◆ GetElevApprox() [2/2]

int wsf::Terrain::GetElevApprox ( double aLat,
double aLon,
float & aElev )

Get the terrain height at the closest sample point.

Parameters
aLatLatitude in the range [-90, 90]
aLonLongitude in the range [-180, 180]
aElev[output] The terrain height at the point. This will be 0 if there is no terrain in for the requested point or if terrain processing has been disabled.
Returns
0 if the requested location is in the current tile (or if there is no terrain) or non-zero if a tile switch was required.

Referenced by WsfTRIMSIM_SensorComponent::CorrectForAltitude(), WsfNavigationMesh::DebugDrawMesh(), WsfEM_ALARM_Terrain::get_cell_height_deg(), GetElevApprox(), WsfTerrainPathFinder::Initialize(), operator=(), wsf::TerrainInterface::PerformQueries(), and WsfWeaponServer::ProcessCommand().

◆ GetElevInterp() [1/2]

int wsf::Terrain::GetElevInterp ( const double aWCS[3],
float & aElev )

Get the terrain height by interpolating from the bounding sample points.

The terrain height is determined by performing bi-linear interpolation using the four corner points of the cell that contains the requested point.

Parameters
aWCSWCS location of the point
aElev[output] The terrain height at the point. This will be 0 if there is no terrain in for the requested point or if terrain processing has been disabled (or if at sea level).
Returns
0 if the requested location is in the current tile (or if there is no terrain) or non-zero if a tile switch was required.

References GetElevInterp().

◆ GetElevInterp() [2/2]

int wsf::Terrain::GetElevInterp ( double aLat,
double aLon,
float & aElev )

Get the terrain height by interpolating from the bounding sample points.

The terrain height is determined by performing bi-linear interpolation using the four corner points of the cell that contains the requested point.

Parameters
aLatLatitude in the range [-90, 90]
aLonLongitude in the range [-180, 180]
aElev[output] The terrain height at the point. This will be 0 if there is no terrain in for the requested point or if terrain processing has been disabled (or if at sea level).
Returns
0 if the requested location is in the current tile (or if there is no terrain) or non-zero if a tile switch was required.

Referenced by HorizontalMapFunction::BuildContours(), WsfPlatform::CompleteLoad(), WsfTBM_Mover::ComputeTargetError(), wsf::coverage::RectangularGrid::CreateRectangularGrid(), ClutterTableFunction::Execute(), FlightPathAnalysisFunction::Execute(), GetElevInterp(), WsfWeapon::GetTargetLocationWCS(), WsfFalseTarget::Initialize(), WsfTBM_Mover::Initialize(), WsfTBM_Mover::Initialize2(), WsfRotorcraftMover::LocalUpdate(), wsf::TerrainInterface::MaskedByTerrainP(), operator=(), wsf::TerrainInterface::PerformQueries(), wsf::altloc::Component::PreInitialize(), WsfTrack::ProcessInputBlock(), WsfParabolicMover::SetImpactTOFAndLL(), WsfGuidedMoverBase::Update(), UT_DEFINE_SCRIPT_METHOD(), UT_DEFINE_SCRIPT_METHOD(), UT_DEFINE_SCRIPT_METHOD(), UT_DEFINE_SCRIPT_METHOD(), UT_DEFINE_SCRIPT_METHOD(), UT_DEFINE_SCRIPT_METHOD(), UT_DEFINE_SCRIPT_METHOD(), wsf::coverage::Grid::WriteGridDataFile(), and WsfParabolicMover::~WsfParabolicMover().

◆ GetHeightExtremaIn() [1/2]

bool wsf::Terrain::GetHeightExtremaIn ( WsfSimulation & aSimulation,
double aLatSouth,
double aLonWest,
double aLatNorth,
double aLonEast,
Post & aMin,
Post & aMax,
WsfZone * aZonePtr = nullptr )

Compute height extrema within a range of (Lat, Lon) tiles. Optional WsfZoneReference will ignore any terrain outside the zone (if pointer is non-zero). CAUTION: This function is CPU and memory-intensive, and is NOT recommended for real-time use, due to danger of overframing!

Parameters
aSimulationThe Simulation
aLatSouthLatitude of the south western edge of the rectangle [-90, 90].
aLonWestLongitude of the south western edge of the rectangle [-180, 180].
aLatNorthLatitude of the north eastern edge of the rectangle [-90, 90].
aLonEastLongitude of the south eastern edge of the rectangle [-180, 180].
aMinReturned (Lat, Lon) and Height of lowest terrain sample.
aMaxReturned (Lat, Lon) and Height of highest terrain sample.
aZonePtr(Optional) The zone will be checked for IsInside() at (lat, lon) before use of this sample.

References GetManager(), WsfDtedRect::GetNELat(), WsfDtedRect::GetNELon(), WsfDtedRect::GetSWLat(), WsfDtedRect::GetSWLon(), WsfDtedRect::GetTile(), WsfDtedRect::GetTileCount(), WsfZone::IsInitialized(), wsf::Terrain::Post::mHeightM, wsf::Terrain::Post::mLatDeg, wsf::Terrain::Post::mLonDeg, WsfZone::PointIsInside(), and success.

◆ GetHeightExtremaIn() [2/2]

bool wsf::Terrain::GetHeightExtremaIn ( WsfSimulation & aSimulation,
WsfZone * aZonePtr,
Post & aMin,
Post & aMax )

Compute height extrema within a polygonal (Lat, Lon)-defined zone. CAUTION: This function is CPU and memory-intensive, and is NOT recommended for real-time use, due to danger of overframing.

Parameters
aSimulationThe Simulation
aZonePtrThe zone region to check for extrema.
aMinReturned (Lat, Lon) and Height of lowest terrain sample.
aMaxReturned (Lat, Lon) and Height of highest terrain sample.

References GetHeightExtremaIn(), and WsfZone::GetLatLonExtrema().

Referenced by GetHeightExtremaIn(), and wsf::TerrainInterface::PerformQueries().

◆ GetManager()

GeoElevationTileManager & wsf::Terrain::GetManager ( )
protected

◆ GetNormalENU()

void wsf::Terrain::GetNormalENU ( double aLat,
double aLon,
double aNormal[3] )
inline

◆ GetNormalNED()

void wsf::Terrain::GetNormalNED ( double aLat,
double aLon,
double aNormal[3] )
inline

◆ GetTilePtr()

GeoElevationTile * wsf::Terrain::GetTilePtr ( )
inlineprotected

◆ GetVegElevApprox()

int wsf::Terrain::GetVegElevApprox ( double aLat,
double aLon,
float & aElev )

Get the vegetation layer height at the closest sample point.

Parameters
aLatLatitude in the range [-90, 90]
aLonLongitude in the range [-180, 180]
aElev[output] The terrain height at the point. This will be 0 if there is no terrain in for the requested point or if terrain processing has been disabled.
Returns
0 if the requested location is in the current tile (or if there is no terrain) or non-zero if a tile switch was required.

Referenced by operator=().

◆ GetVegElevInterp()

int wsf::Terrain::GetVegElevInterp ( double aLat,
double aLon,
float & aElev )

Get the vegetation layer height by interpolating from the bounding sample points.

The terrain height is determined by performing bi-linear interpolation using the four corner points of the cell that contains the requested point.

Parameters
aLatLatitude in the range [-90, 90]
aLonLongitude in the range [-180, 180]
aElev[output] The terrain height at the point. This will be 0 if there is no terrain in for the requested point or if terrain processing has been disabled (or if at sea level).
Returns
0 if the requested location is in the current tile (or if there is no terrain) or non-zero if a tile switch was required.

Referenced by operator=().

◆ Initialize() [1/2]

bool wsf::Terrain::Initialize ( TerrainInterface * aInterfacePtr)

References TerrainInterface.

Referenced by Initialize(), and operator=().

◆ Initialize() [2/2]

bool wsf::Terrain::Initialize ( WsfSimulation & aSimulation)

◆ IsBathymetryEnabled()

bool wsf::Terrain::IsBathymetryEnabled ( )
inline

◆ IsEnabled()

bool wsf::Terrain::IsEnabled ( )
inline

Is terrain enabled? This can be used by a caller to bypass expensive terrain-related calls if terrain is not available.

Returns
'true' if enabled or 'false' if not.

Referenced by WsfTRIMSIM_SensorComponent::CorrectForAltitude(), ClutterTableFunction::Execute(), WsfEM_ALARM_Terrain::Initialize(), and WsfWeaponServer::ProcessCommand().

◆ IsGeodeticDatabase()

bool wsf::Terrain::IsGeodeticDatabase ( )
inline

◆ IsVegetationEnabled()

bool wsf::Terrain::IsVegetationEnabled ( )
inline

◆ LoadTile()

bool wsf::Terrain::LoadTile ( double aLat,
double aLon )
inlineprotected

◆ MaskedByTerrain()

bool wsf::Terrain::MaskedByTerrain ( double aLat1,
double aLon1,
double aAlt1,
double aLat2,
double aLon2,
double aAlt2,
double aMaxRange,
double aRadiusScale = 1.0 )

Is the line of sight between two points masked by the terrain?

Parameters
aLat1Latitude of the first point [-90, 90]
aLon1Longitude of the first point [-180, 180]
aAlt1Altitude MSL of the first point.
aLat2Latitude of the second point [-90, 90]
aLon2Longitude of the second point [-180, 180]
aAlt2Altitude MSL of the second point.
aMaxRangeDistance at which to stop checking.
aRadiusScaleEffective earth radius multiplier (default = 1.0)
Returns
'true' if masked by terrain or 'false' if not.

Referenced by ComputeTerrainImpactP(), wsf::TerrainInterface::PerformQueries(), TerrainHitAlongLOS(), and WsfEM_ALARM_Terrain::visble2().

◆ MaskedByTerrainFast()

bool wsf::Terrain::MaskedByTerrainFast ( double aLat1,
double aLon1,
double aAlt1,
double aLat2,
double aLon2,
double aAlt2,
double aMaxRange )

Is the line of sight between two points masked by the terrain? This version varies the step size with height above terrain, but is only valid for an earth scale radius of 1.0.

Parameters
aLat1Latitude of the first point [-90, 90]
aLon1Longitude of the first point [-180, 180]
aAlt1Altitude MSL of the first point.
aLat2Latitude of the second point [-90, 90]
aLon2Longitude of the second point [-180, 180]
aAlt2Altitude MSL of the second point.
aMaxRangeDistance at which to stop checking.
Returns
'true' if masked by terrain or 'false' if not.

◆ MaskedByVegetation()

bool wsf::Terrain::MaskedByVegetation ( double aLat1,
double aLon1,
double aAlt1,
double aLat2,
double aLon2,
double aAlt2,
double aMaxRange,
double aRadiusScale = 1.0 )

Is the line of sight between two points masked by the vegetation layer?

Parameters
aLat1Latitude of the first point [-90, 90]
aLon1Longitude of the first point [-180, 180]
aAlt1Altitude MSL of the first point.
aLat2Latitude of the second point [-90, 90]
aLon2Longitude of the second point [-180, 180]
aAlt2Altitude MSL of the second point.
aMaxRangeDistance at which to stop checking.
aRadiusScaleEffective earth radius multiplier (default = 1.0)
Returns
'true' if masked by vegetation layer or 'false' if not.

◆ MaskedByVegetationFast()

bool wsf::Terrain::MaskedByVegetationFast ( double aLat1,
double aLon1,
double aAlt1,
double aLat2,
double aLon2,
double aAlt2,
double aMaxRange )

Is the line of sight between two points masked by the vegetation? This version varies the step size with height above vegetation, but is only valid for an earth scale radius of 1.0.

Parameters
aLat1Latitude of the first point [-90, 90]
aLon1Longitude of the first point [-180, 180]
aAlt1Altitude MSL of the first point.
aLat2Latitude of the second point [-90, 90]
aLon2Longitude of the second point [-180, 180]
aAlt2Altitude MSL of the second point.
aMaxRangeDistance at which to stop checking.
Returns
'true' if masked by vegetation or 'false' if not.

◆ operator=()

◆ TerrainHitAlongLOS()

bool wsf::Terrain::TerrainHitAlongLOS ( const double aEyepointWCS[3],
double aTerminusWCS[3] )

Get the terrain "pixel" along a line-of-sight ray. This algorithm is a brute force approach, and serves as a placeholder for a more elegant solution to come later (?). This will be a CPU- intensive operation. Algorithm will march outward from eyepoint to terminus, so please limit the maximum range as much as is possible. Does not include possible cloud occulting, use the WsfEnvironment for that, prior to using this function.

Parameters
aEyepointWCSEyepoint of the beginning of the LOS segment.
aTerminusWCSEndpoint of the LOS segment. Will be modified only if return value is true.
Returns
'true' If aTerminusWCS was moved closer to aEyepointWCS, to place at terrain intersect.

References ComputeTerrainImpactP(), and MaskedByTerrain().

◆ TerrainInterface

friend class TerrainInterface
friend

The documentation for this class was generated from the following files:
Copyrights Multiple, All Rights Reserved