PostgreSQL earthdistance安装Mac

时间:2018-04-07 13:56:52

标签: postgresql earthdistance

earthdistance modulePostgresql 9.6.5上安装OSX El Capitan 10.11.6。 PG已安装,正常工作。我创建了extension,首先安装了cube

rich=# CREATE EXTENSION earthdistance CASCADE;
NOTICE:  installing required extension "cube"
CREATE EXTENSION

重启我的盒子。打开psql,选择正确的数据库,询问函数(\df):

    rich=# \df
                                                                                     List of functions
     Schema |        Name        | Result data type |           Argument data types            |  Type
    --------+--------------------+------------------+------------------------------------------+--------
     public | cube               | cube             | cube, double precision                   | normal
     public | cube               | cube             | cube, double precision, double precision | normal
     public | cube               | cube             | double precision                         | normal
     public | cube               | cube             | double precision, double precision       | normal
     public | cube               | cube             | double precision[]                       | normal
     public | cube               | cube             | double precision[], double precision[]   | normal
     public | cube_cmp           | integer          | cube, cube                               | normal
     public | cube_contained     | boolean          | cube, cube                               | normal
     public | cube_contains      | boolean          | cube, cube                               | normal
     public | cube_coord         | double precision | cube, integer                            | normal
     public | cube_coord_llur    | double precision | cube, integer                            | normal
     public | cube_dim           | integer          | cube                                     | normal
     public | cube_distance      | double precision | cube, cube                               | normal
     public | cube_enlarge       | cube             | cube, double precision, integer          | normal
     public | cube_eq            | boolean          | cube, cube                               | normal
     public | cube_ge            | boolean          | cube, cube                               | normal
     public | cube_gt            | boolean          | cube, cube                               | normal
     public | cube_in            | cube             | cstring                                  | normal
     public | cube_inter         | cube             | cube, cube                               | normal
     public | cube_is_point      | boolean          | cube                                     | normal
     public | cube_le            | boolean          | cube, cube                               | normal
     public | cube_ll_coord      | double precision | cube, integer                            | normal
     public | cube_lt            | boolean          | cube, cube                               | normal
     public | cube_ne            | boolean          | cube, cube                               | normal
     public | cube_out           | cstring          | cube                                     | normal
     public | cube_overlap       | boolean          | cube, cube                               | normal
     public | cube_size          | double precision | cube                                     | normal
     public | cube_subset        | cube             | cube, integer[]                          | normal
     public | cube_union         | cube             | cube, cube                               | normal
     public | cube_ur_coord      | double precision | cube, integer                            | normal
     public | distance_chebyshev | double precision | cube, cube                               | normal
     public | distance_taxicab   | double precision | cube, cube                               | normal
     public | earth              | double precision |                                          | normal
     public | earth_box          | cube             | earth, double precision                  | normal
     public | earth_distance     | double precision | earth, earth                             | normal
     public | g_cube_compress    | internal         | internal                                 | normal
     public | g_cube_consistent  | boolean          | internal, cube, smallint, oid, internal  | normal
     public | g_cube_decompress  | internal         | internal                                 | normal
     public | g_cube_distance    | double precision | internal, cube, smallint, oid, internal  | normal
     public | g_cube_penalty     | internal         | internal, internal, internal             | normal
     public | g_cube_picksplit   | internal         | internal, internal                       | normal
     public | g_cube_same        | internal         | cube, cube, internal                     | normal
     public | g_cube_union       | cube             | internal, internal                       | normal
     public | gc_to_sec          | double precision | double precision                         | normal
     public | geo_distance       | double precision | point, point                             | normal
     public | latitude           | double precision | earth                                    | normal
     public | ll_to_earth        | earth            | double precision, double precision       | normal
     public | longitude          | double precision | earth                                    | normal
     public | sec_to_gc          | double precision | double precision                         | normal
    (49 rows)

所以似乎extension加载得很好。作为测试,我使用以下简单命令:

SELECT point(43.664828,-79.341620) <@> point(44.418390, -80.096013)

psql我没有收到任何反馈。在Postico 1.3.2(PG客户端)中,我收到以下错误:

ERROR:  operator does not exist: point <@> point
LINE 1: SELECT point(43.664828,-79.341620) <@> point(44.418390, -80....
                                           ^
HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.

根据反馈,似乎没有安装模块。我希望这可以正常工作,因为extension已正确安装,我正在使用earth_distance function的正确语法。我尝试过具有相同类型错误的其他查询,表明不识别运算符。

我做错了什么?

1 个答案:

答案 0 :(得分:0)

解决。事实证明,您必须选择database的{​​{1}}才能应用于该特定extension。只需输入database就在应用程序级别内,因此psql显然对任何数据库都是盲目的。因此,请使用CREATE EXTENSION earthdistance CASCADE语法输入psql,然后应用psql <dbname>将其应用于您选择的数据库。