0

我不确定以下查询有什么问题:

SELECT id,  earth_distance(ll_to_earth( 41.273147, -75.896858 ), 
ll_to_earth(business_address_latitude, business_address_longitude)) as distance_from_current_location FROM events 
WHERE earth_box( ll_to_earth(41.273147, -75.896858), 20000.00) @> ll_to_earth(business_address_latitude, business_address_longitude);

试图搜索 20000 半径内的记录,但当我检查结果时,它给了我超过 20000 米的距离的记录,比如 24286 米的距离。我不确定上述查询有什么问题。任何建议请。

4

1 回答 1

1

没有错,你只是用盒子而不是圆圈,所以这很正常。手册明确指出:

此框中的某些点距离该位置的指定大圆距离更远,因此查询中应包含使用 earth_distance 的第二次检查。

因此,只需在外部查询中选择距离 <=20000 的点。

于 2013-05-06T10:10:58.500 回答