Opened 12 years ago
Closed 12 years ago
#4458 closed defect (fixed)
[PATCH] FGDB driver does not ensure feature class names are valid
Reported by: | ryanl | Owned by: | warmerdam |
---|---|---|---|
Priority: | normal | Milestone: | 1.9.1 |
Component: | OGR_SF | Version: | 1.9.0 |
Severity: | normal | Keywords: | FileGDB, File Geodatabase |
Cc: | robert.coup@… |
Description
If an input contains field names that are invalid in a FGDB the driver attempts to add them directly, error messages are displayed and the resulting database does not contain the fields.
ERROR 1: Error: Failed at creating Field for 9NUMBER (The name of the Field is invalid: valid names may contain letters, numbers or underscores.) Warning 1: The output driver has claimed to have added the 9NUMBER field, but it did not!
The FGDB API also lets you create fields with reserved words but these will break when opened with ArcMap, this will be fixed with the next API release apparently.
The attached patch cleans field names by changing invalid characters to "_", appending "_" to reserved words (similarly to ArcCatalog), shrinks names to 64 characters and ensures uniqueness of the names. It also adds an alias to the original field name.
I have attached an example csv that contains several fields with invalid names and the expected output.
References:
- Reserved words: http://blogs.esri.com/Support/blogs/supportcenter/archive/2010/05/26/Words-_2800_by-Reservation-Only_2900_.aspx
- Field name length: http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/File_geodatabase_size_and_name_limits/003n0000007q000000
- Invalid characters (Fields starting with underscores work fine): http://support.esri.com/en/knowledgebase/techarticles/detail/23087
Attachments (5)
Change History (10)
by , 12 years ago
Attachment: | cleanFields.diff added |
---|
comment:1 by , 12 years ago
Hi Ryan,
I would modify the patch to ensure that fields that start with a number get an underscore prefixed to the field name, rather than replacing the number character with an underscore. i.e "9NUMBER" becomes "_9NUMBER" rather than "_NUMBER". This way fields names have a better chance of remaining unique and the process won't error.
Cheers Jeremy
by , 12 years ago
Attachment: | cleanFields.2.diff added |
---|
Patch using jpalmer's idea to prefix fields starting with a number
comment:2 by , 12 years ago
Milestone: | → 1.9.1 |
---|---|
Resolution: | → fixed |
Status: | new → closed |
Version: | svn-trunk → 1.9.0 |
r23777 /trunk/ (6 files in 2 dirs): FileGDB: do compulsory field name laundering. Add a LAUNDER_RESERVED_KEYWORDS layer creation option, which defaults to YES, to control whether an optional laundering step should also be done (adapted from a patch by ryanl, #4458)
r23778 /branches/1.9/gdal/ogr/ogrsf_frmts/filegdb/ (5 files): FileGDB: do compulsory field name laundering. Add a LAUNDER_RESERVED_KEYWORDS layer creation option, which defaults to YES, to control whether an optional laundering step should also be done (adapted from a patch by ryanl, #4458)
comment:3 by , 12 years ago
r23787 /trunk/gdal/ogr/ogrsf_frmts/filegdb/drv_filegdb.html: FileGDB: un-document LAUNDER_RESERVED_KEYWORDS option. Setting it to NO isn't really usefull (#4458)
r23788 /branches/1.9/gdal/ogr/ogrsf_frmts/filegdb/drv_filegdb.html: FileGDB: un-document LAUNDER_RESERVED_KEYWORDS option. Setting it to NO isn't really usefull (#4458)
by , 12 years ago
Attachment: | keyword_case.patch added |
---|
The current implementation does not do a case insensitive match. This patch fixes this.
comment:4 by , 12 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
comment:5 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
fix against r23761