|
osgEarth 2.1.1
|
Inheritance diagram for KML_Placemark:
Collaboration diagram for KML_Placemark:Public Member Functions | |
| virtual void | build (const Config &conf, KMLContext &cx) |
Definition at line 26 of file KML_Placemark.
| void KML_Placemark::build | ( | const Config & | conf, |
| KMLContext & | cx | ||
| ) | [virtual] |
Definition at line 28 of file KML_Placemark.cpp.
{
Style style;
if ( conf.hasValue("styleurl") )
{
// process a "stylesheet" style
const Style* ref_style = cx._sheet->getStyle( conf.value("styleurl"), false );
if ( ref_style )
style = *ref_style;
}
else if ( conf.hasChild("style") )
{
// process an "inline" style
KML_Style kmlStyle;
kmlStyle.scan( conf.child("style"), cx );
style = cx._activeStyle;
}
URI iconURI;
MarkerSymbol* marker = style.get<MarkerSymbol>();
if ( marker && marker->url().isSet() )
{
iconURI = URI( marker->url()->expr(), marker->url()->uriContext() );
}
std::string text =
conf.hasValue("name") ? conf.value("name") :
conf.hasValue("description") ? conf.value("description") :
"Unnamed";
// read in the geometry:
bool isPoly = false;
bool isPoint = false;
osg::Vec3d position;
KML_Geometry geometry;
geometry.build(conf, cx, style);
if ( geometry._geom.valid() && geometry._geom->getTotalPointCount() > 0 )
{
Geometry* geom = geometry._geom.get();
position = geom->getBounds().center();
isPoly = geom->getComponentType() == Geometry::TYPE_POLYGON;
isPoint = geom->getComponentType() == Geometry::TYPE_POINTSET;
}
FeatureNode* fNode = 0L;
PlacemarkNode* pNode = 0L;
// if we have a non-single-point geometry, render it.
if ( geometry._geom.valid() && geometry._geom->getTotalPointCount() > 1 )
{
const ExtrusionSymbol* ex = style.get<ExtrusionSymbol>();
const AltitudeSymbol* alt = style.get<AltitudeSymbol>();
bool draped =
(ex == 0L && alt == 0L && isPoly) ||
(ex == 0L && alt != 0L && alt->clamping() == AltitudeSymbol::CLAMP_TO_TERRAIN);
// Make a feautre node; drape if we're not extruding.
fNode = new FeatureNode( cx._mapNode, new Feature(geometry._geom.get()), draped );
fNode->setStyle( style );
if ( draped )
fNode->getOrCreateStateSet()->setMode(GL_LIGHTING, 1);
}
if ( isPoint )
{
osg::Image* image = iconURI.readImage();
if ( !image )
{
image = cx._options->defaultIconImage().get();
if ( !image )
{
image = cx._options->defaultIconURI()->readImage();
}
}
// apply the default text symbol for labeling, if necessary:
if ( !style.get<TextSymbol>() && cx._options->defaultTextSymbol().valid() )
{
style.addSymbol( cx._options->defaultTextSymbol().get() );
}
pNode = new PlacemarkNode( cx._mapNode, position, image, text, style );
}
if ( fNode && pNode )
{
osg::Group* group = new osg::Group();
group->addChild( fNode );
group->addChild( pNode );
cx._groupStack.top()->addChild( group );
KML_Feature::build( conf, cx, group );
}
else if ( pNode )
{
cx._groupStack.top()->addChild( pNode );
KML_Feature::build( conf, cx, pNode );
}
else if ( fNode )
{
cx._groupStack.top()->addChild( fNode );
KML_Feature::build( conf, cx, fNode );
}
}
Here is the call graph for this function:
1.7.3