简体   繁体   English

函数makepoint postgresql 9.1错误postgis

[英]function makepoint postgresql 9.1 error postgis

Migrating postgres 8.4 to 9.1 and moving my project to a new server I get this error 将Postgres 8.4迁移到9.1并将项目移到新服务器上时出现此错误

ERROR: function makepoint(unknown, unknown) does not exist LINE 4: distance_sphere(makepoint('14.2995419','41.0310868'),mak... ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts. 错误:函数makepoint(未知,未知)不存在第4行:distance_sphere(makepoint('14 .2995419','41.0310868'),mak ... ^提示:没有函数与给定的名称和参数类型匹配。您可能需要添加显式类型转换。

Googling I saw that could be a problem with postgis ... then I have followed this guide http://trac.osgeo.org/postgis/wiki/UsersWikiPostGIS20Ubuntu1204src and I installed everything on the server ... 谷歌搜索,我发现这可能是postgis的问题...然后我遵循了该指南http://trac.osgeo.org/postgis/wiki/UsersWikiPostGIS20Ubuntu1204src ,我将所有内容都安装在服务器上...

Nothing works ... and I'm in danger of becoming insane ... Does anyone know how to fix it!? 什么都行不通...而且我有变得发疯的危险...有人知道如何修复它!

As pointed out previously, these functions were previously called "makepoint" and "distance_sphere", but later renamed with a "ST_" prefix (ST = "spatial type"). 如前所述,这些函数以前称为“ makepoint”和“ distance_sphere”,但后来用“ ST_”前缀重命名(ST =“空间类型”)。

A really simple solution is to add the legacy.sql functions to either your template_postgis (if used) or your target database using something like: 一个非常简单的解决方案是使用以下方法将legacy.sql函数添加到template_postgis (如果使用)或目标数据库中:

sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/legacy.sql

From the error it would seem that you are enclosing your points in quotes, hence the complaint about unknown, unknown. 从错误看来,您似乎将要点括在引号中,因此抱怨未知,未知。 ST_Makepoint will expect two double precision numbers as input. ST_Makepoint将期望使用两个双精度数字作为输入。 You should also prefix all spatial functions with ST_, as has been stated in the comments. 如注释中所述,您还应在所有空间函数之前加上ST_。

If you run the following from a psql prompt: 如果从psql提示符下运行以下命令:

\df ST_MakePoint

you will see the 3 versions that are supported, for 2, 3 and 4 dimensions, all taking doubles. 您将看到支持2、3和4尺寸的3个版本,所有版本均加倍。

For example: 例如:

select st_distance_sphere(st_makepoint(14.2995419,41.0310868), st_makepoint(15.2995419,40.0310868)) as dist;

returns 139665.10 m 返回139665.10 m

For what is is worth, the ST_ is considered standard's compliant. 对于有价值的产品,ST_被认为是符合标准的。 Oracle uses ST_ before all its spatial functions, as does Postgres/Postgis, MySQL supports both ST_ and just straight function names and Microsoft decided to drop the underscore altogether when they implemented spatial sql in SQL Server 2008, so you have STUnion, for example. Oracle在其所有空间函数之前都使用ST_,Postgres / Postgis也是如此,MySQL支持ST_和直接函数名,并且Microsoft决定在SQL Server 2008中实现空间sql时完全删除下划线,因此您拥有STUnion。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM