项目中用到经纬度相互转换,自己写感觉太麻烦,查询后发现利用geos和proj4可以完成坐标转换,现在记录一下方便以后自己查询。
//经纬度转utm坐标
int convert_lonlat_utm(const new3s_PointXYZ &lon_lat_coord, new3s_PointXYZ &utm_coord)
{
OGRSpatialReference *RefSource = new OGRSpatialReference;
RefSource->SetWellKnownGeogCS("WGS84");
OGRSpatialReference *RefTarget = new OGRSpatialReference;
RefTarget = RefSource->CloneGeogCS();
int utmzone = lon_lat_coord.get_x() / 6 + 31;
RefTarget->SetProjCS("UTM(WGS84) in northern hemisphere.");