Hi, when I use the shapefile datastore to open up an existing shapefile with a number attribute including a decimal count, then add a feature and finally save, I find the definitions of number columns changed: I initially have a number attribute with a field length of 18 and a decimal count of 4. If I add a feature and then save this column definition gets changed to a field length of 18 and a decimal count of 15.
The reason is the static createDbaseHeader method in https://github.com/geotools/geotools/blob/master/modules/plugin/shapefile/src/main/java/org/geotools/data/shapefile/ShapefileDataStore.java, which is called everytima a Shapefile is written down (see constructor of ShapefileFeatureWriter: https://github.com/geotools/geotools/blob/master/modules/plugin/shapefile/src/main/java/org/geotools/data/shapefile/ShapefileFeatureWriter.java) . This method does a lot of magic and sets for double and float the decimal count to Math.min(Math.max(l - 2, 0), 15); where l is the field length cut at an upper bound. When creating the simple feature type on reading in shapefiles the decimal count is just ignored and fieldlength is set to the fieldlength (18 in my example). So the formula above would give a shrinking decimal at every save at a field length of 16 and below (-2 on each saving). Where does the -2 come from? As a general solution, not regarding fixing the formula above, I see two possibilities: - change the ShapefileFeatureWriter to just create a new Header if it is a new shapefile and use the old one if it is available - not loosing the decimal count on building the feature type (how are other formats doing this? As a user property?) and then use this value upon creating the new header Can you please provide some thoughts on the formula above and the solution of the general problem? Thank you, Hendrik Peilke ________________________________ IBYKUS AG f?r Informationstechnologie, Erfurt / HRB 108616 - D-Jena / Vorstand: Helmut C. Henkel, Dr. Lutz Richter, Eckehart Klingner Vorsitzender des Aufsichtsrates: Dr. Helmut Vorndran
_______________________________________________ GeoTools-Devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/geotools-devel
