Opened 18 years ago
Last modified 18 years ago
#1101 closed enhancement (fixed)
Override geom column name in ogr PostgreSQL driver
Reported by: | Owned by: | warmerdam | |
---|---|---|---|
Priority: | high | Milestone: | |
Component: | default | Version: | unspecified |
Severity: | minor | Keywords: | |
Cc: |
Description
Override name of geometry column when using the Postgresql driver in create mode. To invoke, supply this argument on command line: -lco GEOMETRY_NAME=the_geom Patch supplied below. To apply patch: cd gdal-1.3.1/ogr/ogrsf_frmts/pg/ patch ogrpgdatasource.cpp pathtopatch/ogr_pgname.patch ----------------------------- ogr_pgname.patch ----------------------------- diff -aur gdal-1.3.1/ogrpgdatasource.cpp gdal-new/ogrpgdatasource.cpp --- gdal-1.3.1/ogrpgdatasource.cpp 2006-03-01 14:43:52.000000000 -0600 +++ gdal-new/ogrpgdatasource.cpp 2006-03-01 14:33:10.000000000 -0600 @@ -541,8 +541,8 @@ if( bHavePostGIS ) { sprintf( szCommand, - "SELECT DropGeometryColumn('%s','%s','wkb_geometry')", - pszDBName, pszLayerName ); + "SELECT DropGeometryColumn('%s','%s',(SELECT f_geometry_column from geometry_columns where f_table_name='%s' order by f_geometry_column limit 1))", + pszDBName, pszLayerName, pszLayerName); CPLDebug( "OGR_PG", "PGexec(%s)", szCommand ); @@ -698,10 +698,17 @@ if( bHavePostGIS ) { const char *pszGeometryType; + const char *pszGFldName; if( CSLFetchNameValue( papszOptions, "DIM") != NULL ) nDimension = atoi(CSLFetchNameValue( papszOptions, "DIM")); + /** rgp added this **/ + if( CSLFetchNameValue( papszOptions, "GEOMETRY_NAME") != NULL ) + pszGFldName = CSLFetchNameValue( papszOptions, "GEOMETRY_NAME"); + else + pszGFldName = "wkb_geometry"; + /* Sometimes there is an old cruft entry in the geometry_columns * table if things were not properly cleaned up before. We make * an effort to clean out such cruft. @@ -751,8 +758,8 @@ } sprintf( szCommand, - "select AddGeometryColumn('%s','%s','wkb_geometry',%d,'%s',% d)", - pszDBName, pszLayerName, nSRSId, pszGeometryType, + "select AddGeometryColumn('%s','%s','%s',%d,'%s',%d)", + pszDBName, pszLayerName, pszGFldName, nSRSId, pszGeometryType, nDimension ); CPLDebug( "OGR_PG", "PQexec(%s)", szCommand );
Attachments (1)
Change History (3)
by , 18 years ago
Attachment: | ogr_pgname.patch added |
---|
Allow override of Postgresql geometry column name
comment:2 by , 18 years ago
Applied (with a bit of fixing for newer code), and also updated in docs.
Note:
See TracTickets
for help on using tickets.