Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/364.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java (Geotools库)如何将韩国语坐标(EPSG:5179)转换为十进制度坐标(EPSG:4326)_Java_Coordinates_Coordinate Systems_Geotools_Epsg - Fatal编程技术网

Java (Geotools库)如何将韩国语坐标(EPSG:5179)转换为十进制度坐标(EPSG:4326)

Java (Geotools库)如何将韩国语坐标(EPSG:5179)转换为十进制度坐标(EPSG:4326),java,coordinates,coordinate-systems,geotools,epsg,Java,Coordinates,Coordinate Systems,Geotools,Epsg,从韩国语2000坐标系(EPSG:5179)转换为十进制(EPSG:4326)时,我遇到了一个问题 我们正在为韩国公司开发地理信息系统。我们使用Geotools库进行多个后端实现。但是,我现在在从EPSG:5179转换到EPSG:4326时遇到了问题。例如:使用多个在线转换器时,如 正在尝试转换韩语坐标: x:1307285 y:2229260 a预期结果为(十进制度数格式): x:131.0999928 y:40.0099722 所以,现在我正试图使用Geotools库使用此文档进行相同的转换

从韩国语2000坐标系(EPSG:5179)转换为十进制(EPSG:4326)时,我遇到了一个问题

我们正在为韩国公司开发地理信息系统。我们使用Geotools库进行多个后端实现。但是,我现在在从EPSG:5179转换到EPSG:4326时遇到了问题。例如:使用多个在线转换器时,如 正在尝试转换韩语坐标: x:1307285 y:2229260

a预期结果为(十进制度数格式): x:131.0999928 y:40.0099722

所以,现在我正试图使用Geotools库使用此文档进行相同的转换

我的示例测试:

public void testProjectedKoreanCoordinatesToDecimalDegree() throws FactoryException, TransformException {
    //EPSG:5179 -> EPSG:4326 CONVERSION

    CoordinateReferenceSystem sourceCRS = CRS.decode("EPSG:5179");
    CoordinateReferenceSystem targetCRS = CRS.decode("EPSG:4326");

    double coordinateX = 1307285;
    double coordinateY = 2229260;

    Coordinate in = new Coordinate(coordinateX, coordinateY);
    Coordinate out = in;

    MathTransform transform = CRS.findMathTransform(sourceCRS, targetCRS);
    Coordinate result = JTS.transform(in, out, transform);
    DegreeCoordinates degreeCoordinates = DegreeCoordinates.fromJTSCoordinate(result);

    double expectedLongitude = 131.0999928;
    double expectedLatitude = 40.0099721;

    assertEquals(expectedLongitude, degreeCoordinates.getLongitude(), 0.00001);
    assertEquals(expectedLatitude, degreeCoordinates.getLatitude(), 0.00001);
}
因此,在第一次坐标比较时测试失败,实际输出为: 经度:140.340217725

经度应为131.0999928时

你有什么建议我做错了什么吗?提前谢谢你

这是一个典型的(程序员)错误,您假设您的坐标是X-Y或东北顺序。但如果你看一下EPSG:5179的定义,你会发现:

PROJCS["Korea 2000 / Unified CS", 
  GEOGCS["Korea 2000", 
    DATUM["Geocentric datum of Korea", 
      SPHEROID["GRS 1980", 6378137.0, 298.257222101, AUTHORITY["EPSG","7019"]], 
      TOWGS84[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], 
      AUTHORITY["EPSG","6737"]], 
    PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]], 
    UNIT["degree", 0.017453292519943295], 
    AXIS["Geodetic latitude", NORTH], 
    AXIS["Geodetic longitude", EAST], 
    AUTHORITY["EPSG","4737"]], 
  PROJECTION["Transverse_Mercator", AUTHORITY["EPSG","9807"]], 
  PARAMETER["central_meridian", 127.5], 
  PARAMETER["latitude_of_origin", 38.00000000000001], 
  PARAMETER["scale_factor", 0.9996], 
  PARAMETER["false_easting", 1000000.0], 
  PARAMETER["false_northing", 2000000.0], 
  UNIT["m", 1.0], 
  AXIS["Northing", NORTH], 
  AXIS["Easting", EAST], 
  AUTHORITY["EPSG","5179"]]
其坐标为东北或y-x,因此如果将代码修改为:

Coordinate in = new Coordinate(coordinateY, coordinateX); 
您将得到正确答案,我得到
(40.00997217325207131.0999927804759)