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

TilePattern Class Reference

List of all members.

Public Member Functions

 TilePattern (const std::string &pattern)
const std::string & getPattern () const
const double & getTileWidth () const
const double & getTileHeight () const
void getTileBounds (const int &x, const int &y, double &minX, double &minY, double &maxX, double &maxY)
std::string getRequestString (const int &x, const int &y)
const std::string & getLayers ()
const std::string & getFormat ()
const std::string & getStyles ()
const std::string & getSRS ()
const osg::Vec2d & getTopLeftMin ()
const osg::Vec2d & getTopLeftMax ()
const int & getImageWidth ()
const int & getImageHeight ()
const std::string & getPrototype ()
const osg::Vec2d & getDataMin ()
void setDataMin (const osg::Vec2d &min)
const osg::Vec2d & getDataMax ()
void setDataMax (const osg::Vec2d &max)

Private Member Functions

void init ()

Private Attributes

std::string _layers
std::string _format
std::string _styles
std::string _srs
int _imageWidth
int _imageHeight
osg::Vec2d _topLeftMin
osg::Vec2d _topLeftMax
double _tileWidth
double _tileHeight
std::string _prototype
std::string _pattern
osg::Vec2d _dataMin
osg::Vec2d _dataMax

Friends

class TileServiceReader

Detailed Description

Classes for utilizing the JPL OnEarth tiled access patterns described at http://onearth.jpl.nasa.gov/tiled.html

Another good discussion on how the format works is described here: http://lists.eogeo.org/pipermail/tiling/2006-March/000017.html

The TileService specifies a series of predefined WMS access patterns that will result in very fast access. The tiling is quadtree based with the lowest level of detail generally consisting of 4 256x256 degree tiles with the upper left corner at -180,90. TilePattern corresponds to the

Definition at line 41 of file TileService.


Constructor & Destructor Documentation

TilePattern::TilePattern ( const std::string &  pattern)

Definition at line 49 of file TileService.cpp.

{
    _pattern = pattern;
    init();
}

Member Function Documentation

const osg::Vec2d& TilePattern::getDataMax ( ) [inline]

Definition at line 71 of file TileService.

{return _dataMax;}
const osg::Vec2d& TilePattern::getDataMin ( ) [inline]

Definition at line 68 of file TileService.

{return _dataMin;}
const std::string& TilePattern::getFormat ( ) [inline]

Definition at line 55 of file TileService.

{return _format;}
const int& TilePattern::getImageHeight ( ) [inline]

Definition at line 64 of file TileService.

{return _imageHeight;}
const int& TilePattern::getImageWidth ( ) [inline]

Definition at line 63 of file TileService.

{return _imageWidth;}
const std::string& TilePattern::getLayers ( ) [inline]

Definition at line 54 of file TileService.

{return _layers;}
const std::string& TilePattern::getPattern ( ) const [inline]

Definition at line 46 of file TileService.

{return _pattern;}
const std::string& TilePattern::getPrototype ( ) [inline]

Definition at line 66 of file TileService.

{return _prototype;}
std::string TilePattern::getRequestString ( const int &  x,
const int &  y 
)

Definition at line 108 of file TileService.cpp.

{
    double minX, minY, maxX, maxY;
    getTileBounds(x, y, minX, minY, maxX, maxY);

    char buf[2048];
    sprintf(buf, _prototype.c_str(), minX, minY, maxX, maxY);
    return buf;
}
const std::string& TilePattern::getSRS ( ) [inline]

Definition at line 57 of file TileService.

{return _srs;}
const std::string& TilePattern::getStyles ( ) [inline]

Definition at line 56 of file TileService.

{return _styles;}
void TilePattern::getTileBounds ( const int &  x,
const int &  y,
double &  minX,
double &  minY,
double &  maxX,
double &  maxY 
)

Definition at line 99 of file TileService.cpp.

{
    minX = _topLeftMin.x() + (double)x * _tileWidth;
    maxX = minX + _tileWidth;

    maxY = _topLeftMax.y() - (double)y * _tileHeight;
    minY = maxY - _tileHeight;
}
const double& TilePattern::getTileHeight ( ) const [inline]

