[gdal-dev] FileGDB -preserve_fid

Even Rouault even.rouault at mines-paris.org
Thu Dec 13 00:14:51 PST 2012


Le jeudi 13 décembre 2012 02:24:40, Jeremy Palmer a écrit :
> Hi,
> 
> I'm trying to copy data from PostgreSQL to FileGDB. My PostgreSQL table has
> a primary key column and ogr indenties it as the FID e.g
> 
> CREATE TABLE public.test_fileGDB (
>     id INTEGER PRIMARY KEY,
>     data1 TEXT,
>     shape GEOMETRY(POINT, 4167)
> );
> 
> INSERT INTO public.test_fileGDB (id, data1, shape) VALUES (100, 'FileGDB
> test record', ST_SetSrid(ST_MakePoint(160, -40), 4167));
> 
> ogrinfo PG:'dbname=my_db' public.test_filegdb
> INFO: Open of `PG:dbname=my_db'
>       using driver `PostgreSQL' successful.
> 
> Layer name: test_filegdb
> Geometry: Point
> Feature Count: 1
> Extent: (160.000000, -40.000000) - (160.000000, -40.000000)
> Layer SRS WKT:
> GEOGCS["NZGD2000",
>     DATUM["New_Zealand_Geodetic_Datum_2000",
>         SPHEROID["GRS 1980",6378137,298.257222101,
>             AUTHORITY["EPSG","7019"]],
>         TOWGS84[0,0,0,0,0,0,0],
>         AUTHORITY["EPSG","6167"]],
>     PRIMEM["Greenwich",0,
>         AUTHORITY["EPSG","8901"]],
>     UNIT["degree",0.0174532925199433,
>         AUTHORITY["EPSG","9122"]],
>     AUTHORITY["EPSG","4167"]]
> FID Column = id
> Geometry Column = shape
> data1: String (0.0)
> 
> OGRFeature(test_filegdb):100
>   data1 (String) = FileGDB test record
>   POINT (160 -40)
> 
> However when I try to copy it into a FileGDB the FID data is lost:
> 
> ogr2ogr -preserve_fid --config FGDB_BULK_LOAD YES -f FileGDB test.gdb
> PG:'dbname=my_db' public.test_filegdb -nln test_filegdb
> 
> ogrinfo test.gdb test_filegdb
> INFO: Open of `test.gdb'
>       using driver `FileGDB' successful.
> 
> Layer name: test_filegdb
> Geometry: Point
> Feature Count: 1
> Extent: (160.000000, -40.000000) - (160.000000, -40.000000)
> Layer SRS WKT:
> GEOGCS["NZGD2000",
>     DATUM["New_Zealand_Geodetic_Datum_2000",
>         SPHEROID["GRS 1980",6378137,298.257222101,
>             AUTHORITY["EPSG","7019"]],
>         TOWGS84[0,0,0,0,0,0,0],
>         AUTHORITY["EPSG","6167"]],
>     PRIMEM["Greenwich",0,
>         AUTHORITY["EPSG","8901"]],
>     UNIT["degree",0.0174532925199433,
>         AUTHORITY["EPSG","9122"]],
>     AUTHORITY["EPSG","4167"]]
> FID Column = OBJECTID
> Geometry Column = SHAPE
> data1: String (0.0)
> OGRFeature(test_filegdb):1
>   data1 (String) = FileGDB test record
>   POINT (160 -40)
> 
> 
> Is this a bug or did I use the wrong ogr2ogr options?

At first sight, I would say it is a limitation of the FileGDB API.

In FGdbLayer::CreateFeature( OGRFeature *poFeature ),

you can see the following commented code :

    /* Cannot write to FID field - it is managed by GDB*/
    //std::wstring wfield_name = StringToWString(m_strOIDFieldName);
    //hr = fgdb_row.SetInteger(wfield_name, poFeature->GetFID());

So there was an attempt made of preserving the FID, but apparently it doesn't 
work.

Looking at Row.h in the FileGDB API include files, I can see that there's a 
public GetOID() method, but SetOID() is private. So it seems that the FileGDB 
API manages itself the OID.

Even


More information about the gdal-dev mailing list