本文整理汇总了C++中GeoHeightField::getHeightField方法的典型用法代码示例。如果您正苦于以下问题:C++ GeoHeightField::getHeightField方法的具体用法?C++ GeoHeightField::getHeightField怎么用?C++ GeoHeightField::getHeightField使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GeoHeightField
的用法示例。
在下文中一共展示了GeoHeightField::getHeightField方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writer
osg::Image*
createImage( const TileKey& key, ProgressCallback* progress )
{
// Use the underlying ElevationLayer to create a heightfield and then color it.
GeoHeightField geoHF = _layer->createHeightField(key, progress);
if (geoHF.valid())
{
osg::HeightField* hf = geoHF.getHeightField();
osg::Image* image = new osg::Image();
image->allocateImage(hf->getNumColumns(),hf->getNumRows(),1, GL_RGBA, GL_UNSIGNED_BYTE);
memset(image->data(), 0, image->getImageSizeInBytes());
ImageUtils::PixelWriter writer(image);
for (unsigned int c = 0; c < hf->getNumColumns(); c++)
{
for (unsigned int r = 0; r < hf->getNumRows(); r++)
{
float v = hf->getHeight(c, r );
if (v != NO_DATA_VALUE)
{
osg::Vec4 color = _transferFunction->getColor(v);
writer(color, c, r);
}
}
}
return image;
}
return NULL;
}
示例2: handleTile
bool handleTile(const TileKey& key)
{
bool ok = false;
GeoHeightField hf = _source->createHeightField(key, 0L);
if ( hf.valid() )
ok = _dest->storeHeightField(key, hf.getHeightField(), 0L);
return ok;
}
示例3: point
osg::Vec3d getWorld( const GeoHeightField& geoHF, unsigned int c, unsigned int r)
{
double x = geoHF.getExtent().xMin() + (double)c * geoHF.getXInterval();
double y = geoHF.getExtent().yMin() + (double)r * geoHF.getYInterval();
double h = geoHF.getHeightField()->getHeight(c,r);
osg::Vec3d world;
GeoPoint point(geoHF.getExtent().getSRS(), x, y, h );
point.toWorld( world );
return world;
}
示例4: bestKey
//.........这里部分代码省略.........
std::vector<bool> heightFallback(contenders.size(), false);
std::vector<bool> heightFailed(contenders.size(), false);
std::vector<bool> offsetFailed(offsets.size(), false);
// The maximum number of heightfields to keep in this local cache
const unsigned maxHeightFields = 50;
unsigned numHeightFieldsInCache = 0;
const SpatialReference* keySRS = keyToUse.getProfile()->getSRS();
bool realData = false;
unsigned int total = numColumns * numRows;
// query resolution interval (x, y) of each sample.
osg::ref_ptr<osg::ShortArray> deltaLOD = new osg::ShortArray(total);
int nodataCount = 0;
TileKey scratchKey; // Storage if a new key needs to be constructed
bool requiresResample = true;
// If we only have a single contender layer, and the tile is the same size as the requested
// heightfield then we just use it directly and avoid having to resample it
if (contenders.size() == 1 && offsets.empty())
{
ElevationLayer* layer = contenders[0].layer.get();
TileKey& contenderKey = contenders[0].key;
GeoHeightField layerHF = layer->createHeightField(contenderKey, 0);
if (layerHF.valid())
{
if (layerHF.getHeightField()->getNumColumns() == hf->getNumColumns() &&
layerHF.getHeightField()->getNumRows() == hf->getNumRows())
{
requiresResample = false;
memcpy(hf->getFloatArray()->asVector().data(),
layerHF.getHeightField()->getFloatArray()->asVector().data(),
sizeof(float) * hf->getFloatArray()->size()
);
deltaLOD->resize(hf->getFloatArray()->size(), 0);
realData = true;
}
}
}
// If we need to mosaic multiple layers or resample it to a new output tilesize go through a resampling loop.
if (requiresResample)
{
for (unsigned c = 0; c < numColumns; ++c)
{
double x = xmin + (dx * (double)c);
// periodically check for cancelation
if (progress && progress->isCanceled())
{
return false;
}
for (unsigned r = 0; r < numRows; ++r)
{
double y = ymin + (dy * (double)r);
// Collect elevations from each layer as necessary.
int resolvedIndex = -1;
示例5: getName
//.........这里部分代码省略.........
return GeoHeightField::INVALID;
// build a HF from the TileSource.
//hf = createHeightFieldImplementation( key, progress );
createImplementation(key, hf, normalMap, progress);
}
// Check for cancelation before writing to a cache
if (progress && progress->isCanceled())
{
return GeoHeightField::INVALID;
}
// validate it to make sure it's legal.
if ( hf.valid() && !validateHeightField(hf.get()) )
{
OE_WARN << LC << "Driver " << getTileSource()->getName() << " returned an illegal heightfield" << std::endl;
hf = 0L; // to fall back on cached data if possible.
}
// cache if necessary
if ( hf &&
cacheBin &&
!fromCache &&
policy.isCacheWriteable() )
{
cacheBin->write(cacheKey, hf.get(), 0L);
}
// We have an expired heightfield from the cache and no new data from the TileSource. So just return the cached data.
if (!hf.valid() && cachedHF.valid())
{
OE_DEBUG << LC << "Using cached but expired heightfield for " << key.str() << std::endl;
hf = cachedHF;
}
if ( !hf.valid() )
{
return GeoHeightField::INVALID;
}
// Set up the heightfield params.
double minx, miny, maxx, maxy;
key.getExtent().getBounds(minx, miny, maxx, maxy);
hf->setOrigin( osg::Vec3d( minx, miny, 0.0 ) );
double dx = (maxx - minx)/(double)(hf->getNumColumns()-1);
double dy = (maxy - miny)/(double)(hf->getNumRows()-1);
hf->setXInterval( dx );
hf->setYInterval( dy );
hf->setBorderWidth( 0 );
}
if ( hf.valid() )
{
result = GeoHeightField( hf.get(), normalMap.get(), key.getExtent() );
}
}
// Check for cancelation before writing to a cache:
if ( progress && progress->isCanceled() )
{
return GeoHeightField::INVALID;
}
// post-processing -- must be done before caching because it may alter the heightfield data
if ( result.valid() && !fromMemCache && hf.valid() )
{
if ( options().noDataPolicy() == NODATA_MSL )
{
// requested VDatum:
const VerticalDatum* outputVDatum = key.getExtent().getSRS()->getVerticalDatum();
const Geoid* geoid = 0L;
// if there's an output vdatum, just set all invalid's to zero MSL.
if ( outputVDatum == 0L )
{
// if the output is geodetic (HAE), but the input has a geoid,
// use that geoid to populate the invalid data at sea level.
const VerticalDatum* profileDatum = getProfile()->getSRS()->getVerticalDatum();
if ( profileDatum )
geoid = profileDatum->getGeoid();
}
HeightFieldUtils::resolveInvalidHeights(
hf.get(),
result.getExtent(),
NO_DATA_VALUE,
geoid );
}
}
// write to mem cache if needed:
if ( result.valid() && !fromMemCache && _memCache.valid() )
{
CacheBin* bin = _memCache->getOrCreateDefaultBin();
bin->write(cacheKey, result.getHeightField(), 0L);
}
return result;
}
示例6: GeoHeightField
//.........这里部分代码省略.........
// if we're cache-only, but didn't get data from the cache, fail silently.
if ( !hf.valid() && isCacheOnly() )
{
return GeoHeightField::INVALID;
}
if ( !hf.valid() )
{
// bad tilesource? fail
if ( !getTileSource() || !getTileSource()->isOK() )
return GeoHeightField::INVALID;
if ( !isKeyInRange(key) )
return GeoHeightField::INVALID;
// build a HF from the TileSource.
hf = createHeightFieldFromTileSource( key, progress );
// validate it to make sure it's legal.
if ( hf.valid() && !validateHeightField(hf.get()) )
{
OE_WARN << LC << "Driver " << getTileSource()->getName() << " returned an illegal heightfield" << std::endl;
hf = 0L; // to fall back on cached data if possible.
}
// memory cache first:
if ( hf && _memCache.valid() )
{
CacheBin* bin = _memCache->getOrCreateBin( key.getProfile()->getFullSignature() );
bin->write(key.str(), hf.get());
}
// cache if necessary
if ( hf &&
cacheBin &&
!fromCache &&
getCachePolicy().isCacheWriteable() )
{
cacheBin->write( key.str(), hf );
}
// We have an expired heightfield from the cache and no new data from the TileSource. So just return the cached data.
if (!hf.valid() && cachedHF.valid())
{
OE_DEBUG << LC << "Using cached but expired heightfield for " << key.str() << std::endl;
hf = cachedHF;
}
if ( !hf.valid() )
{
return GeoHeightField::INVALID;
}
// Set up the heightfield so we don't have to worry about it later
double minx, miny, maxx, maxy;
key.getExtent().getBounds(minx, miny, maxx, maxy);
hf->setOrigin( osg::Vec3d( minx, miny, 0.0 ) );
double dx = (maxx - minx)/(double)(hf->getNumColumns()-1);
double dy = (maxy - miny)/(double)(hf->getNumRows()-1);
hf->setXInterval( dx );
hf->setYInterval( dy );
hf->setBorderWidth( 0 );
}
if ( hf.valid() )
{
result = GeoHeightField( hf.get(), key.getExtent() );
}
}
// post-processing:
if ( result.valid() )
{
if ( _runtimeOptions.noDataPolicy() == NODATA_MSL )
{
// requested VDatum:
const VerticalDatum* outputVDatum = key.getExtent().getSRS()->getVerticalDatum();
const Geoid* geoid = 0L;
// if there's an output vdatum, just set all invalid's to zero MSL.
if ( outputVDatum == 0L )
{
// if the output is geodetic (HAE), but the input has a geoid,
// use that geoid to populate the invalid data at sea level.
const VerticalDatum* profileDatum = getProfile()->getSRS()->getVerticalDatum();
if ( profileDatum )
geoid = profileDatum->getGeoid();
}
HeightFieldUtils::resolveInvalidHeights(
result.getHeightField(),
result.getExtent(),
NO_DATA_VALUE,
geoid );
}
}
return result;
}