gwaldron / osgearth

3D Maps for OpenSceneGraph / C++14
https://www.pelicanmapping.com/home-1/opensource
Other
1.47k stars 772 forks source link

why crash when show 2D map? #2582

Closed yaterman closed 1 month ago

yaterman commented 1 month ago

osgEarth Version (required):2.8

What is the problem?

std::string wktString = "EPSG:3857";            //wgs84
    osgEarth::ProfileOptions profileOpts;
    profileOpts.srsString() = wktString;

    // 设置缓存目录
    osgEarth::Drivers::FileSystemCacheOptions cacheOpts;
    std::string cacheDir = path.toStdString() + "/data/tmp";
    cacheOpts.rootPath() = cacheDir;

    osgEarth::MapOptions mapOpts;
    mapOpts.cache() = cacheOpts;
    mapOpts.coordSysType() = osgEarth::MapOptions::CSTYPE_PROJECTED;
    mapOpts.profile() = profileOpts;

    // 创建地图节点
    osg::ref_ptr<osgEarth::Map> map = new osgEarth::Map(mapOpts);

    osg::ref_ptr<osgEarth::MapNode> mapNode = new osgEarth::MapNode(map);

    osgEarth::Drivers::GDALOptions gdal;
    gdal.url() = path.toStdString() + "/data/world.tif";;   // 二维地图资源路径
    osg::ref_ptr<osgEarth::ImageLayer> layer = new osgEarth::ImageLayer("mapImage", gdal);
    map->addImageLayer(layer);
    root->addChild(mapNode);

when program run line osg::ref_ptr mapNode = new osgEarth::MapNode(map); app crash,why?

How have you tried to resolve i

Help US help YOU: include a screenshot, code block, or data file that we can use to reproduce the issue!

gwaldron commented 1 month ago

Where does it crash? Do you have a stack trace?

osgEarth 2.8 is almost 8 years old. It will be difficult for us to give you support for such an old version. Please consider upgrading to the latest version 3.6.