使用Geotools计算两点距离偏差过大,如何正确计算?
Geotools计算两点距离偏差过大问题
我尝试使用Geotools计算两点间的距离,但结果比谷歌地图及在线计算器的数值大很多。
第一种实现代码:
GeodeticCalculator gc = new GeodeticCalculator(); gc.setStartingGeographicPoint(59.93748473405807, 10.683153934843533); gc.setDestinationGeographicPoint(59.949602112593716, 10.731101898029312); System.out.println(gc.getOrthodromicDistance());
根据谷歌地图及在线计算器,两点距离约为3000米,但Geotools返回的结果为5466米,偏差极大。
我还尝试了另一种方法,结果约为5471米,偏差依旧明显:
GeometryFactory gf = new GeometryFactory(); Point p1 = gf.createPoint(new Coordinate(59.93748473405807, 10.683153934843533)); Point p2 = gf.createPoint(new Coordinate(59.949602112593716, 10.731101898029312)); try { CoordinateReferenceSystem auto = CRS.decode("AUTO:42001,59.93748473405807,10.683153934843533"); MathTransform transform = CRS.findMathTransform(DefaultGeographicCRS.WGS84, auto); Geometry p3 = JTS.transform(p1, transform); Geometry p4 = JTS.transform(p2, transform); System.out.println(p3.distance(p4)); } catch (Exception e) { e.printStackTrace(); }
请问我哪里操作出错了?
内容的提问来源于stack exchange,提问作者acanthite
相关产品推荐
相关产品推荐

