Skip to content

Commit

Permalink
Fixed saving and loading multipoint geometry with only one point
Browse files Browse the repository at this point in the history
  • Loading branch information
gosimowi committed Aug 8, 2024
1 parent c5ff6c9 commit 1035839
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
13 changes: 10 additions & 3 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,9 @@ private GeometryCollection CreateCollection(GeometryFactory factory, int dim, in
}

break;

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

Expand Down Expand Up @@ -403,9 +410,9 @@ private MultiPoint CreateMultiPoint(GeometryFactory factory, int dim, int lrs, d
if (!(sOffset >= 1) || !(sOffset <= coords.Count))
throw new ArgumentException("ELEM_INFO STARTING_OFFSET " + sOffset +
" inconsistent with ORDINATES length " + coords.Count);
if (etype != SdoEType.Coordinate)
if (etype != SdoEType.Coordinate && etype != SdoEType.Multipoint)
throw new ArgumentException("ETYPE " + etype + " inconsistent with expected POINT");
if (!(interpretation > 1))
if (interpretation == 0)
{
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion src/NetTopologySuite.IO.Oracle/OracleGeometryWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ private static int ProcessMultiPoint(MultiPoint multiPoint, int dimension, List<
// just ProcessPoint for each point, since that would append to elemInfoList multiple
// times. instead, elemInfoList gets incremented just once. *shrugs*.
elemInfoList.Add(pos);
elemInfoList.Add((int)SdoEType.Coordinate);
elemInfoList.Add((int)SdoEType.Multipoint);
elemInfoList.Add(cnt);

for (int i = 0; i < cnt; i++)
Expand Down
1 change: 1 addition & 0 deletions src/NetTopologySuite.IO.Oracle/Sdo/SdoEType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ internal enum SdoEType
Coordinate = 1,
Line = 2,
Polygon = 3,
Multipoint = 4,

PolygonExterior = 1003,
PolygonInterior = 2003
Expand Down
2 changes: 2 additions & 0 deletions test/NetTopologySuite.IO.Oracle.Test/OracleTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ 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)]
Expand Down Expand Up @@ -82,6 +83,7 @@ public void BasicConversion(string wkt, int srid)
/// <param name="wkt"></param>
/// <param name="wktresult"></param>
/// <param name="srid"></param>
[TestCase("GEOMETRYCOLLECTION(MULTIPOINT(11 12))", "GEOMETRYCOLLECTION(MULTIPOINT(11 12))", - 1)]
[TestCase("GEOMETRYCOLLECTION(MULTIPOINT(11 12, 20 20))", "GEOMETRYCOLLECTION(MULTIPOINT(11 12, 20 20))", - 1)]
[TestCase("GEOMETRYCOLLECTION(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))))", "GEOMETRYCOLLECTION(POLYGON((10 10,20 10,20 20,10 20,10 10),(5 5,5 6,6 6,6 5,5 5)),POLYGON((10 10,20 10,20 20,20 10,10 10),(5 5,5 6,6 6,6 5,5 5)))", - 1)]
[TestCase("GEOMETRYCOLLECTION(MULTILINESTRING((10 10,20 10,20 20,10 20,10 10),(5 5,5 6,6 6,6 5,5 5)))", "GEOMETRYCOLLECTION(LINESTRING(10 10,20 10,20 20,10 20,10 10),LINESTRING(5 5,5 6,6 6,6 5,5 5))", -1)]
Expand Down

0 comments on commit 1035839

Please sign in to comment.