我有很多点使 getOrthodromicDistance 方法在geotools lib中异常失败,而这些点是有效的纬度点:
引发异常的点(纬度,经度):
val p1= (5.318765,-75.786109)
val p2= (-6.32907,106.09254)
例如例外:点 75°47,2'W 06°19,7'S 和 106°05,6'E 05°19,1'N 没有收敛。java.lang.ArithmeticException:点 75°47,2'W 06°19,7'S 和 106°05,6'E 05°19,1'N 没有收敛。在 org.geotools.referenceencing.GeodeticCalculator.computeDirection(GeodeticCalculator.java:1073)
Scala中使用的代码:
def latlonDistance(p1:(Double,Double), p2:(Double,Double)):Double={
val world= new GeodeticCalculator()
world.setStartingGeographicPoint(p1._2, p2._1)
world.setDestinationGeographicPoint(p2._2, p1._1)
world.getOrthodromicDistance
}
注意:我在 latlonDistance 中传递的点格式是(lat,lon) 如上所述,而setStartingGeographicPoint, setDestinationGeographicPoint 需要(lon,lat) 顺序。
使用的版本:
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-referencing</artifactId>
<version>13.2</version>
</dependency>
在 python 中按预期工作:
>>> from geopy.distance import vincenty
>>> pt1= [5.318765,-75.786109]
>>> pt2= [-6.32907,106.09254]
>>> vincenty(pt1 , pt2)
Distance(19791.6883647)
org.geotools.referencing.datum.DefaultEllipsoid 中的 orthodromicDistance 方法不收敛。任何解决方法?