osgEarth 2.1.1
Static Public Member Functions | Private Member Functions

TileServiceReader Class Reference

List of all members.

Static Public Member Functions

static TileServiceread (const std::string &location, const osgDB::ReaderWriter::Options *options)
static TileServiceread (std::istream &in)

Private Member Functions

 TileServiceReader ()
 TileServiceReader (const TileServiceReader &tsr)

Detailed Description

Definition at line 225 of file TileService.


Constructor & Destructor Documentation

TileServiceReader::TileServiceReader ( ) [inline, private]

Definition at line 231 of file TileService.

{}
TileServiceReader::TileServiceReader ( const TileServiceReader tsr) [inline, private]

Definition at line 232 of file TileService.

{}

Member Function Documentation

TileService * TileServiceReader::read ( const std::string &  location,
const osgDB::ReaderWriter::Options *  options 
) [static]

Definition at line 211 of file TileService.cpp.

{
    TileService *tileService = NULL;
    if ( osgDB::containsServerAddress( location ) )
    {
        HTTPResponse response = HTTPClient::get( location, options);
        if (response.isOK() && response.getNumParts() > 0 )
        {
            tileService = read( response.getPartStream( 0 ) );
        }
    }
    else
    {
        if ((osgDB::fileExists(location)) && (osgDB::fileType(location) == osgDB::REGULAR_FILE))
        {
            std::ifstream in( location.c_str() );
            tileService = read( in );
        }
    }
    return tileService;
}

Here is the call graph for this function:

Here is the caller graph for this function:

TileService * TileServiceReader::read ( std::istream &  in) [static]

Definition at line 272 of file TileService.cpp.

{
    osg::ref_ptr<TileService> tileService = new TileService;

    osg::ref_ptr<XmlDocument> doc = XmlDocument::load( in );
    if (!doc.valid())
    {
        OE_INFO << "Failed to load TileService " << std::endl;
        return 0;
    }
    
    //Get the root TileMap element
    osg::ref_ptr<XmlElement> e_root = doc->getSubElement( ELEM_WMS_TILE_SERVICE );
    if (!e_root.valid())
    {
        OE_INFO << "Could not find root TileService element " << std::endl;
        return 0;
    }

    tileService->setVersion( e_root->getAttr( ATTR_VERSION ) );

    //Get properties from the Service element.
    osg::ref_ptr<XmlElement> e_service = e_root->getSubElement( ELEM_SERVICE );
    if (!e_service.valid())
    {
        OE_INFO << "Could not find Service element " << std::endl;
        return 0;
    }

    tileService->setName( e_service->getSubElementText( ELEM_NAME ) );
    tileService->setTitle( e_service->getSubElementText( ELEM_TITLE ) );
    tileService->setAbstract( e_service->getSubElementText( ELEM_ABSTRACT ) );
    tileService->setAccessConstraints( e_service->getSubElementText( ELEM_ACCESSCONSTRAINTS ) );

    //Get the TiledPattern element which contains the TiledGroups
    osg::ref_ptr<XmlElement> e_tiledPatterns = e_root->getSubElement( ELEM_TILEDPATTERNS );
    if (!e_tiledPatterns.valid())
    {
        OE_INFO << "Could not find TiledPatterns element" << std::endl;
        return 0;
    }

    //Get the bounding box from the TiledPatterns
    osg::ref_ptr<XmlElement> e_bb = e_tiledPatterns->getSubElement( ELEM_LATLONBOUNDINGBOX );
    if (e_bb.valid())
    {
      double minX, minY, maxX, maxY;
      readBoundingBox(e_bb.get(), minX, minY, maxX, maxY);
      tileService->setDataMin(osg::Vec2d(minX, minY));
      tileService->setDataMax(osg::Vec2d(maxX, maxY));
    }

    addTilePatterns(e_tiledPatterns.get(), tileService.get());

    OE_INFO << "Returning TileService with " << tileService->getPatterns().size() << " patterns " << std::endl;
    return tileService.release();
}

Here is the call graph for this function:


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