osgEarth 2.1.1
Classes | Public Member Functions | Protected Member Functions | Private Attributes | Friends

osgEarth::TileSource Class Reference

Inheritance diagram for osgEarth::TileSource:
Collaboration diagram for osgEarth::TileSource:

List of all members.

Classes

struct  HeightFieldOperation
struct  ImageOperation

Public Member Functions

 TileSource (const TileSourceOptions &options=TileSourceOptions())
virtual int getPixelsPerTile () const
const DataExtentListgetDataExtents () const
DataExtentListgetDataExtents ()
virtual osg::Image * createImage (const TileKey &key, ImageOperation *op=0L, ProgressCallback *progress=0L)
virtual osg::HeightField * createHeightField (const TileKey &key, HeightFieldOperation *prepOp=0L, ProgressCallback *progress=0L)
virtual bool isOK () const
bool isValid () const
virtual const ProfilegetProfile () const
virtual float getNoDataValue ()
virtual float getNoDataMinValue ()
virtual float getNoDataMaxValue ()
virtual unsigned int getMaxDataLevel () const
virtual unsigned int getMinDataLevel () const
virtual bool supportsPersistentCaching () const
virtual std::string getExtension () const
TileBlacklistgetBlacklist ()
const TileBlacklistgetBlacklist () const
virtual bool hasData (const TileKey &key) const
virtual bool hasDataAtLOD (unsigned lod) const
virtual bool hasDataInExtent (const GeoExtent &extent) const
virtual bool isDynamic () const
virtual osg::Object * cloneType () const
virtual osg::Object * clone (const osg::CopyOp &) const
virtual bool isSameKindAs (const osg::Object *obj) const
virtual const char * className () const
virtual const char * libraryName () const
virtual void initialize (const std::string &referenceURI, const Profile *overrideProfile=NULL)=0
const TileSourceOptionsgetOptions () const

Protected Member Functions

virtual ~TileSource ()
virtual osg::Image * createImage (const TileKey &key, ProgressCallback *progress)=0
virtual osg::HeightField * createHeightField (const TileKey &key, ProgressCallback *progress)
void setProfile (const Profile *profile)

Private Attributes

osg::ref_ptr< const Profile_profile
const TileSourceOptions _options
osg::ref_ptr< TileBlacklist_blacklist
std::string _blacklistFilename
osg::ref_ptr< MemCache_memCache
DataExtentList _dataExtents

Friends

class Map
class MapEngine
class TileSourceFactory

Detailed Description

A TileSource is an object that can create image and/or heightfield tiles. Driver plugins are responsible for creating and returning a TileSource that the Map will then use to create tiles for tile keys.

Definition at line 208 of file TileSource.


Constructor & Destructor Documentation

TileSource::TileSource ( const TileSourceOptions options = TileSourceOptions())

Definition at line 141 of file TileSource.cpp.

                                                         :
_options( options )
{
    this->setThreadSafeRefUnref( true );

    if ( *options.L2CacheSize() > 0 )
    {
        _memCache = new MemCache( *options.L2CacheSize() );
    }
    else
    {
        OE_INFO << LC << "L2 Cache disabled" << std::endl;
    }

    if (_options.blacklistFilename().isSet())
    {
        _blacklistFilename = _options.blacklistFilename().value();
    }

    
    if (!_blacklistFilename.empty() && osgDB::fileExists(_blacklistFilename))
    {
        _blacklist = TileBlacklist::read(_blacklistFilename);
        if (_blacklist.valid())
        {
            OE_INFO << "Read blacklist from file" << _blacklistFilename << std::endl;
        }
    }

    if (!_blacklist.valid())
    {
        //Initialize the blacklist if we couldn't read it.
        _blacklist = new TileBlacklist();
    }
}

Here is the call graph for this function:

TileSource::~TileSource ( ) [protected, virtual]

Definition at line 177 of file TileSource.cpp.

{
    if (_blacklist.valid() && !_blacklistFilename.empty())
    {
        _blacklist->write(_blacklistFilename);
    }
}

Member Function Documentation

virtual const char* osgEarth::TileSource::className ( ) const [inline, virtual]

