首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >地质工具GeodeticCalculator

地质工具GeodeticCalculator
EN

Stack Overflow用户
提问于 2020-02-28 17:05:43
回答 1查看 490关注 0票数 0

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

然而,计算点与原始点的距离大于50米,这是一个较大的误差。

以下是代码:

代码语言:javascript
复制
 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();
 }

}

产出如下:

Azimuth=44.97189638988797 computedEndPoint=Point2D.Double-4.00014170719737,41.49715519864095 Distance=53.17698966547863

我希望computedEndPoint从一开始就与声明的终结点非常相似(如果不是完全相同的话)。这两点之间的距离接近于零。

现在我的问题是:我做错了什么?或者GeodedicCalculator中有什么bug?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-03-01 11:12:49

50米以上130公里是0.04%的误差-这是相当好的往返的迭代数值方法。

你使用的是GeodedicCalculator,它使用地球形状的近似来进行计算。GeoTools使用C.F.Karney,大地测量算法,J. Geodesy 87,43-55 (2013)的GeographicLib实现,解释了用于解决问题的近似方法。

回答 on gis.stackexchange.com解释了在使用纬度和经度时,您可以期望从各种小数位数中得到的精度水平,在本XKCD动画中也对此进行了概述。

你的最低精度点是4DP,所以从其余的计算结果来看,你不能期望超过10米。即使在航空领域,你也不太可能比实际测量的5 DP更好,并且更有可能以3DP和10 s-100米的精度工作。

更新

进一步的调查表明,是你原来的距离值是错误的。

代码语言:javascript
复制
  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));

给我:

代码语言:javascript
复制
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的距离误差。这对于任何领域都应该是可以的。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60456328

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档