osgEarth 2.1.1
Defines | Functions

/home/cube/sources/osgearth/src/osgEarth/TMS.cpp File Reference

#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>
Include dependency graph for TMS.cpp:

Go to the source code of this file.

Defines

#define LC   "[TMS] "
#define ELEM_TILEMAP   "tilemap"
#define ELEM_TITLE   "title"
#define ELEM_ABSTRACT   "abstract"
#define ELEM_SRS   "srs"
#define ELEM_VERTICAL_SRS   "vsrs"
#define ELEM_BOUNDINGBOX   "boundingbox"
#define ELEM_ORIGIN   "origin"
#define ELEM_TILE_FORMAT   "tileformat"
#define ELEM_TILESETS   "tilesets"
#define ELEM_TILESET   "tileset"
#define ELEM_DATA_EXTENTS   "dataextents"
#define ELEM_DATA_EXTENT   "dataextent"
#define ATTR_VERSION   "version"
#define ATTR_TILEMAPSERVICE   "tilemapservice"
#define ATTR_MINX   "minx"
#define ATTR_MINY   "miny"
#define ATTR_MAXX   "maxx"
#define ATTR_MAXY   "maxy"
#define ATTR_X   "x"
#define ATTR_Y   "y"
#define ATTR_MIN_LEVEL   "minlevel"
#define ATTR_MAX_LEVEL   "maxlevel"
#define ATTR_WIDTH   "width"
#define ATTR_HEIGHT   "height"
#define ATTR_MIME_TYPE   "mime-type"
#define ATTR_EXTENSION   "extension"
#define ATTR_PROFILE   "profile"
#define ATTR_HREF   "href"
#define ATTR_ORDER   "order"
#define ATTR_UNITSPERPIXEL   "units-per-pixel"

Functions

static std::string toString (double value, int precision=25)
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)
std::string getSRSString (const osgEarth::SpatialReference *srs)
static XmlDocumenttileMapToXmlDocument (const TileMap *tileMap)

Define Documentation

#define ATTR_EXTENSION   "extension"

Definition at line 129 of file TMS.cpp.

#define ATTR_HEIGHT   "height"

Definition at line 127 of file TMS.cpp.

#define ATTR_HREF   "href"

Definition at line 133 of file TMS.cpp.

#define ATTR_MAX_LEVEL   "maxlevel"

Definition at line 124 of file TMS.cpp.

#define ATTR_MAXX   "maxx"

Definition at line 119 of file TMS.cpp.

#define ATTR_MAXY   "maxy"

Definition at line 120 of file TMS.cpp.

#define ATTR_MIME_TYPE   "mime-type"

Definition at line 128 of file TMS.cpp.

#define ATTR_MIN_LEVEL   "minlevel"

Definition at line 123 of file TMS.cpp.

#define ATTR_MINX   "minx"

Definition at line 117 of file TMS.cpp.

#define ATTR_MINY   "miny"

Definition at line 118 of file TMS.cpp.

#define ATTR_ORDER   "order"

Definition at line 134 of file TMS.cpp.

#define ATTR_PROFILE   "profile"

Definition at line 131 of file TMS.cpp.

#define ATTR_TILEMAPSERVICE   "tilemapservice"

Definition at line 115 of file TMS.cpp.

#define ATTR_UNITSPERPIXEL   "units-per-pixel"

Definition at line 135 of file TMS.cpp.

#define ATTR_VERSION   "version"

Definition at line 114 of file TMS.cpp.

#define ATTR_WIDTH   "width"

Definition at line 126 of file TMS.cpp.

#define ATTR_X   "x"

Definition at line 121 of file TMS.cpp.

#define ATTR_Y   "y"

Definition at line 122 of file TMS.cpp.

#define ELEM_ABSTRACT   "abstract"

Definition at line 103 of file TMS.cpp.

#define ELEM_BOUNDINGBOX   "boundingbox"

Definition at line 106 of file TMS.cpp.

#define ELEM_DATA_EXTENT   "dataextent"

Definition at line 112 of file TMS.cpp.

#define ELEM_DATA_EXTENTS   "dataextents"

Definition at line 111 of file TMS.cpp.

#define ELEM_ORIGIN   "origin"

Definition at line 107 of file TMS.cpp.

#define ELEM_SRS   "srs"

Definition at line 104 of file TMS.cpp.

#define ELEM_TILE_FORMAT   "tileformat"

Definition at line 108 of file TMS.cpp.

#define ELEM_TILEMAP   "tilemap"

Definition at line 101 of file TMS.cpp.

#define ELEM_TILESET   "tileset"

Definition at line 110 of file TMS.cpp.

#define ELEM_TILESETS   "tilesets"

Definition at line 109 of file TMS.cpp.

#define ELEM_TITLE   "title"

Definition at line 102 of file TMS.cpp.

#define ELEM_VERTICAL_SRS   "vsrs"

Definition at line 105 of file TMS.cpp.

#define LC   "[TMS] "

Definition at line 39 of file TMS.cpp.


Function Documentation

std::string getSRSString ( const osgEarth::SpatialReference srs)

Definition at line 318 of file TMS.cpp.

{
    if (srs->isMercator())
    {
        return "EPSG:900913";
    }
    else if (srs->isGeographic())
    {
        return "EPSG:4326";
    }
    else
    {
        return srs->getInitString(); //srs();
    }   
}

Here is the call graph for this function:

Here is the caller graph for this function:

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);
}

Here is the caller graph for this function:

static XmlDocument* tileMapToXmlDocument ( const TileMap tileMap) [static]

Definition at line 541 of file TMS.cpp.

{
    //Create the root XML document
    osg::ref_ptr<XmlDocument> doc = new XmlDocument();
    doc->setName( ELEM_TILEMAP );
    
    //Create the root node
    //osg::ref_ptr<XmlElement> e_tile_map = new XmlElement( ELEM_TILEMAP );
    //doc->getChildren().push_back( e_tile_map.get() );

    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());

    //Write out the data areas
    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();
}

Here is the call graph for this function:

Here is the caller graph for this function:

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;
}
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines