怎么使用Qt+GDAL库实现制作经纬度坐标转换工具
1、功能界面

下面是用Global Mapper计算的结果,证明计算正确。

2、功能介绍
支持CGCS2000/WGS84/XIAN80/BEIJING54四种常用坐标系;
自动判断输入经纬度和X/Y坐标的合法性;
依据标准3°带自动计算中央子午线;
支持经纬度转投影坐标以及投影坐标转经纬度。
3、实现逻辑
1)利用GDAL库构建基础坐标系数据。
OGRSpatialReference m_spatialReference;
if(m_Coordinate == CoordinateDialog::CGCS2000)
{
qDebug() << "CGCS2000";
m_spatialReference.importFromEPSG(4490);
}
else if(m_Coordinate == CoordinateDialog::WGS84)
{
qDebug() << "WGS84";
m_spatialReference.importFromEPSG(4326);
}
else if(m_Coordinate == CoordinateDialog::XIAN80)
{
qDebug() << "XIAN80";
m_spatialReference.importFromEPSG(4610);
}
else if(m_Coordinate == CoordinateDialog::BeiJing54)
{
qDebug() << "BeiJing54";
m_spatialReference.importFromEPSG(4214);
}2)设定投影坐标系并进行转换
m_spatialReference.SetTM(0.0, nMeridian, 1.0, nAreacode*1000000 + nOffsetE, nOffsetN); OGRSpatialReference* pLonLat = m_spatialReference.CloneGeogCS(); // X、Y转经纬度 OGRCoordinateTransformation* pXY2LonLat = OGRCreateCoordinateTransformation(&m_spatialReference, pLonLat); // 经纬度转X、Y OGRCoordinateTransformation* pXY2LonLat = OGRCreateCoordinateTransformation(&m_spatialReference, pLonLat); pXY2LonLat->Transform(1, &dLon, &dLat)