Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix decimal parsing issue for scientific notation in DbfNumericDecimalField (#57) #58

Merged
merged 2 commits into from
Sep 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Loading