|
osgEarth 2.1.1
|
Inheritance diagram for osgEarth::TileMap:
Collaboration diagram for osgEarth::TileMap:Public Types | |
| typedef std::vector< TileSet > | TileSetList |
Public Member Functions | |
| TileMap () | |
| const std::string & | getTileMapService () const |
| void | setTileMapService (const std::string &tileMapService) |
| const std::string & | getVersion () const |
| void | setVersion (const std::string &version) |
| const std::string & | getTitle () const |
| void | setTitle (const std::string &title) |
| const std::string & | getAbstract () const |
| void | setAbstract (const std::string &value) |
| const std::string & | getSRS () const |
| void | setSRS (const std::string &srs) |
| const std::string & | getVerticalSRS () const |
| void | setVerticalSRS (const std::string &vsrs) |
| const std::string & | getFilename () const |
| void | setFilename (const std::string &filename) |
| unsigned int | getMinLevel () const |
| unsigned int | getMaxLevel () const |
| void | computeMinMaxLevel () |
| void | computeNumTiles () |
| double | getOriginX () const |
| void | setOriginX (double x) |
| double | getOriginY () const |
| void | setOriginY (double y) |
| void | setOrigin (double x, double y) |
| void | getExtents (double &minX, double &minY, double &maxX, double &maxY) const |
| void | setExtents (double minX, double minY, double maxX, double maxY) |
| unsigned int | getNumTilesWide () const |
| void | setNumTilesWide (unsigned int w) |
| unsigned int | getNumTilesHigh () const |
| void | setNumTilesHigh (unsigned int h) |
| osgEarth::Profile::ProfileType | getProfileType () const |
| void | setProfileType (osgEarth::Profile::ProfileType type) |
| const Profile * | createProfile () const |
| TileFormat & | getFormat () |
| const TileFormat & | getFormat () const |
| TileSetList & | getTileSets () |
| const TileSetList & | getTileSets () const |
| DataExtentList & | getDataExtents () |
| const DataExtentList & | getDataExtents () const |
| std::string | getURL (const osgEarth::TileKey &tileKey, bool invertY) |
| bool | intersectsKey (const osgEarth::TileKey &tileKey) |
| void | generateTileSets (unsigned int numLevels=20) |
Static Public Member Functions | |
| static TileMap * | create (const std::string &url, const Profile *profile, const std::string &format, int tile_width, int tile_height) |
| static TileMap * | create (const TileSource *tileSource, const Profile *profile) |
Protected Attributes | |
| std::string | _tileMapService |
| std::string | _version |
| std::string | _title |
| std::string | _abstract |
| std::string | _srs |
| std::string | _vsrs |
| double | _originX |
| double | _originY |
| double | _minX |
| double | _minY |
| double | _maxX |
| double | _maxY |
| TileSetList | _tileSets |
| TileFormat | _format |
| std::string | _filename |
| unsigned int | _minLevel |
| unsigned int | _maxLevel |
| unsigned int | _numTilesWide |
| unsigned int | _numTilesHigh |
| osgEarth::Profile::ProfileType | _profile_type |
| DataExtentList | _dataExtents |
| typedef std::vector<TileSet> osgEarth::TileMap::TileSetList |
| TileMap::TileMap | ( | ) |
| void TileMap::computeMinMaxLevel | ( | ) |
Computes the minimum and maximum levels of valid data for this TileMap
Definition at line 146 of file TMS.cpp.
{
_minLevel = INT_MAX;
_maxLevel = 0;
for (TileSetList::iterator itr = _tileSets.begin(); itr != _tileSets.end(); ++itr)
{
if (itr->getOrder() < _minLevel) _minLevel = itr->getOrder();
if (itr->getOrder() > _maxLevel) _maxLevel = itr->getOrder();
}
}
Here is the caller graph for this function:| void TileMap::computeNumTiles | ( | ) |
Computes the number of tiles at level 0 from the existing TileSets
Definition at line 157 of file TMS.cpp.
{
_numTilesWide = -1;
_numTilesHigh = -1;
if (_tileSets.size() > 0)
{
unsigned int level = _tileSets[0].getOrder();
double res = _tileSets[0].getUnitsPerPixel();
_numTilesWide = (int)((_maxX - _minX) / (res * _format.getWidth()));
_numTilesHigh = (int)((_maxY - _minY) / (res * _format.getWidth()));
//In case the first level specified isn't level 0, compute the number of tiles at level 0
for (unsigned int i = 0; i < level; i++)
{
_numTilesWide /= 2;
_numTilesHigh /= 2;
}
OE_DEBUG << LC << "TMS has " << _numTilesWide << ", " << _numTilesHigh << " tiles at level 0 " << std::endl;
}
}
Here is the call graph for this function:| TileMap * TileMap::create | ( | const std::string & | url, |
| const Profile * | profile, | ||
| const std::string & | format, | ||
| int | tile_width, | ||
| int | tile_height | ||
| ) | [static] |
Creates a TileMap corresponding to one of osgEarth's built-in profile types
Definition at line 336 of file TMS.cpp.
{
//Profile profile(type);
const GeoExtent& ex = profile->getExtent();
TileMap* tileMap = new TileMap();
tileMap->setProfileType(profile->getProfileType()); //type);
tileMap->setExtents(ex.xMin(), ex.yMin(), ex.xMax(), ex.yMax());
tileMap->setOrigin(ex.xMin(), ex.yMin());
tileMap->_filename = url;
tileMap->_srs = getSRSString(profile->getSRS());
tileMap->_vsrs = profile->getVerticalSRS() ? profile->getVerticalSRS()->getInitString() : "";
tileMap->_format.setWidth( tile_width );
tileMap->_format.setHeight( tile_height );
tileMap->_format.setExtension( format );
profile->getNumTiles( 0, tileMap->_numTilesWide, tileMap->_numTilesHigh );
tileMap->generateTileSets();
tileMap->computeMinMaxLevel();
return tileMap;
}
Here is the call graph for this function:
Here is the caller graph for this function:| TileMap * TileMap::create | ( | const TileSource * | tileSource, |
| const Profile * | profile | ||
| ) | [static] |
Creates a TileMap based on the parameters of a TileSource
Definition at line 364 of file TMS.cpp.
{
TileMap* tileMap = new TileMap();
tileMap->setTitle( tileSource->getName() );
tileMap->setProfileType( profile->getProfileType() );
const GeoExtent& ex = profile->getExtent();
tileMap->_srs = getSRSString(profile->getSRS()); //srs();
tileMap->_vsrs = profile->getVerticalSRS() ? profile->getVerticalSRS()->getInitString() : 0L;
tileMap->_originX = ex.xMin();
tileMap->_originY = ex.yMin();
tileMap->_minX = ex.xMin();
tileMap->_minY = ex.yMin();
tileMap->_maxX = ex.xMax();
tileMap->_maxY = ex.yMax();
profile->getNumTiles( 0, tileMap->_numTilesWide, tileMap->_numTilesHigh );
tileMap->_format.setWidth( tileSource->getPixelsPerTile() );
tileMap->_format.setHeight( tileSource->getPixelsPerTile() );
tileMap->_format.setExtension( tileSource->getExtension() );
tileMap->generateTileSets();
return tileMap;
}
Here is the call graph for this function:| const Profile * TileMap::createProfile | ( | ) | const |
Definition at line 182 of file TMS.cpp.
{
osg::ref_ptr< SpatialReference > spatialReference = osgEarth::SpatialReference::create(_srs);
if (spatialReference->isMercator())
{
//HACK: Some TMS sources, most notably TileCache, use a global mercator extent that is very slightly different than
// the automatically computed mercator bounds which can cause rendering issues due to the some texture coordinates
// crossing the dateline. If the incoming bounds are nearly the same as our definion of global mercator, just use our definition.
double eps = 0.01;
osg::ref_ptr< const Profile > merc = osgEarth::Registry::instance()->getGlobalMercatorProfile();
if (_numTilesWide == 1 && _numTilesHigh == 1 &&
osg::equivalent(merc->getExtent().xMin(), _minX, eps) &&
osg::equivalent(merc->getExtent().yMin(), _minY, eps) &&
osg::equivalent(merc->getExtent().xMax(), _maxX, eps) &&
osg::equivalent(merc->getExtent().yMax(), _maxY, eps))
{
return osgEarth::Registry::instance()->getGlobalMercatorProfile();
}
}
if (_profile_type == Profile::TYPE_GEODETIC) return osgEarth::Registry::instance()->getGlobalGeodeticProfile();
if (_profile_type == Profile::TYPE_MERCATOR) return osgEarth::Registry::instance()->getGlobalMercatorProfile();
return Profile::create(
_srs,
_minX, _minY, _maxX, _maxY,
_vsrs,
osg::maximum(_numTilesWide, (unsigned int)1),
osg::maximum(_numTilesHigh, (unsigned int)1) );
}
Here is the call graph for this function:
Here is the caller graph for this function:| void TileMap::generateTileSets | ( | unsigned int | numLevels = 20 | ) |
Automatically generates a number of TileSets
Definition at line 296 of file TMS.cpp.
{
osg::ref_ptr<const Profile> profile = createProfile();
_tileSets.clear();
double width = (_maxX - _minX);
// double height = (_maxY - _minY);
for (unsigned int i = 0; i < numLevels; ++i)
{
unsigned int numCols, numRows;
profile->getNumTiles(i, numCols, numRows);
double res = (width / (double)numCols) / (double)_format.getWidth();
TileSet ts;
ts.setUnitsPerPixel(res);
ts.setOrder(i);
_tileSets.push_back(ts);
}
}
Here is the call graph for this function:
Here is the caller graph for this function:| const std::string& osgEarth::TileMap::getAbstract | ( | ) | const [inline] |
| DataExtentList& osgEarth::TileMap::getDataExtents | ( | ) | [inline] |
Definition at line 340 of file TMS.
{ return _dataExtents;}
Here is the caller graph for this function:| const DataExtentList& osgEarth::TileMap::getDataExtents | ( | ) | const [inline] |
Definition at line 341 of file TMS.
{ return _dataExtents;}
| void TileMap::getExtents | ( | double & | minX, |
| double & | minY, | ||
| double & | maxX, | ||
| double & | maxY | ||
| ) | const |
Gets the extents of this TileMap
| minX | The minimum x coordinate of the extents |
| minY | The minimum y coordinate of the extents |
| maxX | The maximum x coordinate of the extents |
| maxY | The maximum y coordinate of the extents |
Definition at line 82 of file TMS.cpp.
Here is the caller graph for this function:| const std::string& osgEarth::TileMap::getFilename | ( | ) | const [inline] |
| TileFormat& osgEarth::TileMap::getFormat | ( | ) | [inline] |
Gets the TileFormat for this TileMap
Definition at line 325 of file TMS.
{return _format;}
Here is the caller graph for this function:| const TileFormat& osgEarth::TileMap::getFormat | ( | ) | const [inline] |
| unsigned int osgEarth::TileMap::getMaxLevel | ( | ) | const [inline] |
| unsigned int osgEarth::TileMap::getMinLevel | ( | ) | const [inline] |
| unsigned int osgEarth::TileMap::getNumTilesHigh | ( | ) | const [inline] |
Gets the number of tiles high at lod 0
Definition at line 312 of file TMS.
{ return _numTilesHigh; }
| unsigned int osgEarth::TileMap::getNumTilesWide | ( | ) | const [inline] |
Gets the number of tiles wide at lod 0
Definition at line 302 of file TMS.
{ return _numTilesWide; }
| double osgEarth::TileMap::getOriginX | ( | ) | const [inline] |
| double osgEarth::TileMap::getOriginY | ( | ) | const [inline] |
| osgEarth::Profile::ProfileType osgEarth::TileMap::getProfileType | ( | ) | const [inline] |
Definition at line 319 of file TMS.
{return _profile_type;}
| const std::string& osgEarth::TileMap::getSRS | ( | ) | const [inline] |
| const std::string& osgEarth::TileMap::getTileMapService | ( | ) | const [inline] |
Gets the tile map service for this TileMap
Definition at line 156 of file TMS.
{return _tileMapService;}
Here is the caller graph for this function:| TileSetList& osgEarth::TileMap::getTileSets | ( | ) | [inline] |
| const TileSetList& osgEarth::TileMap::getTileSets | ( | ) | const [inline] |
| const std::string& osgEarth::TileMap::getTitle | ( | ) | const [inline] |
| std::string TileMap::getURL | ( | const osgEarth::TileKey & | tileKey, |
| bool | invertY | ||
| ) |
Gets a URL string that can be used to retrieve the image for the given TileKey
| tileKey | The TileKey to get the URL for. |
| invertY | If false, treat tile 0,0 as the lower left tile in the the map. If true, treat 0,0 as the top left tile in the map. |
Definition at line 218 of file TMS.cpp.
{
if (!intersectsKey(tilekey))
{
//OE_NOTICE << LC << "No key intersection for tile key " << tilekey.str() << std::endl;
return "";
}
unsigned int zoom = tilekey.getLevelOfDetail();
unsigned int x, y;
tilekey.getTileXY(x, y);
//Some TMS like services swap the Y coordinate so 0,0 is the upper left rather than the lower left. The normal TMS
//specification has 0,0 at the bottom left, so inverting Y will make 0,0 in the upper left.
//http://code.google.com/apis/maps/documentation/overlays.html#Google_Maps_Coordinates
if (!invertY)
{
unsigned int numRows, numCols;
tilekey.getProfile()->getNumTiles(tilekey.getLevelOfDetail(), numCols, numRows);
y = numRows - y - 1;
}
//OE_NOTICE << LC << "KEY: " << tilekey.str() << " level " << zoom << " ( " << x << ", " << y << ")" << std::endl;
//Select the correct TileSet
if ( _tileSets.size() > 0 )
{
for (TileSetList::iterator itr = _tileSets.begin(); itr != _tileSets.end(); ++itr)
{
if (itr->getOrder() == zoom)
{
std::stringstream ss;
std::string path = osgDB::getFilePath(_filename);
ss << path << "/" << zoom << "/" << x << "/" << y << "." << _format.getExtension();
//OE_NOTICE << LC << "Returning URL " << ss.str() << std::endl;
std::string ssStr;
ssStr = ss.str();
return ssStr;
}
}
}
else // Just go with it. No way of knowing the max level.
{
std::stringstream ss;
std::string path = osgDB::getFilePath(_filename);
ss << path << "/" << zoom << "/" << x << "/" << y << "." << _format.getExtension();
std::string ssStr;
ssStr = ss.str();
return ssStr;
}
return "";
}
Here is the call graph for this function:| const std::string& osgEarth::TileMap::getVersion | ( | ) | const [inline] |
| const std::string& osgEarth::TileMap::getVerticalSRS | ( | ) | const [inline] |
| bool TileMap::intersectsKey | ( | const osgEarth::TileKey & | tileKey | ) |
Determines whether or not the given TileKey intersects the TileMap
Definition at line 274 of file TMS.cpp.
{
double keyMinX, keyMinY, keyMaxX, keyMaxY;
//Check to see if the key overlaps the bounding box using lat/lon. This is necessary to check even in
//Mercator situations in case the BoundingBox is described using lat/lon coordinates such as those produced by GDAL2Tiles
//This should be considered a bug on the TMS production side, but we can work around it for now...
tilekey.getExtent().getBounds(keyMinX, keyMinY, keyMaxX, keyMaxY);
bool inter = intersects(_minX, _minY, _maxX, _maxY, keyMinX, keyMinY, keyMaxX, keyMaxY);
if (!inter && tilekey.getProfile()->getSRS()->isMercator())
{
tilekey.getProfile()->getSRS()->transform2D(keyMinX, keyMinY, tilekey.getProfile()->getSRS()->getGeographicSRS(), keyMinX, keyMinY);
tilekey.getProfile()->getSRS()->transform2D(keyMaxX, keyMaxY, tilekey.getProfile()->getSRS()->getGeographicSRS(), keyMaxX, keyMaxY);
inter = intersects(_minX, _minY, _maxX, _maxY, keyMinX, keyMinY, keyMaxX, keyMaxY);
}
return inter;
}
Here is the call graph for this function:
Here is the caller graph for this function:| void osgEarth::TileMap::setAbstract | ( | const std::string & | value | ) | [inline] |
| void TileMap::setExtents | ( | double | minX, |
| double | minY, | ||
| double | maxX, | ||
| double | maxY | ||
| ) |
Sets the extents of this TileMap
| minX | The minimum x coordinate of the extents |
| minY | The minimum y coordinate of the extents |
| maxX | The maximum x coordinate of the extents |
| maxY | The maximum y coordinate of the extents |
Definition at line 90 of file TMS.cpp.
Here is the caller graph for this function:| void osgEarth::TileMap::setFilename | ( | const std::string & | filename | ) | [inline] |
| void osgEarth::TileMap::setNumTilesHigh | ( | unsigned int | h | ) | [inline] |
| void osgEarth::TileMap::setNumTilesWide | ( | unsigned int | w | ) | [inline] |
| void TileMap::setOrigin | ( | double | x, |
| double | y | ||
| ) |
| void osgEarth::TileMap::setOriginX | ( | double | x | ) | [inline] |
| void osgEarth::TileMap::setOriginY | ( | double | y | ) | [inline] |
| void osgEarth::TileMap::setProfileType | ( | osgEarth::Profile::ProfileType | type | ) | [inline] |
Definition at line 320 of file TMS.
{_profile_type = type;}
Here is the caller graph for this function:| void osgEarth::TileMap::setSRS | ( | const std::string & | srs | ) | [inline] |
| void osgEarth::TileMap::setTileMapService | ( | const std::string & | tileMapService | ) | [inline] |
Sets the tile map service for this TileMap
Definition at line 161 of file TMS.
{_tileMapService = tileMapService;}
| void osgEarth::TileMap::setTitle | ( | const std::string & | title | ) | [inline] |
| void osgEarth::TileMap::setVersion | ( | const std::string & | version | ) | [inline] |
| void osgEarth::TileMap::setVerticalSRS | ( | const std::string & | vsrs | ) | [inline] |
std::string osgEarth::TileMap::_abstract [protected] |
DataExtentList osgEarth::TileMap::_dataExtents [protected] |
std::string osgEarth::TileMap::_filename [protected] |
TileFormat osgEarth::TileMap::_format [protected] |
unsigned int osgEarth::TileMap::_maxLevel [protected] |
double osgEarth::TileMap::_maxX [protected] |
double osgEarth::TileMap::_maxY [protected] |
unsigned int osgEarth::TileMap::_minLevel [protected] |
double osgEarth::TileMap::_minX [protected] |
double osgEarth::TileMap::_minY [protected] |
unsigned int osgEarth::TileMap::_numTilesHigh [protected] |
unsigned int osgEarth::TileMap::_numTilesWide [protected] |
double osgEarth::TileMap::_originX [protected] |
double osgEarth::TileMap::_originY [protected] |
std::string osgEarth::TileMap::_srs [protected] |
std::string osgEarth::TileMap::_tileMapService [protected] |
TileSetList osgEarth::TileMap::_tileSets [protected] |
std::string osgEarth::TileMap::_title [protected] |
std::string osgEarth::TileMap::_version [protected] |
std::string osgEarth::TileMap::_vsrs [protected] |
1.7.3