osgEarth 2.1.1
Defines | Functions

/home/cube/sources/osgearth/src/osgEarthDrivers/wms/Capabilities.cpp File Reference

#include "Capabilities"
#include <osgEarth/XmlUtils>
#include <osgEarth/HTTPClient>
#include <osgDB/FileNameUtils>
#include <osgDB/FileUtils>
Include dependency graph for Capabilities.cpp:

Go to the source code of this file.

Defines

#define ATTR_VERSION   "version"
#define ELEM_CAPABILITY   "capability"
#define ELEM_REQUEST   "request"
#define ELEM_ABSTRACT   "abstract"
#define ELEM_GETMAP   "getmap"
#define ELEM_FORMAT   "format"
#define ELEM_LAYER   "layer"
#define ELEM_NAME   "name"
#define ELEM_TITLE   "title"
#define ELEM_STYLE   "style"
#define ELEM_SRS   "srs"
#define ELEM_CRS   "crs"
#define ELEM_LATLONBOUNDINGBOX   "latlonboundingbox"
#define ELEM_BOUNDINGBOX   "boundingbox"
#define ATTR_MINX   "minx"
#define ATTR_MINY   "miny"
#define ATTR_MAXX   "maxx"
#define ATTR_MAXY   "maxy"

Functions

static LayergetLayerByName (const string &name, Layer::LayerList &layers)
static void readLayers (XmlElement *e, Layer *parentLayer, Layer::LayerList &layers)

Define Documentation

#define ATTR_MAXX   "maxx"

Definition at line 174 of file Capabilities.cpp.

#define ATTR_MAXY   "maxy"

Definition at line 175 of file Capabilities.cpp.

#define ATTR_MINX   "minx"

Definition at line 172 of file Capabilities.cpp.

#define ATTR_MINY   "miny"

Definition at line 173 of file Capabilities.cpp.

#define ATTR_VERSION   "version"

Definition at line 158 of file Capabilities.cpp.

#define ELEM_ABSTRACT   "abstract"

Definition at line 161 of file Capabilities.cpp.

#define ELEM_BOUNDINGBOX   "boundingbox"

Definition at line 171 of file Capabilities.cpp.

#define ELEM_CAPABILITY   "capability"

Definition at line 159 of file Capabilities.cpp.

#define ELEM_CRS   "crs"

Definition at line 169 of file Capabilities.cpp.

#define ELEM_FORMAT   "format"

Definition at line 163 of file Capabilities.cpp.

#define ELEM_GETMAP   "getmap"

Definition at line 162 of file Capabilities.cpp.

#define ELEM_LATLONBOUNDINGBOX   "latlonboundingbox"

Definition at line 170 of file Capabilities.cpp.

#define ELEM_LAYER   "layer"

Definition at line 164 of file Capabilities.cpp.

#define ELEM_NAME   "name"

Definition at line 165 of file Capabilities.cpp.

#define ELEM_REQUEST   "request"

Definition at line 160 of file Capabilities.cpp.

#define ELEM_SRS   "srs"

Definition at line 168 of file Capabilities.cpp.

#define ELEM_STYLE   "style"

Definition at line 167 of file Capabilities.cpp.

#define ELEM_TITLE   "title"

Definition at line 166 of file Capabilities.cpp.


Function Documentation

static Layer* getLayerByName ( const string &  name,
Layer::LayerList layers 
) [static]

Definition at line 32 of file Capabilities.cpp.

{
    for (Layer::LayerList::iterator i = layers.begin(); i != layers.end(); ++i)
    {
        if (osgDB::equalCaseInsensitive(i->get()->getName(),name)) return i->get();
        Layer *l = getLayerByName(name, i->get()->getLayers());
        if (l) return l;
    }
    return 0;
}
static void readLayers ( XmlElement e,
Layer parentLayer,
Layer::LayerList layers 
) [static]

Definition at line 180 of file Capabilities.cpp.

{
    XmlNodeList layerNodes = e->getSubElements( ELEM_LAYER );
    for( XmlNodeList::const_iterator i = layerNodes.begin(); i != layerNodes.end(); i++ )
    {
        XmlElement* e_layer = static_cast<XmlElement*>( i->get() );

        Layer *layer = new Layer;
        layer->setName( e_layer->getSubElementText( ELEM_NAME ) );
        layer->setTitle( e_layer->getSubElementText( ELEM_TITLE ) );
        layer->setAbstract( e_layer->getSubElementText( ELEM_ABSTRACT ) );        

        //Read all the supported styles
        XmlNodeList styles = e_layer->getSubElements( ELEM_STYLE );
        for( XmlNodeList::const_iterator styleitr = styles.begin(); styleitr != styles.end(); styleitr++ )
        {
            XmlElement* e_style = static_cast<XmlElement*>( styleitr->get() );
            string name = e_style->getSubElementText( ELEM_NAME );
            string title = e_style->getSubElementText( ELEM_TITLE );
            layer->getStyles().push_back(Style(name,title));
        }

        //Read all the supported SRS's
        XmlNodeList spatialReferences = e_layer->getSubElements( ELEM_SRS );
        for (XmlNodeList::const_iterator srsitr = spatialReferences.begin(); srsitr != spatialReferences.end(); ++srsitr)
        {
            string srs = static_cast<XmlElement*>( srsitr->get() )->getText();
            layer->getSpatialReferences().push_back(srs);
        }

        //Read all the supported CRS's
        spatialReferences = e_layer->getSubElements( ELEM_CRS );
        for (XmlNodeList::const_iterator srsitr = spatialReferences.begin(); srsitr != spatialReferences.end(); ++srsitr)
        {
            string crs = static_cast<XmlElement*>( srsitr->get() )->getText();
            layer->getSpatialReferences().push_back(crs);
        }

        osg::ref_ptr<XmlElement> e_bb = e_layer->getSubElement( ELEM_LATLONBOUNDINGBOX );
        if (e_bb.valid())
        {
            double minX, minY, maxX, maxY;
            minX = as<double>(e_bb->getAttr( ATTR_MINX ), 0);
            minY = as<double>(e_bb->getAttr( ATTR_MINY ), 0);
            maxX = as<double>(e_bb->getAttr( ATTR_MAXX ), 0);
            maxY = as<double>(e_bb->getAttr( ATTR_MAXY ), 0);
            layer->setLatLonExtents(minX, minY, maxX, maxY);
        }

        e_bb = e_layer->getSubElement( ELEM_BOUNDINGBOX );
        if (e_bb.valid())
        {
            double minX, minY, maxX, maxY;
            minX = as<double>(e_bb->getAttr( ATTR_MINX ), 0);
            minY = as<double>(e_bb->getAttr( ATTR_MINY ), 0);
            maxX = as<double>(e_bb->getAttr( ATTR_MAXX ), 0);
            maxY = as<double>(e_bb->getAttr( ATTR_MAXY ), 0);
            layer->setExtents(minX, minY, maxX, maxY);
        }

        //Add the layer to the list and set its parent layer
        layers.push_back(layer);
        layer->setParentLayer( parentLayer );

        //Read any other layers that are in the layer node
        readLayers( e_layer, layer, layer->getLayers());
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines