The layer disappeared when I dynamically added a new shapfile layer

classic Classic list List threaded Threaded
4 messages Options
osgEarthVR osgEarthVR
Reply | Threaded
Open this post in threaded view
|

The layer disappeared when I dynamically added a new shapfile layer

When I initialized the scene and added the shapefile layer, everything was fine.but The old shapefile  Model layer disappeared when I dynamically added a new shapfile layer,Only the new shapefile Model layer remains,why?
osgEarthVR osgEarthVR
Reply | Threaded
Open this post in threaded view
|

Re: The layer disappeared when I dynamically added a new shapfile layer

The add shapefile procedure code is the same。
osgEarthVR osgEarthVR
Reply | Threaded
Open this post in threaded view
|

Re: The layer disappeared when I dynamically added a new shapfile layer

This is an implicit problem. Maybe adding a new Shape Modle Layer will not immediately cause the old layer to disappear. When I execute the following function:

dirtyModelLayers()
{
        for (int i = 0; i < m_ActiveMap->getNumModelLayers(); ++i)
        {
                osgEarth::ModelSource* pModelSource = m_ActiveMap->getModelLayerAt(i)->getModelSource();
                if (pModelSource)
                {
                        pModelSource->dirty();
                }
        }
}
the old shape Model layer to disappear.
osgEarthVR osgEarthVR
Reply | Threaded
Open this post in threaded view
|

Re: The layer disappeared when I dynamically added a new shapfile layer

 osgEarth::Drivers::OGRFeatureOptions featureOptions;
        featureOptions.url() = "C:/osgEarth-build/data/world.shp";

        osgEarth::Features::ConvertTypeFilter* filter = new osgEarth::Features::ConvertTypeFilter();
        filter->toType() = osgEarth::Symbology::Geometry::TYPE_LINESTRING;
        featureOptions.filters().push_back(filter);

        osgEarth::Symbology::Style style;
        osgEarth::Symbology::LineSymbol* ls = style.getOrCreateSymbol<osgEarth::Symbology::LineSymbol>();
        ls->stroke()->color() = osgEarth::Symbology::Color::Yellow;
        ls->stroke()->width() = 2.0f;

        osgEarth::Drivers::FeatureGeomModelOptions geomOptions;
        geomOptions.featureOptions() = featureOptions;
        geomOptions.styles() = new osgEarth::Symbology::StyleSheet();
        geomOptions.styles()->addStyle(style);
        geomOptions.enableLighting() = false;

        osgEarth::ModelLayerOptions layerOptions("feature", geomOptions);
        layerOptions.overlay() = false;
        map->addModelLayer(new osgEarth::ModelLayer(layerOptions));

layerOptions.overlay() = false; 

The function overlay() is undefined