GeoTools 和 GIS 新手,我正在尝试使用 GeoTools 库计算孟买和德班之间的距离。我正在接近小距离的准确结果,但当我进行较大距离时,计算结果偏离了 2000 公里,我不完全理解 CRS 系统。下面是我计算孟买和德班之间距离的代码
Coordinate source = new Coordinate(19.0760, 72.8777); ///Mumbai Lat Long
Coordinate destination1 = new Coordinate(-29.883333, 31.049999); //Durban Lat Long
GeometryFactory geometryFactory = new GeometryFactory();
Geometry point1 = geometryFactory.createPoint(source);
Geometry point2 = geometryFactory.createPoint(destination1);
CoordinateReferenceSystem auto = auto = CRS.decode("AUTO:42001,13.45,52.3");
MathTransform transform = CRS.findMathTransform(DefaultGeographicCRS.WGS84, auto);
Geometry g3 = JTS.transform(point1, transform);
Geometry g4 = JTS.transform(point2, transform);
double distance = g3.distance(g4);
Run Code Online (Sandbox Code Playgroud)