|
osgEarth 2.1.1
|
Collaboration diagram for osgEarth::GeoHeightField:Public Member Functions | |
| GeoHeightField () | |
| GeoHeightField (osg::HeightField *heightField, const GeoExtent &extent, const VerticalSpatialReference *vsrs) | |
| bool | valid () const |
| bool | getElevation (const SpatialReference *inputSRS, double x, double y, ElevationInterpolation interp, const VerticalSpatialReference *outputVSRS, float &out_elevation) const |
| GeoHeightField | createSubSample (const GeoExtent &destEx, ElevationInterpolation interpolation) const |
| const GeoExtent & | getExtent () const |
| const osg::HeightField * | getHeightField () const |
| osg::HeightField * | getHeightField () |
| osg::HeightField * | takeHeightField () |
Static Public Attributes | |
| static GeoHeightField | INVALID |
Protected Attributes | |
| osg::ref_ptr< osg::HeightField > | _heightField |
| GeoExtent | _extent |
| osg::ref_ptr< const VerticalSpatialReference > | _vsrs |
| GeoHeightField::GeoHeightField | ( | ) |
Constructs an empty (invalid) heightfield.
Definition at line 977 of file GeoData.cpp.
: _heightField( 0L ), _extent( GeoExtent::INVALID ), _vsrs( 0L ) { //nop }
Here is the caller graph for this function:| GeoHeightField::GeoHeightField | ( | osg::HeightField * | heightField, |
| const GeoExtent & | extent, | ||
| const VerticalSpatialReference * | vsrs | ||
| ) |
Constructs a new georeferenced heightfield.
Definition at line 985 of file GeoData.cpp.
: _heightField( heightField ), _extent( extent ), _vsrs( vsrs ) { if ( _heightField ) { double minx, miny, maxx, maxy; _extent.getBounds(minx, miny, maxx, maxy); _heightField->setOrigin( osg::Vec3d( minx, miny, 0.0 ) ); _heightField->setXInterval( (maxx - minx)/(double)(_heightField->getNumColumns()-1) ); _heightField->setYInterval( (maxy - miny)/(double)(_heightField->getNumRows()-1) ); _heightField->setBorderWidth( 0 ); } }
Here is the call graph for this function:| GeoHeightField GeoHeightField::createSubSample | ( | const GeoExtent & | destEx, |
| ElevationInterpolation | interpolation | ||
| ) | const |
Subsamples the heightfield, returning a new heightfield corresponding to the destEx extent. The destEx must be a smaller, inset area of sourceEx.
Definition at line 1062 of file GeoData.cpp.
{
double div = destEx.width()/_extent.width();
if ( div >= 1.0f )
return GeoHeightField::INVALID;
int w = _heightField->getNumColumns();
int h = _heightField->getNumRows();
//double dx = _heightField->getXInterval() * div;
//double dy = _heightField->getYInterval() * div;
double xInterval = _extent.width() / (double)(_heightField->getNumColumns()-1);
double yInterval = _extent.height() / (double)(_heightField->getNumRows()-1);
double dx = xInterval * div;
double dy = yInterval * div;
osg::HeightField* dest = new osg::HeightField();
dest->allocate( w, h );
dest->setXInterval( dx );
dest->setYInterval( dy );
// copy over the skirt height, adjusting it for tile size.
dest->setSkirtHeight( _heightField->getSkirtHeight() * div );
double x, y;
int col, row;
for( x = destEx.xMin(), col=0; col < w; x += dx, col++ )
{
for( y = destEx.yMin(), row=0; row < h; y += dy, row++ )
{
float height = HeightFieldUtils::getHeightAtLocation( _heightField.get(), x, y, _extent.xMin(), _extent.yMin(), xInterval, yInterval, interpolation);
dest->setHeight( col, row, height );
}
}
osg::Vec3d orig( destEx.xMin(), destEx.yMin(), _heightField->getOrigin().z() );
dest->setOrigin( orig );
return GeoHeightField( dest, destEx, _vsrs.get() );
}
Here is the call graph for this function:
Here is the caller graph for this function:| bool GeoHeightField::getElevation | ( | const SpatialReference * | inputSRS, |
| double | x, | ||
| double | y, | ||
| ElevationInterpolation | interp, | ||
| const VerticalSpatialReference * | outputVSRS, | ||
| float & | out_elevation | ||
| ) | const |
Gets the elevation value at a specified point.
| srs | Spatial reference of the query coordinates. (If you pass in NULL, the method will assume that the SRS is equivalent to that of the GeoHeightField. Be sure this is case of you will get incorrect results.) |
| x,y | Coordinates at which to query the elevation value. |
| interp | Interpolation method for the elevation query. |
| outputVSRS | Convert the output elevation value to this VSRS (NULL to ignore) |
| out_elevation | Output: the elevation value |
Definition at line 1005 of file GeoData.cpp.
{
double local_x = x, local_y = y;
if ( inputSRS && !inputSRS->transform2D(x, y, _extent.getSRS(), local_x, local_y) )
return false;
if ( _extent.contains(local_x, local_y) )
{
double xInterval = _extent.width() / (double)(_heightField->getNumColumns()-1);
double yInterval = _extent.height() / (double)(_heightField->getNumRows()-1);
elevation = HeightFieldUtils::getHeightAtLocation(
_heightField.get(),
local_x, local_y,
_extent.xMin(), _extent.yMin(),
xInterval, yInterval,
interp);
if ( elevation != NO_DATA_VALUE )
{
if ( VerticalSpatialReference::canTransform( _vsrs.get(), outputVSRS ) )
{
// need geodetic coordinates for a VSRS transformation:
double lat_deg, lon_deg, newElevation;
if ( inputSRS->isGeographic() ) {
lat_deg = y;
lon_deg = x;
}
else if ( _extent.getSRS()->isGeographic() ) {
lat_deg = local_y;
lon_deg = local_x;
}
else {
_extent.getSRS()->transform2D( x, y, inputSRS->getGeographicSRS(), lon_deg, lat_deg );
}
if ( _vsrs->transform( outputVSRS, lat_deg, lon_deg, elevation, newElevation ) )
elevation = newElevation;
}
}
return true;
}
else
{
elevation = 0.0f;
return false;
}
}
Here is the call graph for this function:
Here is the caller graph for this function:| const GeoExtent & GeoHeightField::getExtent | ( | ) | const |
Gets the geospatial extent of the heightfield.
Definition at line 1104 of file GeoData.cpp.
{
return _extent;
}
Here is the caller graph for this function:| const osg::HeightField * GeoHeightField::getHeightField | ( | ) | const |
Gets a pointer to the underlying OSG heightfield.
Definition at line 1110 of file GeoData.cpp.
{
return _heightField.get();
}
| osg::HeightField * GeoHeightField::getHeightField | ( | ) |
Definition at line 1116 of file GeoData.cpp.
{
return _heightField.get();
}
| osg::HeightField * GeoHeightField::takeHeightField | ( | ) |
Gets a pointer to the underlying OSG heightfield, and releases the internal reference.
Definition at line 1122 of file GeoData.cpp.
{
return _heightField.release();
}
Here is the caller graph for this function:| bool osgEarth::GeoHeightField::valid | ( | ) | const [inline] |
True if this is a valid heightfield.
Definition at line 356 of file GeoData.
{ return _heightField.valid(); }
Here is the caller graph for this function:GeoExtent osgEarth::GeoHeightField::_extent [protected] |
osg::ref_ptr<osg::HeightField> osgEarth::GeoHeightField::_heightField [protected] |
osg::ref_ptr<const VerticalSpatialReference> osgEarth::GeoHeightField::_vsrs [protected] |
GeoHeightField GeoHeightField::INVALID [static] |
1.7.3