#include <osg/Notify>
#include <osgDB/FileUtils>
#include <osgDB/FileNameUtils>
#include <osgEarth/Common>
#include <osgEarth/GeoData>
#include <osgEarth/HTTPClient>
#include <osgEarth/XmlUtils>
#include <osgEarth/TMS>
#include <osgEarth/TileKey>
#include <osgEarth/TileSource>
#include <osgEarth/Registry>
#include <osgEarth/StringUtils>
#include <limits.h>
#include <iomanip>
Go to the source code of this file.
Define Documentation
#define ATTR_EXTENSION "extension" |
#define ATTR_HEIGHT "height" |
#define ATTR_MAX_LEVEL "maxlevel" |
#define ATTR_MIME_TYPE "mime-type" |
#define ATTR_MIN_LEVEL "minlevel" |
#define ATTR_ORDER "order" |
#define ATTR_PROFILE "profile" |
#define ATTR_TILEMAPSERVICE "tilemapservice" |
#define ATTR_UNITSPERPIXEL "units-per-pixel" |
#define ATTR_VERSION "version" |
#define ATTR_WIDTH "width" |
#define ELEM_ABSTRACT "abstract" |
#define ELEM_BOUNDINGBOX "boundingbox" |
#define ELEM_DATA_EXTENT "dataextent" |
#define ELEM_DATA_EXTENTS "dataextents" |
#define ELEM_ORIGIN "origin" |
#define ELEM_TILE_FORMAT "tileformat" |
#define ELEM_TILEMAP "tilemap" |
#define ELEM_TILESET "tileset" |
#define ELEM_TILESETS "tilesets" |
#define ELEM_TITLE "title" |
#define ELEM_VERTICAL_SRS "vsrs" |
Function Documentation
bool intersects |
( |
const double & |
minXa, |
|
|
const double & |
minYa, |
|
|
const double & |
maxXa, |
|
|
const double & |
maxYa, |
|
|
const double & |
minXb, |
|
|
const double & |
minYb, |
|
|
const double & |
maxXb, |
|
|
const double & |
maxYb |
|
) |
| |
Definition at line 137 of file TMS.cpp.
{
return osg::maximum(minXa, minXb) <= osg::minimum(maxXa,maxXb) &&
osg::maximum(minYa, minYb) <= osg::minimum(maxYa, maxYb);
}
Definition at line 541 of file TMS.cpp.
{
osg::ref_ptr<XmlDocument> doc = new XmlDocument();
doc->setName( ELEM_TILEMAP );
doc->getAttrs()[ ATTR_VERSION ] = tileMap->getVersion();
doc->getAttrs()[ ATTR_TILEMAPSERVICE ] = tileMap->getTileMapService();
doc->addSubElement( ELEM_TITLE, tileMap->getTitle() );
doc->addSubElement( ELEM_ABSTRACT, tileMap->getAbstract() );
doc->addSubElement( ELEM_SRS, tileMap->getSRS() );
doc->addSubElement( ELEM_VERTICAL_SRS, tileMap->getVerticalSRS() );
osg::ref_ptr<XmlElement> e_bounding_box = new XmlElement( ELEM_BOUNDINGBOX );
double minX, minY, maxX, maxY;
tileMap->getExtents( minX, minY, maxX, maxY );
e_bounding_box->getAttrs()[ATTR_MINX] = toString(minX);
e_bounding_box->getAttrs()[ATTR_MINY] = toString(minY);
e_bounding_box->getAttrs()[ATTR_MAXX] = toString(maxX);
e_bounding_box->getAttrs()[ATTR_MAXY] = toString(maxY);
doc->getChildren().push_back(e_bounding_box.get() );
osg::ref_ptr<XmlElement> e_origin = new XmlElement( ELEM_ORIGIN );
e_origin->getAttrs()[ATTR_X] = toString(tileMap->getOriginX());
e_origin->getAttrs()[ATTR_Y] = toString(tileMap->getOriginY());
doc->getChildren().push_back(e_origin.get());
osg::ref_ptr<XmlElement> e_tile_format = new XmlElement( ELEM_TILE_FORMAT );
e_tile_format->getAttrs()[ ATTR_EXTENSION ] = tileMap->getFormat().getExtension();
e_tile_format->getAttrs()[ ATTR_MIME_TYPE ] = tileMap->getFormat().getMimeType();
e_tile_format->getAttrs()[ ATTR_WIDTH ] = toString<unsigned int>(tileMap->getFormat().getWidth());
e_tile_format->getAttrs()[ ATTR_HEIGHT ] = toString<unsigned int>(tileMap->getFormat().getHeight());
doc->getChildren().push_back(e_tile_format.get());
osg::ref_ptr< const osgEarth::Profile > profile = tileMap->createProfile();
osg::ref_ptr<XmlElement> e_tile_sets = new XmlElement ( ELEM_TILESETS );
std::string profileString = "none";
if (profile->isEquivalentTo(osgEarth::Registry::instance()->getGlobalGeodeticProfile()))
{
profileString = "global-geodetic";
}
else if (profile->isEquivalentTo(osgEarth::Registry::instance()->getGlobalMercatorProfile()))
{
profileString = "global-mercator";
}
else
{
profileString = "local";
}
e_tile_sets->getAttrs()[ ATTR_PROFILE ] = profileString;
for (TileMap::TileSetList::const_iterator itr = tileMap->getTileSets().begin(); itr != tileMap->getTileSets().end(); ++itr)
{
osg::ref_ptr<XmlElement> e_tile_set = new XmlElement( ELEM_TILESET );
e_tile_set->getAttrs()[ATTR_HREF] = itr->getHref();
e_tile_set->getAttrs()[ATTR_ORDER] = toString<unsigned int>(itr->getOrder());
e_tile_set->getAttrs()[ATTR_UNITSPERPIXEL] = toString(itr->getUnitsPerPixel());
e_tile_sets->getChildren().push_back( e_tile_set.get() );
}
doc->getChildren().push_back(e_tile_sets.get());
if (tileMap->getDataExtents().size() > 0)
{
osg::ref_ptr<XmlElement> e_data_extents = new XmlElement( ELEM_DATA_EXTENTS );
for (DataExtentList::const_iterator itr = tileMap->getDataExtents().begin(); itr != tileMap->getDataExtents().end(); ++itr)
{
osg::ref_ptr<XmlElement> e_data_extent = new XmlElement( ELEM_DATA_EXTENT );
e_data_extent->getAttrs()[ATTR_MINX] = toString(itr->xMin());
e_data_extent->getAttrs()[ATTR_MINY] = toString(itr->yMin());
e_data_extent->getAttrs()[ATTR_MAXX] = toString(itr->xMax());
e_data_extent->getAttrs()[ATTR_MAXY] = toString(itr->yMax());
e_data_extent->getAttrs()[ATTR_MIN_LEVEL] = toString<unsigned int>(itr->getMinLevel());
e_data_extent->getAttrs()[ATTR_MAX_LEVEL] = toString<unsigned int>(itr->getMaxLevel());
e_data_extents->getChildren().push_back( e_data_extent );
}
doc->getChildren().push_back( e_data_extents.get() );
}
return doc.release();
}
static std::string toString |
( |
double |
value, |
|
|
int |
precision = 25 |
|
) |
| [static] |
Definition at line 41 of file TMS.cpp.
{
std::stringstream out;
out << std::fixed << std::setprecision(precision) << value;
std::string outStr;
outStr = out.str();
return outStr;
}