-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50 from NetTopologySuite/fix/issue049_handle_deci…
…mal_fields Handle decimal fields. Fix #49.
- Loading branch information
Showing
10 changed files
with
81 additions
and
3 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
src/NetTopologySuite.IO.Esri.Shapefile/Dbf/Fields/DbfNumericDecimalField.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Globalization; | ||
using System.Text; | ||
|
||
namespace NetTopologySuite.IO.Esri.Dbf.Fields | ||
{ | ||
/// <summary> | ||
/// Int64 field definition. | ||
/// </summary> | ||
public class DbfNumericDecimalField : DbfNumericField<decimal> | ||
{ | ||
/// <summary> | ||
/// Intializes new instance of the numerif field class. | ||
/// </summary> | ||
/// <param name="name">Field name.</param> | ||
/// <param name="length">The number of significant digits (including decimal separator).</param> | ||
/// <param name="precision">The number of fractional digits.</param> | ||
public DbfNumericDecimalField(string name, int length, int precision) | ||
: base(name, DbfType.Numeric, length, precision) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the field class. | ||
/// </summary> | ||
/// <param name="name">Field name.</param> | ||
public DbfNumericDecimalField(string name) : this(name, MaxFieldLength, MaxFieldPrecision) | ||
{ | ||
} | ||
|
||
/// <inheritdoc/> | ||
protected override decimal StringToNumber(string s) | ||
{ | ||
return decimal.Parse(s, CultureInfo.InvariantCulture); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/49 | ||
/// </summary> | ||
internal class Issue049 | ||
{ | ||
[Test] | ||
public void Decimal0_OpenShapefile() | ||
{ | ||
var shpPath = TestShapefiles.PathTo("Issues/049/221-1_28.03.202411-16.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["DOSIS"].Value.ToString(); | ||
Assert.IsNotEmpty(dosis); | ||
Assert.IsFalse(shpReader.Geometry.IsEmpty); | ||
} | ||
} | ||
} |
Binary file not shown.
1 change: 1 addition & 0 deletions
1
test/TestData/TestShapefiles/Issues/049/221-1_28.03.202411-16.prj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]] |
Binary file not shown.
Binary file not shown.