osgEarth 2.1.1
Public Member Functions | Private Attributes

TileCacheSource Class Reference

Inheritance diagram for TileCacheSource:
Collaboration diagram for TileCacheSource:

List of all members.

Public Member Functions

 TileCacheSource (const TileSourceOptions &options)
void initialize (const std::string &referenceURI, const Profile *overrideProfile)
osg::Image * createImage (const TileKey &key, ProgressCallback *progress)
virtual std::string getExtension () const

Private Attributes

std::string _configPath
const TileCacheOptions _options

Detailed Description

Definition at line 40 of file ReaderWriterTileCache.cpp.


Constructor & Destructor Documentation

TileCacheSource::TileCacheSource ( const TileSourceOptions options) [inline]

Definition at line 43 of file ReaderWriterTileCache.cpp.

                                                        : TileSource( options ), _options( options )
    {
    }

Member Function Documentation

osg::Image* TileCacheSource::createImage ( const TileKey key,
ProgressCallback progress 
) [inline, virtual]

Creates an image for the given TileKey. The returned object is new and is the responsibility of the caller.

Implements osgEarth::TileSource.

Definition at line 63 of file ReaderWriterTileCache.cpp.

    {
        unsigned int level, tile_x, tile_y;
        level = key.getLevelOfDetail() +1;
        key.getTileXY( tile_x, tile_y );

        unsigned int numCols, numRows;
        key.getProfile()->getNumTiles(level, numCols, numRows);
        
        // need to invert the y-tile index
        tile_y = numRows - tile_y - 1;

        char buf[2048];
        sprintf( buf, "%s/%s/%02d/%03d/%03d/%03d/%03d/%03d/%03d.%s",
            _options.url()->full().c_str(),
            _options.layer()->c_str(),
            level,
            (tile_x / 1000000),
            (tile_x / 1000) % 1000,
            (tile_x % 1000),
            (tile_y / 1000000),
            (tile_y / 1000) % 1000,
            (tile_y % 1000),
            _options.format()->c_str() );

       
        std::string path = buf;

        //If we have a relative path and the map file contains a server address, just concat the server path and the cache together.
        if (osgEarth::isRelativePath(path) && osgDB::containsServerAddress( _configPath ) )
        {
            path = osgDB::getFilePath(_configPath) + std::string("/") + path;
        }

        //If the path doesn't contain a server address, get the full path to the file.
        if (!osgDB::containsServerAddress(path))
        {
            path = osgEarth::getFullPath(_configPath, path);
        }
        
        osg::ref_ptr<osg::Image> image;
        HTTPClient::readImageFile(path, image, 0L, progress ); //getOptions(), progress );
        return image.release();

        //if (osgDB::containsServerAddress(path))
        //{
        //    //Use the HTTPClient if it's a server address.
        //    return HTTPClient::readImageFile( path, getOptions(), progress );
        //}

        //return osgDB::readImageFile( path, getOptions() );
    }

Here is the call graph for this function:

virtual std::string TileCacheSource::getExtension ( ) const [inline, virtual]

Gets the preferred extension for this TileSource

Reimplemented from osgEarth::TileSource.

Definition at line 117 of file ReaderWriterTileCache.cpp.

    {
        return _options.format().value();
    }
void TileCacheSource::initialize ( const std::string &  referenceURI,
const Profile overrideProfile 
) [inline, virtual]

Initialize the TileSource. The profile should be computed and set here using setProfile()

Implements osgEarth::TileSource.

Definition at line 47 of file ReaderWriterTileCache.cpp.

    {
        _configPath = referenceURI;

                if (overrideProfile)
                {
                    //If we were given a profile, take it on.
                        setProfile(overrideProfile);
                }
                else
                {
                        //Assume it is global-geodetic
                        setProfile( osgEarth::Registry::instance()->getGlobalGeodeticProfile() );
                }            
    }

Here is the call graph for this function:


Member Data Documentation

std::string TileCacheSource::_configPath [private]

Definition at line 123 of file ReaderWriterTileCache.cpp.

Reimplemented from osgEarth::TileSource.

Definition at line 124 of file ReaderWriterTileCache.cpp.


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