Geotools 距离计算失败,几个经纬度点没有收敛异常

sko*_*nto 5 exception geotools convergence

我有很多点导致 getOrthodromicDistance 方法在 geotools lib 中失败并出现异常,而这些点是有效的经纬度点:

\n\n

抛出异常的点(纬度,经度):

\n\n
val p1= (5.318765,-75.786109)\nval p2= (-6.32907,106.09254)\n
Run Code Online (Sandbox Code Playgroud)\n\n

例如例外:\n 点 75\xc2\xb047,2'W 06\xc2\xb019,7'S 和 106\xc2\xb005,6'E 05\xc2\xb019,1'N 没有收敛。\njava.lang。 ArithmeticException: org.geotools.referencing 上的点 75\xc2\xb047,2'W 06\xc2\xb019,7'S 和 106\xc2\xb005,6'E 05\xc2\xb019,1'N.\n 没有收敛.GeodeticCalculator.computeDirection(GeodeticCalculator.java:1073)

\n\n

Scala 中使用的代码:

\n\n
  def latlonDistance(p1:(Double,Double), p2:(Double,Double)):Double={\n      val world= new GeodeticCalculator()\n      world.setStartingGeographicPoint(p1._2, p2._1)\n      world.setDestinationGeographicPoint(p2._2, p1._1)\n      world.getOrthodromicDistance\n   }\n
Run Code Online (Sandbox Code Playgroud)\n\n

注意:我在 latlonDistance 中传递的点格式是 (lat,lon) 如上所述,而 setStartingGeographicPoint、setDestinationGeographicPoint 需要 (lon,lat) \norder。

\n\n

使用的版本:

\n\n
        <dependency>\n          <groupId>org.geotools</groupId>\n          <artifactId>gt-referencing</artifactId>\n          <version>13.2</version>\n        </dependency>\n
Run Code Online (Sandbox Code Playgroud)\n\n

在 python 中按预期工作:

\n\n
>>> from geopy.distance import vincenty\n>>> pt1= [5.318765,-75.786109]\n>>> pt2= [-6.32907,106.09254]\n>>> vincenty(pt1 , pt2)\nDistance(19791.6883647)\n
Run Code Online (Sandbox Code Playgroud)\n\n

这是 org.geotools.referencing.datum.DefaultEllipsoid 中的 orthodromicDistance 方法不收敛。有什么解决方法吗?

\n

Ian*_*ton 3

问题在于,这不是一个简单的计算,因为 Vincenty 算法是一个迭代过程,并且某些点集不一定收敛(在极限集中)。

有两种可能的解决方案 1 - 编辑 GeodeticCalculator 将可能的迭代次数从 12 增加到 15,这在这种情况下有效,但我不能保证在其他情况下也有效。或者2使用另一种算法,按照这个问题的答案中的链接,我在Sourceforge找到了GeographicLib库,并将其与您的观点一起使用。它是由其他答案中链接的论文的作者(@cffk)撰写的。

对于您的积分,它给出的 20004 公里看起来非常合理。