NetTopologySuite / NetTopologySuite.IO.ShapeFile

The ShapeFile IO module for NTS.
33 stars 25 forks source link

Inconsistency determining and writing Int32 in the DBaseFileHeader #56

Closed kristofdegrave closed 3 years ago

kristofdegrave commented 3 years ago

In the DBaseFileHeader, we determine with the following logic if the Type is an Int32 or Int64:

https://github.com/NetTopologySuite/NetTopologySuite.IO.ShapeFile/blob/c0819c1cfbf8c52146a0004e0e7b3a2b48044d98/src/NetTopologySuite.IO.ShapeFile/Dbase/DbaseFieldDescriptor.cs#L176-L184

If we create a Header based on a feature, the following logic is used: https://github.com/NetTopologySuite/NetTopologySuite.IO.ShapeFile/blob/c0819c1cfbf8c52146a0004e0e7b3a2b48044d98/src/NetTopologySuite.IO.ShapeFile/Dbase/DbaseFieldDescriptor.cs#L176-L184 With the following values: https://github.com/NetTopologySuite/NetTopologySuite.IO.ShapeFile/blob/c0819c1cfbf8c52146a0004e0e7b3a2b48044d98/src/NetTopologySuite.IO.ShapeFile/ShapefileDataWriter.cs#L97-L101

This means an Int32 is defined with a length of 10 when writting. If you would read this header again, using the DBaseFieldDescriptor logic, it would be turn into an Int64 instead of an Int32.

airbreather commented 3 years ago

Fixed with #59. Thanks!