https://mygeodata.cloud/cs2cs/
CoordinateTrans::CoordinateTrans()
{
Xian80_3_degree_Gauss_Kruger_zone.resize(46);
Xian80_6_degree_Gauss_Kruger_zone.resize(23);
wgs84 = "+proj=longlat +datum=WGS84 +no_defs ";
Xian80_3_degree_Gauss_Kruger_zone[25] = "+proj=tmerc +lat_0=0 +lon_0=75 +k=1 +x_0=25500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m +no_defs ";
Xian80_3_degree_Gauss_Kruger_zone[26] = "+proj=tmerc +lat_0=0 +lon_0=78 +k=1 +x_0=26500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m +no_defs ";
Xian80_3_degree_Gauss_Kruger_zone[27] = "+proj=tmerc +lat_0=0 +lon_0=81 +k=1 +x_0=27500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m +no_defs ";
Xian80_3_degree_Gauss_Kruger_zone[28] = "+proj=tmerc +lat_0=0 +lon_0=84 +k=1 +x_0=28500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m +no_defs ";
Xian80_3_degree_Gauss_Kruger_zone[29] = "+proj=tmerc +lat_0=0 +lon_0=87 +k=1 +x_0=29500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m +no_defs ";
Xian80_3_degree_Gauss_Kruger_zone[30] = "+proj=tmerc +lat_0=0 +lon_0=90 +k=1 +x_0=30500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m +no_defs ";
Xian80_3_degree_Gauss_Kruger_zone[31] = "+proj=tmerc +lat_0=0 +lon_0=93 +k=1 +x_0=31500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m +no_defs ";
Xian80_3_degree_Gauss_Kruger_zone[32] = "+proj=tmerc +lat_0=0 +lon_0=96 +k=1 +x_0=32500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m +no_defs ";//
Xian80_3_degree_Gauss_Kruger_zone[33] = "+proj=tmerc +lat_0=0 +lon_0=99 +k=1 +x_0=33500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m +no_defs ";
Xian80_3_degree_Gauss_Kruger_zone[34] = "+proj=tmerc +lat_0=0 +lon_0=102 +k=1 +x_0=34500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m +no_defs ";
Xian80_3_degree_Gauss_Kruger_zone[35] = "+proj=tmerc +lat_0=0 +lon_0=105 +k=1 +x_0=35500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m +no_defs ";
Xian80_3_degree_Gauss_Kruger_zone[36] = "+proj=tmerc +lat_0=0 +lon_0=108 +k=1 +x_0=36500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m +no_defs ";
Xian80_3_degree_Gauss_Kruger_zone[37] = "+proj=tmerc +lat_0=0 +lon_0=111 +k=1 +x_0=37500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m +no_defs ";
Xian80_3_degree_Gauss_Kruger_zone[38] = "+proj=tmerc +lat_0=0 +lon_0=114 +k=1 +x_0=38500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m +no_defs ";
Xian80_3_degree_Gauss_Kruger_zone[39] = "+proj=tmerc +lat_0=0 +lon_0=117 +k=1 +x_0=39500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m +no_defs ";
Xian80_3_degree_Gauss_Kruger_zone[40] = "+proj=tmerc +lat_0=0 +lon_0=120 +k=1 +x_0=40500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m +no_defs ";
Xian80_3_degree_Gauss_Kruger_zone[41] = "+proj=tmerc +lat_0=0 +lon_0=123 +k=1 +x_0=41500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m +no_defs ";
Xian80_3_degree_Gauss_Kruger_zone[42] = "+proj=tmerc +lat_0=0 +lon_0=126 +k=1 +x_0=42500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m +no_defs ";
Xian80_3_degree_Gauss_Kruger_zone[43] = "+proj=tmerc +lat_0=0 +lon_0=129 +k=1 +x_0=43500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m +no_defs ";
Xian80_3_degree_Gauss_Kruger_zone[44] = "+proj=tmerc +lat_0=0 +lon_0=132 +k=1 +x_0=44500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m +no_defs ";
Xian80_3_degree_Gauss_Kruger_zone[45] = "+proj=tmerc +lat_0=0 +lon_0=135 +k=1 +x_0=45500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m +no_defs ";
}
bool CoordinateTrans::transform_wgs84_2_xian80(const double l, const double b, double& x, double& y)
{
int zone_num = l / 3.0 + 0.5;
projPJ pj_wgs84 = pj_init_plus(wgs84.c_str());
projPJ pj_city = pj_init_plus(Xian80_3_degree_Gauss_Kruger_zone[zone_num].c_str());
double xx, yy;
xx = l * DEG_TO_RAD;
yy = b * DEG_TO_RAD;
pj_transform(pj_wgs84, pj_city, 1, 1, &xx, &yy, NULL);
x = xx; y = yy;
return true;
}
bool CoordinateTrans::transform_xian80_2_wgs84(const double x, const double y, double& l, double& b)
{
int zone_num = x / 1000000.0;
projPJ pj_wgs84 = pj_init_plus(wgs84.c_str());
projPJ pj_city = pj_init_plus(Xian80_3_degree_Gauss_Kruger_zone[zone_num].c_str());
b = y;
l = x;
pj_transform(pj_city, pj_wgs84, 1, 1, &l, &b, NULL);
b /= DEG_TO_RAD;
l /= DEG_TO_RAD;
return true;
}
|