后吉斯计算点之间的距离超过两个

发布于 2025-01-27 13:52:31 字数 174 浏览 2 评论 0原文

我有一张桌子上有位置的桌子。是否有任何可靠的方法来计算A-和GT之间的距离; b - > c - >使用Postgis的D等。

Distance = AB + AC + CD etc.

每个点都有{LAT,LNG}。

感谢您提供的任何帮助。

I have a table that has a position in it. Is there any solid way to calculate the distance between A --> B --> C --> D etc using Postgis.

Distance = AB + AC + CD etc.

Each point has {lat, lng}.

I appreciate any help you can provide.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦魇绽荼蘼 2025-02-03 13:52:31

您可以使用LEADlag与a window 。然后,您可以在外部查询中计算距离和sum,如果需要的话。

SELECT sum(dist) 
FROM (
  SELECT id, ST_DistanceSphere(geom, lead(geom) OVER(ORDER BY id)) as dist 
  FROM myTable) sub;

You can use lead or lag to work with next/previous row of a window. You can then compute the distance and sum it if you want, in an outer query.

SELECT sum(dist) 
FROM (
  SELECT id, ST_DistanceSphere(geom, lead(geom) OVER(ORDER BY id)) as dist 
  FROM myTable) sub;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文