NetTopologySuite/NetTopologySuite.IO.Esri

Allow DbfCharacterField support 255 length.

Closed this issue · 3 comments

jp-rl commented

Hi!

Sometimes, character fields in dbf file (inside ShapeFile) has 255 chars length. This one generates error during reading.

a posible solution:

--- a/src/NetTopologySuite.IO.Esri.Shapefile/Dbf/Fields/DbfCharacterField.cs
+++ b/src/NetTopologySuite.IO.Esri.Shapefile/Dbf/Fields/DbfCharacterField.cs
@@ -22,7 +22,7 @@ public DbfCharacterField(string name, int length = MaxFieldLength) : this(name,
}

     internal DbfCharacterField(string name, int length, Encoding encoding)
  •        : base(name, DbfType.Character, Math.Min(length, MaxFieldLength), 0)
    
  •        : base(name, DbfType.Character, Math.Min(length, MaxFieldLength+1), 0)
       {
           _encoding = encoding;
       }
    

TIA,
regards

Thank you @jp-rl for submitting this issue. Unfortunately, we are unable to investigate further without additional information. Can you provide sample shapefile or sample code that causes the error?

Hi @KubaSzostak, I have uploaded a file so you can investigate...
thank you,

Line.zip

According to dBASE documentation the limit of character fields is 254. The same limit is stated in Esri documentation. The shapefile you provided contains character fields of 255 length. Nevertheless, I will adjust the code, so it properly handle 255 characters even though it's not compliant with the specification.