AGI STK Objects 11 Send comments on this topic.
GetAltitude Method (IAgCentralBodyTerrainCollectionElement)
See Also  Example
Lat
Lon
AltRef





Description

Returns the altitude at the specified position.

Syntax

[Visual Basic .NET]
Public Function GetAltitude( _
   ByVal Lat As System.Object, _
   ByVal Lon As System.Object, _
   ByVal AltRef As AgEAltRefType _
) As Double

[C#]
public double GetAltitude(
System.Object Lat,
System.Object Lon,
AgEAltRefType AltRef
);

[Managed C++]
public: double GetAltitude(
VARIANT Lat,
VARIANT Lon,
AgEAltRefType AltRef
);

[Java]
public double getAltitude(
Variant Lat,
Variant Lon,
AgEAltRefType AltRef
);

[Unmanaged C++]
public: HRESULT GetAltitude(
VARIANT Lat,
VARIANT Lon,
AgEAltRefType AltRef,
double * ReturnValue
);

Parameters

Lat
Lon
AltRef
Member Value Description
eMSL 0 Reference the altitude to Mean Sea Level.
eTerrain 1 Reference the altitude to terrain.
eWGS84 2 WGS84: reference the altitude to the central body's reference ellipsoid.
eEllipsoid 3 Ellipsoid: reference the altitude to the central body's reference ellipsoid(non-Earth).

Example

Gets the altitude of the terrain at a single location and in batches.
[C#] Copy Code
IAgScenario scneario = (IAgScenario)root.CurrentScenario; 
 
// If you haven't done so, add the terrain to your scenario (for example .PDTT) 
IAgCentralBodyTerrainCollectionElement earthTerrain = scneario.Terrain["Earth"]; 
earthTerrain.TerrainCollection.Add(terrainFile, AgETerrainFileType.ePDTTTerrainFile); 
 
// Get single altitude 
double altitude = earthTerrain.GetAltitude(latitude, longitude, AgEAltRefType.eMSL); 
 
// Get points in batches. 
Array specifiedPositions = new object[,] 

    { 40.0386, -75.5966 }, 
    { 28.5383, -81.3792 }, 
    { 37.7749, -122.4194 } 
}; 
 
Array altitudes = earthTerrain.GetAltitudeBatch(ref specifiedPositions, AgEAltRefType.eWGS84); 
 
// GetAltitudeBatch returns a one-dimensional array of altitude values in the distance unit perference. 
int numPoints = altitudes.GetLength(0); 
for (int i = 0; i < numPoints; ++i) 

    Console.WriteLine("Latitude={0}, Longitude={1}, Altitude={2}", specifiedPositions.GetValue(i, 0), specifiedPositions.GetValue(i, 1), altitudes.GetValue(i)); 

 

Gets the altitude of the terrain at a single location and in batches.
[Visual Basic .NET] Copy Code
Dim scneario As IAgScenario = DirectCast(root.CurrentScenario, IAgScenario)

' If you haven't done so, add the terrain to your scenario (for example .PDTT)
Dim earthTerrain As IAgCentralBodyTerrainCollectionElement = scneario.Terrain("Earth")
earthTerrain.TerrainCollection.Add(terrainFile, AgETerrainFileType.ePDTTTerrainFile)

' Get single altitude
Dim altitude As Double = earthTerrain.GetAltitude(latitude, longitude, AgEAltRefType.eMSL)

' Get points in batches.
#If Not CSToJava Then
#Else
#End If
Dim specifiedPositions As Array = New Object(,) {{40.0386, -75.5966}, {28.5383, -81.3792}, {37.7749, -122.4194}}

#If Not CSToJava Then
Dim altitudes As Array = earthTerrain.GetAltitudeBatch(specifiedPositions, AgEAltRefType.eWGS84)
#Else
#End If

' GetAltitudeBatch returns a one-dimensional array of altitude values in the distance unit perference.
Dim numPoints As Integer = altitudes.GetLength(0)
Dim i As Integer = 0
While i < numPoints
    Console.WriteLine("Latitude={0}, Longitude={1}, Altitude={2}", specifiedPositions.GetValue(i, 0), specifiedPositions.GetValue(i, 1), altitudes.GetValue(i))
    System.Threading.Interlocked.Increment(i)
End While

See Also

© 2016 Analytical Graphics, Inc. All Rights Reserved.

STK Programming Interface 11.0.1