osgEarth 2.1.1
Static Public Member Functions | Private Member Functions

osgEarth::WMSCapabilitiesReader Class Reference

List of all members.

Static Public Member Functions

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

Private Member Functions

 WMSCapabilitiesReader ()
 WMSCapabilitiesReader (const WMSCapabilitiesReader &cr)

Detailed Description

Definition at line 242 of file Capabilities.


Constructor & Destructor Documentation

osgEarth::WMSCapabilitiesReader::WMSCapabilitiesReader ( ) [inline, private]

Definition at line 248 of file Capabilities.

{}
osgEarth::WMSCapabilitiesReader::WMSCapabilitiesReader ( const WMSCapabilitiesReader cr) [inline, private]

Definition at line 249 of file Capabilities.

{}

Member Function Documentation

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

Definition at line 136 of file Capabilities.cpp.

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

Here is the call graph for this function:

Here is the caller graph for this function:

WMSCapabilities * WMSCapabilitiesReader::read ( std::istream &  in) [static]

Definition at line 253 of file Capabilities.cpp.

{
    osg::ref_ptr<WMSCapabilities> capabilities = new WMSCapabilities;

    osg::ref_ptr<XmlDocument> doc = XmlDocument::load( in );
    if (!doc.valid() || doc->getChildren().empty())
    {
        OE_NOTICE << "Failed to load Capabilities " << std::endl;
        return 0;
    }

    //Get the Capabilities version
    osg::ref_ptr<XmlElement> e_root = static_cast<XmlElement*>(doc->getChildren()[0].get());
    capabilities->setVersion( e_root->getAttr(ATTR_VERSION ) );

    osg::ref_ptr<XmlElement> e_capability = e_root->getSubElement( ELEM_CAPABILITY );
    if (!e_capability.valid())
    {
        OE_NOTICE << "Could not find Capability element" << std::endl;
        return 0;
    }

    //Get the supported formats
    osg::ref_ptr<XmlElement> e_request = e_capability->getSubElement( ELEM_REQUEST );
    if (e_request.valid())
    {
        osg::ref_ptr<XmlElement> e_getMap = e_request->getSubElement( ELEM_GETMAP );
        if ( e_getMap.valid() )
        {
            //Read all the formats
            XmlNodeList formats = e_getMap->getSubElements( ELEM_FORMAT );
            for( XmlNodeList::const_iterator i = formats.begin(); i != formats.end(); i++ )
            {            
                string format = trim(static_cast<XmlElement*>( i->get() )->getText());
                capabilities->getFormats().push_back(format);
            }
        }
    }

    //Try to read the layers
    readLayers( e_capability.get(), 0, capabilities->getLayers());

    return capabilities.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