Main Page   Class Hierarchy   Compound List   File List   Compound Members  

vtElevationGrid Class Reference

#include <ElevationGrid.h>

List of all members.

Public Methods

 vtElevationGrid ()
 vtElevationGrid (DRECT area,int iColumns,int iRows,bool bFloat,vtProjection proj)
 ~vtElevationGrid ()
bool ConvertProjection (vtElevationGrid *pOld,vtProjection &NewProj,void progress_callback(int)=NULL)
bool LoadFromDEM (const char *szFileName,void progress_callback(int)=NULL)
bool LoadFromASC (const char *szFileName,void progress_callback(int)=NULL)
bool LoadFromTerragen (const char *szFileName,void progress_callback(int)=NULL)
bool LoadFromCDF (const char *szFileName,void progress_callback(int)=NULL)
bool LoadFromDTED (const char *szFileName,void progress_callback(int)=NULL)
bool LoadFromGTOPO30 (const char *szFileName,void progress_callback(int)=NULL)
bool LoadFromGRD (const char *szFileName,void progress_callback(int)=NULL)
bool LoadFromPGM (const char *szFileName,void progress_callback(int)=NULL)
bool LoadFromRAW (const char *szFileName,int width,int height,int bytes_per_element,float vertical_units)
bool LoadFromBT (const char *szFileName,void progress_callback(int)=NULL)
bool LoadBTHeader (FILE *fp)
bool LoadWithGDAL (const char *szFileName,void progress_callback(int))
void SaveToTerragen (FILE *fp)
void SaveToBT (FILE *fp)
void ComputeHeightExtents ()
void GetHeightExtents (float &fMinHeight,float &fMaxHeight)
void GetDimensions (int &nColumns,int &nRows)
DPoint2 GetSpacing ()
bool ContainsPoint (float x,float y)
void SetFValue (int i,int j,float value)
void SetValue (int i,int j,short value)
int GetValue (int i,int j)
float GetFValue (int i,int j)
float GetClosestValue (double x,double y)
float GetFilteredValue (double x,double y)
char* GetDEMName ()
DRECT& GetGridExtents ()
DRECT GetAreaExtents ()
void SetGridExtents (DRECT &ext)
bool IsFloatMode ()
void ColorDibFromElevation1 (vtDIB *pDIB,RGBi color_ocean)
vtProjectionGetProjection ()
void GetCorners (DLine2 &line,bool bGeo)
void SetCorners (DLine2 &line)

Protected Methods

void ComputeExtentsFromCorners ()
void ComputeCornersFromExtents ()

Protected Attributes

DRECT m_area
int m_iColumns
int m_iRows
bool m_bFloatMode
short* m_pData
float* m_pFData
DPoint2 m_Corners [4]
vtProjection m_proj


Detailed Description

The vtElevationGrid class represents a generic grid of elevation data. It supports reading and writing the data from several file formats.

Height elements ("heixels") can be either integer (2 bytes) or floating point (4 bytes). Heixel values are always in meters. Areas of unknown elevation are represented by the value INVALID_ELEVATION.

To load a grid from a file, first create an empty grid, then call the appropriated Load method.


Constructor & Destructor Documentation

vtElevationGrid::vtElevationGrid ( )
 

Constructor: Creates an empty grid.

vtElevationGrid::vtElevationGrid ( DRECT area,
int iColumns,
int iRows,
bool bFloat,
vtProjection proj )
 

Constructor: Creates a grid of given size.

Parameters:
area   the coordinate extents of the grid (rectangular area)
iColumns   number of columns in the grid (east-west)
iRows   number of rows (north-south)
bFloat   data size: true to use floating-point, false for shorts.
proj   the geographical projection to use.

The grid will initially have no data in it (all values are INVALID_ELEVATION).

vtElevationGrid::~vtElevationGrid ( )
 

Destructor


Member Function Documentation

void vtElevationGrid::ColorDibFromElevation1 ( vtDIB * pDIB,
RGBi color_ocean )
 

Use the height data in the grid to fill a bitmap with a shaded color image.

Parameters:
pDIB   The bitmap to color.
color_ocean   The color to use for areas at sea level.

