Skip to content

Commit

Permalink
Merge pull request #58 from DiegoNetoMartins/develop
Browse files Browse the repository at this point in the history
Fix decimal parsing issue for scientific notation in `DbfNumericDecimalField` (#57)
  • Loading branch information
KubaSzostak authored Sep 7, 2024
2 parents c43e9fc + d1f50ed commit 9799852
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public DbfNumericDecimalField(string name) : this(name, MaxFieldLength, MaxField
/// <inheritdoc/>
protected override decimal StringToNumber(string s)
{
return decimal.Parse(s, CultureInfo.InvariantCulture);
return decimal.Parse(s, NumberStyles.Float, CultureInfo.InvariantCulture);
}
}
}
30 changes: 30 additions & 0 deletions test/NetTopologySuite.IO.Esri.Test/Issues/Issue057.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using NetTopologySuite.IO.Esri.Shapefiles.Readers;
using NUnit.Framework;

namespace NetTopologySuite.IO.Esri.Test.Issues;

/// <summary>
/// https://github.com/NetTopologySuite/NetTopologySuite.IO.Esri/issues/57
/// </summary>
internal class Issue057
{
[Test]
public void Decimal0_OpenShapefile()
{
var shpPath = TestShapefiles.PathTo("Issues/057/deter-nf-deter-public.shp");
var options = new ShapefileReaderOptions
{
GeometryBuilderMode = GeometryBuilderMode.FixInvalidShapes
};
using var shpReader = Shapefile.OpenRead(shpPath, options);

Assert.AreEqual(shpReader.ShapeType, ShapeType.Polygon);

while (shpReader.Read())
{
var dosis = shpReader.Fields["AREA_KM"].Value.ToString();
Assert.IsNotEmpty(dosis);
Assert.IsFalse(shpReader.Geometry.IsEmpty);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
UTF-8
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GEOGCS["SIRGAS 2000",DATUM["Sistema_de_Referencia_Geocentrico_para_las_AmericaS_2000",SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6674"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4674"]]
Binary file not shown.
Binary file not shown.

0 comments on commit 9799852

Please sign in to comment.