地球距离没有给出正确的结果。 [英] earthdistance is not giving correct results.

查看:58
本文介绍了地球距离没有给出正确的结果。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行PostgreSQL 8.0 beta 1.我正在使用

earthdistance找到两个不同的纬度和逻辑位置之间的距离。 />
不幸的是,结果似乎是错误的。


这是我正在做的事情:

select

earth_distance(ll_to_earth(''122.55688'','''45.513746''),ll_to_earth(''122.396357'',''47.648845'');


结果我得到的是:


128862.563227506


从波特兰到西雅图的距离不是128862

英里。



__________________________________

你是Yahoo!?

Yahoo!邮件是新的和改进的 - 检查出来!
http://promotions.yahoo。 com / new_mail


---------------------------(播出结束)---------------------------

提示1:订阅和取消订阅命令转到 ma ******* @ postgresql.org

解决方案

mi**********@yahoo.com (mike cox)写道:

我正在运行PostgreSQL 8.0 beta 1.我正在使用
earthdistance找到两者之间的距离不同纬度和经度位置。不幸的是,结果似乎是错误的。

这就是我正在做的事情:
选择
earth_distance(ll_to_earth('' 122.55688'',''45.513746''),ll_to_earth(''122.396357'',''47.648845'');

我得到的是这个:




我相信ll_to_earth()期待ll_to_earth(纬度,经度),


此外,我认为earth_distance以米为单位返回它的值。


mike cox< mi ********** @ yahoo.com>写道:

从波特兰到西雅图的距离不是128862
里程。




128.8公里怎么样?除非你重新定义了基本单位,否则地球距离文档会说它是以米为单位




问候,tom lane


---------------------------(播出结束)------------ ---------------

提示4:不要杀死-9''邮政局长


2004年10月2日星期六下午07:09:25 -0400,Tom Lane写道:

mike cox< mi ********* *@yahoo.com>写道:

从波特兰到西雅图的距离不是128862
里程。



128.8公里怎么样?除非你重新定义了基本单位,否则地球距离文档会说它只有几米。




128.8公里大约80英里;从波特兰到

的距离西雅图更像是150英里。

earth_distance(ll_to_earth(''122.55688'', ''45 .513746''),ll_to_earth(''122.396357'',''47.648845'');




我没玩过地球距离,但我猜这个论点

到ll_to_earth应该是(纬度,经度)而不是(经度,

纬度)。


以下是我自己实现的hasrsine

函数的一些查询,这是另一种测量球体距离的方法:


=>选择hasrsine(122.55688,45.513746,122.396357,47.648845);

hasrsine

------------------

79.9258188445352


128.8km数字。更正

参数的顺序给出了:


=>选择hasrsine(45.513746,122.55688,47.648845,122.396357);

arersine

------------------

147.614987754694


西雅图


-

Michael Fuhr
http ://www.fuhr.org/~mfuhr/


---------------------- -----(播出结束)---------------------------

提示8:解释分析是你的朋友


I''m running PostgreSQL 8.0 beta 1. I''m using the
earthdistance to find the distance between two
different latitude and logitude locations.
Unfortunately, the result seems to be wrong.

Here is what I''m doing:
select
earth_distance(ll_to_earth(''122.55688'',''45.513746'' ),ll_to_earth(''122.396357'',''47.648845''));

The result I get is this:

128862.563227506

The distance from Portland to Seattle is not 128862
miles.


__________________________________
Do you Yahoo!?
Yahoo! Mail is new and improved - Check it out!
http://promotions.yahoo.com/new_mail

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

解决方案

mi**********@yahoo.com (mike cox) writes:

I''m running PostgreSQL 8.0 beta 1. I''m using the
earthdistance to find the distance between two
different latitude and logitude locations.
Unfortunately, the result seems to be wrong.

Here is what I''m doing:
select
earth_distance(ll_to_earth(''122.55688'',''45.513746'' ),ll_to_earth(''122.396357'',''47.648845''));

The result I get is this:



I believe ll_to_earth() is expecting ll_to_earth(latitude, longitude),

Also, I think earth_distance returns it''s value in meters.


mike cox <mi**********@yahoo.com> writes:

The distance from Portland to Seattle is not 128862
miles.



How about 128.8 kilometers? The earthdistance docs say it''s in meters
unless you''ve redefined the base unit.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 4: Don''t ''kill -9'' the postmaster


On Sat, Oct 02, 2004 at 07:09:25PM -0400, Tom Lane wrote:

mike cox <mi**********@yahoo.com> writes:

The distance from Portland to Seattle is not 128862
miles.



How about 128.8 kilometers? The earthdistance docs say it''s in meters
unless you''ve redefined the base unit.



128.8 kilometers is about 80 miles; the distance from Portland to
Seattle is more like 150 miles.

earth_distance(ll_to_earth(''122.55688'',''45.513746'' ),ll_to_earth(''122.396357'',''47.648845''));



I haven''t played with earthdistance, but I''d guess that the arguments
to ll_to_earth should be (latitude, longitude) instead of (longitude,
latitude).

Here are some queries from my own implementation of the haversine
function, which is another way to measure distances on a sphere:

=> select haversine(122.55688, 45.513746, 122.396357, 47.648845);
haversine
------------------
79.9258188445352

That distance is miles, which is almost exactly equivalent to the
128.8km figure from earth_distance(). Correcting the order of the
arguments gives this:

=> select haversine(45.513746, 122.55688, 47.648845, 122.396357);
haversine
------------------
147.614987754694

That''s more like the true distance in miles between Portland and
Seattle

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend


这篇关于地球距离没有给出正确的结果。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