osgEarth 2.1.1
|
Public Member Functions | |
TileBlacklist () | |
void | add (const osgTerrain::TileID &tile) |
void | remove (const osgTerrain::TileID &tile) |
void | clear () |
bool | contains (const osgTerrain::TileID &tile) const |
unsigned int | size () const |
void | write (std::ostream &output) const |
void | write (const std::string &filename) const |
Static Public Member Functions | |
static TileBlacklist * | read (std::istream &in) |
static TileBlacklist * | read (const std::string &filename) |
Private Types | |
typedef std::set < osgTerrain::TileID > | BlacklistedTiles |
Private Attributes | |
BlacklistedTiles | _tiles |
osgEarth::Threading::ReadWriteMutex | _mutex |
A collection of tiles that should be considered blacklisted
Definition at line 144 of file TileSource.
typedef std::set< osgTerrain::TileID > osgEarth::TileBlacklist::BlacklistedTiles [private] |
Definition at line 198 of file TileSource.
TileBlacklist::TileBlacklist | ( | ) |
Creates a new TileBlacklist
Definition at line 38 of file TileSource.cpp.
{
//NOP
}
void TileBlacklist::add | ( | const osgTerrain::TileID & | tile | ) |
Adds the given tile to the blacklist
Definition at line 44 of file TileSource.cpp.
{ Threading::ScopedWriteLock lock(_mutex); _tiles.insert(tile); OE_DEBUG << "Added " << tile.level << " (" << tile.x << ", " << tile.y << ") to blacklist" << std::endl; }
void TileBlacklist::clear | ( | ) |
Removes all tiles from the blacklist
Definition at line 60 of file TileSource.cpp.
{ Threading::ScopedWriteLock lock(_mutex); _tiles.clear(); OE_DEBUG << "Cleared blacklist" << std::endl; }
bool TileBlacklist::contains | ( | const osgTerrain::TileID & | tile | ) | const |
Returns whether the given tile is in the blacklist
Definition at line 68 of file TileSource.cpp.
{ Threading::ScopedReadLock lock(const_cast<TileBlacklist*>(this)->_mutex); return _tiles.find(tile) != _tiles.end(); }
TileBlacklist * TileBlacklist::read | ( | const std::string & | filename | ) | [static] |
Reads a TileBlacklist from the given filename
Definition at line 106 of file TileSource.cpp.
{ if (osgDB::fileExists(filename) && (osgDB::fileType(filename) == osgDB::REGULAR_FILE)) { std::ifstream in( filename.c_str() ); return read( in ); } return NULL; }
TileBlacklist * TileBlacklist::read | ( | std::istream & | in | ) | [static] |
Reads a TileBlacklist from the given istream
Definition at line 82 of file TileSource.cpp.
{ osg::ref_ptr< TileBlacklist > result = new TileBlacklist(); while (!in.eof()) { std::string line; std::getline(in, line); if (!line.empty()) { int z, x, y; if (sscanf(line.c_str(), "%d %d %d", &z, &x, &y) == 3) { result->add(osgTerrain::TileID(z, x, y )); } } } return result.release(); }
void TileBlacklist::remove | ( | const osgTerrain::TileID & | tile | ) |
Removes the given tile from the blacklist
Definition at line 52 of file TileSource.cpp.
{ Threading::ScopedWriteLock lock(_mutex); _tiles.erase(tile); OE_DEBUG << "Removed " << tile.level << " (" << tile.x << ", " << tile.y << ") from blacklist" << std::endl; }
unsigned int TileBlacklist::size | ( | ) | const |
Returns the size of the blacklist
Definition at line 75 of file TileSource.cpp.
{ Threading::ScopedReadLock lock(const_cast<TileBlacklist*>(this)->_mutex); return _tiles.size(); }
void TileBlacklist::write | ( | const std::string & | filename | ) | const |
Writes this TileBlacklist to the given filename
Definition at line 117 of file TileSource.cpp.
{ std::string path = osgDB::getFilePath(filename); if (!path.empty() && !osgDB::fileExists(path) && !osgDB::makeDirectory(path)) { OE_NOTICE << "Couldn't create path " << path << std::endl; return; } std::ofstream out(filename.c_str()); write(out); }
void TileBlacklist::write | ( | std::ostream & | output | ) | const |
Writes this TileBlacklist to the given ostream
Definition at line 130 of file TileSource.cpp.
{ Threading::ScopedReadLock lock(const_cast<TileBlacklist*>(this)->_mutex); for (BlacklistedTiles::const_iterator itr = _tiles.begin(); itr != _tiles.end(); ++itr) { output << itr->level << " " << itr->x << " " << itr->y << std::endl; } }
Definition at line 200 of file TileSource.
Definition at line 199 of file TileSource.