Ticket #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

