Opened 14 years ago
Closed 12 years ago
#2671 closed enhancement (fixed)
[PATCH] delete fields in .dbf
Reported by: | wonder | Owned by: | warmerdam |
---|---|---|---|
Priority: | normal | Milestone: | 1.9.0 |
Component: | OGR_SF | Version: | svn-trunk |
Severity: | normal | Keywords: | shape |
Cc: | jef, msieczka, Markus Neteler, gislab |
Description
I've developed a patch to allow deletion of fields in an existing DBF file. It's done by overwriting header and moving records in DBF file (without creating a new temporary file).
The patch adds new C++ function OGRLayer::DeleteField(int field) and C API equivalent OGR_L_DeleteField.
One downside is that after deletion of a field, the .dbf file is not truncated as there's no hook for truncation. However this doesn't affect overall functionality.
Attachments (6)
Change History (21)
by , 14 years ago
Attachment: | dbf_delete_field.patch added |
---|
comment:1 by , 14 years ago
Btw. if you like the patch I'm willing to create another one to support adding fields to existing DBF files in similar way as deletion is done.
Martin
comment:2 by , 14 years ago
Component: | default → OGR_SF |
---|---|
Keywords: | shape added |
Status: | new → assigned |
Martin,
Adding a DeleteField() method for OGRLayer's would require an RFC voted on by the GDAL PSC. I'm personally a bit leery about it, but if it were pursued I think it might be best approached as part of more general manipulation of the field list (reordering, modifying type).
Also, it is too late for such capabilities in GDAL/OGR 1.6, now in beta.
I would be very receiptive to an implementation of CreateField() on existing .dbf files which could be incorporated if available in time for 1.6.0 beta2.
comment:3 by , 14 years ago
I have applied the portion of the patch that adds DBFDeleteField() upstream in shapelib. This can be valuable to some people even if OGR does not support deleting fields.
comment:4 by , 14 years ago
Cc: | added |
---|
comment:5 by , 14 years ago
Cc: | added |
---|
comment:6 by , 14 years ago
Cc: | added |
---|
comment:7 by , 14 years ago
Cc: | added |
---|
comment:8 by , 14 years ago
Cc: | added; removed |
---|
comment:10 by , 13 years ago
Frank,
can we try to resolve this ticket to get this functionality into next release (1.8 I guess)? I'm willing to create an RFC, however I'd like to skip the general manipulation as you've proposed and I'd ask only for DeleteField method. Basically the reordering and modifying types of attributes aren't really much requested features and would increase the scope of work significantly.
Martin
comment:14 by , 12 years ago
Shapelib patched as suggested, and results brought back downstream into GDAL trunk (r22367).
comment:15 by , 12 years ago
Milestone: | → 1.9.0 |
---|---|
Resolution: | → fixed |
Status: | assigned → closed |
r22368 /trunk/gdal/ogr/ (9 files in 3 dirs): RFC35 : core of implementation (#2671)
r22369 /trunk/gdal/ogr/ogrsf_frmts/ (6 files in 3 dirs): RFC35 : implementation in Shapefile, Memory and PG drivers (#2671)
r22370 /trunk/gdal/swig/ (4 files in 4 dirs): RFC35: SWIG bindings (#2671)
r22371 /trunk/autotest/ogr/ (ogr_pg.py ogr_rfc35_mem.py ogr_rfc35_shape.py): RFC35: autotest for implementation in Shapefile, Memory and PG drivers (#2671)
patch for deletion of field in dbf