本文整理汇总了C++中MapFrame::getMapInfo方法的典型用法代码示例。如果您正苦于以下问题:C++ MapFrame::getMapInfo方法的具体用法?C++ MapFrame::getMapInfo怎么用?C++ MapFrame::getMapInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MapFrame
的用法示例。
在下文中一共展示了MapFrame::getMapInfo方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
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() );
}
}
}
}
}
示例2: TileModel
void
TileModelFactory::createTileModel(const TileKey& key,
const MapFrame& frame,
bool accumulate,
osg::ref_ptr<TileModel>& out_model,
ProgressCallback* progress)
{
osg::ref_ptr<TileModel> model = new TileModel( frame.getRevision(), frame.getMapInfo() );
model->_useParentData = _terrainReqs->parentTexturesRequired();
model->_tileKey = key;
model->_tileLocator = GeoLocator::createForKey(key, frame.getMapInfo());
OE_START_TIMER(fetch_imagery);
// Fetch the image data and make color layers.
unsigned index = 0;
unsigned order = 0;
for( ImageLayerVector::const_iterator i = frame.imageLayers().begin(); i != frame.imageLayers().end(); ++i )
{
ImageLayer* layer = i->get();
if ( layer->getEnabled() && layer->isKeyInRange(key) )
{
BuildColorData build;
build.init( key, layer, order, frame.getMapInfo(), _terrainOptions, _liveTiles.get(), model.get() );
bool addedToModel = build.execute(progress);
if ( addedToModel )
{
// only bump the order if we added something to the data model.
order++;
}
}
}
if (progress)
progress->stats()["fetch_imagery_time"] += OE_STOP_TIMER(fetch_imagery);
// make an elevation layer.
OE_START_TIMER(fetch_elevation);
buildElevation(key, frame, accumulate, _terrainReqs->elevationTexturesRequired(), model.get(), progress);
if (progress)
progress->stats()["fetch_elevation_time"] += OE_STOP_TIMER(fetch_elevation);
// make a normal map layer (if necessary)
if ( _terrainReqs->normalTexturesRequired() )
{
OE_START_TIMER(fetch_normalmap);
buildNormalMap(key, frame, accumulate, model.get(), progress);
if (progress)
progress->stats()["fetch_normalmap_time"] += OE_STOP_TIMER(fetch_normalmap);
}
// If nothing was added, not even a fallback heightfield, something went
// horribly wrong. Leave without a tile model. Chances are that a parent tile
// not not found in the live-tile registry.
if ( model->_colorData.size() == 0 && !model->_elevationData.getHeightField() )
{
return;
}
// OK we are making a tile, so if there's no heightfield yet, make an empty one (and mark it
// as fallback data of course)
if ( !model->_elevationData.getHeightField() )
{
osg::HeightField* hf = HeightFieldUtils::createReferenceHeightField( key.getExtent(), 15, 15 );
model->_elevationData = TileModel::ElevationData(
hf,
GeoLocator::createForKey(key, frame.getMapInfo()),
true );
}
// look up the parent model and cache it.
osg::ref_ptr<TileNode> parentTile;
if ( _liveTiles->get(key.createParentKey(), parentTile) )
{
model->_parentModel = parentTile->getTileModel();
}
out_model = model.release();
}
示例3:
void
TileModelFactory::buildNormalMap(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;
osg::ref_ptr<osg::HeightField> parentHF;
osg::ref_ptr<const TileModel> parentModel;
bool isFallback = false;
unsigned minNormalLOD =
_terrainOptions.minNormalMapLOD().isSet() ?
_terrainOptions.minNormalMapLOD().get() : 0u;
if ( key.getLOD() >= minNormalLOD )
{
// look up the parent's heightfield to use as a template
TileKey parentKey = key.createParentKey();
if ( accumulate )
{
osg::ref_ptr<TileNode> parentNode;
if (_liveTiles->get(parentKey, parentNode))
{
parentModel = parentNode->getTileModel();
parentHF = parentModel->_normalData.getHeightField();
if ( parentHF->getNumColumns() == EMPTY_NORMAL_MAP_SIZE )
parentHF = 0L;
}
}
// Make a new heightfield:
if (_normalHFCache->getOrCreateHeightField(frame, key, parentHF.get(), hf, isFallback, SAMPLE_FIRST_VALID, interp, progress))
{
if ( isFallback && parentModel.valid() )
{
model->_normalData = parentModel->_normalData;
model->_normalData._fallbackData = true;
}
else
{
model->_normalData = TileModel::NormalData(
hf,
GeoLocator::createForKey( key, mapInfo ),
isFallback );
}
}
}
else
{
// empty HF must be at least 2x2 for normal texture gen to work
hf = HeightFieldUtils::createReferenceHeightField(
key.getExtent(), EMPTY_NORMAL_MAP_SIZE, EMPTY_NORMAL_MAP_SIZE, true );
model->_normalData = TileModel::NormalData(
hf,
GeoLocator::createForKey( key, mapInfo ),
false );
}
if ( isFallback && parentModel.valid() )
{
model->_normalTexture = parentModel->_normalTexture.get();
}
else
{
model->generateNormalTexture();
}
}
示例4:
bool
HeightFieldCache::getOrCreateHeightField(const MapFrame& frame,
const TileKey& key,
//bool cummulative,
const osg::HeightField* parent_hf,
osg::ref_ptr<osg::HeightField>& out_hf,
bool& out_isFallback,
ElevationSamplePolicy samplePolicy,
ElevationInterpolation interp,
ProgressCallback* progress )
{
// default
out_isFallback = false;
// check the quick cache.
HFKey cachekey;
cachekey._key = key;
cachekey._revision = frame.getRevision();
cachekey._samplePolicy = samplePolicy;
if (progress)
progress->stats()["hfcache_try_count"] += 1;
bool hit = false;
LRUCache<HFKey,HFValue>::Record rec;
if ( _cache.get(cachekey, rec) )
{
out_hf = rec.value()._hf.get();
out_isFallback = rec.value()._isFallback;
if (progress)
{
progress->stats()["hfcache_hit_count"] += 1;
progress->stats()["hfcache_hit_rate"] = progress->stats()["hfcache_hit_count"]/progress->stats()["hfcache_try_count"];
}
return true;
}
// Find the parent tile and start with its heightfield.
if ( parent_hf )
{
TileKey parentKey = key.createParentKey();
out_hf = HeightFieldUtils::createSubSample(
parent_hf,
parentKey.getExtent(),
key.getExtent(),
interp );
if ( !out_hf.valid() && ((int)key.getLOD())-1 > _firstLOD )
{
// This most likely means that a parent tile expired while we were building the child.
// No harm done in that case as this tile will soo be discarded as well.
OE_DEBUG << "MP HFC: Unable to find tile " << key.str() << " in the live tile registry"
<< std::endl;
return false;
}
}
if ( !out_hf.valid() )
{
//TODO.
// This sets the elevation tile size; query size for all tiles.
out_hf = HeightFieldUtils::createReferenceHeightField(
key.getExtent(), _tileSize, _tileSize, true );
}
bool populated = frame.populateHeightField(
out_hf,
key,
true, // convertToHAE
samplePolicy,
progress );
// Treat Plate Carre specially by scaling the height values. (There is no need
// to do this with an empty heightfield)
const MapInfo& mapInfo = frame.getMapInfo();
if ( mapInfo.isPlateCarre() )
{
HeightFieldUtils::scaleHeightFieldToDegrees( out_hf.get() );
}
// cache it.
HFValue cacheval;
cacheval._hf = out_hf.get();
cacheval._isFallback = !populated;
_cache.insert( cachekey, cacheval );
out_isFallback = !populated;
return true;
}
示例5: TileModel
void
TileModelFactory::createTileModel(const TileKey& key,
const MapFrame& frame,
osg::ref_ptr<TileModel>& out_model) //,
//bool& out_hasRealData)
{
osg::ref_ptr<TileModel> model = new TileModel( frame.getRevision(), frame.getMapInfo() );
model->_tileKey = key;
model->_tileLocator = GeoLocator::createForKey(key, frame.getMapInfo());
// Fetch the image data and make color layers.
unsigned order = 0;
for( ImageLayerVector::const_iterator i = frame.imageLayers().begin(); i != frame.imageLayers().end(); ++i )
{
ImageLayer* layer = i->get();
if ( layer->getEnabled() )
{
BuildColorData build;
build.init( key, layer, order, frame.getMapInfo(), _terrainOptions, model.get() );
bool addedToModel = build.execute();
if ( addedToModel )
{
// only bump the order if we added something to the data model.
order++;
}
}
}
// make an elevation layer.
BuildElevationData build;
build.init( key, frame, _terrainOptions, model.get(), _hfCache );
build.execute();
// Bail out now if there's no data to be had.
if ( model->_colorData.size() == 0 && !model->_elevationData.getHeightField() )
{
return;
}
// OK we are making a tile, so if there's no heightfield yet, make an empty one (and mark it
// as fallback data of course)
if ( !model->_elevationData.getHeightField() )
{
osg::HeightField* hf = HeightFieldUtils::createReferenceHeightField( key.getExtent(), 15, 15 );
model->_elevationData = TileModel::ElevationData(
hf,
GeoLocator::createForKey(key, frame.getMapInfo()),
true );
}
// look up the parent model and cache it.
osg::ref_ptr<TileNode> parentTile;
if ( _liveTiles->get(key.createParentKey(), parentTile) )
model->_parentModel = parentTile->getTileModel();
out_model = model.release();
}