osgEarth 2.1.1
Public Member Functions

KML_GroundOverlay Struct Reference

Inheritance diagram for KML_GroundOverlay:
Collaboration diagram for KML_GroundOverlay:

List of all members.

Public Member Functions

virtual void scan (const Config &conf, KMLContext &cx)
virtual void build (const Config &conf, KMLContext &cx)

Detailed Description

Definition at line 27 of file KML_GroundOverlay.


Member Function Documentation

void KML_GroundOverlay::build ( const Config conf,
KMLContext cx 
) [virtual]

Definition at line 32 of file KML_GroundOverlay.cpp.

{
    // the URL of the overlay image
    std::string href = conf.child("icon").value("href");
    if ( href.empty() ) {
        OE_WARN << LC << "GroundOverlay missing required Icon element" << std::endl;
        return;
    }

    ImageOverlay* im = 0L;

    // the extent of the overlay image
    const Config& llb = conf.child("latlonbox");
    if ( !llb.empty() )
    {
        double north = llb.value<double>("north", 0.0);
        double south = llb.value<double>("south", 0.0);
        double east  = llb.value<double>("east", 0.0);
        double west  = llb.value<double>("west", 0.0);
        Angular rotation( llb.value<double>("rotation", 0.0), Units::DEGREES );

        osg::ref_ptr<osg::Image> image = URI(href, conf.uriContext()).readImage();
        if ( !image.valid() ) {
            OE_WARN << LC << "GroundOverlay failed to read image from " << href << std::endl;
            return;
        }

        im = new ImageOverlay( cx._mapNode, image.get() );
        im->setBoundsAndRotation( Bounds(west, south, east, north), rotation );
        cx._groupStack.top()->addChild( im );
    }

    else if ( conf.hasChild("gx:latlonquad") )
    {
        const Config& llq = conf.child("gx:latlonquad");
        KML_Geometry g;
        Style style;
        g.buildChild( llq, cx, style );
        if ( g._geom.valid() && g._geom->size() >= 4 )
        {
            osg::ref_ptr<osg::Image> image = URI(href, conf.uriContext()).readImage();
            if ( !image.valid() ) {
                OE_WARN << LC << "GroundOverlay failed to read image from " << href << std::endl;
                return;
            }

            const Geometry& p = *(g._geom.get());
            im = new ImageOverlay( cx._mapNode, image.get() );
            im->setCorners( 
                osg::Vec2d( p[0].x(), p[0].y() ),
                osg::Vec2d( p[1].x(), p[1].y() ),
                osg::Vec2d( p[3].x(), p[3].y() ),
                osg::Vec2d( p[2].x(), p[2].y() ) );
            cx._groupStack.top()->addChild( im );
        }
    }

    else {
        OE_WARN << LC << "GroundOverlay missing required LatLonBox/gx:LatLonQuad element" << std::endl;
        return;
    }


    // superclass build always called last
    KML_Overlay::build( conf, cx, im );
}

Here is the call graph for this function:

void KML_GroundOverlay::scan ( const Config conf,
KMLContext cx 
) [virtual]

Reimplemented from KML_Overlay.

Definition at line 26 of file KML_GroundOverlay.cpp.

{
    KML_Overlay::scan( conf, cx );
}

Here is the call graph for this function:


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