sko*_*nto 5 exception geotools convergence
我有很多点导致 getOrthodromicDistance 方法在 geotools lib 中失败并出现异常,而这些点是有效的经纬度点:
\n\n抛出异常的点(纬度,经度):
\n\nval p1= (5.318765,-75.786109)\nval p2= (-6.32907,106.09254)\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\nScala 中使用的代码:
\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注意:我在 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在 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这是 org.geotools.referencing.datum.DefaultEllipsoid 中的 orthodromicDistance 方法不收敛。有什么解决方法吗?
\n问题在于,这不是一个简单的计算,因为 Vincenty 算法是一个迭代过程,并且某些点集不一定收敛(在极限集中)。
有两种可能的解决方案 1 - 编辑 GeodeticCalculator 将可能的迭代次数从 12 增加到 15,这在这种情况下有效,但我不能保证在其他情况下也有效。或者2使用另一种算法,按照这个问题的答案中的链接,我在Sourceforge找到了GeographicLib库,并将其与您的观点一起使用。它是由其他答案中链接的论文的作者(@cffk)撰写的。
对于您的积分,它给出的 20004 公里看起来非常合理。
| 归档时间: | 
 | 
| 查看次数: | 377 次 | 
| 最近记录: |