osgEarth 2.1.1
Public Member Functions | Public Attributes

KML_Geometry Struct Reference

Inheritance diagram for KML_Geometry:
Collaboration diagram for KML_Geometry:

List of all members.

Public Member Functions

 KML_Geometry ()
virtual void parseCoords (const Config &conf, KMLContext &cx)
virtual void parseStyle (const Config &conf, KMLContext &cs, Style &style)
virtual void build (const Config &confParent, KMLContext &cx, Style &style)
void buildChild (const Config &conf, KMLContext &cx, Style &style)

Public Attributes

osg::ref_ptr< Geometry_geom
bool _extrude
bool _tessellate

Detailed Description

Definition at line 28 of file KML_Geometry.


Constructor & Destructor Documentation

KML_Geometry::KML_Geometry ( ) [inline]

Definition at line 30 of file KML_Geometry.

: _extrude(false), _tessellate(false) { }

Member Function Documentation

void KML_Geometry::build ( const Config confParent,
KMLContext cx,
Style style 
) [virtual]

Definition at line 29 of file KML_Geometry.cpp.

{
    const ConfigSet& children = parentConf.children();
    for( ConfigSet::const_iterator i = children.begin(); i != children.end(); ++i )
    {
        buildChild( *i, cx, style );
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void KML_Geometry::buildChild ( const Config conf,
KMLContext cx,
Style style 
)

Definition at line 39 of file KML_Geometry.cpp.

{
    if ( conf.key() == "point" )
    {
        KML_Point g;
        g.parseStyle(conf, cx, style);
        g.parseCoords(conf, cx);
        _geom = g._geom.get();
    }
    else if ( conf.key() == "linestring" )
    {
        KML_LineString g;
        g.parseStyle(conf, cx, style);
        g.parseCoords(conf, cx);
        _geom = g._geom.get();
    }
    else if ( conf.key() == "linearring" )
    {
        KML_LinearRing g;
        g.parseStyle(conf, cx, style);
        g.parseCoords(conf, cx);
        _geom = g._geom.get();
    }
    else if ( conf.key() == "polygon" || conf.key() == "gx:latlonquad" )
    {
        KML_Polygon g;
        g.parseStyle(conf, cx, style);
        g.parseCoords(conf, cx);
        _geom = g._geom.get();
    }
    else if ( conf.key() == "multigeometry" )
    {
        KML_MultiGeometry g;
        g.parseStyle(conf, cx, style);
        g.parseCoords(conf, cx);
        const ConfigSet& mgChildren = conf.children();
        
        for( ConfigSet::const_iterator i = mgChildren.begin(); i != mgChildren.end(); ++i )
        {
            const Config& mgChild = *i;
            Style subStyle = style;
            KML_Geometry subGeom;
            subGeom.parseStyle( mgChild, cx, subStyle );
            subGeom.buildChild( mgChild, cx, style );
            if ( subGeom._geom.valid() )
                dynamic_cast<MultiGeometry*>(g._geom.get())->getComponents().push_back( subGeom._geom.get() );
        }
        //g.parseCoords(conf.child("multigeometry"), cx);
        _geom = g._geom.get();
    }
    else if ( conf.key() == "model" )
    {
        KML_Model g;
        g.parseStyle(conf, cx, style);
        g.parseCoords(conf, cx);
        _geom = g._geom.get();
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void KML_Geometry::parseCoords ( const Config conf,
KMLContext cx 
) [virtual]

Reimplemented in KML_LinearRing, KML_LineString, KML_MultiGeometry, KML_Point, and KML_Polygon.

Definition at line 99 of file KML_Geometry.cpp.

{
    const Config& coords = conf.child("coordinates");
    StringVector tuples;
    StringTokenizer( coords.value(), tuples, " ", "", false, true );
    for( StringVector::const_iterator s=tuples.begin(); s != tuples.end(); ++s )
    {
        StringVector parts;
        StringTokenizer( *s, parts, ",", "", false, true );
        if ( parts.size() >= 2 )
        {
            osg::Vec3d point;
            point.x() = as<double>( parts[0], 0.0 );
            point.y() = as<double>( parts[1], 0.0 );
            if ( parts.size() >= 3 ) {
                point.z() = as<double>( parts[2], 0.0 );
            }
            _geom->push_back(point);
        }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void KML_Geometry::parseStyle ( const Config conf,
KMLContext cs,
Style style 
) [virtual]

Reimplemented in KML_Polygon.

Definition at line 122 of file KML_Geometry.cpp.

{
    _extrude = conf.value("extrude") == "1";
    _tessellate = conf.value("tessellate") == "1";

    std::string am = conf.value("altitudemode");

    // clampToGround is the default. We will be draping the geometry UNLESS tessellate is
    // set to true.
    if ( (am.empty() || am == "clampToGround") && _tessellate )
    {
        AltitudeSymbol* af = style.getOrCreate<AltitudeSymbol>();
        af->clamping() = AltitudeSymbol::CLAMP_TO_TERRAIN;
        _extrude = false;
    }

    // "relativeToGround" means the coordinates' Z values are relative to the Z of the
    // terrain at that point. NOTE: GE flattens rooftops in this mode when extrude=1,
    // which seems wrong..
    else if ( am == "relativeToGround" )
    {
        AltitudeSymbol* af = style.getOrCreate<AltitudeSymbol>();
        af->clamping() = AltitudeSymbol::CLAMP_RELATIVE_TO_TERRAIN;
    }

    // "absolute" means to treat the Z values as-is
    else if ( am == "absolute" )
    {
        AltitudeSymbol* af = style.getOrCreate<AltitudeSymbol>();
        af->clamping() = AltitudeSymbol::CLAMP_ABSOLUTE;
    }

    if ( _extrude )
    {
        ExtrusionSymbol* es = style.getOrCreate<ExtrusionSymbol>();
        es->flatten() = false;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 36 of file KML_Geometry.

Definition at line 35 of file KML_Geometry.

Definition at line 36 of file KML_Geometry.


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