void vtElevationGrid::ComputeCornersFromExtents ( ) [protected]
 

For a grid whose absolute extents are known, use those extents to imply the 4 corners coordinates.

void vtElevationGrid::ComputeExtentsFromCorners ( ) [protected]
 

For a grid whose 4 corners coordinates are known, use those corners to imply absolute extents.

void vtElevationGrid::ComputeHeightExtents ( )
 

Scans the grid to compute the minimum and maximum height values.

See also:
GetHeightExtents

bool vtElevationGrid::ContainsPoint ( float x,
float y ) [inline]
 

Test if a point is within the extents of the grid.

bool vtElevationGrid::ConvertProjection ( vtElevationGrid * pOld,
vtProjection & NewProj,
void progress_callback(int) = NULL )
 

Initializes an elevation grid by converting the contents of an another grid to a new projection.

Parameters:
pOld   An existing elevation grid to convert from.
NewProj   The new projection to convert to.
Returns:
True if successful.

DRECT vtElevationGrid::GetAreaExtents ( )
 

Return geographic extents of the *area* covered by grid.

float vtElevationGrid::GetClosestValue ( double x,
double y )
 

Get the height of the grid at a specific world coordinate. The value of the gridpoint closest to the specified location is returned. If the location is not within the extents of the grid, INVALID_ELEVATION is returned.

Parameters:
x, y   The coordinate to query.

char * vtElevationGrid::GetDEMName ( ) [inline]
 

Return the embedded name of the DEM is it has one

void vtElevationGrid::GetDimensions ( int & nColumns,
int & nRows )
 

Get the grid size of the grid. The values are placed into the arguments by reference.

Parameters:
nColumns   The number of columns (east-west)
nRows   THe number of rows (north-south)

float vtElevationGrid::GetFValue ( int i,
int j )
 

Get an elevation value from the grid.

Parameters:
i, j   Location in the grid.
Returns:
The value in (float) meters.

float vtElevationGrid::GetFilteredValue ( double x,
double y )
 

Get the interpolated height of the grid at a specific world coordinate. The value is linearly interpolated between the surrounding gridpoints. If the location is not within the extents of the grid, INVALID_ELEVATION is returned.

Parameters:
x, y   The coordinate to query.

DRECT & vtElevationGrid::GetGridExtents ( ) [inline]
 

Return geographic extents of the grid.

void vtElevationGrid::GetHeightExtents ( float & fMinHeight,
float & fMaxHeight )
 

Gets the minimum and maximum height values. The values are placed in the arguments by reference. You must have first called ComputeHeightExtents.

DPoint2 vtElevationGrid::GetSpacing ( )
 

Get the grid spacing, the width of each column and row.

int vtElevationGrid::GetValue ( int i,
int j )
 

Get an elevation value from the grid.

Parameters:
i, j   Location in the grid.
Returns:
The value in (integer) meters.

bool vtElevationGrid::IsFloatMode ( ) [inline]
 

Get the data size of the grid: true if floating point (4-byte), false if integer (2-byte).

bool vtElevationGrid::LoadBTHeader ( FILE * fp )
 

Loads just the header information from a BT (Binary Terrain) file.

This can be useful if you want to check the information such as the size of the data, without reading the entire file.

Returns:
true if the header was successfully parsed.

bool vtElevationGrid::LoadFromASC ( const char * szFileName,
void progress_callback(int) = NULL )
 

Loads from a Arc/Info compatible ASCII grid file. Projection is read from a corresponding .prj file.

Returns:
true if the file was successfully opened and read.

bool vtElevationGrid::LoadFromBT ( const char * szFileName,
void progress_callback(int) = NULL )
 

Loads from a BT (Binary Terrain) file.

Both the current version (1.1) and older BT versions are supported.

Returns:
true if the file was successfully opened and read.

bool vtElevationGrid::LoadFromCDF ( const char * szFileName,
void progress_callback(int) = NULL )
 

Loads from a netCDF file. Elevation values are assumed to be integer meters. Projection is assumed to be geographic.

Returns:
true if the file was successfully opened and read.

bool vtElevationGrid::LoadFromDEM ( const char * szFileName,
void progress_callback(int) = NULL )
 

