基于proj库对GPS转换,2000坐标互转wgs84坐标


之前在忙一个小项目,好久没有更新了,确实对不住粉丝们。
废话不多说,直接干货:
从2000坐标转wgs84坐标,C++代码

void 2UTMToWGS84(double longitude, double latitude, double hight, double X, double Y, double Z)
{
	projPJ wgs84 = pj_init_plus("+proj=latlong +datum=WGS84");
	projPJ utm = pj_init_plus("+proj=utm +zone=50N +ellps=WGS84 +no_defs");


	pj_get_def(utm, 0);
	pj_transform(utm, wgs84, 1, 1, &longitude, &latitude, &hight);
	const char *strRelease = pj_get_release();
	char*strError = pj_strerrno(2);
	int iErrorNo = *pj_get_errno_ref();

	longitude /= DEG_TO_RAD;
	latitude /= DEG_TO_RAD;
	X = longitude;
	Y = latitude;
	Z = hight;
	pj_free(utm);

}

从wgs84坐标转2000坐标,C++代码

void WGS842UTM(double longitude, double latitude, double hight, double *X, double *Y, double *Z)
{
	projPJ wgs84 = pj_init_plus("+proj=latlong +datum=WGS84 +no_defs");
	projPJ utm = pj_init_plus("+proj=utm +zone=50N +ellps=WGS84");
	longitude *= DEG_TO_RAD;
	latitude *= DEG_TO_RAD;

	pj_get_def(wgs84, 0);
	pj_transform(wgs84, utm, 1, 1, &longitude, &latitude, &hight);
	const char *strRelease = pj_get_release();
	char*strError = pj_strerrno(2);
	int iErrorNo = *pj_get_errno_ref();

	*X = longitude;
	*Y = latitude;
	*Z = hight;
	pj_free(utm);
}

转载自:https://blog.csdn.net/xdw_it/article/details/83994701

You may also like...

退出移动版