Dealing with null values in shapefile attributes (DBF files) is tricky. It is not very well defined. Also see
GEOT-3204 Closed QGis and OGR2OGR write out stars (*****) for null values. However, many other tools will put spaces (hex 20). The current DbaseFileReader will parse spaces as 0.0 (zero). Which makes it impossible to distinguish the null value from a real zero value. See lines 581-583: https://github.com/geotools/geotools/blob/master/modules/plugin/shapefile/src/main/java/org/geotools/data/shapefile/dbf/DbaseFileReader.java#L581 I believe a better solution would be to return unparsable data as null instead of a rather arbitrary zero. That or throw an exception. Attached is a simple test case with 4 different records. One contains a value, another zero, another stars and the final one contains spaces. I can submit a pull request to fix this if this is accepted. |