Exemple #1
0
void
KML_Geometry::buildChild( const Config& conf, KMLContext& cx, Style& style)
{
    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();
    }
}
Exemple #2
0
void
KML_Geometry::buildChild( xml_node<>* node, KMLContext& cx, Style& style)
{
	std::string name = toLower(node->name());
    if ( name == "point" )
    {
        KML_Point g;
        g.parseCoords(node, cx);
        _geom = g._geom.get();
        g.parseStyle(node, cx, style);
    }
    else if (name == "linestring" )
    {
        KML_LineString g;
        g.parseCoords(node, cx);
        _geom = g._geom.get();
        g.parseStyle(node, cx, style);
    }
    else if ( name == "linearring" || name == "gx:latlonquad" )
    {
        KML_LinearRing g;
        g.parseCoords(node, cx);
        _geom = g._geom.get();
        g.parseStyle(node, cx, style);
    }
    else if ( name == "polygon" )
    {
        KML_Polygon g;
        g.parseCoords(node, cx);
        _geom = g._geom.get();
        g.parseStyle(node, cx, style);
    }
    else if ( name == "multigeometry" )
    {
        KML_MultiGeometry g;
        g.parseCoords(node, cx);
        _geom = g._geom.get();
        
        for( xml_node<>* n = node->first_node(); n; n = n->next_sibling())
        {
            KML_Geometry subGeom;
            subGeom.buildChild( n, cx, style ); //use single style for all subgeometries
            if ( subGeom._geom.valid() )
                dynamic_cast<MultiGeometry*>(g._geom.get())->getComponents().push_back( subGeom._geom.get() );
        }
    }
    else if ( name == "model" )
    {
        KML_Model g;
        g.parseCoords(node, cx);
        _geom = g._geom.get();
        g.parseStyle(node, cx, style);
    }
}