C++ 从Qt Creator构建osgEarth应用程序

C++ 从Qt Creator构建osgEarth应用程序,c++,qt-creator,osgearth,C++,Qt Creator,Osgearth,我尝试运行simpleosgearth示例: #include <osgViewer/Viewer> #include <osgEarth/MapNode> #include <osgEarth/ImageLayer> #include <osgEarth/ElevationLayer> #include <osgEarth/ModelLayer> #include <osgEarth/GeoTransform> #in

我尝试运行simple
osgearth
示例:

#include <osgViewer/Viewer>

#include <osgEarth/MapNode>
#include <osgEarth/ImageLayer>
#include <osgEarth/ElevationLayer>
#include <osgEarth/ModelLayer>
#include <osgEarth/GeoTransform>

#include <osgEarthUtil/EarthManipulator>
#include <osgEarthUtil/ExampleResources>
#include <osgEarthUtil/AutoScaleCallback>

#include <osgEarthDrivers/tms/TMSOptions>
#include <osgEarthDrivers/wms/WMSOptions>
#include <osgEarthDrivers/gdal/GDALOptions>
#include <osgEarthDrivers/osg/OSGOptions>
#include <osgEarthDrivers/xyz/XYZOptions>

#include <osg/PositionAttitudeTransform>

using namespace osgEarth;
using namespace osgEarth::Drivers;
using namespace osgEarth::Util;

/**
 * How to create a simple osgEarth map and display it.
 */
int
main(int argc, char** argv)
{
    osg::ArgumentParser arguments(&argc,argv);

    // create the empty map.
    Map* map = new Map();

    // add a TMS imagery layer:
    TMSOptions imagery;
    imagery.url() = "http://readymap.org/readymap/tiles/1.0.0/7/";
    map->addLayer( new ImageLayer("ReadyMap Imagery", imagery) );

    // add a TMS elevation layer:
    TMSOptions elevation;
    elevation.url() = "http://readymap.org/readymap/tiles/1.0.0/116/";
    map->addLayer( new ElevationLayer("ReadyMap Elevation", elevation) );

    // add a semi-transparent XYZ layer:
    XYZOptions xyz;
    xyz.url() = "http://[abc].tile.openstreetmap.org/{z}/{x}/{y}.png";
    xyz.profile()->namedProfile() = "spherical-mercator";
    ImageLayer* imageLayer = new ImageLayer("OSM", xyz);
    imageLayer->setOpacity(0.5f);
    map->addLayer(imageLayer);

    // add a local GeoTIFF inset layer:
    GDALOptions gdal;
    gdal.url() = "../data/boston-inset.tif";
    map->addLayer(new ImageLayer("Boston", gdal));

    // add a WMS radar layer with transparency, and disable caching since
    // this layer updates on the server periodically.
    WMSOptions wms;
    wms.url() = "http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r.cgi";
    wms.format() = "png";
    wms.layers() = "nexrad-n0r";
    wms.srs() = "EPSG:4326";
    wms.transparent() = true;
    ImageLayerOptions wmsLayerOptions("WMS NEXRAD", wms);
    wmsLayerOptions.cachePolicy() = CachePolicy::NO_CACHE;
    map->addLayer(new ImageLayer(wmsLayerOptions));

    // add a local simple image as a layer using the OSG driver:
    OSGOptions osg;
    osg.url() = "../data/osgearth.gif";
    osg.profile()->srsString() = "wgs84";
    osg.profile()->bounds()->set(-90.0, 10.0, -80.0, 15.0);
    map->addLayer(new ImageLayer("Simple image", osg));

    // put a model on the map atop Pike's Peak, Colorado, USA
    osg::ref_ptr<osg::Node> model = osgDB::readRefNodeFile("cow.osgt.(0,0,3).trans.osgearth_shadergen");
    if (model.valid())
    {
        osg::PositionAttitudeTransform* pat = new osg::PositionAttitudeTransform();
        pat->addCullCallback(new AutoScaleCallback<osg::PositionAttitudeTransform>(5.0));
        pat->addChild(model.get());

        GeoTransform* xform = new GeoTransform();
        xform->setPosition(GeoPoint(SpatialReference::get("wgs84"), -105.042292, 38.840829));
        xform->addChild(pat);

        map->addLayer(new ModelLayer("Model", xform));
    }

    // make the map scene graph:
    MapNode* node = new MapNode( map );

    // initialize a viewer:
    osgViewer::Viewer viewer(arguments);
    viewer.setCameraManipulator( new EarthManipulator() );
    viewer.getCamera()->setSmallFeatureCullingPixelSize(-1.0f);
    viewer.setSceneData( node );

    // add some stock OSG handlers:
    MapNodeHelper().configureView(&viewer);

    return viewer.run();
}
输出
osgearth\u查看器文件.earth

<map name="readymap.org" type="geocentric">

    <image name="readymap_imagery" driver="tms">
        <url>http://readymap.org/readymap/tiles/1.0.0/7/</url>
    </image>

    <elevation name="readymap_elevation" driver="tms" vdatum="egm96">
        <url>http://readymap.org/readymap/tiles/1.0.0/116/</url>
    </elevation>

    <xi:include href="viewpoints.xml"/>
</map>
[osgEarth]* [MapNodeHelper] No earth file.
[osgEarth]  
Usage: osgearth_viewer file.earth
  --sky                         : add a sky model
  --ocean                       : add an ocean model
  --kml <file.kml>              : load a KML or KMZ file
  --coords                      : display map coords under mouse
  --dms                         : dispay deg/min/sec coords under mouse
  --dd                          : display decimal degrees coords under mouse
  --mgrs                        : show MGRS coords under mouse
  --ortho                       : use an orthographic camera
  --autoclip                    : installs an auto-clip plane callback
  --images [path]               : finds and loads image layers from folder [path]
  --image-extensions [ext,...]  : with --images, extensions to use
  --out-earth [file]            : write the loaded map to an earth file
  --uniform [name] [min] [max]  : create a uniform controller with min/max values
[osgEarth]*[MapNodeHelper]没有接地文件。
[osgEarth]
用法:osgearth_viewer file.earth
--天空:添加天空模型
--海洋:添加海洋模型
--kml:加载kml或KMZ文件
--坐标:在鼠标下显示地图坐标
--dms:dispay deg/min/sec鼠标下坐标
--dd:在鼠标下显示小数度坐标
--经理:在鼠标下显示经理协调
--正交:使用正交摄影机
--自动剪裁:安装自动剪裁平面回调
--图像[路径]:从文件夹[路径]查找并加载图像层
--图像扩展[ext]:带--images,要使用的扩展
--输出地球[文件]:将加载的地图写入地球文件
--统一[名称][min][max]:创建具有最小/最大值的统一控制器
可能是什么?我不明白。请帮忙:(

试试这个简单的方法:

下载并尝试加载上述简单文件。确保您拥有与“.earth”文件相关的所有数据

谢谢