我需要安装earthdistance ,Postgresql的扩展。 它的页面说:
earthdistance模块提供了两种不同的方法来计算地球表面的大圆距离。 首先描述的一个取决于立方体包(必须在安装接地距离之前安装)。 第二个是基于内置的点数据types,使用坐标的经度和纬度。
这似乎是真的..
dealermade=# CREATE EXTENSION earthdistance FROM unpackaged; ERROR: required extension "cube" is not installed
但是,我无法安装cube
dealermade=# CREATE EXTENSION cube FROM unpackaged; ERROR: type "cube" does not exist
看起来尴尬cube扩展需要它提供的cubetypes。 我正在使用PostgreSQL 9.1.1 。 我在Ubuntu上这样做,我已经安装了companion包postgresql-contrib-9.1 。 这就是说,我的系统上没有cube.sql 。
如果我尝试直接安装earthdistance.sql ,我得到这个
$ psql -d db -f /usr/share/postgresql/9.1/extension/earthdistance--1.0.sql CREATE FUNCTION psql:/usr/share/postgresql/9.1/extension/earthdistance--1.0.sql:31: ERROR: type "cube" does not exist CREATE FUNCTION CREATE FUNCTION psql:/usr/share/postgresql/9.1/extension/earthdistance--1.0.sql:49: ERROR: type "earth" does not exist psql:/usr/share/postgresql/9.1/extension/earthdistance--1.0.sql:55: ERROR: type earth does not exist psql:/usr/share/postgresql/9.1/extension/earthdistance--1.0.sql:61: ERROR: type earth does not exist psql:/usr/share/postgresql/9.1/extension/earthdistance--1.0.sql:67: ERROR: type earth does not exist psql:/usr/share/postgresql/9.1/extension/earthdistance--1.0.sql:73: ERROR: type earth does not exist psql:/usr/share/postgresql/9.1/extension/earthdistance--1.0.sql:79: ERROR: could not access file "MODULE_PATHNAME": No such file or directory psql:/usr/share/postgresql/9.1/extension/earthdistance--1.0.sql:88: ERROR: function geo_distance(point, point) does not exist
FROM unpackaged只有当它已经被安装为一个contrib模块(即从9.0升级),你需要把它变成一个扩展。 因此,只是:
CREATE EXTENSION cube; CREATE EXTENSION earthdistance;