Definition at line 49 of file TileService.

{ return _tileHeight; }
const double& TilePattern::getTileWidth ( ) const [inline]

Definition at line 48 of file TileService.

{ return _tileWidth; }
const osg::Vec2d& TilePattern::getTopLeftMax ( ) [inline]

Definition at line 60 of file TileService.

{return _topLeftMax;}
const osg::Vec2d& TilePattern::getTopLeftMin ( ) [inline]

Definition at line 59 of file TileService.

{return _topLeftMin;}
void TilePattern::init ( ) [private]

Definition at line 57 of file TileService.cpp.

{
    _dataMin.x() = -180;
    _dataMin.y() = -90;
    _dataMax.x() = 180;
    _dataMax.y() = 90;

    //request=GetMap&layers=global_mosaic&srs=EPSG:4326&format=image/jpeg&styles=visual&width=512&height=512&bbox=-180,-166,76,90
    //Convert the filename to lower case
    std::string lower = osgDB::convertToLowerCase( _pattern );

    _layers = extractBetween(lower, "layers=", "&");
    _styles = extractBetween(lower, "styles=", "&");
    _srs = extractBetween(lower, "srs=", "&");
    _format = extractBetween(lower, "format=image/", "&");
    _imageWidth = as<int>(extractBetween(lower, "width=", "&"), 0);
    _imageHeight = as<int>(extractBetween(lower, "height=", "&"), 0);

    //Read the coordinates of the top left tile
    std::string bbox = extractBetween(lower, "bbox=", "&");
    sscanf(bbox.c_str(), "%lf,%lf,%lf,%lf", &_topLeftMin.x(), &_topLeftMin.y(), &_topLeftMax.x(), &_topLeftMax.y());

    //Compute the tile dimensions
    _tileWidth = _topLeftMax.x() - _topLeftMin.x();
    _tileHeight = _topLeftMax.y() - _topLeftMin.y();

    //Create the prototype
    string::size_type len = lower.find( bbox );
    if (len != string::npos)
    {
        string beforeBB = _pattern.substr(0, len);

        string::size_type after = len + bbox.length();
        string afterBB = "";
        if (after < _pattern.length()-1)
        {
            afterBB = _pattern.substr(after, _pattern.length() - after);
        }
        _prototype = beforeBB + std::string("%lf,%lf,%lf,%lf") + afterBB;
    }
}

Here is the call graph for this function:

void TilePattern::setDataMax ( const osg::Vec2d &  max) [inline]

Definition at line 72 of file TileService.

{_dataMax = max;}
void TilePattern::setDataMin ( const osg::Vec2d &  min) [inline]

Definition at line 69 of file TileService.

{_dataMin = min;}

Friends And Related Function Documentation

friend class TileServiceReader [friend]

Definition at line 75 of file TileService.


Member Data Documentation

osg::Vec2d TilePattern::_dataMax [private]

Definition at line 96 of file TileService.

osg::Vec2d TilePattern::_dataMin [private]

Definition at line 95 of file TileService.

std::string TilePattern::_format [private]

Definition at line 80 of file TileService.

Definition at line 84 of file TileService.

int TilePattern::_imageWidth [private]

Definition at line 83 of file TileService.

std::string TilePattern::_layers [private]

Definition at line 79 of file TileService.

std::string TilePattern::_pattern [private]

Definition at line 93 of file TileService.

std::string TilePattern::_prototype [private]

Definition at line 92 of file TileService.

std::string TilePattern::_srs [private]

Definition at line 82 of file TileService.

std::string TilePattern::_styles [private]

Definition at line 81 of file TileService.

double TilePattern::_tileHeight [private]

Definition at line 90 of file TileService.

double TilePattern::_tileWidth [private]

Definition at line 89 of file TileService.

osg::Vec2d TilePattern::_topLeftMax [private]

Definition at line 87 of file TileService.

osg::Vec2d TilePattern::_topLeftMin [private]

Definition at line 86 of file TileService.


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