Make shapefile reader tolerant to inconsistent shapefiles where deleted records are only marked in DBF files
Description
Environment
Attachments
Activity
Mass transitioning all resolved issues that have not been updated in the last month to closed state
CodeHaus Comment From: aaime - Time: Fri, 3 Jan 2014 12:21:01 -0600
---------------------
Had a look, the file is certainly corrupt, but some software manages to read it anyways. The situation is as follows:
the file header says there are 26 features
the shx file contains 26 features
however, if one bothers to check, the dbf file has four records marked as deleted
So, the file is inconsistent, the shp header and the shx should also consider the deleted features, but they don't. Anyways, since some software manages to read this file, we'll have a look at trying to read it properly anyways. But, if the caller just asks for the total feature count, 26 will still be returned, just like ogrinfo does for example:
ogrinfo -al -so /tmp/IN_ForcedFeederCables.shp
INFO: Open of `/tmp/IN_ForcedFeederCables.shp'
using driver `ESRI Shapefile' successful.
Layer name: IN_ForcedFeederCables
Geometry: Line String
Feature Count: 26
Extent: (202928.872442, 476264.238032) - (210902.717362, 482301.424681)
Layer SRS WKT:
GEOGCS["GCS_WGS_1984",
DATUM["WGS_1984",
SPHEROID["WGS_84",6378137,298.257223563]],
PRIMEM["Greenwich",0],
UNIT["Degree",0.017453292519943295]]
CABLEGRAN: Integer (4.0)
However, ogrinfo returns only 22 features if it is asked to dump all features, so it is taking into account the deletion flag when reading the dbf.
CodeHaus Comment From: dieterdp - Time: Tue, 20 Aug 2013 07:38:32 -0500
---------------------
Removing the .qix makes no difference.
Tried with 10-RC1, and it also reports 26 features.
Some background: I encountered this bug when using version 8.1, which did read 22 features, but not the correct ones (the invalid ones were being read, and valid ones were not). The difference between versions, and the fact that QGis reports 22 features, made me believe this to be a bug in GeoTools.
CodeHaus Comment From: aaime - Time: Tue, 20 Aug 2013 07:14:45 -0500
---------------------
Also, the shapefile reader got almost completely rewritten for the 10.x series, and the 9.x series is officially closed now, there won't be any more release. Can you try 10-RC1?
CodeHaus Comment From: aaime - Time: Tue, 20 Aug 2013 07:13:52 -0500
---------------------
Just to be sure, have you tried removing the .qix file and trying again?
Geotools incorrectly reads 26 features from the attached shapefile. This should be 22 features.
I presume the additional features are previously deleted entries in the shapefile, though I cannot be sure as I received this shapefile from an external party.