Reimplemented in osgEarth::Features::FeatureTileSource.

Definition at line 338 of file TileSource.

{ return "TileSource"; }
virtual osg::Object* osgEarth::TileSource::clone ( const osg::CopyOp &  ) const [inline, virtual]

Reimplemented in osgEarth::Features::FeatureTileSource.

Definition at line 336 of file TileSource.

{ return 0; } // clone() not appropriate
virtual osg::Object* osgEarth::TileSource::cloneType ( ) const [inline, virtual]

Reimplemented in osgEarth::Features::FeatureTileSource.

Definition at line 335 of file TileSource.

{ return 0; } // cloneType() not appropriate
osg::HeightField * TileSource::createHeightField ( const TileKey key,
HeightFieldOperation prepOp = 0L,
ProgressCallback progress = 0L 
) [virtual]

Creates a heightfield for the given TileKey

Definition at line 219 of file TileSource.cpp.

{
    // Try to get it from the memcache first:
        if (_memCache.valid())
        {
        osg::ref_ptr<const osg::HeightField> cachedHF;
                if ( _memCache->getHeightField( key, CacheSpec(), cachedHF ) )
        {
            return new osg::HeightField( *cachedHF.get() );
        }
        }

    osg::ref_ptr<osg::HeightField> newHF = createHeightField( key, progress );

    if ( prepOp )
        (*prepOp)( newHF );

    if ( newHF.valid() && _memCache.valid() )
    {
        _memCache->setHeightField( key, CacheSpec(), newHF.get() );
    }

    //TODO: why not just newHF.release()? -gw
    return newHF.valid() ? new osg::HeightField( *newHF.get() ) : 0L;
}

Here is the caller graph for this function:

osg::HeightField * TileSource::createHeightField ( const TileKey key,
ProgressCallback progress 
) [protected, virtual]

Creates a heightfield for the given TileKey The returned object is new and is the responsibility of the caller.

Reimplemented in ArcGISSource, AGSMapCacheSource, GDALTileSource, TileServiceSource, VPBSource, WCS11Source, WMSSource, WorldWindSource, and YahooSource.

Definition at line 246 of file TileSource.cpp.

{
    osg::ref_ptr<osg::Image> image = createImage(key, progress);
    osg::HeightField* hf = 0;
    if (image.valid())
    {
        ImageToHeightFieldConverter conv;
        hf = conv.convert( image.get() );
    }      
    return hf;
}

Here is the call graph for this function:

osg::Image * TileSource::createImage ( const TileKey key,
ImageOperation op = 0L,
ProgressCallback progress = 0L 
) [virtual]

Creates an image for the given TileKey

Definition at line 192 of file TileSource.cpp.

{
    // Try to get it from the memcache fist
    if (_memCache.valid())
    {
        osg::ref_ptr<const osg::Image> cachedImage;
        if ( _memCache->getImage( key, CacheSpec(), cachedImage ) )
        {
            return ImageUtils::cloneImage(cachedImage.get());
        }
    }

    osg::ref_ptr<osg::Image> newImage = createImage(key, progress);

    if ( prepOp )
        (*prepOp)( newImage );

    if ( newImage.valid() && _memCache.valid() )
    {
        // cache it to the memory cache.
        _memCache->setImage( key, CacheSpec(), newImage.get() );
    }

    return newImage.release();
}

Here is the call graph for this function:

Here is the caller graph for this function:

virtual osg::Image* osgEarth::TileSource::createImage ( const TileKey key,
ProgressCallback progress 
) [protected, pure virtual]
TileBlacklist * TileSource::getBlacklist ( )

Gets the blacklist for this TileSource

Definition at line 374 of file TileSource.cpp.

{
    return _blacklist.get();
}

Here is the caller graph for this function:

const TileBlacklist * TileSource::getBlacklist ( ) const

Definition at line 380 of file TileSource.cpp.

{
    return _blacklist.get();
}
const DataExtentList& osgEarth::TileSource::getDataExtents ( ) const [inline]

Gets the list of areas with data for this TileSource

Definition at line 230 of file TileSource.

