Skip to content
This repository has been archived by the owner on Jul 24, 2021. It is now read-only.

osm2pgsql can't create gist index on PostGIS 2.0 geometry columns #3994

Closed
openstreetmap-trac opened this issue Jul 23, 2021 · 1 comment
Closed

Comments

@openstreetmap-trac
Copy link

Reporter: lr1234567
[Submitted to the original trac issue database at 1.12pm, Tuesday, 6th September 2011]

In PostGIS 2.0 both 2D indexes and 3D indexes are supported and system defaults to creating 2D index. As such the gist ops names have changed.

osm2pgsql seems to hard-code the ops in output-pgsql.c
looking at latest revision (r26626)
lines 1371-1374

 if (Options->tblsmain_index) {
            pgsql_exec(sql_conn, PGRES_COMMAND_OK, "CREATE INDEX %s_index ON %s USING GIST (way GIST_GEOMETRY_OPS) TABLESPACE %s;\n", table->name, table->name, Options->tblsmain_index);
        } else {
            pgsql_exec(sql_conn, PGRES_COMMAND_OK, "CREATE INDEX %s_index ON %s USING GIST (way GIST_GEOMETRY_OPS);\n", table->name, table->name);
        }

These should be changed to get rid of the GIST_GEOMETRY_OPS so that it works with both PostGIS 1.* and 2.0 series.

so change to:

 if (Options->tblsmain_index) {
            pgsql_exec(sql_conn, PGRES_COMMAND_OK, "CREATE INDEX %s_index ON %s USING GIST (way) TABLESPACE %s;\n", table->name, table->name, Options->tblsmain_index);
        } else {
            pgsql_exec(sql_conn, PGRES_COMMAND_OK, "CREATE INDEX %s_index ON %s USING GIST (way);\n", table->name, table->name);
        }

Thanks,
Regina Obe

@openstreetmap-trac
Copy link
Author

Author: amm
[Added to the original trac issue at 2.47am, Saturday, 17th September 2011]

Thank you for the report. This should be fixed in revision r26659.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant