GeographicLib安装
安装
下载压缩包安装:
Unpack the source, running one of
季氏将伐颛臾钢琴重量tar xfpz GeographicLib-1.
then enter the directory created with
cd GeographicLib-1.51
Create a parate build directory and enter it, for example,
mkdir BUILD
cd BUILD
白玫瑰花>孕晚期宫缩频繁Run cmake, pointing it to the source directory (…). On Linux, Unix, and MacOSX systems, the command is cmake ..
Build and install the software. In non-IDE environments, run
make # compile the library and utilities
make test # run some tests
make install # as root, if CMAKE_INSTALL_PREFIX is a system directory
include in files
find_package (GeographicLib REQUIRED)
add_executable (program source1.cpp source2.cpp)
target_link_libraries (program ${GeographicLib_LIBRARIES})
实例:WGS84转UTM再转MGRS(部分通⽤代码省略)
盗心贼
#include<GeographicLib/Geodesic.hpp>
#include<GeographicLib/UTMUPS.hpp>
有关秋天的诗句
#include<GeographicLib/MGRS.hpp>
double northing, easting;// UTM坐标
bool northp;// 北半球还是南半球
int izone;// UTM的zone
//WGS84->UTM
UTMUPS::Forward(newGps.lat, newGps.lon, izone, northp, easting, northing);
string zonestr = UTMUPS::EncodeZone(izone, northp);
cout << zonestr <<" "<< easting <<" "<< northing <<"\n";
//UTM->MGRS
string mgrs;
// int prec=5, 意思是精确到m,如果prec=7,精确到cm,如此类推
李瑟娥
MGRS::Forward(izone, northp, easting, northing,7, mgrs);
// mgrs code转成MGRS坐标
cout <<stod(mgrs.substr(5,7).inrt(5,"."))<<" "<<stod(mgrs.substr(12).inrt(5,"."))<<"\n";工作检讨