gvSIG bugs #2681
Field name truncation with Export to
Status: | Closed | % Done: | 100% | |
---|---|---|---|---|
Priority: | Normal | Spent time: | - | |
Assignee: | Joaquín del Cerro Murciano | |||
Category: | - | |||
Target version: | 2.1.0-2248-testing | |||
Severity: | Major | Add-on version: | ||
gvSIG version: | 2.1.0 | Add-on build: | ||
gvSIG build: | 2235 | Add-on resolve version: | ||
Operative System: | Add-on resolve build: | |||
Keywords: | Proyecto: | |||
Has patch: | Yes | Hito: | ||
Add-on name: | Unknown |
Description
Suppose we have a GeoDB or a WFS layer with long field names, i.e. greater than 10. Then, if we use Layer > "Export to" tool choosing the "Shape format", a warning says that some fields have been truncated showing us how. For instance:
cod_provincia > cod_pr_ia_0 codice_istat > codice_at_0
Firstly, the resulting field name is too long (#2672). Secondly, there aren't duplicate field names in order to justify the final _0 in both cases. Finally, it's not very understandable the resulting field names in reference to the original ones.
Instead, this is how GDAL/OGR truncates long field names:
Attribute names can only be up to 10 characters long. Starting with version 1.7, the OGR Shapefile driver tries to generate unique field names. Successive duplicate field names, including those created by truncation to 10 characters, will be truncated to 8 characters and appended with a serial number from 1 to 99.(Source: http://www.gdal.org/drv_shapefile.html)
So the examples mentioned before should be:
cod_provincia > cod_provin codice_istat > codice_ist
Suppose we have another field name cod_provincia_bis. They should become:
cod_provincia > cod_prov_1 codice_istat > codice_ist cod_provincia_bis > cod_prov_2
Associated revisions
change method to field name truncation in Export-to, refs #2681
History
#1 Updated by Antonio Falciano over 9 years ago
The latest example I did is wrong, because the first field should be only truncated according to what GDAL actually does. So the right truncation of the above mentioned fields should produce:
cod_provincia > cod_provin codice_istat > codice_ist cod_provincia_bis > cod_prov_1
#2 Updated by Antonio Falciano over 9 years ago
- % Done changed from 0 to 100
- Assignee set to Joaquín del Cerro Murciano
- File ExporttoShapeService.patch added
I attach a patch that implements the GDAL truncation method when exporting to shp, like explained in its comments:
/* * GDAL field name truncation method (extended from 100 to 255) * THISISAVERYLONGNAME => THISISAVER, THISISAV_1 ... THISISAV_9, * THISISAV10 ... THISISAV99, THISISA100 ... THISISA255 * (255 = max number of fields in a SHP) */
See also #2672.
#3 Updated by Antonio Falciano over 9 years ago
- File ExporttoShapeService_final.patch added
Ops... After further tests, I've discovered an error with the final index (that was starting from 2 instead of 1) in the previous patch, so I attach a revised version of it. I'm sorry for the inconvenience.
#4 Updated by Antonio Falciano over 9 years ago
- File field_name_truncation_test.csv added
- File ExporttoShapeService_final2.patch added
I've discovered another error (two "=" were missing), sorry... Test cases are quite difficult to find (or to create), so I've made a CSV file (in attachment) to add as table, add as an event theme to a view and finally to export in order to verify how the field name truncation works.
#5 Updated by Álvaro Anguix over 9 years ago
- Has patch set to Yes
#6 Updated by Antonio Falciano over 9 years ago
- Target version set to 2.1.0-2259-rc3
#7 Updated by Joaquín del Cerro Murciano over 9 years ago
- Target version changed from 2.1.0-2259-rc3 to 2.1.0-2248-testing
- Status changed from New to Fixed
#8 Updated by Álvaro Anguix over 9 years ago
- Status changed from Fixed to Closed