postgresql osm2pgsql:函数 AddGeometryColumn 不存在

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13132649/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 23:48:26  来源:igfitidea点击:

osm2pgsql: Function AddGeometryColumn doesn't exist

postgresqlpostgisopenstreetmappostgresql-9.2

提问by Dmitrii Pisarenko

I want to import OSM fileinto my PostgreSQL database (Windows, Postgres Version 9.2) using the tool Osm2pgsql.

我想使用Osm2pgsql工具将OSM 文件导入我的 PostgreSQL 数据库(Windows,Postgres 9.2 版)。

When I run following command

当我运行以下命令时

osm2pgsql.exe --create -d mydb artyom.xml -U myuser -W --style default.style

I get the error

我收到错误

SELECT AddGeometryColumn('planet_osm_point', 'way', 900913, 'POINT', 2 );
 failed: FEHLER:  Funktion addgeometrycolumn(unknown, unknown, integer, unknown,
 integer) existiert nicht
LINE 1: SELECT AddGeometryColumn('planet_osm_point', 'way', 900913, ...
               ^
HINT:  Keine Funktion stimmt mit dem angegebenen Namen und den Argumenttypen ├╝b
erein. Sie m├╝ssen m├?glicherweise ausdr├╝ckliche Typumwandlungen hinzuf├╝gen.

Error occurred, cleaning up

Translation from German:

德语翻译:

SELECT AddGeometryColumn('planet_osm_point', 'way', 900913, 'POINT', 2 );
 failed: ERROR:  Function addgeometrycolumn(unknown, unknown, integer, unknown,
 integer) doesn't exist
LINE 1: SELECT AddGeometryColumn('planet_osm_point', 'way', 900913, ...
               ^
HINT: No function matches the specified name and argument types. Maybe you need
to make explicit casts.

Error occurred, cleaning up

How can I fix this?

我怎样才能解决这个问题?

回答by Craig Ringer

It looks like you haven't added PostGIS support to the database you're trying to use osm2pgsql.exeon. See the PostGIS installation documentation (2.0).

看起来您尚未将 PostGIS 支持添加到您尝试使用的数据库中osm2pgsql.exe。请参阅PostGIS 安装文档 (2.0)

Since you are using PostGIS 2.0, you should be able to just CREATE EXTENSION postgis;to load PostGIS. This command must be run as a superuser - normally the user postgres. Use:

由于您使用的是 PostGIS 2.0,您应该能够CREATE EXTENSION postgis;加载 PostGIS。该命令必须以超级用户的身份运行——通常是用户postgres。用:

psql -U postgres mydbname

to connect as user postgres.

以用户身份连接postgres

It appears that at least the Windows builds of osm2pgsqldon't support PostGIS 2.0 - or didn't about six months ago, anyway. See this issue reporton the OSM GitHub, and the instructions on how to set a PostGIS 2 database to be compatible with an osm2pgsql that expects PostGIS 1.x. Future readers should check that these steps are still actually required before proceeding; it's likely that osm2pgsqlfor Windows will be updated to support PostGIS 2 at some point.

看来至少 Windows 版本osm2pgsql不支持 PostGIS 2.0 - 或者大约六个月前不支持,无论如何。请参阅OSM GitHub 上的此问题报告,以及有关如何设置 PostGIS 2 数据库以与需要 PostGIS 1.x 的 osm2pgsql 兼容的说明。未来的读者应该在继续之前检查这些步骤是否仍然需要;osm2pgsqlWindows可能会在某个时候更新以支持 PostGIS 2。

回答by aorta

Rather late but I stumbled and tripped upon this Sept '16. The SQL line:

相当晚了,但我在 16 年 9 月偶然发现并绊倒了。SQL 行:

SELECT AddGeometryColumn('planet_osm_point', 'way', 900913, 'POINT', 2 );

SELECT AddGeometryColumn('planet_osm_point', 'way', 900913, 'POINT', 2 );

needs to be rewritten as this function signature:

需要重写为这个函数签名:

('catalog','schema','table','column',srid,'type',type_mod,boolean);

('catalog','schema','table','column',srid,'type',type_mod,boolean);

White space is immaterial. So something like the following should do the trick:

空白是非物质的。所以像下面这样的东西应该可以解决问题:

SELECT AddGeometryColumn('','','planet_osm_point', 'way', 900913, 'POINT', 2,true );

Check one of the actual INSERT statements for the correct column name which in my version is 'geom'.

检查实际的 INSERT 语句之一以获取正确的列名称,在我的版本中为“geom”。

Ensure that varchars are quoted, integers and boolean are unquoted and of course that the right values are in the places.

确保 varchars 被引用,整数和布尔值未被引用,当然正确的值在这些地方。

Good luck.

祝你好运。