/**
* xian80 3度带 111E 转 wgs84
* @param x
* @param y
* @return
*/
public static String Xian80_To_WGS84(double x ,double y){
CRSFactory targetFactory = new CRSFactory();
CRSFactory crsFactory = new CRSFactory();
//源坐标系统(xian80 3度带 111E)
String srcCRS = "2382";
String srcCRS_params="+proj=tmerc +lat_0=0 +lon_0=111 +k=1 +x_0=500000 +y_0=0 +towgs84=-340.837355,928.607907,342.347456,3.108375,6.805874,2.513279,164.630038 +units=m +no_defs ";
CoordinateReferenceSystem src = crsFactory.createFromParameters(srcCRS,srcCRS_params);
//目标坐标系统
String target_param = "+proj=longlat +datum=WGS84 +no_defs ";
CoordinateReferenceSystem target = targetFactory.createFromParameters("wgs84", target_param);
CoordinateTransformFactory ctf = new CoordinateTransformFactory();
org.locationtech.proj4j.CoordinateTransform transform = ctf.createTransform(src, target);
ProjCoordinate projCoordinate = new ProjCoordinate(x, y);
transform.transform(projCoordinate, projCoordinate);
return projCoordinate.x +","+ projCoordinate.y;
}
因为不同的坐标系之间转换,需要转换参数,求解转换参数是关键所在,代码里面采用的是七参数,
即 +towgs84=-340.837355, 928.607907, 342.347456, 3.108375, 6.805874, 2.513279, 164.630038,此参数只是针对 xian80 3度带 111E 转 wgs84 可用,不同的坐标系转换需要重新计算转换参数 。
参考文章: