本文整理汇总了C++中GeoHeightField::getExtent方法的典型用法代码示例。如果您正苦于以下问题:C++ GeoHeightField::getExtent方法的具体用法?C++ GeoHeightField::getExtent怎么用?C++ GeoHeightField::getExtent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GeoHeightField
的用法示例。
在下文中一共展示了GeoHeightField::getExtent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: getName
GeoHeightField
ElevationLayer::createHeightField(const TileKey& key,
ProgressCallback* progress )
{
METRIC_SCOPED_EX("ElevationLayer::createHeightField", 2,
"key", key.str().c_str(),
"name", getName().c_str());
if (getStatus().isError())
{
return GeoHeightField::INVALID;
}
// If the layer is disabled, bail out.
if ( getEnabled() == false )
{
return GeoHeightField::INVALID;
}
GeoHeightField result;
osg::ref_ptr<osg::HeightField> hf;
osg::ref_ptr<NormalMap> normalMap;
// Check the memory cache first
bool fromMemCache = false;
// cache key combines the key with the full signature (incl vdatum)
// the cache key combines the Key and the horizontal profile.
std::string cacheKey = Cache::makeCacheKey(
Stringify() << key.str() << "-" << key.getProfile()->getHorizSignature(),
"elevation");
const CachePolicy& policy = getCacheSettings()->cachePolicy().get();
if ( _memCache.valid() )
{
CacheBin* bin = _memCache->getOrCreateDefaultBin();
ReadResult cacheResult = bin->readObject(cacheKey, 0L);
if ( cacheResult.succeeded() )
{
result = GeoHeightField(
static_cast<osg::HeightField*>(cacheResult.releaseObject()),
key.getExtent());
fromMemCache = true;
}
}
if ( !result.valid() )
{
// See if there's a persistent cache.
CacheBin* cacheBin = getCacheBin( key.getProfile() );
// Can we continue? Only if either:
// a) there is a valid tile source plugin;
// b) a tile source is not expected, meaning the subclass overrides getHeightField; or
// c) we are in cache-only mode and there is a valid cache bin.
bool canContinue =
getTileSource() ||
!isTileSourceExpected() ||
(policy.isCacheOnly() && cacheBin != 0L);
if (!canContinue)
{
disable("Error: layer does not have a valid TileSource, cannot create heightfield");
return GeoHeightField::INVALID;
}
// validate the existance of a valid layer profile.
if ( !policy.isCacheOnly() && !getProfile() )
{
disable("Could not establish a valid profile.. did you set one?");
return GeoHeightField::INVALID;
}
// Now attempt to read from the cache. Since the cached data is stored in the
// map profile, we can try this first.
bool fromCache = false;
osg::ref_ptr< osg::HeightField > cachedHF;
if ( cacheBin && policy.isCacheReadable() )
{
ReadResult r = cacheBin->readObject(cacheKey, 0L);
if ( r.succeeded() )
{
bool expired = policy.isExpired(r.lastModifiedTime());
cachedHF = r.get<osg::HeightField>();
if ( cachedHF && validateHeightField(cachedHF.get()) )
{
if (!expired)
{
hf = cachedHF;
fromCache = true;
}
}
}
}
// if we're cache-only, but didn't get data from the cache, fail silently.
if ( !hf.valid() && policy.isCacheOnly() )
//.........这里部分代码省略.........
示例3: GeoHeightField
GeoHeightField
ElevationLayer::createHeightField(const TileKey& key,
ProgressCallback* progress )
{
GeoHeightField result;
osg::ref_ptr<osg::HeightField> hf;
// If the layer is disabled, bail out.
if ( getEnabled() == false )
{
return GeoHeightField::INVALID;
}
// Check the memory cache first
if ( _memCache.valid() )
{
CacheBin* bin = _memCache->getOrCreateBin( key.getProfile()->getFullSignature() );
ReadResult cacheResult = bin->readObject(key.str() );
if ( cacheResult.succeeded() )
{
result = GeoHeightField(
static_cast<osg::HeightField*>(cacheResult.releaseObject()),
key.getExtent());
}
//_memCache->dumpStats(key.getProfile()->getFullSignature());
}
if ( !result.valid() )
{
// See if there's a persistent cache.
CacheBin* cacheBin = getCacheBin( key.getProfile() );
// validate that we have either a valid tile source, or we're cache-only.
if ( ! (getTileSource() || (isCacheOnly() && cacheBin) ) )
{
OE_WARN << LC << "Error: layer does not have a valid TileSource, cannot create heightfield" << std::endl;
_runtimeOptions.enabled() = false;
return GeoHeightField::INVALID;
}
// validate the existance of a valid layer profile.
if ( !isCacheOnly() && !getProfile() )
{
OE_WARN << LC << "Could not establish a valid profile" << std::endl;
_runtimeOptions.enabled() = false;
return GeoHeightField::INVALID;
}
// Now attempt to read from the cache. Since the cached data is stored in the
// map profile, we can try this first.
bool fromCache = false;
osg::ref_ptr< osg::HeightField > cachedHF;
if ( cacheBin && getCachePolicy().isCacheReadable() )
{
ReadResult r = cacheBin->readObject( key.str() );
if ( r.succeeded() )
{
bool expired = getCachePolicy().isExpired(r.lastModifiedTime());
cachedHF = r.get<osg::HeightField>();
if ( cachedHF && validateHeightField(cachedHF) )
{
if (!expired)
{
hf = cachedHF;
fromCache = true;
}
}
}
}
// 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() )
{
//.........这里部分代码省略.........