geotools GeodeticCalculator

问题描述 投票:0回答:1

具有两个点和一个距离,我试图计算方位角,然后重新计算其中一个点。

但是,计算点与原始点之间的距离超过50米,这是一个很大的误差。

这里是代码:

 public static void main(String[] args) {

 double startLongitude = -5.1085;
 double startLatitude = 40.6682667;
 double endLongitude = -4.000597497067124;
 double endLatitude = 41.49682079962159;
 double distance = 130947.51;

 try {
 CoordinateReferenceSystem crs = CRS.decode("EPSG:4326");
 GeodeticCalculator calculator = new GeodeticCalculator(crs);

 calculator.setStartingGeographicPoint(startLongitude, startLatitude);
 calculator.setDestinationGeographicPoint(endLongitude, endLatitude);
 double azimuth = calculator.getAzimuth();
 System.out.println("Azimuth=" + azimuth);

 calculator = new GeodeticCalculator(crs);
 calculator.setStartingGeographicPoint(startLongitude, startLatitude);
 calculator.setDirection(azimuth, distance);
 Point2D computedEndPoint = calculator.getDestinationGeographicPoint();
 System.out.println("computedEndPoint=" + computedEndPoint);

 calculator = new GeodeticCalculator(crs);
 calculator.setStartingGeographicPoint(endLongitude, endLatitude);
 calculator.setDestinationGeographicPoint(computedEndPoint);
 distance = calculator.getOrthodromicDistance();
 System.out.println("Distance=" + distance);

 } catch (FactoryException e) {
 e.printStackTrace();
 }

}

输出为:

方位角= 44.97189638988797

computedEndPoint = Point2D.Double [-4.00014170719737,41.49715519864095]

Distance = 53.17698966547863

我希望从起点开始,calculatedEndPoint与声明的终点非常相似(如果不完全相同)。而且这两点之间的距离接近于零。

现在我的问题是:我做错了什么?还是在GeodedicCalculator中有一些错误?

gis geotools azimuth
1个回答
0
投票

130km上的50m为0.04%的误差-对于迭代数值方法的往返而言非常好。

您使用的是GeodedicCalculator,它使用的是地球形状的近似值。 GeoTools使用C. F. F. Karney的GeographicLib实现,Algorithms for geodesics,J。Geodesy 87,43-55(2013),解释了用于解决问题的近似方法。

answer上的gis.stackexchange.com解释了当使用纬度和经度时,从各种小数位数可以期望得到的精度水平,也在此XKCD cartoon中进行了总结:

enter image description here

您的最低精度点是4DP,因此在其余的计算中,您不能指望比10米高出许多。即使在航空领域,您也不太可能获得比5 DP更好的实际测量结果,并且更有可能采用3DP和10s-100s米精度。

更新

进一步的调查表明,您的原始距离值有误。

  calculator.setStartingGeographicPoint(startLongitude, startLatitude);
  calculator.setDestinationGeographicPoint(endLongitude, endLatitude);
  double azimuth = calculator.getAzimuth();
  System.out.println("Azimuth=" + azimuth);
  double fullDistance = calculator.getOrthodromicDistance();
  System.out.println("distance " + fullDistance);
  System.out.println("% error " + (Math.abs(fullDistance - distance) / fullDistance) * 100);
  calculator = new GeodeticCalculator(crs);
  calculator.setStartingGeographicPoint(startLongitude, startLatitude);
  calculator.setDirection(azimuth, fullDistance);
  Point2D computedEndPoint = calculator.getDestinationGeographicPoint();
  System.out.println("computedEndPoint=" + computedEndPoint);

  calculator = new GeodeticCalculator(crs);
  calculator.setStartingGeographicPoint(endLongitude, endLatitude);
  calculator.setDestinationGeographicPoint(computedEndPoint);
  distance = calculator.getOrthodromicDistance();
  System.out.println("Distance=" + distance);
  System.out.println("% error " + ((distance / fullDistance) * 100));

给我:

Azimuth=44.971973670068415
distance 130893.86215735915
% error 0.04098575880994952
computedEndPoint=Point2D.Double[-4.000599999999989, 41.49682]
Distance=9.64120596409175E-10
% error 7.365666964965247E-13

如您所见,所有误差都出现在第一个计算中,前进/后退行程给出了相同的点,距离误差为9e-10m。这对于任何域都应该很好。

© www.soinside.com 2019 - 2024. All rights reserved.