{ return _dataExtents; }

Here is the caller graph for this function:

DataExtentList& osgEarth::TileSource::getDataExtents ( ) [inline]

Definition at line 231 of file TileSource.

{ return _dataExtents; }
virtual std::string osgEarth::TileSource::getExtension ( ) const [inline, virtual]

Gets the preferred extension for this TileSource

Reimplemented in AGGLiteRasterizerTileSource, ArcGISSource, AGSMapCacheSource, DebugTileSource, MBTilesSource, OSGTileSource, TileCacheSource, TileServiceSource, TMSSource, VPBSource, VPBSource, WCS11Source, WMSSource, WorldWindSource, and YahooSource.

Definition at line 305 of file TileSource.

{return "png";}

Here is the caller graph for this function:

unsigned int TileSource::getMaxDataLevel ( ) const [virtual]

Gets the maximum level of detail available from the tile source. Unlike getMaxLevel(), which reports the maximum level at which to use this tile source in a Map, this method reports the maximum level for which the tile source is able to return data.

Reimplemented in OSGTileSource.

Definition at line 278 of file TileSource.cpp.

{
    //If we have no data extents, just use a reasonably high number
    if (_dataExtents.size() == 0) return 35;

    unsigned int maxDataLevel = 0;
    for (DataExtentList::const_iterator itr = _dataExtents.begin(); itr != _dataExtents.end(); ++itr)
    {
        if (itr->getMaxLevel() > maxDataLevel) maxDataLevel = itr->getMaxLevel();
    }
    return maxDataLevel;
}

Here is the caller graph for this function:

unsigned int TileSource::getMinDataLevel ( ) const [virtual]

Gets the minimum level of detail available from the tile source. Unlike getMinLevel(), which reports the minimum level at which to use this tile source in a Map, this method reports the minimum level for which the tile source is able to return data.

Definition at line 292 of file TileSource.cpp.

{
    //If we have no data extents, just use 0
    if (_dataExtents.size() == 0) return 0;

    unsigned int minDataLevel = INT_MAX;
    for (DataExtentList::const_iterator itr = _dataExtents.begin(); itr != _dataExtents.end(); ++itr)
    {
        if (itr->getMinLevel() < minDataLevel) minDataLevel = itr->getMinLevel();
    }
    return minDataLevel;
}
virtual float osgEarth::TileSource::getNoDataMaxValue ( ) [inline, virtual]

Gets the nodata max value

Definition at line 278 of file TileSource.

                                          {
            return _options.noDataMaxValue().value(); }

Here is the caller graph for this function:

virtual float osgEarth::TileSource::getNoDataMinValue ( ) [inline, virtual]

Gets the nodata min value

Definition at line 272 of file TileSource.

                                          {
            return _options.noDataMinValue().value(); }

Here is the caller graph for this function:

virtual float osgEarth::TileSource::getNoDataValue ( ) [inline, virtual]

Gets the nodata elevation value

Definition at line 266 of file TileSource.

                                       {
            return _options.noDataValue().value(); }

Here is the caller graph for this function:

const TileSourceOptions& osgEarth::TileSource::getOptions ( ) const [inline]

Definition at line 346 of file TileSource.

                                                    {
            return _options; }

Here is the caller graph for this function:

int TileSource::getPixelsPerTile ( ) const [virtual]

Gets the number of pixels per tile for this TileSource.

Reimplemented in ArcGISSource, TMSSource, WMSSource, and WorldWindSource.

Definition at line 186 of file TileSource.cpp.

{
    return _options.tileSize().value();
}

Here is the call graph for this function:

Here is the caller graph for this function:

const Profile * TileSource::getProfile ( ) const [virtual]

Gets the Profile of the TileSource

Definition at line 272 of file TileSource.cpp.

{
    return _profile.get();
}

Here is the caller graph for this function:

bool TileSource::hasData ( const TileKey key) const [virtual]

Whether or not the source has data for the given TileKey

Definition at line 347 of file TileSource.cpp.

