osgEarth编译
osgEarth加载谷歌卫星地图的源码案例
osgEarth加载谷歌卫星地图的源码案例2014-12-24 11:51 242人阅读评论(0) 收藏举报osgEarth谷歌卫星地图一、准备工作安装水经注万能地图下载器,如果没有安装本软件,可以百度“水经注软件”到官方网站下载。
编译OSG、OSGEarth和第三方插件等,这里有一个已经编译好的vs2010+osgearth,下载地址“/share/link?shareid=107009&uk=2801833827”。
二、下载地图首先需要把谷歌卫星地图下载下来,这里以“郫县”为例。
启动水经注万能地图下载器,点击“框选下载区域”,双击下载区域,选择级数,如下图。
image001.jpg(269.3 KB, 下载次数: 0)下载附件保存到相册2014-12-23 16:01 上传在级别列表中,你可以选择任何级别,但一般来讲城区选择19级,郊区选择16级比理想,但选择级别之前,最好在在线地图浏览中先查看所想要下载的级别是否有数据,这里我们以10级为例。
选择好级别后,点击确定开始下载。
下载完成后会弹出对话框询问是否要立即导出,选择“是”,然后显示“导出图片数据”对话框,如下图所示。
在该对话框中,不需要作任何设置,点击“输出”按钮以默认参数导出数据即可。
默认导出路径为“D:\SGDownload\tt1_拼接[默认]\L10”。
三、VS2010创建应用程序解压编译包后还不能直接使用,需要设置环境变量:OSG_ROOT X:\OSGOSG_FILE_PATH %OSG_ROOT%\dataOSG_WINDOW 600 15 800 800Path %OSG_ROOT%\bin;设置文件目录属性Osgearth的一个主要目标是易于应用集成,实际上有2种方式去整合osgearth.第一种方式你可以建立一个earth file,然后在你的应用程序中加载它.第二种使用osgearth API的时候以编程方式动态建立一个地图。
OSGEarth编译与测试
第一章OSGEarth编译与测试2.1 OSGEarth编译第一步:配置系统环境变量。
新设置OSG_FILE_PATH变量,值为E:\OSGearth\OSGEARTH\data; E:\OSGearth\GDAL\data;向PATH添加值:E:\OSGearth\3rdParty\bin;E:\OSGearth\OSGEARTH\bin\Debug;E:\OSGearth\OSGEARTH\bin\Release;第二步:使用“生成”->“批生产”,选择all_build(debug|win32和release|win32)进行生成。
在编译过程中存在4个文件无法编译成功,但是不影响正常的测试。
第三步:修改这些错误。
上述错误的问题主要出现在E:\osgearth\osgearth\src\applications\osgearth_imageoverlay\osgearth_imageoverlay.cpp文件的36-39行。
原因是OSG_MIN_VERSION_REQUIRED(2,9,6)限制了osg的版本。
本文使用了v3.0.1版,因此需要添加需要添加ImageOverlayEditor文件。
(目前还没有解决)2.2 OSGEarth测试测试release版本:1.打开cmd窗口,进入E:\osgearth\osgearth\vs2010\bin\Release;2.输入命令:osgearth_viewer.exe E:\osgearth\osgearth\tests\gdal_tiff.earth;会出现一个提示3.复制所需的dll到E:\osgearth\osgearth\vs2010\bin\Release文件夹中。
可能需要重复好多次。
4.测试成功会出现下面界面:。
osgEarth编译环境配置
中国西安OSGEARTH三维地形开源项目项目使用手册XComs2011-11-4[在此处键入文档的摘要。
摘要通常是对文档内容的简短总结。
在此处键入文档的摘要。
摘要通常是对文档内容的简短总结。
]前言本书主要基于OSGEarth v2.0版本进行编写,以vs2010主要编译工具,windowsXP 作为运行平台。
根据实际项目需求编写,主要目录前言 (2)第一章OSGEarth介绍 (5)第二章OSGEarth编译环境配置 (5)第一节OSGEarth V2.0相关资源 (5)第二节Open Scene Graph安装与配置 (6)2.1 CMake介绍与安装 (6)2.2 Open Scene Graph介绍 (7)2.3 Open Scene Graph 安装 (8)第三节CURL安装与配置 (18)3.1 CURL介绍 (18)3.2 CURL编译 (19)第四节GDAL安装与配置 (20)4.1 GDAL介绍 (20)4.2 GDAL编译 (21)第五节GEOS安装与配置 (23)5.1 GEOS介绍 (23)5.2 GEOS编译 (23)第六节Expat安装与配置 (29)6.1 Expat介绍 (29)6.2 Expat配置 (29)第七节SQLite安装与配置 (30)7.1 SQLite介绍 (30)7.2 SQLite编译与配置 (30)第八节Minizip安装与配置 (32)8.1 MiniZip介绍 (32)8.2 MiniZip的编译与配置 (32)第九节Virtual Planet Builder安装与配置 (33)9.1 Virtual Planet Builder介绍 (33)9.2 Virtual Planet Builder编译 (34)最后其他资源的配置 (42)X.1 Open Scene Graph 第三方支持库 (42)X.2 libzip库 (43)X.3 Osgearth资源下载 (43)第三章OSGEarth编译 (46)第一节sln生成 (46)1.1 CMAKE配置 (46)1.2 VS2010配置 (52)第二节OSGEarth编译与测试 (54)2.1 OSGEarth编译 (54)2.2 OSGEarth测试 (56)第四章OSGEarth学习 (57)第一章OSGEarth介绍第二章OSGEarth编译环境配置OSGEarth的编译环境配置随着版本的不同、运行平台的不同,也有很大的差异。
Minizip安装与配置
Minizip安装与配置8.1 MiniZip介绍ZIP,是一个计算机文件的压缩的算法,原名Deflate(真空),发明者为菲尔·卡茨(Phil Katz)),他于1989年1月公布了该格式的资料。
ZIP通常使用后缀名“.zip”,它的MIME格式为application/zip 。
目前,ZIP格式属于几种主流的压缩格式之一,其竞争者包括RAR格式以及开放源码的7-Zip格式。
从性能上比较,RAR格式较ZIP格式压缩率较高,而7-Zip由于提供了免费的压缩工具而逐渐在更多的领域得到应用。
WinMount可以把ZIP挂载到虚拟盘,无需解压,随机读取,这又是另一大创新。
ZIP是一种相当简单的分别压缩每个文件的存档格式。
分别压缩文件允许不必读取另外的数据而检索独立的文件;理论上,这种格式允许对不同的文件使用不同的算法。
不管用何种方法,对这种格式的一个告诫是对于包含很多小文件的时候,存档会明显的比压缩成一个独立的文件(在类Unix系统中一个经典的例子是普通的tar.gz存档是由一个使用gzip压缩的TAR存档组成)要大。
ZIP的规约指出文件可以不经压缩或者使用不同的压缩算法来存储。
然而,在实际上,ZIP几乎差不多总是在使用卡茨(Katz)的DEFLATE算法。
ZIP支持基于对称加密系统的一个简单的密码,现在已知有严重的缺陷,已知明文攻击,字典攻击和暴力攻击。
ZIP也支持分卷压缩。
在近来一段时间,ZIP加入了包括新的压缩和加密方法的新特征,不过这些新特征并没有被许多工具所支持并且没有得到广泛应用。
8.2 MiniZip的编译与配置将unzip101h.zip中的文件复制到E:\osgearth\minizip\include;将zlib125dll.zip中文件夹dll32和static32中的lib文件和dll文件复制到E:\osgearth\minizip\lib中。
Osgearth编译需要的minizip文件已经处理完成。
虚拟现实建模与编程第5章 OSG的编译
(3)CMAKE_CONFIGURATION_TYPES:定义了工程文件中工程配置的种 类,缺省值包括Debug,Release,MinSizeRel和RelWithDebInfo四种类型。注意 不同的配置类型在工程中对应不同的编译选项,可以在CMAKE_CXX_FLAGS 和CMAKE_EXE_LINKER_FLAGS中进行修改。
2008, 然后单击Finish确定。 5.在此之后,软件便开始配置这个项目,它会分析项目中已有的相关配置,然后 将有疑问的未配置项目标定为红色。
6.设置相关的cache value参数,主要包括: (1)ACTUAL_3RDPARTY_DIR:设置为前面的 E:\OSG\3rdParty
ACTUAL_3DPARTY_DIR:即整合的第三方开发库所在目录,如果下载了OSG提供
5.3 用Cmake生成Project & Solution files
1.在E:\OSG\OpenSceneGraph下新建两个文件夹,分别命名为build、bin,用
于放置编译文件。 2.解压cmake-2.8.6,打开bin/cmake-gui.exe,将E:\OSG\OpenSceneGraph下的 CMakeLists.txt拖到界面上。
5.1 准备安装资料包程序(到OSG官方网站都可以下载)
下载相关的工具软件
在安装程序前,首先需要下载相关的工具软件: 1.最新版的OSG库:OpenSceneGraph-3.0.1.zip。 2.安装源代码所需要的工具:cmake-2.8.6-win32-x86.zip及以上版本均可。
osgEarth如何加载离线谷歌卫星地图瓦片的源码教程
osgEarth如何加载离线谷歌卫星地图瓦片的源码教程说明本实例演示重新编译bing驱动直接加载本地离线影像瓦片地图。
本实例使用软件版本:osg3.3.1和osgEarth2.5 VC10编译环境(参考osgearth加载谷歌卫星地图的源码案例),vs2010,水经注万能地图下载器。
影像瓦片来源“水经注万能地图下载器”。
如果没有安装本软件,可以百度“水经注软件”到官方网站下载。
一、下载瓦片数据启动水经注万能地图下载器,点击“我的下载”,选择“新建任务”,弹出“选择地图类型”对话框,选择相应的地图类型,点击“确认”,如下图。
弹出“新建任务”对话框输入全球坐标,由于我们需要导出瓦片数据,为了增加缩放效果,这里我们从1级到8级都勾选上。
选择好级别后,点击开始下载。
下载完成后会弹出对话框询问是否要立即导出,选择“是”,然后显示“导出图片数据”对话框,如下图所示。
在该对话框中,选择导出“瓦片:Bing Map”,导出级别“1-8”,选择保存路径,点击“输出”按钮导出数据即可。
二、重新编译Bing驱动新建“osgdb_osgearth_bingd”动态库项目,如下图所示。
点击“确定”,弹出“应用程序向导”,如下图所示。
点击下一步选择程序类型“DLL”,点击“完成”。
添加“包含目录”和“库目录”包含目录设置为“D:\OSG\include”库目录设置为“D:\OSG\lib“以上目录路径根据OSG文件位置设定。
附加依赖项OpenThreads.libosgd.libosgAnimationd.libosgDBd.libosgdb_osgearth_feature_ogrd.lib osgdb_osgearth_feature_tfsd.lib osgdb_osgearth_feature_wfsd.lib osgEarthd.lib osgEarthAnnotationd.lib osgEarthFeaturesd.lib osgEarthSymbologyd.libosgEarthUtild.libosgFXd.lib osgGAd.lib osgManipulatord.lib osgParticled.lib osgPresentationd.lib osgShadowd.lib osgSimd.lib osgTerraind.lib osgTextd.lib osgUtild.lib osgViewerd.lib osgVolumed.lib osgWidgetd.lib点击“确定“。
osgEarth用户手册
1、OSGEARTH 安装OsgEarth是一个跨平台的库,可以使用版本号为2.6.2或更新版本的Cmake 对其进行编译。
1.1、获取源码三个方法可以获取osgearth源码:Option1:使用GITosgEarth源码托管于GitHub,所以我们需要一个Git客户端。
Windows下推荐T ortoiseGit,SVN 小乌龟的Git 版本。
评价:该有的功能基本都有了,还是不错的。
备注:GitHub是一个为那些使用Git版本控制系统的项目提供基于互联网的存取服务的Git存取站点。
它是由GItHub公司(先前被称作用Logical Awesome)的开发者Chris Wanstrath, PJ Hyett, 和Tom Preston-Werner 使用Ruby on Rails写成的。
最新版本是Version 2.0,osgearth_2.0_T2011-02-24。
Option2: 下载tarballtarball是linux下最方便的打包工具,是以tar这个指令来打包与压缩的档案。
下载页面: /gwaldron/osgearth/downloadsOption3:使用版本控制SVN在您的SVN客户端上键入:/gwaldron/osgearth.git1.2、准备工作osgEarth需要第三方支持库才能编译。
所需的依赖服务如下:●OpenSceneGraph 2.8或更新的●GDAL 1.6或更新的,Geospatial Data Abstraction Layer的缩写。
是一个在X/MIT许可协议下的开源栅格空间数据转换库●CURL- HTTP transfer library,是一个利用URL语法在命令行方式下工作的文件传输工具。
可选依赖如下(没有他们,osgEarth可以运行,但将会失去一些功能):●GEOS3.2.0或更高版本-C++拓展库,这个库是用来osgEarthFeatures模块执行各种几何处理操作,如缓冲和交集。
osgEarth_Document
osgEarth - Terrain On Demand ¶The objectives of osgEarth are to:•Enable the development of geospatial applications in OSG.•Make it as easy as possible to visualize terrain models.•Interoperate with open mapping standards, technologies, and data.What it is ¶osgEarth is a terrain generation system for OpenSceneGraph applications. There are two ways to render terrain using osgEarth:•On-demand terrain: Generate and display a terrain at run-time with no pre-processing;osgEarth will access the raw data sources at application run time and composite them into a terrain model on the fly. No terrain model is actually stored to disk.•Pre-built terrain: Use the osgearth_seed utility to pre-cache image, elevation, and vector data from your raw data sources, and then run off the cache. This is similar to the way traditional terrain generation systems work - you build your terrain offline, then load it into yourapplication.Design ¶osgEarth's internal design reflects its focus on real-time data ingestion. Data sources are generally optimized into tile hierarchies for fast serving and consumption over the web. osgEarth deals with map data in terms of these tile hierarchies. Any raster source, no matter its organization or location, will be broken down into a hierarchy of optimized tiles by osgEarth for display.Now, the farther away the structure of your source data is from a tile hierarchy, the more processing osgEarth will need to apply to it before display - and more processing means less performance. (Caching can mitigate this to a great extent.) Yes, osgEarth can and will mosaic, reproject, and crop data to get it onto the terrain ... but it's happiest and fastest when the source data is already optimized. Read the section of Data Preparation for more details on how to prepare source data for best results.Try it on ¶The quickest and easiest way to get up and running with osgEarth is to simply load a .earth file. Find the tests folder and fire it up from the command line:osgviewer gdal_tiff.earthWe call this the zero-integration approach to using osgEarth. osgEarth includes a standard OSG loader that will read these files and produce a scene graph. If you have the osgEarth runtime libraries in your path, you can incorporate osgEarth terrains into your application without any additional coding.Is it for you? ¶So: does osgEarth replace the need for offline terrain database creation tools? In many cases it does, but that will depend entirely on your particular application.Consider using osgEarth if you need to:•Get a terrain base map up and running quickly and easily•Access open-standards map data services like WMS, WCS, or TMS •Integrate locally-stored data with web-service-based data•Incorporate new geospatial data layers at run-time•Run in a "thin-client" environment•Deal with data that may change over time•Integrate with a commercial data providerCreating Maps - Primer ¶This is a basic primer on creating maps for osgEarth. We suggest you peruse the sample .earth files in the source code repository for a wide away of examples.osgEarth uses an XML based file format called an Earth File to specify exactly how source data turns into an OSG scene graph.For a detailed view of all the options available when creating an Earth File, please see the Earth File Elements Reference.At it's core, the Earth File allows you to specify•The type of map to create (geocentric or projected)•The image, elevation, vector and model sources to use•Where the data will be cachedThe samples folder in the repository contains numerous examples of Earth files and how to use them.Simple Map File ¶Here is a very simple example that reads data from a WMS server and renders it to a round-earth3D model:<map name="MyMap" type="geocentric" version="2"><image name="bluemarble" driver="gdal"><url>/data/world.tif</url></image></map>This Earth File creates a geocentric Map named "MyMap?" with a single GeoTIFF image source called "bluemarble". The driver attribute tells osgEarth which of it's drivers to use to load the image. All sub-elements are specific to the selected driver. To learn how to configure each of the drivers in osgEarth, please see the drivers page.Multiple Image Layers ¶osgEarth supports maps with multiple image sources. This allows you to create maps such as base layer with a transportation overlay or provide high resolution insets for specific areas while providing a lower resolution base map. To add multiple images to a Earth File, simply add multiple "image" elements to your Earth File.<map name="Transportation" type="geocentric" version="2"><!--Add a base map of the blue marble data--><image name="bluemarble" driver="gdal"><url>c:/data/bluemarble.tif</url></image><!--Add a high resolution inset of Washington, DC--><image name="dc" driver="gdal"><url>c:/data/dc_high_res.tif</url></image></map>The above map provides two images from local data sources using the GDAL plugin. osgEarth uses various methods to render the image layers, so the limit on how many image layers you can render depends on your hardware (more info). Order is important when defining multiple image sources: they are applied bottom to top in the order that they specified in the file.Elevation Data ¶Adding elevation data to an Earth File is very similar to adding images. Elevation data can be added to an Earth File by adding an elevation element to the XML:<map name="Elevation" type="geocentric" version="2"><!--Add a base map of the blue marble data--><image name="bluemarble" driver="gdal"><url>c:/data/bluemarble.tif</url></image><!--Add SRTM data--><elevation name="srtm" driver="gdal"><url>c:/data/SRTM.tif</url></elevation></map>This Earth File has a base blue marble image as well as a elevation grid that is loaded from a local GeoTiff? file. Any number of elevation sources can be added to the Earth File and they will be combined together by osgEarth. As with images, order is important to elevation data as well. For instance, if you had a base elevation datasource that had low resolution coverage of the entire world and a high resolution inset of Denver, CO, you would specify the base data FIRST, followed by the high res data.Most drivers in osgEarth support reading heightfields as well as imagery. However, it is important to note that only 16 and 32 bit datasources can be used as heightfield datasources.Caching ¶osgEarth can cache tiles on disk in order to increase performance to avoid downloading/processing tiles multiple times.<map name="TMS Example" type="geocentric" version="2"><image name="metacarta blue marble" driver="tms"><url>/wms-c/Basic.py/1.0.0/satellite/</url></image><options><!--Specify where to cache the data--><cache><path>c:/osgearth_cache</path></cache></options></map>This Earth File shows the most basic way to specify a cache for osgEarth. This tells osgEarth to enable caching and to cache to c:/osgearth_cache. Both absolute and relative paths can be used when specifying the cache path. If a relative path is given for the cache path, it will be relative to the location of the Earth File.A more detailed description of how to configure caching is available in the caching section.<map> ¶A map configuration that describes how to render geospatial data as a unified terrain model. osgEarth can render maps in one of two ways:•Geocentric - If the value of the map's type attribute is geocentric, round, globe or earth then the map will be displayed as a whole earth, geocentric globe. Please note that only geodetic and mercator profiles can be rendered as a Geocentric globe.•Projected - If the value of the map's type attribute is projected or flat then the map will be displayed in a flat projection. This is useful for displaying data that is in a projectedcoordinate system such as UTM, but you can also render whole earth geodetic or mercator data in a flat projection, e.g., for 2D mapping applications.Attributes ¶name Human-readable name of the map. optionaltype Type of map to render: geocentric for round-earth (default), projected for flat-earth (default: geocentric)optionalversion Specified the version of the earth-file format. Should be "2" when usingosgEarth 2.x.requiredSub-elements ¶<options>Configures the map and all runtime behavior of the terrain engine. optional<image>An image layer. Your graphics hardware, along with the compositor thatosgEarth is using, will determine the maximum number of <image> layersyou can display.optional<elevation> An elevation layer. Elevation layers of different sizes and resolutions can be stacked. There is no artificial limit to the number of elevation layersosgEarth supports.optional<model> A model data source (e.g., feature data, external models) optional <overlay> A layer that drapes geometry over the terrain optional Example ¶<map name="earth" type="geocentric" version="2"><options>...</options><image ...></image><elevation...></elevation></map>osgEarth Drivers ¶Image / Elevation Drivers ¶These drivers generate image or elevation tiles that make up the terrain itself.AGGLite Rasterizes feature data into image tiles.ArcGIS Reads imagery data from ESRI ArcGIS Server map services or the ArcGIS Online web serviceComposite Combines multiple <image> layers into one logical image layerGDAL Reads geo-referenced imagery and elevation data in a large number of formats including GeoTIFFOSG Reads non-geo-referenced imagery (like JPEGs) using one of the OpenSceneGraph image reader/writersTileCache Reads image tiles from a MetaCarta TileCache cache folderTileService Reads tiles from a NASA WorldWind TileService repositoryTMS Reads tiles from an OSGeo TileMapService repositoryWCS Reads from an OGC Web Coverage ServiceWMS Reads from an OGC Web Mapping ServiceVPB Integrates with an existing VirtualPlanetBuilder terrainModel Drivers ¶Model drivers ingest data and create nodes that can be placed on top of the terrain. These could be "draped" layers, or they could be 3D models.Feature Geometry Renders vector data as OSG geometryFeature Overlay Drapes vector data on the terrain using projected texturesFeature Stencil Drapes vector data on the terrain using a stencil buffer techniqueSimple Loads an external model and places it in the scene graphFeature Drivers ¶Feature drivers are used to read raw GIS vector data. They do not create visible geometry directly; model drivers that display vector data will use feature drivers to read in the vector data.OGR Reads raw vector feature data from Shapefiles and a number of other formats using the GDAL/OGR toolkitCache Drivers ¶Cache drivers are used to provide tile caching implementations to osgEarth.tms Stores cached tiles in a TMS-style file hierarchy on disk. (DEFAULT)sqlite3Caches tiles in an sqlite3 database on disk.Terrain Engine Drivers ¶A terrain engine driver provides osgEarth with a terrain skin (image+elevation) rendering implementation.A terrain renderer based on the OpenSceneGraph osgTerrain library. osgterrain(DEFAULT)Caching ¶osgEarth can cache tiles in order to increase performance. One an image or heightfield has been created once, it is generally much faster to access a local cache for that tile rather than create the tile or download it from the web again.All layers in the map share a single cache object defined at the map level.There are multiple types of caches that can be used in osgEarth, but all caches are specified with the following format:<cache type="cache_type"><property1>value</property2><property2>value</property2>...</cache>The type parameters tells osgEarth which type of cache to create. All properties and their corresponding values will be passed to the cache to configure it.General Notes•All disk based caches use the image and heightfield name to create the folder to cache to.Please make sure that your layer names are unique per each cache path.•osgEarth uses OpenSceneGraph?'s existing plugins to read and write data. Make sure that the format you specify for the caches has good support for reading and writing. For example, the tiff plugin in OpenSceneGraph? 2.6.1 has a problem writing 16 and 32 bit datasets, so it is inappropriate to use when caching heightfields. The DDS plugin does support writing both16 and 32 bit datasets to disk. The tiff plugin is the recommended plugin to use for OSG 2.8and above.•It is possible to run osgEarth completely off of a cache by setting theOSGEARTH_CACHE_ONLY environment variable or using the <cache_only> attribute.•It is possible to override the cache format and disable caching for a particular layer by using the <cache_enabled> and <cache_format> elementsSeeding the Cache ¶Sometimes it is useful to pre-seed your cache for a particular area of interest. osgEarth provides a utility application, osgearth_seed to accomplish this task. osgearth_seed will take an Earth file and populate your cache.osgearth_seed UsageCommand:osgearth_seed [options] filenameOptions:--bounds minx miny maxx, maxy The geospatial extents to seed.--min-level level The minimum level to seed down to.--max-level level The maximum level to seed down to.-b Shorthand for --bounds.--cache-path Use a different cache path than the one defined in the earth file--cache-type Override the cache type if youoverride the cache path (tms or disk).Types of Caches ¶TMS (default) ¶If the cache type is tms then osgEarth caches files to disk using a format compatible with the TMS specification.The tms style cache has the following properties:•path - The path on disk to cache tiles to•format - The format to cache to (png, jpg, dds, etc). If no format is specified, the preferred format of the image or heightfield source will be used. If there is no preferred format for the source, the default will be png.•tms_type - If the value of tms_type is google then the y tile index will be inverted so that 0,0 is the top left tile rather than the bottom left tile.<map name="My Map" type="geocentric"><!--Specify a map level "tms" cache for all images and heightfields--><cache type="tms"><path>c:/osgearth_cache</path></cache><image name="bluemarble" driver="tms"><url>/wms-c/Basic.py/1.0.0/satellite/</url></image><image name="inset" driver="gdal"><url>c:/data/inset.tiff</url></image></map>Sqlite3 ¶Set the cache type to sqlite3 to store your cache in a sqlite database file. This is nice because the entire cache is in a single file, making it easy to transport if necessary.The sqlite3 cache has the following properties:•path - path to the database file.Example:<map type="globe"><cache type="sqlite3"><path>c:/osgearth_cache.db</path><max_size>300</max_size> <!-- MB --></cache><image name="bluemarble" driver="tms"><url>/wms-c/Basic.py/1.0.0/satellite/</url></image>Tile Cache ¶If the cache type is tilecache then osgEarth caches files to disk using a format that is compatible with Metacarta's TileCache "Disk" style caching. This means that the resulting osgEarth cache canbe used by any client that can consume publicly accessible TileCache? disk caches such as OpenLayers or osgEarth. This is very useful because as you are browsing and caching tiles, you are actually creating a map that can be browsed by other clients. If no cache type is specified, then a TileCache? style cache will be used.The tilecache style cache has the following properties:•path - The path on disk to cache tiles to•format - The format to cache to (png, jpg, dds, etc). If no format is specified, the preferred format of the image or heightfield source will be used. If there is no preferred format for the source, the default will be png.<map name="My Map" type="geocentric"><!--Specify a map level "tilecache" cache for all images and heightfields--><cache type="tilecache"><!--All tiles will be cached to c:/osgearth_cache--><path>c:/osgearth_cache</path><!--All tiles will be cached to png format. If we did not specify the format, tiles would be cached to the preferred format of the tile source--><format>png</format></cache><image name="TMS" driver="tms"><url>/wms-c/Basic.py/1.0.0/satellite/</url></image><image name="inset" driver="gdal"><url>c:/data/inset.tiff</url></image></map>Back to DocumentationosgEarth Developers Guide (Version 2.x) ¶osgEarth was designed with ease of application integration as one of its main goals. There are really two ways to go about integrating osgEarth. You can create an Earth File and load it into your application or you can programmatically create a map at runtime using the osgEarth API. Topics:•Working with maps•The utilities library•Shader composition•Building your own driver?Loading a Map ¶Because much of the functionality of osgEarth is wrapped up in OpenSceneGraph plugins, it is possible to load a map from an Earth File with a single line of code:osg::Node* globe = osgDB::readNodeFile("myglobe.earth");You now have an OpenSceneGraph Node that can be added to your scene graph and displayed. Seriously, it really is that simple! :)This method of loading a Map is more often than not all that an application will need to do. If your application already supports VirtualPlanetBuilder terrain databases, then you should have very little work in integrating osgEarth as the scene graphs are extremely similar. Both are based on osgTerrain and the !PagedLOD system and both are decorated with an osg::CoordinateSystemNode. The only real difference between the two is that an osgEarth database is built on the fly rather than pre-generated.Programmatic Map Creation ¶osgEarth also provides an API for creating Maps at runtime. This is very useful if your application allows a use to select from various layers to display at runtime.The basic steps to creating a Map with the API are:1.Create a Map object2.Add imagery and elevation layers to the Map as you see fit3.Create a MapNode that will render the Map object4.Add your MapNode to your scene graph.You can add layers to the map at any time. However, once you add a layer to the map, it makes a copy of the options and you can no longer change them.#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 globeMap* map = new Map();// Add an imagery layer (blue marble from a TMS source){TMSOptions tms;tms.url() = "/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 );Working with a MapNode at runtime ¶Whether the Map was loaded from an Earth File or created at run time, the Map can modified at runtime. If a Map was loaded from an Earth File, you will first need to get a reference to the MapNode to work with. Use the !Map::findMapNode utility function://Load the maposg::Node* loadedModel = osgDB::readNodeFile("mymap.earth");//Find the MapNodeosgEarth::MapNode* mapNode = MapNode::findMapNode( loadedModel );Once you have a reference to the MapNode, you can add image or elevation layers:// Add an OpenStreetMap image sourceTMSOptions driverOpt;driverOpt.url() = "/";driverOpt.tmsType() = "google";ImageLayerOptions layerOpt( "OSM", driverOpt );layerOpt.profile() = ProfileOptions( "global-mercator" );ImageLayer* osmLayer = new ImageLayer( layerOpt );mapNode->getMap()->addImageLayer( osmLayer );You can also remove or re-order layers:// 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 stackmapNode->getMap()->moveImageLayer( layer, 1 );Processing Source Data ¶If you have geospatial data that you would like to view in osgEarth, you can use the GDAL driver. If you plan on doing this, there a few performance guidelines you should follow:Reproject your dataosgEarth will reproject your data on your fly if it does not have the necessary coordinate system. For instance, if you are trying to view a UTM image on a geodetic globe (epsg:4326). However, osgEarth will run much faster if your data is already in the correct coordinate system. You can use any tool you want to reproject your data such as GDAL, Global Mapper or ArcGIS. For example, to reproject a UTM image to geodetic using gdal_warp:gdalwarp -t_srs epsg:4326 my_utm_image.tif my_gd_image.tifBuild tiled imageryTypically formats such as GeoTiff? store their pixel data in scanlines. This generally works well, but because of the tiled approach that osgEarth uses to access the data, you may find that using a tiled dataset will be more efficient as osgEarth doens't need to read nearly as much data from disk to extract a tile. To create a tiled GeoTiff? using gdal_translate, issue the following command:gdal_translate -of GTiff -co "TILED=YES" myfile.tif myfile_tiled.tifBuild overviewsAdding overviews (also called pyramids or rsets) will greatly increase the peformance of a datasource in osgEarth. You can use the gdaladdo utility to add overviews to a dataset. For example:gdaladdo -r average myimage.tif 2 4 8 16Generating Tiled Datasets ¶While it is possible to use geospatial source data directly in osgEarth, it is much more efficient to pre-tile the data into an optimized tile hierarchy. There are many tools available to accomplish this, including osgEarth!osgEarth ¶One of the easiest ways to create a nicely tiled datasource is to use osgEarth's built in caching mechanism. Caches created by osgEarth are based on open standards datasources such as TMS and can actually be used as a datasource directly once they are cached. For example, lets say we have a single GeoTiff? of NASA's BlueMarble? image that we want to tile up.First, create a map file called bluemarble.earth that references the Blue Marble GeoTiff? using the GDAL plugin<map name="bluemarble" type="geocentric" version="2"><!--Add a reference to the image --><image name="bluemarble" driver="gdal"><url>c:/data/bluemarble.tif</url></image><options><!--Tell osgEarth to cache the tiles in a TMS format--><cache type="tms"><path>c:/osgearth_cache</path><!--Tell osgEarth to cache the tiles to JPG to save disk space--><format>jpg</format></cache></options></map>When you run:osgviewer bluemarble.earthyou should see tile begin to cache to the c:/osgearth_cache/bluemarble folder as you browse around the globe.Lets automate the caching process by using the osgearth_seed program.Run:osgearth_seed --max-level 7 bluemarble.earthOnce this is complete, you will have a fully cached TMS datasource in yourc:/osgearth_cache/bluemarble directory.Now, lets remove the need for the original GeoTiff? file and directly access the TMS datasource. Make a mapfile called bluemarble_tms.earth:<map name="bluemarble-tms" type="geocentric" version="2"><!--Add a reference to the TMS xml file --><image name="bluemarble" driver="tms"><url>c:/osgearth_cache/bluemarble/tms.xml</url></image></map>Running osgviewer with bluemarble_tms.earth will directly hit the cache. You can freely move the bluemarble datasource anywhere you want, even a webserver! For instance, you can deploy the tiles by copying the bluemarble directory to a public folder on your webserver.Then, we could change our bluemarble_tms.earth file to<map name="bluemarble-tms" type="geocentric" version="2"><!--Add a reference to the TMS xml file --><image name="bluemarble" driver="tms"><url>/tiles/bluemarble/tms.xml</url></image></map>Running osgviewer will now hit the tiles on the server! Just for completeness, you could also copy the bluemarble_tms.earth file to your webserver as well and load it from the web like:osgviewer /maps/bluemarble_tms.earthIt is important to note that this procedure doesn't apply only to geospatial data on your source machine. It is completely possible to use this procedure to cache data from a server such as WMS to a local TMS cache!Maptiler ¶MapTiler is a nice little GUI tile generator that was originally developed as the gdal2tiles script forGDAL. It can be used to generate TMS (Tile Map Resource) tile sets that can be used directory in osgEarth.It is very important to note that the BoundingBox? element in the tilemapresource.xml file output by MapTiler? has it's x's and y's reversed. So, once tile generation is complete, open up the tilemapresource.xml file in a text editor, swap the minx/miny, maxx/maxy values and save the fileYou should then be able to create a new [TileSourcePluginTMS TMS] image source that references the tilemapresource.xml fileTileCache? ¶TileCache is a small Python WMS-C implementation that lets you easily publish a caching tile server. Once you have TileCache? installed according to the directions on their website, you can setup osgEarth to access it as a WMS or TMS service and TileCache? will cache the tiles as you browse. Another added benefit is that you can use TileCache?'s "disk" cache mode and then use osgEarth's TileCache Driver to access the cache folder directory.Back to Documentation。
osgEarth编译总结
首先在osg的编译上有一点记录一下:1 我们下载的第三方依赖3rdParty_x86_x64 这个文件对于VS2008和VS2010来说可能VS2008的提供库要全一些。
2 对于3rdParty_x86_x64文件夹下的x86和x64来说我们的系统如果是32位的应该就只能选x86 对于x64来说我们两个包都是可以选择的,据说在64位的系统上的32位程序是模拟运行的。
如果我们编译时选择直接编译。
那最好是选x86那个包。
在这次的选择中选择x64包结果编译到osgDB库的时候出现了错误。
如果想编译出来的程序只是用于x64 那么可以尝试在x64包的基础上对VS进行相关的设置,应该是不会有很大问题的。
下面主要是对osgEarth进行编译由于osgEarth没有对第三方依赖进行打包,所以我们就不得不自己进行配置相关的依赖。
首先下载源码包,我们进入官网/wiki/Downloads下载源码简单明了。
接下来我们下载第三方依赖:1 GDAL下载:/gdal/wiki/DownloadSource在这里我们选择1.8.1版本,因为在1.9.0版本使用中出现了编译不能通过的情况。
当然我们也可以自己将编译过程中出现的问题解决。
在这里我们只是为了编译GDAL“不节外生枝”下面我们来对这个库进行编译:对于这个版本有两种方法可以编译1 它里面有两个.sln,使用其中之一编译就行2 下载完GDAL的源码后,还需要先运行makegdal_gen.bat这个文件,然后打开X:\Program Files\Microsoft Visual Studio\VC98\bin\VCVARS32.BAT,X代表你VS的安装盘.打开后用cd命令切换到你GDAL的目录下执行命令,nmake /f makefile.vc MSVC_VER=1500 BUILD_DEBUG=YES,其中1500代表VS版本2008,当然你也可以进入nmake配置文件修改.文件编译完成后我们有两种不同的处理方法方法一将生成的lib dll 包括: gdal_i.lib gdal.lib cpl.lib(port目录下) ogr.lib(ogr目录下), 以及gdal17.dll 拷贝到E:\OSG\GDAL\apps下,这一种在后面的使用中会直接将这个作为cmake的应用目录(在工程中添加包含目录时会很麻烦,不推荐采用)方法二GDAL编译完成后的文件存放于C0:\warmerda\bld,包含文件include,lib,data,bin,可将它们拷贝到GDAL文件夹下,置于OSG目录下。
编译osg、osgEarth、QGIS
编译QGIS-修改记录目录编译QGIS (1)- (1)修改记录 (2)目录 (3)1.准备 (4)1.1.下载源码: (4)1.2.下载依赖的第三方库 (4)1.3.使用osgeo4w-setup下载第三方依赖库 (4)1.3.1.osgeo4w-setup的获取 (4)1.3.2.下载第三方库 (4)2.编译OpenSceneGraph-3.2.1 (5)3.编译osgearth (5)4.编译QWT 5.2.3 (7)5.编译QGIS (8)5.1.准备: (8)5.2.修改CMakefile.txt文件: (8)5.3.编译Debug版本: (9)5.4.编译Release版本 (10)1.准备1.1.下载源码:下载OpenSceneGraph-3.2.1、osgearth-osgearth-2.5、qgis_2.4的源码;1.2.下载依赖的第三方库使用下载QIS依赖的第三方库。
使用windows-VS10.0.30319-x86-debug.7z中的osg第三方库。
1.3.使用osgeo4w-setup下载第三方依赖库1.3.1.o sgeo4w-setup的获取从安装版QGIS中获取。
或从/osgeo4w/网站获取。
1.3.2.下载第三方库1)运行osgeo4w-setup2)选择“Advanced Install“,下一步;3)选择“Download Without Installing“,下一步。
(只下载不安装,目的是以后继续使用下载的文件。
也可以选择”Install from Internet“);4)在“Select Loacal Package Directory“,选择存放安装包的本地目录,下一步。
5)在“Select Packages“页面中,选择要下载的包。
安装:1)在上述第3)步中,选择“Install from Local Directory“,2)在“Root Directory“中指定安装的目的目录(如E:\QEarth)3)在“Select Loacal Package Directory“中选择上面第4)步指定的存放安装包的本地目录。
osg和osgearth编译
Ubuntu12.04下osg,osgearth编译全步骤1.安装文件夹拷贝到/home目录下2.su -命令切换到root,然后检测Linux环境是否是Linux64位3.检测ffmpeg是否存在,若存在则移除ffmpeg4.检测QT是否存在,若存在则移除QT删除QT5.更新源和直接用命令安装其他依赖的软件更新源:apt-get update -yapt-get upgrade -y安装依赖软件:apt-get install gcc –yapt-get install g++ -yapt-get install yasm –yapt-get install cmake –yapt-get install cmake-gui –yapt-get install curses-gui –yapt-get install cmake-curses-gui –y apt-get build-dep openscenegraph –yapt-get install libboost1.48-all-dev –y apt-get install gtk-2.0 –yapt-get install libgtkglext1-dev –y6.修复boost头文件位置cp –r /usr/include/boost /usr/local/include/7.安装QT进入qt安装包所在目录,开始安装配置环境变量:(1)gedit /etc/profile 打开配置文件,在末尾中添加:OSG_FILE_PATH=/home/GeoVisEnvironmentUbuntu/osg/OpenSceneGraph-Data-3.0.0 QTDIR=/opt/Qt5.4.0/5.4/gcc_64PATH=/opt/Qt5.4.0/Tools/QtCreator/bin:$QTDIR/bin:$PATHexport OSG_FILE_PATHexport QTDIRexport PATH(2)gedit /etc/ld.so.conf.d/libc.conf,在末尾添加:/opt/Qt5.4.0/5.4/gcc_64/lib(3)gedit ~/.bashrc,在末尾同(1)相同的加入:OSG_FILE_PATH=/home/GeoVisEnvironmentUbuntu/osg/OpenSceneGraph-Data-3.0.0 QTDIR=/opt/Qt5.4.0/5.4/gcc_64PATH=/opt/Qt5.4.0/Tools/QtCreator/bin:$QTDIR/bin:$PATHexport OSG_FILE_PATHexport QTDIRexport PATH8.安装ffmpeg进入ffmpeg所在文件夹,tar -xjf ffmpeg-2.5.tar.bz2cd ffmpeg-2.5./configure --enable-shared --enable-picmake -j 4make install9.安装和更新gdal删除之前的gdal库find / -name libgdal.so*解压gdal安装包,进入文件夹,执行./configure执行make –j 8,之后执行make install修正库路径cp ./.libs/libgdal.so* /usr/lib10.将动态链接库加载到内存,即配置路径,然后刷新,将其真正加载到内存并可用执行touch /etc/ld.so.conf.d/libc.confecho "/usr/local/lib64" >> /etc/ld.so.conf.d/libc.confecho "/usr/local/lib" >> /etc/ld.so.conf.d/libc.confldconfig -vsource /etc/profileapt-get autoremove10.编译osg源码编译debug版进入OpenSceneGraph-3.3.1源码所在目录,执行cmake . -DCMAKE_BUILD_TYPE=Debug这一步会报cmake版本过低的错误。
OSGEARTH + VS2010 安装
一、准备工作下载: /wiki/Downloads1. CURL (curl-7.21.7.tar.gz): http://curl.haxx.se/download.html2. GDAL(gdal-1.8.0.tar.gz):/gdal/wiki/DownloadSource3. GEOS(geos-3.2.2.tar.bz2):/geos/4. Expat(expat-win32bin-2.0.1.exe): code:/projects/expat/exe文件:/eaglezhao/expat-win32bin-2.0.1.rar5. libzip(libzip-windows.zip): code:http://nih.at/libzip/编译好的包供下载:vs2008:/trac/osgearth/raw-attachment/wiki/Downloads/libzip-windows.zip vs2010:/eaglezhao/libzip(vs10).rar6. OSGEARTH(SVN上下载):svn:/gwaldron/osgearth.git(目前最新版是osgearth 2.0)二、安装1. CURL使用CMAKE进行配置:生成.sln后编译即可编译好后将目录下的include/curl下文件拷到E:\OSG\3rdparty\include\curl ,进行覆盖编译好后将目录下的lib下的libcurl.dll文件拷到E:\OSG\3rdparty\bin ,进行覆盖2. GDAL直接运行相应的.sln就可以了,我们VS2010打开makegdal10.sln直接编译。
GDAL编译完成后的文件存放于C:\warmerda\bld,包含文件include,lib,data,bin,可将它们拷贝到GDAL文件夹下,置于OSG目录下。
最后进行以下工作:将alg、gcore、ogr、port文件夹下的.h文件拷贝到include下,将生成的lib、 dll 包括: gdal_i.lib gdal.lib cpl.lib(port目录下) ogr.lib(ogr目录下), 以及gdal18.dll拷贝到D:\OSG\GDAL\lib下3. GEOS直接运行geos-3.2.2 \build\msvc10,将生成的geosd.lib,geos.lib, geos_c_i.lib, geosd_c_i.lib拷贝到D:\OSG\geos\lib下,将geos-3.2.2\source\headers下的geos文件夹拷贝到include下4. Expat直接运行即可,安装好后将 Expat 2.0.1\Source\lib里的.h全拷贝到D:\OSG\Expat\include下,将Expat 2.0.1\bin下的文件全拷贝到D:\OSG\Expat\lib下。
OSGEarth编译
第一章OSGEarth编译
上一章我们做的所有工作都是为了配置OSGEarth,
第一节sln生成
VS2010的sln文件生成是OSGEarth的关键。
作者在配置出现很多错误,从而导致了使用VS2010编译出现很多问题。
1.1 CMAKE配置
第一步:启动CMake -gui.exe并设置文件地址,将编译地址设置为E:\OSGEARTH\OSGEARTH\vs2010,然后“configure”
添加方法:点击“Add Entry”,弹出Add Cache Entry对话框(如下图所示)
完成后cmake参数列表顶端出现添加的两个参数:
第二步:设置相关参数
设置完成后再次“configure”
第三步:生成vs2010文件。
点击“Generate”,结果如下:
E:\osgearth\osgearth\vs2010文件夹截图:
1.2 VS2010配置
第一步:使用vs2010打开E:\osgearth\osgearth\vs2010 \OSGEARTH.sln文件。
第二步:打开all_build工程属性,设置库目录和包含目录。
包含目录:
库目录:
保存所有文件,这样SLN文件就可以使用了。
osgEarth编译
以下文档是osg和osgearth的编译过程,系统要求如下:操作系统:win7 home basic x64编译器:vs2010〇前言本文档编译成功后会形成4个目录,分别为:1Open Scene Graph, C:\Open Scene Graph2OpenSceneGraph, C:\OpenSceneGraph3OSG, D:\OSG4osgEarth, D:\osgEarth第一个存放osg软件,用于只使用osg软件用。
文件夹大小199M第二个存放osg+osgearth软件,用于使用osgearth和osg用。
文件夹大小626M第三个存放osg编译过程文件,用于对osg软件升级开发用。
文件夹大小3.6G第四个存放osgEarth编译过程文件,用于对osgEarth软件升级开发用。
文件夹大小2.54G 先编译一osg编译1.1 文件目录构建第一步:我们在D盘编译OSG,首先建立一个文件夹:D:\OSG;第二步:把源代码拷贝进OSG文件夹:D:\OSG\OpenSceneGraph-3.0.1第三步:把3rdParty第三方库拷贝到OSG文件夹:D:\OSG\3rdParty第四步:重新组织3rdParty,把x86文件夹中的内容拷贝到3rdParty中,把x86,x64删除。
如下图所示:第五步:把数据文件Data拷贝到OSG文件夹:D:\OSG\Data通过以上五步,所需准备完毕,文件目录组织情况如下:1.2 Qt和wxWidgets安装下载qt和wxWidgets安装文件:qt-win-opensource-4.8.4-vs2010.exe和wxMSW-2.8.12-Setup.exe,如图所示:1.3 cmake设置第一步:把cmake程序拷贝到C盘,C:\cmake-2.8.11-win32-x86第二步:打开cmake程序第三步:直接在source code文本框中输入D:/OSG/OpenSceneGraph-3.0.1第四步:在OSG文件夹中建立Build目录,用于存放编译工程文件第五步:直接在build the binaries文本框中输入D:/OSG/Build第六步:点击Configure第七步:选择Visual Studio 10,点击finish 第八步:等待初始配置结果:第九步:观察配置结果第十步:TIFF,FreeType配置修改观察cmake配置结果,显示TIFF,FREETYPE,没有找到,需要进行指定,TIFF没有debug版本,这里把debug版本指定为release版本。
osgearth
能够显示经纬度、海拔、分辨率:Osgearth_elevationfeature_model_scatter.earthOsgearth_graticuleOsgearth_featuresOsgearth_featurequeryC:\Program Files\NVIDIA Corporation\PhysX\Common;C:\Program Files\CMake 2.8\bin;F:\OSG视频教程\osgOcean与osgEarth编译相关包\osgEarth\proj446_win32_bin\proj\bin; E:\osgearth\openscenegraph\bin;E:\osgearth\osgearth\vs2010\bin\Debug;E:\osgearth\osgearth\vs2010\bin\Release;E:\osgOcean\osgOcean\vs2010\bin\Debug;E:\osgOcean\osgOcean\vs2010\bin\Release包含文件:E:\osgearth\OpenSceneGraph\include;E:\osgearth\sqlite\include;E:\osgearth\libzip\include;E:\osgearth\geos\include;E:\osg\libpng\include;E:\osg\3rdParty\x86\include;E:\osgearth\osgearth\include;E:\osgOcean\osgOcean\include;$(IncludePath)库文件:E:\osgearth\OpenSceneGraph\lib;E:\osgearth\sqlite\lib;E:\osgearth\libzip\lib;E:\osgearth\geos\lib;E:\osg\libpng\lib;E:\osg\3rdParty\x86\lib;E:\osgearth\osgearth\vs2010\lib;E:\osgOcean\osgOcean\vs2010\lib;$(LibraryPath)E:\osgearth\sqlite\lib;E:\osgearth\OpenSceneGraph\lib;E:\osgearth\libzip\lib;E:\osgearth\geos\lib; E:\osg\3rdParty\x86\lib;$(LibraryPath)E:\osgearth\osgearth\tests>osgearth_featurequery feature_stencil_polygon_draping.earth包含文件:E:\osgearth\OpenSceneGraph\include;E:\osgearth\sqlite\include;E:\osgearth\libzip\include;E:\osge arth\geos\include;E:\osg\libpng\include;E:\osg\3rdParty\x86\include;E:\osgearth\osgearth\include; E:\osgearth\osgearth\src;E:\osgOcean\osgOcean\include;$(IncludePath)库文件:E:\osgearth\OpenSceneGraph\lib;E:\osgearth\sqlite\lib;E:\osgearth\libzip\lib;E:\osgearth\geos\lib; E:\osg\libpng\lib;E:\osg\3rdParty\x86\lib;E:\osgearth\osgearth\vs2010\lib\Debug;E:\osgearth\osge arth\vs2010\lib;E:\osgOcean\osgOcean\vs2010\lib;$(LibraryPath)附加依赖项:OpenThreadsd.lib;osgd.lib;osgDBd.lib;osgFXd.lib;osgGAd.lib;osgManipulatord.lib;osgParticled.l ib;osgShadowd.lib;osgSimd.lib;osgTerraind.lib;osgTextd.lib;osgUtild.lib;osgViewerd.lib;osgdb_os gearth_feature_ogrd.lib;osgdb_osgearth_feature_tfsd.lib;osgdb_osgearth_feature_wfsd.lib;osgdb_ osgearth_gdald.lib;osgEarthd.lib;osgEarthAnnotationd.lib;osgEarthFeaturesd.lib;osgEarthSymbol ogyd.lib;osgEarthUtild.lib;%(AdditionalDependencies)。
osg源码编译
OSG(OpenSceneGraph)是一个开源的高性能3D图形工具包,广泛应用于可视化、游戏、虚拟现实等领域。
以下是OSG源码编译的一般步骤:获取OSG源码:可以从OSG 的官方网站或代码仓库下载最新的源码。
准备编译环境:确保你的系统中已经安装了CMake和编译器(如GCC或Visual Studio)。
解压源码:将下载的OSG源码解压到一个合适的目录。
创建构建目录:在源码目录外创建一个新的目录,用于存放编译过程中生成的中间文件和最终的可执行文件。
配置CMake:打开CMake工具,指定源码目录和构建目录。
根据你的需求,可以选择合适的配置选项,如安装路径、编译选项等。
生成构建文件:点击CMake工具中的“Configure”按钮,等待配置完成后,再点击“Generate”按钮生成构建文件。
编译源码:打开你选择的编译器,加载生成的构建文件,然后开始编译。
编译完成后,你将在构建目录中找到生成的可执行文件和库文件。
请注意,具体的编译步骤可能因你使用的操作系统和编译器而有所不同。
因此,在编译OSG源码之前,建议仔细阅读OSG的官方文档和相关资源,以确保你了解适用于你的环境的详细步骤和要求。
osgearth嵌入qt的实现方式
osgearth嵌入qt的实现方式
osgEarth是一个开源的地球可视化工具,它可以将地球数据(如地图、影像、3D模型等)与OpenGL渲染引擎相结合来实现高效的地球可视化效果。
而Qt是一种跨平台UI开发框架,可以很方便地实现GUI 界面的设计和编程。
下面我们就来介绍一下osgEarth如何嵌入到Qt
应用程序中。
首先,在Qt项目中引入osgEarth库,可以通过CMake编译生成osgEarth的动态链接库(.so或.dll文件),然后将它们加入到Qt项目中。
在Qt源代码中引入osgEarth库的头文件,并在需要使用osgEarth的地方调用相关的接口函数,就可以实现地球数据的加载、
显示、交互等功能。
其次,osgEarth与Qt的交互可以通过Qt提供的QOpenGLWidget
类来实现。
QOpenGLWidget是一个基于OpenGL的窗口部件,可以在Qt
应用程序中创建一个OpenGL上下文,使得可以在其中进行OpenGL绘制。
通过将osgEarth的场景渲染到QOpenGLWidget中,就可以将osgEarth的地球场景嵌入到Qt应用程序中。
最后,需要注意的一点是,在使用osgEarth和Qt开发应用程序时,需要注意二者之间的线程安全问题。
osgEarth是一个多线程的场
景渲染引擎,需要在渲染线程中操作,而Qt的UI部分则必须在主线
程中运行。
因此,在将osgEarth嵌入到Qt应用程序中时,需要保证
二者之间的通信和交互是线程安全的,以避免出现意外的错误和异常。
osgearth论坛问题集锦
刚接触osgearth,想请教大家:怎么获取osgearth支持的影像数据到本地,包括一些层级不高的不需要很精确的全球影像和层级较高的较清晰的部分城市的影像(像Google earth 那样有地名的),以.earth文件中读取本地数据?谢谢大家!使用osgEarth的缓存插件,设置缓存路径就可以了这个方法知道,但不知道从哪可以获取到符合要求(类似Google earth 有位置标签)的影像数据。
可以用谷歌地图下载器下载,然后使用GDAL插件加载可以用GDAL插件加载吗?好像不行哎,你试验成功过嚒?得修改GDAL插件? 图片是没有坐标的,所以得人为制定坐标包围盒? 这个看着有些抽象osgearth在局域网上的配置问题由于个人电脑不能上外网,所以只能在单位内部网络上自行加载地形和影像数据。
在服务器端加载了地形和影像,客户端用.earth文件配置来读取,提示can not initialize TileSource for layer west.tif<map name="earth" type="geocentric" version="2"><image driver="gdal" name="world-tiff" ><url>http://192.168.150/world.tif</url></image><elevation driver="gdal" name="DE-tiff" ><url>http://192.168.150/srtm.tif</url></elevation ><options lighting="false"/></map>我在服务器端没有编译gdal。
osgEarth编译中的问题
1.编译OSG中遇到的问题:a)Png库无法加上: 原因在于需要首先加上zlib的库才可以.2.CURLa)编译OpenSSL1.在64 位Win7 上编译,使用Visual Studio 2010,执行命令nmake -fms\ntdll.mak 时不管是编译32 位库文件还是64 位库文件,都曾遇到如下错误:LINK : fatal error LNK1123: 转换到COFF 期间失败: 文件无效或损坏解决方法是:在计算机中搜索cvtres.exe 文件,在目录\Windows\\Framework 和\Microsoft Visual Studio 10.0\VC下都能找到32位的文件cvtres.exe,发现\Microsoft Visual Studio 10.0\VC下文件版本较老,将其改名或删除。
在目录\Windows\\Framework64 和\Microsoft VisualStudio 10.0\VC\bin 下都能找到64位的文件cvtres.exe,发现\MicrosoftVisual Studio 10.0\VC\bin 下文件版本较老,将其改名或删除。
ii.之后执行nmake -f ms\ntdll.mak 时就不会报告“转换到COFF 期间失败: 文件无效或损坏”的错误了。
b)编译libssh2i.依赖zlib和openssl1.编译zlib,源码编译后默认位置为c:\program Files3.GDALa)修改nmake.opt ‘win64=yes’b)编译GDAL4.GEOSa)nmake /f makefile.vc5.Expata)安装exe文件6.Minizip 使用官网的zlibstat.lib代替7.Cmake osgearth的时候, library要指向具体的lib文件,而不是目录!!!。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
以下文档是osg和osgearth的编译过程,系统要求如下:操作系统:win7 home basic x64编译器:vs2010〇前言本文档编译成功后会形成4个目录,分别为:1Open Scene Graph, C:\Open Scene Graph2OpenSceneGraph, C:\OpenSceneGraph3OSG, D:\OSG4osgEarth, D:\osgEarth第一个存放osg软件,用于只使用osg软件用。
文件夹大小199M第二个存放osg+osgearth软件,用于使用osgearth和osg用。
文件夹大小626M第三个存放osg编译过程文件,用于对osg软件升级开发用。
文件夹大小3.6G第四个存放osgEarth编译过程文件,用于对osgEarth软件升级开发用。
文件夹大小2.54G 先编译一osg编译1.1 文件目录构建第一步:我们在D盘编译OSG,首先建立一个文件夹:D:\OSG;第二步:把源代码拷贝进OSG文件夹:D:\OSG\OpenSceneGraph-3.0.1第三步:把3rdParty第三方库拷贝到OSG文件夹:D:\OSG\3rdParty第四步:重新组织3rdParty,把x86文件夹中的内容拷贝到3rdParty中,把x86,x64删除。
如下图所示:第五步:把数据文件Data拷贝到OSG文件夹:D:\OSG\Data通过以上五步,所需准备完毕,文件目录组织情况如下:1.2 Qt和wxWidgets安装下载qt和wxWidgets安装文件:qt-win-opensource-4.8.4-vs2010.exe和wxMSW-2.8.12-Setup.exe,如图所示:1.3 cmake设置第一步:把cmake程序拷贝到C盘,C:\cmake-2.8.11-win32-x86第二步:打开cmake程序第三步:直接在source code文本框中输入D:/OSG/OpenSceneGraph-3.0.1第四步:在OSG文件夹中建立Build目录,用于存放编译工程文件第五步:直接在build the binaries文本框中输入D:/OSG/Build第六步:点击Configure第七步:选择Visual Studio 10,点击finish 第八步:等待初始配置结果:第九步:观察配置结果第十步:TIFF,FreeType配置修改观察cmake配置结果,显示TIFF,FREETYPE,没有找到,需要进行指定,TIFF没有debug版本,这里把debug版本指定为release版本。
第十一步:GDAL,PNG,libXML2配置修改第十二步:点击generate生成第十三步:关闭cmake1.4 初始编译经过上述步骤,已经生成了项目的工程文件,如下图所示:第一步:打开OpenSceneGraph.sln,如图所示:为了防止出现编译1个多小时,但最后因为最基本的库没有编译成功而白白浪费时间的情况,我们一个一个进行编译。
右键点击OSG Core下面的OpenThreads,如下图所示:显示编译成功:按照上述的表格,编译剩下的17项。
最后核心库编译成功。
下面编译六个程序:osgArchive,osgConv,osgfilecache,osgversion,osgviewer,present3D 右键点击Applicaton,选择生成。
下面编译插件库:一共82个。
首先对几个比较重要,但又容易出问题的库进行单独编译。
比如freetype,png,gdal,curl,jpeg等,都没有问题:最后,右键点击Plugins,选择生成。
各个osg编译成功。
加上单独编译的5个,共82个。
最后编译release版本:1.5 返回cmake重新配置完成局部修改编译如果不想把所有的例子都进行编译,可以最初只编译基本的东西,以后想用到什么再返回cmake重新进行设置,以配置某个局部项目来重新只生成该局部项目。
比如我们上述没有生成例子,现在我生成一个例子。
第一步:关闭vs2010第二步:打开cmake,会有上一次缓冲,即使你不小心把缓冲清除了,重新配置,也只需要配置自己需要的,不用全部都配。
把BUILD_OSG_EXAMPLES选择上.第三步:configure,generate第四步:关闭cmake第五步:打开openSceneGraph.sln第六步:选择Examples osgspheresegment例子生成。
第七步:关闭vs20101.6 软件部署现在把软件部署到计算机上,可以是任意一台同样条件的计算机上,就是win7 64位家庭版。
第一步:比如就部署到C 盘,新建文件夹每二步:在Open Scene Graph 下面建立5个文件夹和一个文本文档D:\OSG\Data 下所有C:\Open Scene Graph\Data 下 1 D:\OSG\Build\bin 下的14个exe 文件2 D:\OSG\Build\bin 下的36个dll 文件3把D:\OSG\Build\bin\osgPlugins-3.0.1下的所有164个dll 文件1 C:\Open Scene Graph\bin2 C:\Open Scene Graph\bin3在C:\Open Scene Graph\bin 下新建文件夹:osgPlugins-3.0.1,把164个dll 文件拷贝到此。
1C:\Open Scene Graph\include第四步:添加lib 文件内容最后生成的文件夹如下所示:1.7 环境变量设置1 设置OSG_FILE_PATH = C:\Open Scene Graph\Data1 设置Path = C:\Open Scene Graph\bin1.8 最后程序验证第一步:cmd ,osgversiond第二步:osgviewerd cow.osgt第三步:osgspheresegmentd程序运行没问题如果想把release版本和其它的例子都编译,可以打开openSceneGraph.sln打开进行编译。
二osgEarth编译1.1文件目录构建第一步:我们在D盘编译osgEarth,首先建立一个文件夹:D:\osgEarth,把源代码放到该文件夹,重命名为osgEarth-2.8.2:第二步:在D:\osgEarth\build建立一个build文件夹.第三步:把D:\OSG\3rdParty拷贝到C:\Open Scene Graph\。
第四步:把C:\Open Scene Graph文件夹拷贝到D:\osgEarth下1.2 编译gdal1)下载gdal2)打开makegdal10.sln,编译结束后,在C:\warmerda\bld\bin下拷贝gdal18.dll到D:\osgEarth\Open Scene Graph\3rdParty\bin下面。
3)把gdal.lib, gdal_i.lib ;port目录下的cpl.lib和ogr目录下的ogr.lib拷贝到:D:\osgEarth\Open Scene Graph\3rdParty\lib下。
4)把alg,gcore,ogr,port文件夹下的.h文件拷贝到D:\osgEarth\Open Scene Graph\3rdParty\include\gdal目录下,可以用搜索文件的方法把下载的gdal中的.h文件都拷贝到D:\osgEarth\Open Scene Graph\3rdParty\include\gdal目录下:1.3 编译libcurl1)下载解压libcurl,打开vs\vc6\下的文件,编译debug 和release版本。
2)把生成的libcurl.dll 和libcurlD.lib拷贝到D:\osgEarth\Open Scene Graph\3rdParty\bin3)把D:\osgEarth\curl-7.30.0\include\curl下的文件拷贝合并到D:\osgEarth\Open SceneGraph\3rdParty\include\curl1.4 编译Geos1) 下载geos,解压到D:\osgEarth2) 打开D:\osgEarth\geos-3.2.3\build\msvc80下的geos 转化为vs2010,进行编译3)分别编译debug 和release版本下的geos_c_dll和geos_lib项目。
4)拷贝D:\osgEarth\geos-3.2.3\build\msvc80\Debug下的geosd.lib ,geosd_c_i.lib到D:\osgEarth\Open Scene Graph\3rdParty\lib;geosd_c.dll到D:\osgEarth\Open Scene Graph\3rdParty\bin5)把D:\osgEarth\geos-3.2.3\source\headers\geos文件夹拷贝到D:\osgEarth\Open Scene Graph\3rdParty\include。
1.5 编译sqlite31)下载两个压缩包:解压后,把sqlite_dll_win32-x86_3071700下的两个文件放到sqlite-amalgamation-3071700解压后的目录下,解压后文件夹重命名为sqlite3。
组合成下面所示:2)新建动态连接库项目:win32控制台dll,空项目。
3)拷贝.h,.c,.def 3个文件到D:\osgEarth\sqlite3\sqlite3\sqlite3下面4)添加头文件sqlite3.h到头文件;添加源文件sqlite3.c,sqlite3.def到源文件。
5)设置项目属性SQLITE_ENABLE_COLUMN_METADATA SQLITE_ENABLE_RTREE6)生成debug 和release版本,分别命名为sqlite3d.lib|sqlite3d.dll, sqlite3.lib|sqlite3.dll 7)把sqlite3.lib 和sqlite3.dll拷贝到D:\osgEarth\Open Scene Graph\3rdParty\binD:\osgEarth\Open Scene Graph\3rdParty\lib1.6 编译minizip就用3rdParty/lib下面的minizip.lib和minizipD.lib,但头文件需要下载,把解压后的头文件放到D:\osgEarth\Open Scene Graph\3rdParty\include\minizip下:1.7 cmake设置打开cmake,设置如下:点击configure,报错:第三步:设置OSG_DIR,设置为D:/osgEarth/Open Scene Graph,点击configure,osg其他的选项会自动识别第四步:THIRD_PARTY_DIR,设置后configure一下第五步:zlib,设置后configure一下第六步:gdal,设置后configure一下第七步:miniMap,设置后configure一下第八步:经过上述配置,已经可以不报错通过。