2012-10-30 9 views
14

Voglio importare OSM file nel mio database PostgreSQL (Windows, Postgres versione 9.2) utilizzando lo strumento Osm2pgsql.osm2pgsql: Funzione AddGeometryColumn non esistente

quando ho eseguito il comando

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

seguito ottengo l'errore

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 

traduzione dal tedesco:

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 

Come posso risolvere questo problema?

+0

Hai installato PostGIS in questo database? –

+0

C'è una cartella PostGIS nel menu "Start". Devo installare esplicitamente PostGIS per un determinato database? –

risposta

20

Sembra che tu non abbia aggiunto il supporto PostGIS al database che stai cercando di utilizzare osm2pgsql.exe su. Vedi the PostGIS installation documentation (2.0).

Poiché si utilizza PostGIS 2.0, si dovrebbe essere in grado di caricare solo PostGIS solo CREATE EXTENSION postgis;. Questo comando deve essere eseguito come superutente, normalmente l'utente postgres. Utilizzare:

psql -U postgres mydbname 

per connettersi come utente postgres.

Sembra che almeno le versioni di Windows di osm2pgsql non supportino PostGIS 2.0, o comunque non circa sei mesi fa. Vedi this issue report su OSM GitHub e instructions on how to set a PostGIS 2 database to be compatible with an osm2pgsql that expects PostGIS 1.x. I futuri lettori dovrebbero verificare che questi passaggi siano ancora effettivamente necessari prima di procedere; è probabile che osm2pgsql per Windows verrà aggiornato per supportare PostGIS 2 a un certo punto.

+0

Quando eseguo '" C: \ Programmi \ Post greSQL \ 9.2 \ bin \ psql "-d ccp-web -f postgis.sql --username = ccp-web-user' in una finestra della riga di comando, ottengo molti errori come 'psql: postgis.sql: 6054: ERRORE: Transazione corrente annullata, i comandi rimanenti saranno ignorati'. Come posso risolverli? –

+0

@DmitriPisarenko Hai un database 'template_postgis'? Creare invece il database da quel modello. Se non vuoi farlo, è difficile dire dagli errori considerati ciò che è sbagliato. Devi dare un'occhiata al * primo * errore.Prova a eseguire il comando psql con l'argomento aggiuntivo '-v ON_ERROR_STOP = 1'. –

+0

Ho creato un database dal modello 'template_postgis_20'. Quando eseguo il comando con '-v ON_ERROR_STOP = 1' ottengo l'errore' psql: C:/Programmi/PostgreSQL/9.2/share/contrib/postgis-2.0/postgis.sql: 47: ERRORE: nessun permesso per laguage C'. Suppongo che sia il comando che fallisce: 'CREATE O SOSTITUIRE LA FUNZIONE spheroid_in (CString) \t RETURNS sferoide \t AS '$ libdir/PostGIS-2.0', 'ellipsoid_in' \t LINGUA 'c' IMMUTABILE OGGETTIVA;' –

1

Piuttosto tardi, ma sono inciampato e inciampato in questo settembre '16. La linea di SQL:

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

ha bisogno di essere riscritta come questa funzione di firma:

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

Lo spazio bianco è irrilevante. Quindi, qualcosa come il seguente dovrebbe fare il trucco:

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

Controllare una delle istruzioni INSERT effettivi per il nome di colonna corretto, che nella mia versione è 'geom'.

Assicurarsi che i varchar siano quotati, numeri interi e valori booleani non quotati e, naturalmente, che i valori corretti siano nei luoghi.

Buona fortuna.