Opened 12 years ago

Closed 14 months ago

#1617 closed enhancement (wontfix)

adding parameter "bool preserveFIDs = true" to CopyLayer() and CopyDataSource()

Reported by: Kosta Owned by: warmerdam
Priority: normal Milestone:
Component: OGR_SF Version: unspecified
Severity: normal Keywords:
Cc:

Description

I would like to add an additional parameter:

bool preserveFIDs = true

to the methods CopyLayer?() and CopyDataSource?().

For example: I get in trouble, if I do a CopyLayer?() into a MySQL data source and the FIDs of the source features do not increase from 1 to n (= feature count), due to the "AUTO_INCREMENT" spec of "OGR_FID" in the MySQL impl.

Patch attached...

Or this is a bug in the MySQL impl and explicitly setting the OGR_FID should be forbidden...

Attachments (1)

preserveFIDs.diff (5.3 KB) - added by Kosta 12 years ago.
patch for adding "bool preserveFIDs = true" to CopyLayer?() and CopyDataSource?()

Download all attachments as: .zip

Change History (5)

Changed 12 years ago by Kosta

Attachment: preserveFIDs.diff added

patch for adding "bool preserveFIDs = true" to CopyLayer?() and CopyDataSource?()

comment:1 Changed 4 years ago by Jukka Rahkonen

There is a -preserve_fid option in ogr2ogr

-preserve_fid: Use the FID of the source features instead of letting the output driver to automatically assign a new one.

Does it mean that the requested feature is implemented and ticket can be closed as fixed?

comment:2 Changed 4 years ago by Jukka Rahkonen

The ticket is probably at least partly outdated and I fear that the patch would not work anymore. RFC https://trac.osgeo.org/gdal/wiki/rfc46_gdal_ogr_unification says: "The CopyDataSource??() virtual method has been removed since no in-tree drivers implement it."

The CopyLayer?() part may still be valid. http://www.gdal.org/gdal_8h.html#ab6af8f62727c70bc767086fc5c0daf9c tells that "The papszOptions argument can be used to control driver specific creation options. These options are normally documented in the format specific documentation." Thus preserveFIDs does not exist in CopyLayer?. However, ogr2ogr has an option for that:

"-preserve_fid:

Use the FID of the source features instead of letting the output driver to automatically assign a new one. Note: starting with GDAL 2.0, if not in append mode, this behaviour becomes the default if the output driver has a FID layer creation option. In which case the name of the source FID column will be used and source feature IDs will be attempted to be preserved. This behaviour can be disabled by setting -unsetFid "

I can't judge if this ticket could be closed because it has been resolved in an alternative way or not.

comment:3 Changed 17 months ago by Jukka Rahkonen

Is this issue solved and ready for closing now?

comment:4 Changed 14 months ago by Even Rouault

Resolution: wontfix
Status: newclosed

Probably no longer needed with the availability of GDALVectorTranslate()

Note: See TracTickets for help on using tickets.