|
osgEarth 2.1.1
|
Collaboration diagram for osgEarth::CacheSeed:Public Member Functions | |
| CacheSeed () | |
| void | setMinLevel (const unsigned int &minLevel) |
| const unsigned int | getMinLevel () const |
| void | setMaxLevel (const unsigned int &maxLevel) |
| const unsigned int | getMaxLevel () const |
| const Bounds & | getBounds () const |
| void | setBounds (const Bounds &bounds) |
| void | setBounds (const double &minLon, const double &minLat, const double &maxLon, const double &maxLat) |
| void | setProgressCallback (osgEarth::ProgressCallback *progress) |
| void | seed (Map *map) |
Protected Member Functions | |
| void | processKey (const MapFrame &mapf, const TileKey &key) const |
| void | cacheTile (const MapFrame &mapf, const TileKey &key) const |
Protected Attributes | |
| unsigned int | _minLevel |
| unsigned int | _maxLevel |
| Bounds | _bounds |
| osg::ref_ptr< ProgressCallback > | _progress |
| osgEarth::CacheSeed::CacheSeed | ( | ) | [inline] |
Definition at line 189 of file CacheSeed.cpp.
{
for( ImageLayerVector::const_iterator i = mapf.imageLayers().begin(); i != mapf.imageLayers().end(); i++ )
{
ImageLayer* layer = i->get();
if ( layer->isKeyValid( key ) )
{
GeoImage image = layer->createImage( key );
}
}
if ( mapf.elevationLayers().size() > 0 )
{
osg::ref_ptr<osg::HeightField> hf;
mapf.getHeightField( key, false, hf );
}
}
Here is the call graph for this function:| const Bounds& osgEarth::CacheSeed::getBounds | ( | ) | const [inline] |
| const unsigned int osgEarth::CacheSeed::getMaxLevel | ( | ) | const [inline] |
| const unsigned int osgEarth::CacheSeed::getMinLevel | ( | ) | const [inline] |
Definition at line 149 of file CacheSeed.cpp.
{
unsigned int x, y, lod;
key.getTileXY(x, y);
lod = key.getLevelOfDetail();
// osg::ref_ptr<osgEarth::VersionedTerrain> terrain = new osgEarth::VersionedTerrain( map, engine );
if ( _minLevel <= lod && _maxLevel >= lod )
{
// OE_NOTICE << "Caching tile = " << key.str() << std::endl; //<< lod << " (" << x << ", " << y << ") " << std::endl;
if ( _progress.valid() && _progress->reportProgress(0, 0, "Caching tile: " + key.str()) )
return; // Task has been cancelled by user
cacheTile( mapf, key );
// bool validData;
//osg::ref_ptr<osg::Node> node = engine->createTile( map, terrain.get(), key, true, false, false, validData );
}
if (lod <= _maxLevel)
{
TileKey k0 = key.createChildKey(0);
TileKey k1 = key.createChildKey(1);
TileKey k2 = key.createChildKey(2);
TileKey k3 = key.createChildKey(3);
//Check to see if the bounds intersects ANY of the tile's children. If it does, then process all of the children
//for this level
if (_bounds.intersects( k0.getExtent().bounds() ) || _bounds.intersects(k1.getExtent().bounds()) ||
_bounds.intersects( k2.getExtent().bounds() ) || _bounds.intersects(k3.getExtent().bounds()) )
{
processKey(mapf, k0);
processKey(mapf, k1);
processKey(mapf, k2);
processKey(mapf, k3);
}
}
}
Here is the call graph for this function:| void CacheSeed::seed | ( | Map * | map | ) |
Performs the seed operation
Definition at line 28 of file CacheSeed.cpp.
{
//Threading::ScopedReadLock lock( map->getMapDataMutex() );
if ( !map->getMapOptions().cache().isSet() )
//if (!map->getCache())
{
OE_WARN << "Warning: Map does not have a cache defined, please define a cache." << std::endl;
return;
}
// osg::ref_ptr<MapEngine> engine = new MapEngine(); //map->createMapEngine();
std::vector<TileKey> keys;
map->getProfile()->getRootKeys(keys);
//Set the default bounds to the entire profile if the user didn't override the bounds
if (_bounds.xMin() == 0 && _bounds.yMin() == 0 &&
_bounds.xMax() == 0 && _bounds.yMax() == 0)
{
const GeoExtent& mapEx = map->getProfile()->getExtent();
_bounds = Bounds( mapEx.xMin(), mapEx.yMin(), mapEx.xMax(), mapEx.yMax() );
}
bool hasCaches = false;
int src_min_level = INT_MAX;
unsigned int src_max_level = 0;
MapFrame mapf( map, Map::TERRAIN_LAYERS, "CacheSeed::seed" );
//Assumes the the TileSource will perform the caching for us when we call createImage
for( ImageLayerVector::const_iterator i = mapf.imageLayers().begin(); i != mapf.imageLayers().end(); i++ )
{
ImageLayer* layer = i->get();
TileSource* src = i->get()->getTileSource();
const ImageLayerOptions& opt = layer->getImageLayerOptions();
if ( opt.cacheOnly() == true )
{
OE_WARN << "Warning: Cannot seed b/c Layer \"" << layer->getName() << "\" is cache only." << std::endl;
return;
}
else if (!src)
{
OE_WARN << "Warning: Layer \"" << layer->getName() << "\" could not create TileSource." << std::endl;
}
else if ( !src->supportsPersistentCaching() )
{
OE_WARN << "Warning: Layer \"" << layer->getName() << "\" does not support seeding." << std::endl;
}
else if ( !layer->getCache() )
{
OE_NOTICE << "Notice: Layer \"" << layer->getName() << "\" has no persistent cache defined; skipping." << std::endl;
}
else
{
hasCaches = true;
if (opt.minLevel().isSet() && opt.minLevel().get() < src_min_level)
src_min_level = opt.minLevel().get();
if (opt.maxLevel().isSet() && opt.maxLevel().get() > src_max_level)
src_max_level = opt.maxLevel().get();
}
}
for( ElevationLayerVector::const_iterator i = mapf.elevationLayers().begin(); i != mapf.elevationLayers().end(); i++ )
{
ElevationLayer* layer = i->get();
TileSource* src = i->get()->getTileSource();
const ElevationLayerOptions& opt = layer->getElevationLayerOptions();
if ( opt.cacheOnly().get())
{
OE_WARN << "Warning: Cannot seed b/c Layer \"" << layer->getName() << "\" is cache only." << std::endl;
return;
}
else if (!src)
{
OE_WARN << "Warning: Layer \"" << layer->getName() << "\" could not create TileSource." << std::endl;
}
else if ( !src->supportsPersistentCaching() )
{
OE_WARN << "Warning: Layer \"" << layer->getName() << "\" does not support seeding." << std::endl;
}
else if ( !layer->getCache() )
{
OE_NOTICE << "Notice: Layer \"" << src->getName() << "\" has no persistent cache defined; skipping." << std::endl;
}
else
{
hasCaches = true;
if (opt.minLevel().isSet() && opt.minLevel().get() < src_min_level)
src_min_level = opt.minLevel().get();
if (opt.maxLevel().isSet() && opt.maxLevel().get() > src_max_level)
src_max_level = opt.maxLevel().get();
}
}
if (!hasCaches)
{
OE_NOTICE << "There are either no caches defined in the map, or no sources to cache. Exiting." << std::endl;
return;
}
if ( src_max_level > 0 && src_max_level < _maxLevel )
{
_maxLevel = src_max_level;
}
OE_NOTICE << "Maximum cache level will be " << _maxLevel << std::endl;
for (unsigned int i = 0; i < keys.size(); ++i)
{
processKey( mapf, keys[i] );
}
}
Here is the call graph for this function:
Here is the caller graph for this function:| void osgEarth::CacheSeed::setBounds | ( | const double & | minLon, |
| const double & | minLat, | ||
| const double & | maxLon, | ||
| const double & | maxLat | ||
| ) | [inline] |
| void osgEarth::CacheSeed::setBounds | ( | const Bounds & | bounds | ) | [inline] |
| void osgEarth::CacheSeed::setMaxLevel | ( | const unsigned int & | maxLevel | ) | [inline] |
| void osgEarth::CacheSeed::setMinLevel | ( | const unsigned int & | minLevel | ) | [inline] |
| void osgEarth::CacheSeed::setProgressCallback | ( | osgEarth::ProgressCallback * | progress | ) | [inline] |
Bounds osgEarth::CacheSeed::_bounds [protected] |
unsigned int osgEarth::CacheSeed::_maxLevel [protected] |
unsigned int osgEarth::CacheSeed::_minLevel [protected] |
osg::ref_ptr<ProgressCallback> osgEarth::CacheSeed::_progress [protected] |
1.7.3