一、Osgearth中的坐标系
1.地理坐标系(gcs):使用经纬、高程来表示一个位置
2.投影坐标系(pcs):使用平面直角坐标系,来表示一个位置
二、设置投影坐标系(代码实现)
CPLSetConfigOption("GDAL_DATA", "D:\\gdal-2.3.3\\data");
string wktString = "PROJCS[\"Beijing_1954_3_degree_Gauss_Kruger_CM_126E\",GEOGCS[\"GCS_Beijing 1954\",DATUM[\"D_Beijing_1954\",SPHEROID[\"Krasovsky_1940\",6378245,298.3]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.017453292519943295]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"latitude_of_origin\",0],PARAMETER[\"central_meridian\",126],PARAMETER[\"scale_factor\",1],PARAMETER[\"false_easting\",500000],PARAMETER[\"false_northing\",0],UNIT[\"Meter\",1],AUTHORITY[\"EPSG\",\"2439\"]]";//如果投影显示,一定要设置为PROJCS
osgEarth::ProfileOptions profileOpts;
profileOpts.srsString() = wktString;
osgEarth::Bounds bs(346696.211, 4828780.610, 758345.372, 5165846.624);//地形的显示范围
profileOpts.bounds() = bs;
//地图配置:设置缓存目录
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;//设置为投影显示
osg::ref_ptr<osgEarth::Map> map = new osgEarth::Map(mapOpts);
osg::ref_ptr<osgEarth::MapNode> mapNode = new osgEarth::MapNode(map);
//以上为设置投影坐标系的核心代码