- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我尝试运行简单的 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();
}
但是我的QtCreator
找不到所有的osgEarth
包。同时,他找到了包osgViewer/Viewer
,没有任何问题。好的。我拿了测试 .earth
文件并尝试使用 osgearth_viewer file.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_viewer file.earth
:
[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
它可能是什么?我不明白。请帮忙:(
最佳答案
尝试这个简单的事情: https://github.com/gwaldron/osgearth/blob/master/tests/gdal_multiple_files.earth
下载并尝试加载上面的简单文件。确保您拥有与“.earth”文件相关的所有数据。
谢谢。
关于c++ - 从 Qt Creator 构建 osgEarth 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49937431/
我正在尝试在 Fedora 上使用 Qt 编译 osgearth 库。我通过这个命令安装 osgEarth: dnf install osgearth-devel 在终端中输入osgearth,会显示
我正在尝试使用 Quarts 构建 osgEarth。官网上的说明是这样的: Point the QT_QMAKE_EXECUTABLE CMake variable to the qmake.exe
我尝试运行简单的 osgearth 示例: #include #include #include #include #include #include #include #include
把osgEarth的ViewerViewer放到QMdiArea里有什么特别的吗?我创建了一个 QMdiArea 作为中心 Widget(称为 setCentralWidget),而不是直接将 osg
我是一名优秀的程序员,十分优秀!