本文整理汇总了C++中TileKey::valid方法的典型用法代码示例。如果您正苦于以下问题:C++ TileKey::valid方法的具体用法?C++ TileKey::valid怎么用?C++ TileKey::valid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TileKey
的用法示例。
在下文中一共展示了TileKey::valid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
unsigned int
CacheEstimator::getNumTiles() const
{
unsigned int total = 0;
for (unsigned int level = _minLevel; level <= _maxLevel; level++)
{
if (_extents.empty())
{
unsigned int wide, high;
_profile->getNumTiles( level, wide, high );
total += (wide * high);
}
else
{
for (std::vector< GeoExtent >::const_iterator itr = _extents.begin(); itr != _extents.end(); ++itr)
{
const GeoExtent& extent = *itr;
TileKey ll = _profile->createTileKey(extent.xMin(), extent.yMin(), level);
TileKey ur = _profile->createTileKey(extent.xMax(), extent.yMax(), level);
if (!ll.valid() || !ur.valid()) continue;
int tilesWide = ur.getTileX() - ll.getTileX() + 1;
int tilesHigh = ll.getTileY() - ur.getTileY() + 1;
int tilesAtLevel = tilesWide * tilesHigh;
total += tilesAtLevel;
}
}
}
return total;
}
示例2: while
bool
OSGTileFactory::createValidGeoImage(ImageLayer* layer,
const TileKey& key,
GeoImage& out_image,
TileKey& out_actualTileKey,
ProgressCallback* progress)
{
//TODO: Redo this to just grab images from the parent TerrainTiles
//Try to create the image with the given key
out_actualTileKey = key;
while (out_actualTileKey.valid())
{
if ( layer->isKeyValid(out_actualTileKey) )
{
out_image = layer->createImage( out_actualTileKey, progress );
if ( out_image.valid() )
{
return true;
}
}
out_actualTileKey = out_actualTileKey.createParentKey();
}
return false;
}
示例3:
// This will be called by AnnotationNode when a new terrain tile comes in.
void
FeatureNode::onTileAdded(const TileKey& key,
osg::Node* graph,
TerrainCallbackContext& context)
{
if (!_clampDirty)
{
bool needsClamp;
if (key.valid())
{
osg::Polytope tope;
key.getExtent().createPolytope(tope);
needsClamp = tope.contains(this->getBound());
}
else
{
// without a valid tilekey we don't know the extent of the change,
// so clamping is required.
needsClamp = true;
}
if (needsClamp)
{
_clampDirty = true;
ADJUST_UPDATE_TRAV_COUNT(this, +1);
//clamp(graph, context.getTerrain());
}
}
}
示例4: getTerrainLayerOptions
bool
TerrainLayer::isKeyValid(const TileKey& key) const
{
if (!key.valid()) return false;
const TerrainLayerOptions& opt = getTerrainLayerOptions();
//Check to see if explicit levels of detail are set
if ( opt.minLevel().isSet() && (int)key.getLevelOfDetail() < opt.minLevel().value() ) return false;
if ( opt.maxLevel().isSet() && (int)key.getLevelOfDetail() > opt.maxLevel().value() ) return false;
//Check to see if levels of detail based on resolution are set
if (opt.minLevelResolution().isSet())
{
unsigned int minLevel = getProfile()->getLevelOfDetailForHorizResolution( opt.minLevelResolution().value(), getTileSize());
OE_DEBUG << "Computed min level of " << minLevel << std::endl;
if (key.getLevelOfDetail() < minLevel) return false;
}
if (opt.maxLevelResolution().isSet())
{
unsigned int maxLevel = getProfile()->getLevelOfDetailForHorizResolution( opt.maxLevelResolution().value(), getTileSize());
OE_DEBUG << "Computed max level of " << maxLevel << std::endl;
if (key.getLevelOfDetail() > maxLevel) return false;
}
return true;
}
示例5:
void
TileModelFactory::buildElevation(const TileKey& key,
const MapFrame& frame,
bool accumulate,
TileModel* model,
ProgressCallback* progress)
{
const MapInfo& mapInfo = frame.getMapInfo();
const osgEarth::ElevationInterpolation& interp =
frame.getMapOptions().elevationInterpolation().get();
// Request a heightfield from the map, falling back on lower resolution tiles
// if necessary (fallback=true)
osg::ref_ptr<osg::HeightField> hf;
bool isFallback = false;
if (_hfCache->getOrCreateHeightField(frame, key, accumulate, hf, isFallback, SAMPLE_FIRST_VALID, interp, progress))
{
model->_elevationData = TileModel::ElevationData(
hf,
GeoLocator::createForKey( key, mapInfo ),
isFallback );
// Edge normalization: requires adjacency information
if ( _terrainOptions.normalizeEdges() == true )
{
for( int x=-1; x<=1; x++ )
{
for( int y=-1; y<=1; y++ )
{
if ( x != 0 || y != 0 )
{
TileKey nk = key.createNeighborKey(x, y);
if ( nk.valid() )
{
osg::ref_ptr<osg::HeightField> hf;
if (_hfCache->getOrCreateHeightField(frame, nk, accumulate, hf, isFallback, SAMPLE_FIRST_VALID, interp, progress) )
{
model->_elevationData.setNeighbor( x, y, hf.get() );
}
}
}
}
}
// parent too.
if ( key.getLOD() > 0 )
{
osg::ref_ptr<osg::HeightField> hf;
if ( _hfCache->getOrCreateHeightField(frame, key.createParentKey(), accumulate, hf, isFallback, SAMPLE_FIRST_VALID, interp, progress) )
{
model->_elevationData.setParent( hf.get() );
}
}
}
}
}
示例6: sharedLock
void
OSGTileFactory::addPlaceholderHeightfieldLayer(StreamingTile* tile,
StreamingTile* ancestorTile,
GeoLocator* defaultLocator,
const TileKey& key,
const TileKey& ancestorKey)
{
osgTerrain::HeightFieldLayer* newHFLayer = 0L;
if ( ancestorTile && ancestorKey.valid() )
{
osg::ref_ptr<osgTerrain::HeightFieldLayer> ancestorLayer;
{
Threading::ScopedReadLock sharedLock( ancestorTile->getTileLayersMutex() );
ancestorLayer = dynamic_cast<osgTerrain::HeightFieldLayer*>(ancestorTile->getElevationLayer());
}
if ( ancestorLayer.valid() )
{
osg::ref_ptr<osg::HeightField> ancestorHF = ancestorLayer->getHeightField();
if ( ancestorHF.valid() )
{
osg::HeightField* newHF = HeightFieldUtils::createSubSample(
ancestorHF.get(),
ancestorKey.getExtent(),
key.getExtent());
newHFLayer = new osgTerrain::HeightFieldLayer( newHF );
newHFLayer->setLocator( defaultLocator );
// lock to set the elevation layerdata:
{
Threading::ScopedWriteLock exclusiveLock( tile->getTileLayersMutex() );
tile->setElevationLayer( newHFLayer );
tile->setElevationLOD( ancestorTile->getElevationLOD() );
}
}
}
}
// lock the tile to write the elevation data.
{
Threading::ScopedWriteLock exclusiveLock( tile->getTileLayersMutex() );
if ( !newHFLayer )
{
newHFLayer = new osgTerrain::HeightFieldLayer();
newHFLayer->setHeightField( createEmptyHeightField( key, 8, 8 ) );
newHFLayer->setLocator( defaultLocator );
tile->setElevationLOD( -1 );
}
if ( newHFLayer )
{
tile->setElevationLayer( newHFLayer );
}
}
}
示例7: TileModel
osg::Node*
MPTerrainEngineNode::createTile( const TileKey& key )
{
osg::ref_ptr<TileModel> model = new TileModel( _update_mapf->getRevision(), _update_mapf->getMapInfo() );
model->_tileKey = key;
model->_tileLocator = GeoLocator::createForKey(key, _update_mapf->getMapInfo());
// Build the heightfield
const MapInfo& mapInfo = _update_mapf->getMapInfo();
const osgEarth::ElevationInterpolation& interp = _update_mapf->getMapOptions().elevationInterpolation().get();
// Request a heightfield from the map, falling back on lower resolution tiles
osg::ref_ptr<osg::HeightField> hf;
TileKey sampleKey = key;
bool populated = false;
if (_update_mapf->elevationLayers().size() > 0)
{
while (!populated)
{
populated = _update_mapf->populateHeightField(hf, sampleKey, true, SAMPLE_FIRST_VALID);
if (!populated)
{
// Fallback on the parent
sampleKey = sampleKey.createParentKey();
if (!sampleKey.valid())
{
return 0;
}
}
}
}
if (!populated)
{
// We have no heightfield so just create a reference heightfield.
hf = HeightFieldUtils::createReferenceHeightField( key.getExtent(), 15, 15 );
sampleKey = key;
}
model->_elevationData = TileModel::ElevationData(
hf,
GeoLocator::createForKey( sampleKey, mapInfo ),
false );
bool optimizeTriangleOrientation = getMap()->getMapOptions().elevationInterpolation() != INTERP_TRIANGULATE;
osg::ref_ptr<TileModelCompiler> compiler = new TileModelCompiler(
_update_mapf->terrainMaskLayers(),
_update_mapf->modelLayers(),
_primaryUnit,
optimizeTriangleOrientation,
_terrainOptions );
return compiler->compile(model.get(), *_update_mapf, 0L);
}
示例8: clamp
void
ImageOverlay::onTileAdded(const TileKey& key,
osg::Node* graph,
TerrainCallbackContext& context)
{
if ( graph == 0L || !key.valid() || _boundingPolytope.contains(graph->getBound()) )
{
clamp( graph, context.getTerrain() );
}
}
示例9: getProfile
bool
TerrainLayer::isKeyInLegalRange(const TileKey& key) const
{
if ( !key.valid() )
{
return false;
}
// We must use the equivalent lod b/c the input key can be in any profile.
unsigned localLOD = getProfile() ?
getProfile()->getEquivalentLOD(key.getProfile(), key.getLOD()) :
key.getLOD();
// First check the key against the min/max level limits, it they are set.
if ((options().maxLevel().isSet() && localLOD > options().maxLevel().value()) ||
(options().minLevel().isSet() && localLOD < options().minLevel().value()))
{
return false;
}
// Next check the maxDataLevel if that is set.
if (options().maxDataLevel().isSet() && localLOD > options().maxDataLevel().get())
{
return false;
}
// Next, check against resolution limits (based on the source tile size).
if (options().minResolution().isSet() || options().maxResolution().isSet())
{
const Profile* profile = getProfile();
if ( profile )
{
// calculate the resolution in the layer's profile, which can
// be different that the key's profile.
double resKey = key.getExtent().width() / (double)getTileSize();
double resLayer = key.getProfile()->getSRS()->transformUnits(resKey, profile->getSRS());
if (options().maxResolution().isSet() &&
options().maxResolution().value() > resLayer)
{
return false;
}
if (options().minResolution().isSet() &&
options().minResolution().value() < resLayer)
{
return false;
}
}
}
return true;
}
示例10: isKeyValid
bool
ElevationLayer::isKeyValid(const TileKey& key) const
{
if (!key.valid())
return false;
if ( _runtimeOptions.minLevel().isSet() && key.getLOD() < _runtimeOptions.minLevel().value() )
{
return false;
}
return TerrainLayer::isKeyValid(key);
}
示例11: OnTileAddedOperation
void
Terrain::notifyTileAdded( const TileKey& key, osg::Node* node )
{
if ( !node )
{
OE_WARN << LC << "notify with a null node!" << std::endl;
}
if (_callbacksSize > 0)
{
if (!key.valid())
OE_WARN << LC << "notifyTileAdded with key = NULL\n";
_updateQueue->add(new OnTileAddedOperation(key, node, this));
}
}
示例12: getProfile
bool
TerrainLayer::isKeyInRange(const TileKey& key) const
{
if ( !key.valid() )
{
return false;
}
// First check the key against the min/max level limits, it they are set.
if ((_runtimeOptions->maxLevel().isSet() && key.getLOD() > _runtimeOptions->maxLevel().value()) ||
(_runtimeOptions->minLevel().isSet() && key.getLOD() < _runtimeOptions->minLevel().value()))
{
return false;
}
// Next, check against resolution limits (based on the source tile size).
if (_runtimeOptions->minResolution().isSet() ||
_runtimeOptions->maxResolution().isSet())
{
const Profile* profile = getProfile();
if ( profile )
{
// calculate the resolution in the layer's profile, which can
// be different that the key's profile.
double resKey = key.getExtent().width() / (double)getTileSize();
double resLayer = key.getProfile()->getSRS()->transformUnits(resKey, profile->getSRS());
if (_runtimeOptions->maxResolution().isSet() &&
_runtimeOptions->maxResolution().value() > resLayer)
{
return false;
}
if (_runtimeOptions->minResolution().isSet() &&
_runtimeOptions->minResolution().value() < resLayer)
{
return false;
}
}
}
return true;
}
示例13: getProfile
bool
TerrainLayer::isKeyValid(const TileKey& key) const
{
if (!key.valid())
return false;
// Check to see if an explicity max LOD is set. Do NOT compare against the minLevel,
// because we still need to create empty tiles until we get to the data. The ImageLayer
// will deal with this.
if ( _runtimeOptions->maxLevel().isSet() && key.getLOD() > _runtimeOptions->maxLevel().value() )
{
return false;
}
// Check to see if levels of detail based on resolution are set
const Profile* profile = getProfile();
if ( profile )
{
if ( !profile->isEquivalentTo( key.getProfile() ) )
{
OE_DEBUG << LC
<< "TerrainLayer::isKeyValid called with key of a different profile" << std::endl;
//return true;
}
if ( _runtimeOptions->maxResolution().isSet() )
{
double keyres = key.getExtent().width() / (double)getTileSize();
double keyresInLayerProfile = key.getProfile()->getSRS()->transformUnits(keyres, profile->getSRS());
if ( _runtimeOptions->maxResolution().isSet() && keyresInLayerProfile < _runtimeOptions->maxResolution().value() )
{
return false;
}
}
}
return true;
}
示例14: while
bool
ElevationPool::fetchTileFromMap(const TileKey& key, MapFrame& frame, Tile* tile)
{
tile->_loadTime = osg::Timer::instance()->tick();
osg::ref_ptr<osg::HeightField> hf = new osg::HeightField();
hf->allocate( _tileSize, _tileSize );
// Initialize the heightfield to nodata
hf->getFloatArray()->assign( hf->getFloatArray()->size(), NO_DATA_VALUE );
TileKey keyToUse = key;
while( !tile->_hf.valid() && keyToUse.valid() )
{
bool ok;
if (_layers.empty())
{
OE_TEST << LC << "Populating from FULL MAP (" << keyToUse.str() << ")\n";
ok = frame.populateHeightField(hf, keyToUse, false /*heightsAsHAE*/, 0L);
}
else
{
OE_TEST << LC << "Populating from layers (" << keyToUse.str() << ")\n";
ok = _layers.populateHeightFieldAndNormalMap(hf.get(), 0L, keyToUse, 0L, INTERP_BILINEAR, 0L);
}
if (ok)
{
tile->_hf = GeoHeightField( hf.get(), keyToUse.getExtent() );
tile->_bounds = keyToUse.getExtent().bounds();
}
else
{
keyToUse = keyToUse.createParentKey();
}
}
return tile->_hf.valid();
}
示例15: bestKey
//.........这里部分代码省略.........
unsigned int maxHeightFields = 50;
unsigned numHeightFieldsInCache = 0;
//double fallBackTime = 0;
const SpatialReference* keySRS = keyToUse.getProfile()->getSRS();
bool realData = false;
//unsigned int numFallback = 0;
unsigned int total = numColumns * numRows;
unsigned int completed = 0;
for (unsigned c = 0; c < numColumns; ++c)
{
double x = xmin + (dx * (double)c);
for (unsigned r = 0; r < numRows; ++r)
{
double y = ymin + (dy * (double)r);
// Collect elevations from each layer as necessary.
bool resolved = false;
for(int i=0; i<contenders.size() && !resolved; ++i)
{
if ( heightFailed[i] )
continue;
ElevationLayer* layer = contenders[i].first.get();
GeoHeightField& layerHF = heightFields[i];
if ( !layerHF.valid() )
{
layerHF = layer->createHeightField(contenders[i].second, progress);
if ( !layerHF.valid() )
{
// This layer potentially has data or it wouldn't have ended up in the contendors list, so try falling back on the parent
TileKey parentKey = contenders[i].second.createParentKey();
while (!layerHF.valid() && parentKey.valid())
{
//numFallback++;
//osg::Timer_t fbStartTime = osg::Timer::instance()->tick();
GeoHeightField parentHF = layer->createHeightField(parentKey, progress);
//osg::Timer_t fbEndTime = osg::Timer::instance()->tick();
// Only penalize time wasted actually falling back.
//if (!parentHF.valid())
// {
// fallBackTime += osg::Timer::instance()->delta_m(fbStartTime, fbEndTime);
//}
if (parentHF.valid())
{
layerHF = parentHF;
break;
}
else
{
parentKey = parentKey.createParentKey();
}
}