[原][译][osgearth]API加载地球(OE官方文档翻译)
原文参考:http://docs.osgearth.org/en/latest/developer/maps.html#programmatic-map-creation
本人翻译水平有限。。。
加载earth地图文件
osg::Node* globe = osgDB::readNodeFile("myglobe.earth");
最简单的方式
API编程式的地图创建
用API创建一个地图的基本步骤是:
1.创建一个地图对象(Map object)
2.在你认为合适的地方添加图像层和高程层
3.创建一个可以绘制“地图对象”的MapNode
4.将MapNode添加进场景图。
你可以在任何时候向地图添加层:
#include <osgEarth/Map>
#include <osgEarth/MapNode>
#include <osgEarthDrivers/tms/TMSOptions>
#include <osgEarthDrivers/gdal/GDALOptions> using namespace osgEarth;
using namespace osgEarth::Drivers;
... // Create a Map and set it to Geocentric to display a globe
Map* map = new Map(); // Add an imagery layer (blue marble from a TMS source)
{
TMSOptions tms;
tms.url() = "http://labs.metacarta.com/wms-c/Basic.py/1.0.0/satellite/";
ImageLayer* layer = new ImageLayer( "NASA", tms );
map->addImageLayer( layer );
} // Add an elevationlayer (SRTM from a local GeoTiff file)
{
GDALOptions gdal;
gdal.url() = "c:/data/srtm.tif";
ElevationLayer* layer = new ElevationLayer( "SRTM", gdal );
map->addElevationLayer( layer );
} // Create a MapNode to render this map:
MapNode* mapNode = new MapNode( map );
... viewer->setSceneData( mapNode );
(注意:官方的文档是OE2.4的,目前的API是OE2.9喽,时间:2017年2月7日10:27:15)
在运行时使用MapNode
MapNode是在场景图中绘制地图的节点(node)
如果,你不是用API创建的MapNode,你需要先使用静态函数get来获取它:
// Load the map
osg::Node* loadedModel = osgDB::readNodeFile("mymap.earth"); // Find the MapNode
osgEarth::MapNode* mapNode = MapNode::get( loadedModel );
如果你有了MapNode,你就可以使用地图了:
// Add an OpenStreetMap image source
TMSOptions driverOpt;
driverOpt.url() = "http://tile.openstreetmap.org/";
driverOpt.tmsType() = "google"; ImageLayerOptions layerOpt( "OSM", driverOpt );
layerOpt.profile() = ProfileOptions( "global-mercator" ); ImageLayer* osmLayer = new ImageLayer( layerOpt );
mapNode->getMap()->addImageLayer( osmLayer );
你也可以删除或重新订制图层:
// Remove a layer from the map. All other layers are repositioned accordingly
mapNode->getMap()->removeImageLayer( layer ); // Move a layer to position 1 in the image stack
mapNode->getMap()->moveImageLayer( layer, );
处理图层
地图包含纹理层和高程层对象,这些层包含一些可以在运行时调整的属性
例如,你可以使用API打开,关闭,或者调整纹理层透明度等
ImageLayer* layer;
...
layer->setOpacity( 0.5 ); // makes the layer partially transparent
另加:
完整的osgearthviewer工具关于api加载的函数
/** @brief 创建场景 */
int Create()
{
// create the map.创建一个地图
Map* map = new Map(); // add a TMS imager layer:添加一个TMS图片层
TMSOptions imagery;
imagery.url() = "http://readymap.org/readymap/tiles/1.0.0/7/";
map->addImageLayer(new ImageLayer("Imagery", imagery)); // add a TMS elevation layer:添加一个高程图
TMSOptions elevation;
elevation.url() = "http://readymap.org/readymap/tiles/1.0.0/9/";
map->addElevationLayer(new ElevationLayer("Elevation", elevation)); // make the map scene graph:
MapNode* node = new MapNode(map); // initialize a viewer:
osgViewer::Viewer viewer;
viewer.setCameraManipulator(new EarthManipulator);
viewer.setSceneData(node); // add some stock OSG handlers:
viewer.addEventHandler(new osgViewer::StatsHandler());
viewer.addEventHandler(new osgViewer::WindowSizeHandler());
viewer.addEventHandler(new osgViewer::ThreadingHandler());
viewer.addEventHandler(new osgViewer::LODScaleHandler());
viewer.addEventHandler(new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()));
viewer.addEventHandler(new osgViewer::HelpHandler(arguments.getApplicationUsage())); return viewer.run();
}
[原][译][osgearth]API加载地球(OE官方文档翻译)的更多相关文章
- [原][osgearth]API加载earth文件的解析
参考:http://blog.csdn.net/cccstudyer/article/details/17691893 通过\src\osgEarthDrivers\earth\ReaderWrite ...
- ArcGIS Javascript API 加载高德在线地图扩展
利用ArcGIS JavaScript API加载高德在线地图的扩展 /** * Created by WanderGIS on 2015/7/15. */ define(["dojo/_b ...
- [原][译][osgearth][EarthFile]关于EarthFile 的Model Layer 讲解(通过earth文件加载模型层)(OE官方文档翻译)
原文参考:http://docs.osgearth.org/en/latest/references/earthfile.html#model-layer 本人翻译能有限.... 模型层 模型层渲染“ ...
- [原][译][osgearth]关于Features & Symbology (特征与符号)(OE绘制矢量几何与特殊字符)讲解(OE官方文档翻译)
原文参考:http://docs.osgearth.org/en/latest/user/features.html 自己翻译的,本人英文水平有限,有问题看原链接,原文 20170802重置修改部分翻 ...
- [原][译][osgearth]样式表style中参数总结(OE官方文档翻译)
几何Geometry 高度Altitude 挤压Extrusion 图标Icon 模型Model 渲染Render 皮肤Skin 文本Text 覆盖Coverage 提示: 在SDK中,样式表的命名空 ...
- Revit API 加载族并生成实例图元
在Revit API中加载族可以使用Doc.LoadFamily方法,传入要加载的族文件路径名,但是这种方式有一种缺点,就是如果族文件在当前工程中没有加载的话则返回成功,如果已经加载过,则返回失败,也 ...
- vue调用豆瓣API加载图片403问题
"豆瓣API是有请求次数限制的”,这会引发图片在加载的时候出现403问题,视图表现为“图片加载不出来”,控制台表现为报错403. 其实是豆瓣限制了图片的加载,我自己用了一个办法把图片缓存下来 ...
- [原]排错实战——解救加载调试符号失败的IDA
原调试IDA排错troubleshootsymbolspdbsysinternalprocess monitor 缘起 最近想借助IDA逆向一个函数.在windows下,调试器(比如vs, windb ...
- ArcGIS Flex API加载大量数据
1.关于大量数据的加载: 直接将所要展示的数据在服务器端发布成一个MapService,在客户端通过ArcGISDynamicMapServiceLayer来加载.这样的话客户端需要展示的仅仅是一张图 ...
随机推荐
- innodb的innodb_buffer_pool_size和MyISAM的key_buffer_size(转自:http://www.java123.net/898181.html)
一. key_buffer_size 对MyISAM表来说非常重要. 如果只是使用MyISAM表,可以把它设置为可用内存的 -%.合理的值取决于索引大小.数据量以及负载 -- 记住,MyISAM表会使 ...
- 170619、springboot编程之HelloWorld
springboot资料看了一段时间了,个人觉得开发效率相当高,也参考了网上很多大牛的技术博客,在这里面我也记录一下,方便以后自己翻阅查看,同时也给新手最一点点指引.如果有侵权大牛博客文章,请告诉我, ...
- 容斥原理解决某个区间[1,n]闭区间与m互质数数量问题
首先贴出代码(闭区间[1,n]范围内和m互质的数) 代码: int solve(II n,II m){ vector<II>p; ;i*i<=m;i++){ ){ p.push_ba ...
- hdu 5056 Boring count (窗体滑动)
You are given a string S consisting of lowercase letters, and your task is counting the number of su ...
- HTML---初识HTML
版权声明:本文为博主原创文章.不经博主同意注明链接就可以转载. https://blog.csdn.net/Senior_lee/article/details/33723573 H ...
- 微软官方推出的win10安装或者创建安装u盘的工具
https://www.microsoft.com/zh-cn/software-download/windows10 下载安装后,可根据提示,一步步的安装win10或者创建安装u盘
- 数据库知识,mysql索引原理
1:innodb底层实现原理:https://blog.csdn.net/u012978884/article/details/52416997 2:MySQL索引背后的数据结构及算法原理 ht ...
- Maven– HelloWorld实例
Maven– HelloWorld实例 maven安装好后,可以通过HelloWorld项目来体验一下maven是如何构建项目的.Maven项目的核心是pom.xml(就像Ant的build.xml一 ...
- 关于ML的思考讲座-周zh-11.30日
1.深度神经网络 1.以往神经网络采用单或双隐层结构,虽然参照了生物上的神经元,但是从本质上来说还是数学,以函数嵌套形成. 2.通常使用的激活函数是连续可微(differentiable)的,sigm ...
- (3)在Windows7上搭建Cocos2d-x
工具准备 搭建开发环境需要安装工具包括 Visual Studio python ———(本教程以python2.7.3版本为例),下载地址:http://www.python.org/downloa ...