Loads elevation from a USGS DEM file. If the data from DEM is in meters, then values are stored as shorts. If DEM data is in feet, then height data will be stored in float, to preserve the precision of the original data. Some non-standard variations of the DEM format are supported.

Returns:
true if the file was successfully opened and read.

bool vtElevationGrid::LoadFromDTED ( const char * szFileName,
void progress_callback(int) = NULL )
 

Loads from a DTED file.

Should support DTED0, DTED1 and DTED2 files, although it has only been tested on DTED0. Projection is assumed to be geographic and elevation is integer meters.

Returns:
true if the file was successfully opened and read.

bool vtElevationGrid::LoadFromGRD ( const char * szFileName,
void progress_callback(int) = NULL )
 

Loads from a Surfer binary grid file (GRD)

Projection is always geographic and elevation is floating-point.

Returns:
true if the file was successfully opened and read.

bool vtElevationGrid::LoadFromGTOPO30 ( const char * szFileName,
void progress_callback(int) = NULL )
 

Loads from a GTOPO30 file.

GTOPO30 files are actually composed of at least 2 files, a header with a .hdr extension and data with a .dem extension. Pass the filename of the .hdr file to this function, and it will automatically look for a corresponding .dem file in the same location.

Projection is always geographic and elevation is integer meters.

Returns:
true if the file was successfully opened and read.

bool vtElevationGrid::LoadFromPGM ( const char * szFileName,
void progress_callback(int) = NULL )
 

Loads from a PGM (Portable Gray Map) file. Both PGM Binary and ASCII varieties are supported.

PGM does not contain any information about geographic location, so the following assumptions are made: UTM coordinates, 1-meter spacing, origin at (0,0).

Returns:
true if the file was successfully opened and read.

bool vtElevationGrid::LoadFromRAW ( const char * szFileName,
int width,
int height,
int bytes_per_element,
float vertical_units )
 

Loads from a RAW file (a naked array of elevation values). The file will not contain any information about at all about data size, data type, or projection, so this information must be passed in as arguments.

Parameters:
szFileName   The file name to read from.
width   The width of the expected array.
height   The height of the expected array.
bytes_per_element   The number of bytes for each elevation value. If this is 1 or 2, the data is assumed to be integer. If 4, then the data is assumed to be floating-point values.
vertical_units   Indicates what scale factor to apply to the elevation values to convert them to meters. E.g. if the file is in meters, pass 1.0, if in feet, pass 0.3048.
Returns:
true if the file was successfully opened and read.

bool vtElevationGrid::LoadFromTerragen ( const char * szFileName,
void progress_callback(int) = NULL )
 

Loads from a Terragen Terrain file.

Returns:
true if the file was successfully opened and read.

bool vtElevationGrid::LoadWithGDAL ( const char * szFileName,
void progress_callback(int) )
 

Loads an elevation grid using the GDAL library. The GDAL library supports a very large number of formats, including SDTS-DEM. See http://www.remotesensing.org/gdal/formats_list.html for the complete list of GDAL-supported formats.

Parameters:
szFileName   The file name to read from.
Returns:
true if the file was successfully opened and read.

void vtElevationGrid::SaveToBT ( FILE * fp )
 

Writes the grid to a BT (Binary Terrain) file. The current BT format version (1.1) is written.

Parameters:
fp   A pointer to a file open for writing.

void vtElevationGrid::SaveToTerragen ( FILE * fp )
 

Writes the grid to a TerraGen Terrain file.

Parameters:
fp   A pointer to a file open for writing.

void vtElevationGrid::SetFValue ( int i,
int j,
float value )
 

Set an elevation value to the grid.

Parameters:
i, j   Location in the grid.
value   The value in (float) meters.

void vtElevationGrid::SetGridExtents ( DRECT & ext ) [inline]
 

Set the geographic extents of the grid.

void vtElevationGrid::SetValue ( int i,
int j,
short value )
 

Set an elevation value to the grid.

Parameters:
i, j   Location in the grid.
value   The value in (integer) meters.


The documentation for this class was generated from the following files:
Generated at Fri Aug 17 14:40:42 2001 for vtdata library by doxygen1.2.4 written by Dimitri van Heesch, © 1997-2000