NetTopologySuite/NetTopologySuite.IO.Esri

Error processing numeric fields in scientific notation with `DbfNumericDecimalField`

Closed this issue · 0 comments

Description:

I am encountering an issue while using the NetTopologySuite.IO.Esri library to read shapefiles that contain numeric fields in scientific notation. The library fails to convert these values to the decimal type due to the string formatting.

Problem Details:

When processing numeric fields with values like "9.095630227029324e-05 ", the current method decimal.Parse(s, CultureInfo.InvariantCulture) cannot correctly interpret the string due to the scientific notation (e). This results in the following exception:

Relevant Code:

Here is an example of code that triggers the error:

string numericString = "9.095630227029324e-05           ";
decimal decimalValue = decimal.Parse(numericString, System.Globalization.CultureInfo.InvariantCulture);

Suggested Solution:

The decimal.Parse method should be used with NumberStyles.Float to support scientific notation. The corrected code would be:

decimal decimalValue = decimal.Parse(numericString, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture);

Affected Class:

The issue occurs in the DbfNumericDecimalField class in the NetTopologySuite.IO.Esri.Dbf.Fields namespace.