在 GeoTools 的帮助下,我遇到了关于心爱的坐标转换的问题:我想将一组坐标从 Gauss-Kruger(区域 5,EPSG 31469)转换为普通的 WGS84 坐标(EPSG 4326)。
我用一个简单的例子构建了一个代码(只需一对坐标即可尝试):
double coordX = 5408301.53;
double coordY = 5659230.5;
double[] punt = new double[2];
CoordinateReferenceSystem sourceCRS = CRS.decode("EPSG:31469");
CoordinateReferenceSystem targetCRS = CRS.decode("EPSG:4326");
MathTransform transform = CRS.findMathTransform(sourceCRS, targetCRS, true);
DirectPosition expPt = new GeneralDirectPosition(coordX, coordY);
expPt = transform.transform(expPt, null);
punt = expPt.getCoordinate();
System.out.println(punt[0] + ", " + punt[1]); //lon, lat
调试后结果如下:48.791886921764345, 17.16525096311777
然后,当我检查我获得的 WGS84 坐标时(只需将它们打入谷歌地图),我最终会在奥地利附近的捷克共和国某处,尽管这对坐标应该在德国东部的某个地方(当然,我通过一些 html 进行了检查解码器):
---> 应该是结果:51.0609167, 13.6900142。
我无法想象发生此故障的任何原因。GeoTools 获得了两个想要的 CRS(我从 java 控制台的响应中附加了一个摘录)
有人能解释一下吗?我会很感激任何帮助!
许多问候,塞巴斯蒂安
**sourceCRS:**
PROJCS["DHDN / 3-degree Gauss-Kruger zone 5",
GEOGCS["DHDN",
DATUM["Deutsches Hauptdreiecksnetz",
SPHEROID["Bessel 1841", 6377397.155, 299.1528128, AUTHORITY["EPSG","7004"]],
TOWGS84[612.4, 77.0, 440.2, -0.054, 0.057, -2.797, 2.55],
AUTHORITY["EPSG","6314"]],
PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]],
UNIT["degree", 0.017453292519943295],
AXIS["Geodetic latitude", NORTH],
AXIS["Geodetic longitude", EAST],
AUTHORITY["EPSG","4314"]],
PROJECTION["Transverse_Mercator", AUTHORITY["EPSG","9807"]],
PARAMETER["central_meridian", 15.0],
PARAMETER["latitude_of_origin", 0.0],
PARAMETER["scale_factor", 1.0],
PARAMETER["false_easting", 5500000.0],
PARAMETER["false_northing", 0.0],
UNIT["m", 1.0],
AXIS["Northing", NORTH],
AXIS["Easting", EAST],
AUTHORITY["EPSG","31469"]]
**targetCRS:**
GEOGCS["WGS 84",
DATUM["World Geodetic System 1984",
SPHEROID["WGS 84", 6378137.0, 298.257223563, AUTHORITY["EPSG","7030"]],
AUTHORITY["EPSG","6326"]],
PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]],
UNIT["degree", 0.017453292519943295],
AXIS["Geodetic latitude", NORTH],
AXIS["Geodetic longitude", EAST],
AUTHORITY["EPSG","4326"]]
CONCAT_MT[PARAM_MT["Affine",
PARAMETER["num_row", 3],
PARAMETER["num_col", 3],
PARAMETER["elt_0_0", 0.0],
PARAMETER["elt_0_1", 1.0],
PARAMETER["elt_1_0", 1.0],
PARAMETER["elt_1_1", 0.0]],
INVERSE_MT[PARAM_MT["Transverse_Mercator",
PARAMETER["semi_major", 6377397.155],
PARAMETER["semi_minor", 6356078.962818189],
PARAMETER["central_meridian", 15.0],
PARAMETER["latitude_of_origin", 0.0],
PARAMETER["scale_factor", 1.0],
PARAMETER["false_easting", 5500000.0],
PARAMETER["false_northing", 0.0]]],
PARAM_MT["Ellipsoid_To_Geocentric",
PARAMETER["dim", 2],
PARAMETER["semi_major", 6377397.155],
PARAMETER["semi_minor", 6356078.962818189]],
PARAM_MT["Position Vector transformation (geog2D domain)",
PARAMETER["dx", 612.4],
PARAMETER["dy", 77.0],
PARAMETER["dz", 440.2],
PARAMETER["ex", -0.054],
PARAMETER["ey", 0.057],
PARAMETER["ez", -2.797],
PARAMETER["ppm", 2.5500000000455714]],
PARAM_MT["Geocentric_To_Ellipsoid",
PARAMETER["dim", 2],
PARAMETER["semi_major", 6378137.0],
PARAMETER["semi_minor", 6356752.314245179]],
PARAM_MT["Affine",
PARAMETER["num_row", 3],
PARAMETER["num_col", 3],
PARAMETER["elt_0_0", 0.0],
PARAMETER["elt_0_1", 1.0],
PARAMETER["elt_1_0", 1.0],
PARAMETER["elt_1_1", 0.0]]]