Skip to content

Commit

Permalink
Fix IO of MultiPoint with single point (#16)
Browse files Browse the repository at this point in the history
* Fixed saving and loading multipoint geometry with only one point

* Code review fixes

closes #15

---------

Co-authored-by: Grzegorz Osimowicz <grzegorz.osimowicz@hexagon.com>
  • Loading branch information
gosimowicz and gosimowi authored Aug 27, 2024
1 parent c5ff6c9 commit 668dd7e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/NetTopologySuite.IO.Oracle/OracleGeometryReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ public Geometry Read(SdoGeometry geom)
var factory = _services.CreateGeometryFactory(srid);

var retVal = Create(factory, gType, point, geom.ElemArray, geom.OrdinatesArray);

if (retVal == null)
{
return null;
}
retVal.SRID = srid;

return retVal;
Expand Down Expand Up @@ -271,7 +276,6 @@ private GeometryCollection CreateCollection(GeometryFactory factory, int dim, in
}

break;

case SdoEType.Line:
geom = CreateLine(factory, dim, lrs, elemInfo, i, coords);

Expand Down Expand Up @@ -405,7 +409,7 @@ private MultiPoint CreateMultiPoint(GeometryFactory factory, int dim, int lrs, d
" inconsistent with ORDINATES length " + coords.Count);
if (etype != SdoEType.Coordinate)
throw new ArgumentException("ETYPE " + etype + " inconsistent with expected POINT");
if (!(interpretation > 1))
if (interpretation == 0)
{
return null;
}
Expand Down
4 changes: 3 additions & 1 deletion test/NetTopologySuite.IO.Oracle.Test/OracleTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,20 @@ public void CCWTestsOnPolygon()
[TestCase("POINT(10 10)", 4326)]
[TestCase("POINT Z(10 10 0)", -1)]
[TestCase("POINT Z(10 10 20)", -1)]
[TestCase("MULTIPOINT(11 12)", -1)]
[TestCase("MULTIPOINT(11 12, 20 20)", -1)]
[TestCase("MULTIPOINT Z(11 12 12, 20 20 20)", -1)]
[TestCase("LINESTRING(10 10,20 20,50 50,34 34)", -1)]
[TestCase("LINESTRING Z(10 10 20,20 20 20,50 50 50,34 34 34)", -1)]
[TestCase("POLYGON((10 10,20 10,20 20,10 20,10 10))", -1)]
[TestCase("POLYGON((10 10,20 10,20 20,10 20,10 10),(5 5,5 6,6 6,6 5,5 5))", -1)]
[TestCase("POLYGON Z((10 10 0,20 10 0,20 20 0,10 20 0,10 10 0),(5 5 0,5 6 0,6 6 0,6 5 0,5 5 0))", -1)]
[TestCase("MULTIPOLYGON(((10 10,20 10,20 20,20 10,10 10)))", -1)]
[TestCase("MULTIPOLYGON(((10 10,20 10,20 20,20 10,10 10)),((10 10,20 10,20 20,20 10,10 10)))", -1)]
[TestCase("MULTIPOLYGON(((10 10,20 10,20 20,10 20,10 10),(5 5,5 6,6 6,6 5,5 5)),((10 10,20 10,20 20,20 10,10 10)))", -1)]
[TestCase("MULTIPOLYGON(((10 10,20 10,20 20,10 20,10 10),(5 5,5 6,6 6,6 5,5 5)),((10 10,20 10,20 20,20 10,10 10),(5 5,5 6,6 6,6 5,5 5)))", -1)]
[TestCase("MULTIPOLYGON Z(((10 10 0,20 10 0,20 20 0,10 20 0,10 10 0),(5 5 0,5 6 0,6 6 0,6 5 0,5 5 0)),((10 10 0,20 10 0,20 20 0,20 10 0,10 10 0),(5 5 0,5 6 0,6 6 0,6 5 0,5 5 0)))", -1)]
[TestCase("MULTILINESTRING((10 10,20 10,20 20,20 10),(5 5,5 6,6 6,6 5))", -1)]
[TestCase("MULTILINESTRING((10 10,20 10,20 20,20 10))", -1)]
[TestCase("MULTILINESTRING((1 1, 2 1, 3 1), (1 2, 2 2, 3 2, 4 2), (1 3, 1 3, 3 3, 4 3))", -1)]
[TestCase("MULTILINESTRING((1 1, 2 1, 3 1), (1 2, 2 2, 3 2, 4 2), (1 3, 1 3, 3 3, 4 3),(1 5, 2 5, 3 5),(1 6, 2 6, 3 6, 4 6))", -1)]
[TestCase("MULTILINESTRING Z((10 10 5,20 10 5,20 20 0,20 10 0,10 10 0),(5 5 0,5 6 0,6 6 0,6 5 0,5 5 0))", -1)]
Expand Down

0 comments on commit 668dd7e

Please sign in to comment.