osgearth二维地球显示

需要用的GDAL

#include 

#include 
#include 
#include 

#include         

        CPLSetConfigOption("GDAL_DATA", "D:\\OSG64\\osgearth\\gdal\\data");

		string wktString = "EPSG:3857";			//web墨卡托投影
		//string wktString = "EPSG:4326";			//wgs84
		osgEarth::ProfileOptions profileOpts;
		profileOpts.srsString() = wktString;
		
		//地图配置:设置缓存目录
		osgEarth::Drivers::FileSystemCacheOptions cacheOpts;
		string cacheDir = "D:/Work/OSGNewBuild/tmp";
		cacheOpts.rootPath() = cacheDir;
		//
		osgEarth::MapOptions mapOpts;
		mapOpts.cache() = cacheOpts;
		mapOpts.coordSysType() = osgEarth::MapOptions::CSTYPE_PROJECTED;

		mapOpts.profile() = profileOpts;

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

		osgEarth::Drivers::GDALOptions gdal;
		gdal.url() = "D:\\OSG64\\osgearth\\osgearth\\data/world.tif";
		osg::ref_ptr layer = new osgEarth::ImageLayer("BlueMarble", gdal);
		map->addImageLayer(layer);
		m_root->addChild(mapNode);
		osg::ref_ptr< osgEarth::Util::EarthManipulator> mainManipulator = new osgEarth::Util::EarthManipulator;
		m_viewer->setCameraManipulator(mainManipulator);

		m_viewer->setUpViewInWindow(100, 100, 800, 600);

 

你可能感兴趣的:(osgEarth学习)