Cannot read DBFs with deleteFlag
--------------------------------
Key: GEOT-3226
URL: http://jira.codehaus.org/browse/GEOT-3226
Project: GeoTools
Issue Type: Bug
Components: data shapefile
Affects Versions: 2.6.3
Reporter: Matthias Kretschmar
Assignee: Andrea Aime
Attachments: test.zip
When an DBF has an delete flag, the deleted row isn't skipped correctly.
DbaseFileReader.read() only skips if a deleted flag is found, but does not read
the end of the row. So the next pass does not read the following row, but the
current one with an offset of 1 bit.
I also checked the Version 2.7-M2 of DbaseFileReader and there are no changes
in the corresponding method.
An possible solution would be to change
final char deleted = (char) buffer.get();
if (deleted == '*') {
continue;
}
buffer.limit(buffer.position() + header.getRecordLength() - 1);
buffer.get(bytes); // SK: There is a side-effect here!!!
buffer.limit(buffer.capacity());
foundRecord = true;
to
final char deleted = (char) buffer.get();
if (deleted != '*') {
foundRecord = true;
}
buffer.limit(buffer.position() + header.getRecordLength() - 1);
buffer.get(bytes); // SK: There is a side-effect here!!!
buffer.limit(buffer.capacity());
Maybe there should also be checked if the variable cnt is correct. It seems,
that it is only incremented, when a not deleted row is read.But the function
hasNext() checks against the number of all rows (deleted and not -
header.getNumRecords()).
The attached JUnit Test has two test methods that check two dbffiles (one with
delete flag and one without)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel