vtdata library
|
Public Member Functions | |
vtElevationGrid () | |
vtElevationGrid (const vtElevationGrid &rhs) | |
vtElevationGrid (const DRECT &area, const IPoint2 &size, bool bFloat, const vtCRS &proj) | |
virtual | ~vtElevationGrid () |
vtElevationGrid & | operator= (const vtElevationGrid &rhs) |
bool | CopyFrom (const vtElevationGrid &rhs) |
bool | CopyHeaderFrom (const vtElevationGrid &rhs) |
bool | CopyDataFrom (const vtElevationGrid &rhs) |
bool | Create (const DRECT &area, const IPoint2 &size, bool bFloat, const vtCRS &proj, vtElevError *err=NULL) |
void | FreeData () |
void | Clear () |
void | Invalidate () |
bool | ConvertProjection (vtElevationGrid *pOld, const vtCRS &NewProj, float bUpgradeToFloat, bool progress_callback(int)=NULL, vtElevError *err=NULL) |
bool | ReprojectExtents (const vtCRS &proj_new) |
void | Scale (float fScale, bool bDirect, bool bRecomputeExtents=true) |
void | VertOffset (float fAmount) |
void | ComputeHeightExtents () |
void | Offset (const DPoint2 &delta) |
int | ReplaceValue (float value1, float value2) |
bool | FillGaps (DRECT *area=NULL, bool progress_callback(int)=NULL) |
bool | FillGapsSmooth (DRECT *area=NULL, bool progress_callback(int)=NULL) |
int | FillGapsByRegionGrowing (int radius_start=2, int radius_stop=5, bool progress_callback(int)=NULL) |
int | FillGapsByRegionGrowing (int radius, bool progress_callback(int)=NULL) |
bool | LoadFromFile (const char *szFileName, bool progress_callback(int)=NULL, vtElevError *err=NULL) |
bool | LoadFrom3TX (const char *szFileName, bool progress_callback(int)=NULL) |
bool | LoadFromASC (const char *szFileName, bool progress_callback(int)=NULL) |
bool | LoadFromDEM (const char *szFileName, bool progress_callback(int)=NULL, vtElevError *err=NULL) |
bool | LoadFromTerragen (const char *szFileName, bool progress_callback(int)=NULL) |
bool | LoadFromDTED (const char *szFileName, bool progress_callback(int)=NULL) |
bool | LoadFromGTOPO30 (const char *szFileName, bool progress_callback(int)=NULL) |
bool | LoadFromGLOBE (const char *szFileName, bool progress_callback(int)=NULL) |
bool | LoadFromGRD (const char *szFileName, bool progress_callback(int)=NULL) |
bool | LoadFromDSAA (const char *szFileName, bool progress_callback(int)=NULL) |
bool | LoadFromPGM (const char *szFileName, bool progress_callback(int)=NULL) |
bool | LoadFromRAW (const char *szFileName, int width, int height, int bytes_per_element, float vertical_units, bool bBigEndian, bool progress_callback(int)) |
bool | LoadFromMicroDEM (const char *szFileName, bool progress_callback(int)=NULL) |
bool | LoadFromXYZ (const char *szFileName, bool progress_callback(int)=NULL) |
bool | LoadFromXYZ (FILE *fp, const char *format, bool progress_callback(int)=NULL) |
bool | LoadFromHGT (const char *szFileName, bool progress_callback(int)=NULL) |
bool | LoadFromBT (const char *szFileName, bool progress_callback(int)=NULL, vtElevError *err=NULL) |
bool | LoadBTHeader (const char *szFileName, vtElevError *err=NULL) |
bool | LoadBTData (const char *szFileName, bool progress_callback(int)=NULL, vtElevError *err=NULL) |
bool | LoadWithGDAL (const char *szFileName, bool progress_callback(int)=NULL, vtElevError *err=NULL) |
bool | LoadFromNTF5 (const char *szFileName, bool progress_callback(int)=NULL) |
bool | SaveTo3TX (const char *szFileName, bool progress_callback(int)=NULL) const |
bool | SaveToGeoTIFF (const char *szFileName) const |
bool | SaveToTerragen (const char *szFileName) const |
bool | SaveToBT (const char *szFileName, bool progress_callback(int)=NULL, bool bGZip=false) |
bool | SaveToSTM (const char *szFileName, bool progress_callback(int)=NULL) |
bool | SaveToPlanet (const char *szDirName, bool progress_callback(int)=NULL) |
bool | SaveToASC (const char *szFileName, bool progress_callback(int)=NULL) const |
bool | SaveToVRML (const char *szFileName, bool progress_callback(int)=NULL) const |
bool | SaveToXYZ (const char *szFileName, bool progress_callback(int)=NULL) const |
bool | SaveToRAWINF (const char *szFileName, bool progress_callback(int)=NULL) const |
bool | SaveToRAW_Unity (const char *szFileName, bool progress_callback(int)=NULL) const |
bool | SaveToPNG16 (const char *fname) |
void | SetFValue (int i, int j, float value) |
void | SetValue (int i, int j, short value) |
short | GetShortValue (int i, int j) const |
float | GetFValue (int i, int j) const |
float | GetFValueSafe (int i, int j) const |
float | GetClosestValue (const DPoint2 &p) const |
float | GetFilteredValue (const DPoint2 &p) const |
const char * | GetDEMName () |
DRECT | GetAreaExtents () const |
bool | IsFloatMode () const |
void | FillWithSingleValue (float fValue) |
void | GetEarthPoint (int i, int j, DPoint2 &p) const |
void | GetEarthLocation (int i, int j, DPoint3 &loc) const |
vtCRS & | GetCRS () |
const vtCRS & | GetProjection () const |
void | SetProjection (const vtCRS &proj) |
bool | GetCorners (DLine2 &line, bool bGeo) const |
void | SetCorners (const DLine2 &line) |
short * | GetData () |
float * | GetFloatData () |
const short * | GetData () const |
const float * | GetFloatData () const |
void | SetScale (float sc) |
float | GetScale () const |
bool | HasData () const |
int | MemoryNeededToLoad () const |
int | MemoryUsed () const |
bool | FindAltitudeOnEarth (const DPoint2 &p, float &fAltitude, bool bTrue=false) const |
virtual float | GetElevation (int iX, int iZ, bool bTrue=false) const |
virtual void | GetWorldLocation (int i, int j, FPoint3 &loc, bool bTrue=false) const |
void | SetupLocalCS (float fVerticalExag=1.0f) |
float | GetWorldValue (int i, int j, bool bTrue=false) const |
bool | FindAltitudeAtPoint (const FPoint3 &p3, float &fAltitude, bool bTrue=false, int iCultureFlags=0, FPoint3 *vNormal=NULL) const |
Public Member Functions inherited from vtHeightFieldGrid3d | |
void | Initialize (const LinearUnits units, const DRECT &earthextents, float fMinHeight, float fMaxHeight, int cols, int rows) |
virtual void | SetEarthExtents (const DRECT &ext) |
bool | CastRayToSurface (const FPoint3 &point, const FPoint3 &dir, FPoint3 &result) const |
bool | LineOfSight (const FPoint3 &point1, const FPoint3 &point2) const |
const DPoint2 & | GetSpacing () const |
const FPoint2 & | GetWorldSpacing () const |
void | GetDimensions (int &nColumns, int &nRows) const |
const IPoint2 & | GetDimensions () const |
int | NumColumns () const |
int | NumRows () const |
void | EarthToGrid (const DPoint2 &epos, IPoint2 &ipos) |
void | WorldToGrid (const FPoint3 &pos, IPoint2 &ipos) |
float | GetInterpolatedElevation (double findex_x, double findex_y, bool bTrue=false) const |
int | FindNumUnknown () |
bool | ColorDibFromElevation (vtBitmapBase *pBM, ColorMap *cmap, int iGranularity, const RGBAi &nodata, bool progress_callback(int)=NULL) const |
bool | ColorDibFromTable (vtBitmapBase *pBM, const ColorMap *color_map, const RGBAi &nodata, bool progress_callback(int)=NULL) const |
void | ShadeDibFromElevation (vtBitmapBase *pBM, const FPoint3 &light_dir, float fLightFactor, float fAmbient=0.1f, float fGamma=1.0f, bool bTrue=false, bool progress_callback(int)=NULL) const |
void | ShadeQuick (vtBitmapBase *pBM, float light_factor, bool bTrue=false, bool progress_callback(int)=NULL) |
void | ShadowCastDib (vtBitmapBase *pBM, const FPoint3 &ight_dir, float fLightFactor, float fAmbient, bool progress_callback(int)=NULL) const |
Public Member Functions inherited from vtHeightField3d | |
void | Initialize (const LinearUnits units, const DRECT &earthextents, float fMinHeight, float fMaxHeight) |
int | PointIsAboveTerrain (const FPoint3 &p) const |
bool | ConvertEarthToSurfacePoint (const DPoint2 &epos, FPoint3 &p3, int iCultureFlags=0, bool bTrue=false) const |
bool | ContainsWorldPoint (float x, float z) const |
void | GetCenter (FPoint3 ¢er) const |
void | SetCulture (CultureExtension *ext) |
float | LineOnSurface (const DLine2 &line, float fSpacing, float fOffset, bool bInterp, bool bCurve, bool bTrue, FLine3 &output) |
Public Member Functions inherited from vtHeightField | |
void | Initialize (const DRECT &extents, float fMinHeight, float fMaxHeight) |
bool | ContainsEarthPoint (const DPoint2 &p, bool bInclusive=false) const |
DRECT & | GetEarthExtents () |
const DRECT & | GetEarthExtents () const |
void | GetHeightExtents (float &fMinHeight, float &fMaxHeight) const |
Protected Member Functions | |
void | SetupMembers () |
void | ComputeExtentsFromCorners () |
void | ComputeCornersFromExtents () |
bool | ParseNTF5 (GDALDataset *pDatasource, vtString &msg, bool progress_callback(int)) |
bool | GetXYZLine (const char *buf, const char *pattern, const char *format, int components, double *x, double *y, double *z) |
void | SetError (vtElevError *err, vtElevError::ErrorType type, const char *szFormat,...) |
bool | AllocateGrid (vtElevError *err=NULL) |
Protected Member Functions inherited from vtHeightField3d | |
void | UpdateWorldExtents () |
Protected Attributes | |
bool | m_bFloatMode |
short * | m_pData |
float * | m_pFData |
float | m_fVMeters |
float | m_fVerticalScale |
DPoint2 | m_Corners [4] |
vtCRS | m_proj |
vtString | m_strOriginalDEMName |
Protected Attributes inherited from vtHeightFieldGrid3d | |
IPoint2 | m_iSize |
FPoint2 | m_fStep |
DPoint2 | m_dStep |
Protected Attributes inherited from vtHeightField3d | |
float | m_fDiagonalLength |
CultureExtension * | m_pCulture |
Protected Attributes inherited from vtHeightField | |
float | m_fMinHeight |
float | m_fMaxHeight |
DRECT | m_EarthExtents |
Additional Inherited Members | |
Public Attributes inherited from vtHeightField3d | |
FRECT | m_WorldExtents |
LocalCS | m_LocalCS |
The vtElevationGrid class represents a generic grid of elevation data. It supports reading and writing the data from many file formats, testing the height at any given point, reprojecting the grid between coordinate systems, and many other operations.
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.
vtElevationGrid::vtElevationGrid | ( | ) |
Constructor: Creates an empty grid.
vtElevationGrid::vtElevationGrid | ( | const vtElevationGrid & | rhs | ) |
Copy constructor.
vtElevationGrid::vtElevationGrid | ( | const DRECT & | area, |
const IPoint2 & | size, | ||
bool | bFloat, | ||
const vtCRS & | proj | ||
) |
Constructor: Creates a grid of given size.
area | the coordinate extents of the grid (rectangular area) |
size | Number of columns and rows in the grid |
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).
|
virtual |
Destructor
void vtElevationGrid::Clear | ( | ) |
Set all the values in the grid to zero.
|
protected |
For a grid whose absolute extents are known, use those extents to imply the 4 corners coordinates.
|
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.
bool vtElevationGrid::ConvertProjection | ( | vtElevationGrid * | pOld, |
const vtCRS & | NewProj, | ||
float | bUpgradeToFloat, | ||
bool | progress_callbackint = NULL , |
||
vtElevError * | err = NULL |
||
) |
Initializes an elevation grid by converting the contents of an another grid to a new projection.
pOld | An existing elevation grid to convert from. |
NewProj | The new projection to convert to. |
bUpgradeToFloat | If true, the resulting grid will always use floating-point values. Otherwise, it matches the input grid. |
progress_callback | If supplied, this function will be called back with a value of 0 to 100 as the operation progresses. |
err | If supplied, will be set to a description of any error that occurs. |
bool vtElevationGrid::Create | ( | const DRECT & | area, |
const IPoint2 & | size, | ||
bool | bFloat, | ||
const vtCRS & | proj, | ||
vtElevError * | err = NULL |
||
) |
Create a grid of given size.
area | the coordinate extents of the grid (rectangular area) |
size | Number of columns and rows in the grid. |
bFloat | data size: true to use floating-point, false for shorts. |
proj | the geographical projection to use. |
err | If supplied, will be set to a description of any error that occurs. |
The grid will initially have no data in it (all values are INVALID_ELEVATION).
bool vtElevationGrid::FillGaps | ( | DRECT * | area = NULL , |
bool | progress_callbackint = NULL |
||
) |
Fill the gaps (heixels of value INVALID_ELVATION) in this grid, by interpolating from the valid values.
This method uses a simple, unoptimized algorithm to move across the grid, one column at a time, averaging the surrounding pixels to fill each gap.
area | Optionally, restrict the operation to a given area. |
progress_callback | Provide if you want a callback on progress. |
int vtElevationGrid::FillGapsByRegionGrowing | ( | int | radius_start = 2 , |
int | radius_stop = 5 , |
||
bool | progress_callbackint = NULL |
||
) |
Fill-in algorithm. Replaces no-data values by repeated region growing. Smoothly extrapolates the filled-in value via partial derivatives. Restricts the fill-in operation to concavities with a diameter of less than radius^2+1 pixels.
int vtElevationGrid::FillGapsByRegionGrowing | ( | int | radius, |
bool | progress_callbackint = NULL |
||
) |
Fill-in algorithm. Replaces no-data values by repeated region growing. Smoothly extrapolates the filled-in value via partial derivatives. Restricts the fill-in operation to concavities with a diameter of less than radius^2+1 pixels.
Adapted subset from original code by: Stefan Roettger.
bool vtElevationGrid::FillGapsSmooth | ( | DRECT * | area = NULL , |
bool | progress_callbackint = NULL |
||
) |
Fill the gaps (heixels of value INVALID_ELVATION) in this grid, by interpolating from the valid values.
This method attempts to be a little better than FillGaps(), by keeping an entire second grid for the interpolated results on each pass, to avoid some cases of the results getting "smeared" left to right. However, this makes it much slower on most data.
area | Optionally, restrict the operation to a given area. |
progress_callback | Provide if you want a callback on progress. |
|
virtual |
Simple elevation test for perfectly regular grid terrain. Find altitude (y) and (optionally) surface normal, given (x,z) world coordinates.
This approach is very straightforward, so it could be significantly sped up if needed.
p | A 3D point in world coordinates. Only the X and Z values are used. |
fAltitude | If the test succeeds, this contains the result by reference. |
bTrue | Pass true to the use the true elevation, false to consider the vertical exaggeration in effect. |
iCultureFlags | Pass 0 to test only the heightfield itself, non-zero to test any culture objects which may be sitting on the heightfield. Values include:
|
vNormal | If you pass a pointer to a vector, it will be filled in with the upwards-pointing surface normal at the given point. |
Implements vtHeightField3d.
|
virtual |
Return the elevation value at a given point in earth coordinates.
p | A 2D point in earth coordinates. |
fAltitude | If the test succeeds, this contains the result by reference. |
bTrue | Pass true to the use the true elevation, false to consider the vertical exaggeration in effect. |
Implements vtHeightField.
void vtElevationGrid::FreeData | ( | ) |
Free any memory being used by this class for elevation data.
DRECT vtElevationGrid::GetAreaExtents | ( | ) | const |
Returns the geographic extents of the area covered by grid.
The standard extents of an elevation grid are the min and max of its data points. However, because each point in the grid is a spot elevation that implies the elevation of the ground around itself, the area over which the elevation could be understood to describe is actually half a heixel larger in each direction. This method returns that larger area.
float vtElevationGrid::GetClosestValue | ( | const DPoint2 & | p | ) | const |
Get the height of the grid at a specific world coordinate (nearest neighbor)
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.
p | The point to query. |
|
inline |
Return the embedded name of the DEM is it has one
float vtElevationGrid::GetFilteredValue | ( | const DPoint2 & | p | ) | const |
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. The height field has a 0.5 pixel safety boundary to catch all samples on the edges.
p | The point to query. |
float vtElevationGrid::GetFValue | ( | int | i, |
int | j | ||
) | const |
Get an elevation value from the grid.
i,j | Column and row location in the grid. |
short vtElevationGrid::GetShortValue | ( | int | i, |
int | j | ||
) | const |
Get a value direct from the grid, in the special case where the grid is composed of short integers with no scaling.
i,j | Column and row location in the grid. |
void vtElevationGrid::Invalidate | ( | ) |
Set all the values in the grid to INVALID_ELEVATION.
|
inline |
Get the data size of the grid heixels (height elements): true
if floating point (4-byte), false
if integer (2-byte).
bool vtElevationGrid::LoadBTHeader | ( | const char * | szFileName, |
vtElevError * | err = NULL |
||
) |
Loads just the header information from a BT (Binary Terrain) file.
true
if the header was successfully parsed. bool vtElevationGrid::LoadFrom3TX | ( | const char * | szFileName, |
bool | progress_callbackint = NULL |
||
) |
Loads from a 3TX ascii grid file. Projection is Geo WGS84, extents are always 1 degree in size.
You should call SetupLocalCS() after loading if you will be doing heightfield operations on this grid.
true
if the file was successfully opened and read. bool vtElevationGrid::LoadFromASC | ( | const char * | szFileName, |
bool | progress_callbackint = NULL |
||
) |
Loads from a Arc/Info compatible ASCII grid file. Projection is read from a corresponding .prj file.
You should call SetupLocalCS() after loading if you will be doing heightfield operations on this grid.
true
if the file was successfully opened and read. bool vtElevationGrid::LoadFromBT | ( | const char * | szFileName, |
bool | progress_callbackint = NULL , |
||
vtElevError * | err = NULL |
||
) |
Loads from a BT (Binary Terrain) file.
true
if the file was successfully opened and read. bool vtElevationGrid::LoadFromDEM | ( | const char * | szFileName, |
bool | progress_callbackint = NULL , |
||
vtElevError * | err = NULL |
||
) |
Loads elevation from a USGS DEM file.
Some non-standard variations of the DEM format are supported.
You should call SetupLocalCS() after loading if you will be doing heightfield operations on this grid.
true
if the file was successfully opened and read. bool vtElevationGrid::LoadFromDSAA | ( | const char * | szFileName, |
bool | progress_callbackint = NULL |
||
) |
Helper function for LoadFromGRD, loads from a Surfer ascii grid file (GRD)
Projection is always geographic and elevation is floating-point.
true
if the file was successfully opened and read. bool vtElevationGrid::LoadFromDTED | ( | const char * | szFileName, |
bool | progress_callbackint = NULL |
||
) |
Loads from a DTED file.
You should call SetupLocalCS() after loading if you will be doing heightfield operations on this grid.
true
if the file was successfully opened and read. bool vtElevationGrid::LoadFromFile | ( | const char * | szFileName, |
bool | progress_callbackint = NULL , |
||
vtElevError * | err = NULL |
||
) |
Load from a file whose type is not known a priori. This will end up calling one of the Load* member functions.
You should call SetupLocalCS() after loading if you will be doing heightfield operations on this grid.
true
if successful. bool vtElevationGrid::LoadFromGLOBE | ( | const char * | szFileName, |
bool | progress_callbackint = NULL |
||
) |
Loads from a NOAA GlOBE file.
In fact, there is no "GLOBE format", GLOBE files are delivered as raw data, which can be intepreted using a variety of separate header files. Using the GLOBE server "Select Your Own Area" feature results in 2 files, a header with a .hdr extension and data with a .bin extension. This method reads those file. Pass the filename of the .hdr file to this function, and it will automatically look for a corresponding .bin file in the same location.
Projection is always geographic and elevation is integer meters.
You should call SetupLocalCS() after loading if you will be doing heightfield operations on this grid.
true
if the file was successfully opened and read. bool vtElevationGrid::LoadFromGRD | ( | const char * | szFileName, |
bool | progress_callbackint = NULL |
||
) |
Loads from a Surfer binary grid file (GRD)
GRD does not contain any information about CRS, so the following assumption is made: UTM zone 1.
You should call SetupLocalCS() after loading if you will be doing heightfield operations on this grid.
true
if the file was successfully opened and read. bool vtElevationGrid::LoadFromGTOPO30 | ( | const char * | szFileName, |
bool | progress_callbackint = NULL |
||
) |
Loads from a GTOPO30 (or SRTM30) 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.
You should call SetupLocalCS() after loading if you will be doing heightfield operations on this grid.
true
if the file was successfully opened and read. bool vtElevationGrid::LoadFromHGT | ( | const char * | szFileName, |
bool | progress_callbackint = NULL |
||
) |
Loads from an "HGT" file, which is the format used by the USGS SRTM FTP site for their 1-degree blocks of SRTM data. It is simply a raw block of signed 2-byte data, in WGS84 geographic coords.
The file will either be: 2,884,802 bytes (for 3 arcsec, 1201*1201) or 25,934,402 bytes (for 1 arcsec, 3601*3601)
You should call SetupLocalCS() after loading if you will be doing heightfield operations on this grid.
true
if the file was successfully opened and read. bool vtElevationGrid::LoadFromMicroDEM | ( | const char * | szFileName, |
bool | progress_callbackint = NULL |
||
) |
Loads from a MicroDEM format file.
You should call SetupLocalCS() after loading if you will be doing heightfield operations on this grid.
true
if the file was successfully opened and read. bool vtElevationGrid::LoadFromNTF5 | ( | const char * | szFileName, |
bool | progress_callbackint = NULL |
||
) |
Loads an elevation grid from an UK Ordnance Survey NTF level 5 file using the OGR library.
szFileName | The file name to read from. |
progress_callback | If supplied, this function will be called back with a value of 0 to 100 as the operation progresses. |
You should call SetupLocalCS() after loading if you will be doing heightfield operations on this grid.
bool vtElevationGrid::LoadFromPGM | ( | const char * | szFileName, |
bool | progress_callbackint = 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).
You should call SetupLocalCS() after loading if you will be doing heightfield operations on this grid.
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, | ||
bool | bBigEndian, | ||
bool | progress_callbackint | ||
) |
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.
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. |
bBigEndian | True for Big-endian byte order, false for Little-endian (Intel byte order). |
progress_callback | If supplied, this function will be called back with a value of 0 to 100 as the operation progresses. |
true
if the file was successfully opened and read. bool vtElevationGrid::LoadFromTerragen | ( | const char * | szFileName, |
bool | progress_callbackint = NULL |
||
) |
Loads from a Terragen Terrain file.
You should call SetupLocalCS() after loading if you will be doing heightfield operations on this grid.
true
if the file was successfully opened and read. bool vtElevationGrid::LoadFromXYZ | ( | const char * | szFileName, |
bool | progress_callbackint = NULL |
||
) |
Loads from an "XYZ file", which is a simple text file containing a set of grid points in the form X,Y,Z - where X and Y are ground coordinates, and Z is elevation. The values may be separated either by commas (X, Y, Z) or by whitespace (X Y Z).
true
if the file was successfully opened and read. bool vtElevationGrid::LoadWithGDAL | ( | const char * | szFileName, |
bool | progress_callbackint = NULL , |
||
vtElevError * | err = NULL |
||
) |
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.
szFileName | The file name to read from. |
progress_callback | If supplied, this function will be called back with a value of 0 to 100 as the operation progresses. |
err | If supplied, will be set to a description of any error that occurs. |
You should call SetupLocalCS() after loading if you will be doing heightfield operations on this grid.
void vtElevationGrid::Offset | ( | const DPoint2 & | delta | ) |
Offset the entire elevation grid horizontally.
delta | The X,Y amount to shift the location of the grid. |
vtElevationGrid & vtElevationGrid::operator= | ( | const vtElevationGrid & | rhs | ) |
Assignment operator.
int vtElevationGrid::ReplaceValue | ( | float | value1, |
float | value2 | ||
) |
Replace one value with another. For example, replace all heixels of value INVALID_ELEVATION with 0.0.
value1 | The heixel value to replace. |
value2 | The value to replace it with. |
bool vtElevationGrid::ReprojectExtents | ( | const vtCRS & | proj_new | ) |
Reprojects an elevation grid by converting just the extents to a new projection.
This is much faster than creating a new grid and reprojecting every heixel, but it only produces correct results when the difference between the projections is only a horizontal shift. For example, this occurs when the only difference between the old and new projection is choice of Datum.
proj_new | The new projection to convert to. |
bool vtElevationGrid::SaveToASC | ( | const char * | szFileName, |
bool | progress_callbackint = NULL |
||
) | const |
Writes an Arc/Info compatible ASCII grid file. Projection is written to a corresponding .prj file.
true
if the file was successfully opened and written. bool vtElevationGrid::SaveToBT | ( | const char * | szFileName, |
bool | progress_callbackint = NULL , |
||
bool | bGZip = false |
||
) |
Writes the grid to a BT (Binary Terrain) file. The current BT format version (1.3) is written.
szFileName | The file name to write to. |
progress_callback | If supplied, this function will be called back with a value of 0 to 100 as the operation progresses. |
bGZip | If true, the data will be compressed with gzip. If true, you should Use a filename ending with ".gz". |
bool vtElevationGrid::SaveToGeoTIFF | ( | const char * | szFileName | ) | const |
Write the elevation grid to a 16-bit greyscale GeoTIFF.
bool vtElevationGrid::SaveToPlanet | ( | const char * | szDirName, |
bool | progress_callbackint = NULL |
||
) |
Write elevation to the MSI Planet (Marconi) format.
true
if the file was successfully opened and written. bool vtElevationGrid::SaveToPNG16 | ( | const char * | fname | ) |
Write elevation a 16-bit greyscale PNG file.
bool vtElevationGrid::SaveToRAW_Unity | ( | const char * | szFileName, |
bool | progress_callbackint = NULL |
||
) | const |
Write elevation to a .raw file, the way Unity import expects it: Scaled to 8 bits (0-255).
bool vtElevationGrid::SaveToRAWINF | ( | const char * | szFileName, |
bool | progress_callbackint = NULL |
||
) | const |
Write elevation to a .raw file along with an .inf file which describes the data for the purpose of exporting to MS Flight Simulator 2004 via their MSFS SDK 'resample' utility.
szFileName | Should end in ".raw" |
progress_callback | If supplied, this function will be called back with a value of 0 to 100 as the operation progresses. |
true
if the file was successfully written. bool vtElevationGrid::SaveToSTM | ( | const char * | szFileName, |
bool | progress_callbackint = NULL |
||
) |
Write elevation to the STM (Simple Terrain Model) format created by Michael Garland for his 'Scape' Terrain Simplification software.
true
if the file was successfully opened and written. bool vtElevationGrid::SaveToTerragen | ( | const char * | szFileName | ) | const |
Writes the grid to a TerraGen Terrain file.
szFileName | The filename to write to. |
bool vtElevationGrid::SaveToVRML | ( | const char * | szFileName, |
bool | progress_callbackint = NULL |
||
) | const |
Write elevation to a VRML file which contains a single ElevationGrid node.
true
if the file was successfully opened and written. bool vtElevationGrid::SaveToXYZ | ( | const char * | szFileName, |
bool | progress_callbackint = NULL |
||
) | const |
Write elevation to a text file which contains an XYZ for each point.
true
if the file was successfully opened and written. void vtElevationGrid::Scale | ( | float | fScale, |
bool | bDirect, | ||
bool | bRecomputeExtents = true |
||
) |
Scale all the valid elevation values in the grid by a given factor.
fScale | The desired scale, e.g. 1.0 produces no change in scale. |
bDirect | If true, scale the stored height values directly. Otherwise, only the height scale (vertical meters per unit) is scaled. |
bRecomputeExtents | If true, recompute the height extents. Default is true. |
void vtElevationGrid::SetFValue | ( | int | i, |
int | j, | ||
float | value | ||
) |
Set an elevation value to the grid.
i,j | Column and row location in the grid. |
value | The value in (float) meters. |
void vtElevationGrid::SetupLocalCS | ( | float | fVerticalExag = 1.0f | ) |
Set up the terrain's coordinate systems, including the conversion from Earth coordinates to the World coordinates of the terrain itself. You should call this method after loading or creating a vtElevationGrid, before using methods on it such as FindAltitudeOnEarth or GetSpacing.
For explanation of vtlib/vtdata world coordinates, please see http://vterrain.org/Doc/coords.html
fVerticalExag | The vertical exaggeration of the terrain, which is how many times higher it should appear than it really is. Pass 1.0 for no exaggeration. |
void vtElevationGrid::SetValue | ( | int | i, |
int | j, | ||
short | value | ||
) |
Set an elevation value to the grid.
i,j | Column and row location in the grid. |
value | The value in (integer) meters. |
void vtElevationGrid::VertOffset | ( | float | fAmount | ) |
Vertically offset the valid elevation values in the grid by a given amount.
fAmount | The amount to be added to every elevation value. |