{
    //If no data extents are provided, just return true
    if (_dataExtents.size() == 0) return true;

    const osgEarth::GeoExtent& keyExtent = key.getExtent();
    bool intersectsData = false;

    for (DataExtentList::const_iterator itr = _dataExtents.begin(); itr != _dataExtents.end(); ++itr)
    {
        if (keyExtent.intersects( *itr ) && key.getLevelOfDetail() >= itr->getMinLevel() && key.getLevelOfDetail() <= itr->getMaxLevel())
        {
            intersectsData = true;
            break;
        }
    }

    return intersectsData;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool TileSource::hasDataAtLOD ( unsigned  lod) const [virtual]

Whether the tile source can generate data for the specified LOD.

Definition at line 306 of file TileSource.cpp.

{
    //If no data extents are provided, just return true
    if ( _dataExtents.size() == 0 )
        return true;

    bool intersects = false;

    for (DataExtentList::const_iterator itr = _dataExtents.begin(); itr != _dataExtents.end(); ++itr)
    {
        if ( itr->getMinLevel() <= lod && lod <= itr->getMaxLevel() )
        {
            intersects = true;
            break;
        }
    }
    return intersects;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool TileSource::hasDataInExtent ( const GeoExtent extent) const [virtual]

Whether the tile source can generate data within the specified extent

Definition at line 326 of file TileSource.cpp.

{
    //If no data extents are provided, just return true
    if ( _dataExtents.size() == 0 )
        return true;

    bool intersects = false;

    for (DataExtentList::const_iterator itr = _dataExtents.begin(); itr != _dataExtents.end(); ++itr)
    {
        if ( extent.intersects( *itr ) )
        {
            intersects = true;
            break;
        }
    }
    return intersects;
}

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void osgEarth::TileSource::initialize ( const std::string &  referenceURI,
const Profile overrideProfile = NULL 
) [pure virtual]
virtual bool osgEarth::TileSource::isDynamic ( ) const [inline, virtual]

Whether this TileSource produces tiles whose data can change after it's been created.

Reimplemented in osgEarth::CompositeTileSource, and WMSSource.

Definition at line 332 of file TileSource.

{ return false; }

Here is the caller graph for this function:

bool TileSource::isOK ( ) const [virtual]

Returns True if this tile source initialized properly and has a valid profile.

Definition at line 260 of file TileSource.cpp.

{
    return getProfile() != NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

virtual bool osgEarth::TileSource::isSameKindAs ( const osg::Object *  obj) const [inline, virtual]

Reimplemented in osgEarth::Features::FeatureTileSource.

Definition at line 337 of file TileSource.

{ return dynamic_cast<const TileSource*>(obj)!=NULL; }
bool osgEarth::TileSource::isValid ( ) const [inline]

Definition at line 256 of file TileSource.

{ return isOK(); }
virtual const char* osgEarth::TileSource::libraryName ( ) const [inline, virtual]

Reimplemented in osgEarth::Features::FeatureTileSource.

Definition at line 339 of file TileSource.

{ return "osgEarth"; }
void TileSource::setProfile ( const Profile profile) [protected]

Called by subclasses to initialize their profile

Definition at line 266 of file TileSource.cpp.

{
    _profile = profile;
}

Here is the caller graph for this function:

bool TileSource::supportsPersistentCaching ( ) const [virtual]

Returns true if data from this source can be cached to disk

Reimplemented in DebugTileSource, and YahooSource.

Definition at line 368 of file TileSource.cpp.

{
    return true;
}

Here is the caller graph for this function:


Friends And Related Function Documentation

friend class Map [friend]

Definition at line 374 of file TileSource.

friend class MapEngine [friend]

Definition at line 375 of file TileSource.

friend class TileSourceFactory [friend]

Definition at line 376 of file TileSource.


Member Data Documentation

Definition at line 378 of file TileSource.

Definition at line 379 of file TileSource.

Definition at line 383 of file TileSource.

osg::ref_ptr<MemCache> osgEarth::TileSource::_memCache [private]

Definition at line 381 of file TileSource.

osg::ref_ptr<const Profile> osgEarth::TileSource::_profile [private]

Reimplemented in WMSSource.

Definition at line 371 of file TileSource.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines