相关疑难解决方法(0)

PostgreSQL:如何获得特定半径内的所有点

我正在使用Postgresql 9.3和iv'e安装了cube和earthdistance扩展.

我正在尝试按照本教程,所以我有一个简单的事件表,包含4个字段:id,name,lat,lng.

现在我正在尝试运行此查询,以获取半径1公里范围内的所有事件:

SELECT events.id, events.name FROM events WHERE earth_box(31.789225, 34.789612, 1000) @> ll_to_earth(events.lat, events.lng);
Run Code Online (Sandbox Code Playgroud)

但我一直收到这个错误:

20:59:34 Kernel error: ERROR:  function earth_box(numeric, numeric, integer) does not exist
  HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
Run Code Online (Sandbox Code Playgroud)

所以我用铸造运行同样的东西:

  SELECT events.id, events.name FROM events WHERE earth_box(CAST(31.789225 AS float8), CAST(34.789612 AS float8), 1000) @> ll_to_earth(events.lat, events.lng);
Run Code Online (Sandbox Code Playgroud)

我得到:

   21:16:17 Kernel error: ERROR:  function earth_box(double precision, double precision, integer) does not exist
                                                              ^ …
Run Code Online (Sandbox Code Playgroud)

postgresql geospatial earthdistance

2
推荐指数
1
解决办法
1462
查看次数

标签 统计

earthdistance ×1

geospatial ×1

postgresql ×1