目标:(十二)中问题13
是Map的时间快照,如注释所说的那样:
/**
* A "snapshot in time" of a Map model revision. Use this class to get a safe "copy" of
* the map model lists that you can use without worrying about the model changing underneath
* you from another thread.
*/
class OSGEARTH_EXPORT MapFrame
osgEarth::MapFrame,是对Map的更高一级封装,经过MpaFrame包装Map可以监控地图图层的变化情况。
对地图进行了一层封装,能够管理地图的版本号、影像层、高层层等。MapFrame的版本号的含义主要是用来判断是否与Map的版本号一致,如果不一致就需要对MapFram和Map进行同步。
osgEarth/MapFrame.cpp
bool
MapFrame::needsSync() const
{
if ( !isValid() )
return false;
osg::ref_ptr<const Map> map;
return
_map.lock(map) &&
(map->getDataModelRevision() != _mapDataModelRevision || !_initialized);
}
使用的场合:
1、计算瓦片包围盒时,包围盒回调函数会放入rex引擎的上下文环境中,供使用
osgEarthDrivers/engine_rex/RexTerrainEngineNode.cpp
void
RexTerrainEngineNode::setMap(const Map* map, const TerrainOptions& options)
{
_modifyBBoxCallback = new ModifyBoundingBoxCallback(_mapFrame);
_engineContext = new EngineContext(
getMap(),
this, // engine
_geometryPool.get(),
_loader.get(),
_unloader.get(),
_rasterizer,
_liveTiles.get(),
_renderBindings,
_terrainOptions,
_selectionInfo,
_modifyBBoxCallback.get());
}
osgEarthDrivers/engine_rex/TileDrawable
struct ModifyBoundingBoxCallback : public osg::Referenced
{
void operator()(const TileKey& key, osg::BoundingBox& bbox) const
{
if (_frame.needsSync())
{
Threading::ScopedMutexLock lock(_mutex);
_frame.sync();
}
for (LayerVector::const_iterator layer = _frame.layers().begin();
layer != _frame.layers().end();
++layer)
{
if (layer->valid())
{