表中有一个point
列。我需要添加另一个point
. 新点与现有点的距离不能小于一定距离。距离由扩展的<@>
操作员给出。earthdistance
如果没有比 1 更接近的现有点,则此查询返回候选点,否则返回任意点。
select
case when not exists (
select 1
from (values ('0.01, 0'::point), ('-0.01, 0'), ('0, 0.01')) s(location)
where location <@> point (0,0) < 1
)
then point(0,0)
else point(1,1)
end
;
我需要一个查询来将最近的可能不存在的点(“空闲槽”)返回到候选点。在这个例子中,它将是 ≅ (0, -0.0144733)
要创建 earthdistance 扩展:
create extension cube;
create extension earthdistance;