Skip to content

Commit

Permalink
Add a better exception message for curved geometries (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
bricelam authored May 15, 2024
1 parent fbb5afb commit 4da3e7a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,7 @@
<data name="UnexpectedOgcGeometryType" xml:space="preserve">
<value>Unsupported type: {0}</value>
</data>
<data name="UnsupportedCurvedGeographyType" xml:space="preserve">
<value>Unsupported type: {0}. Geometries containing circular arc segments aren't supported. Consider using STCurveToLine in SQL to return a polygonal approximation instead.</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,11 @@ private Geometry ToGeometry(Geography geography)
geometries.Remove(shapeIndex);
break;

case OpenGisType.CircularString:
case OpenGisType.CompoundCurve:
case OpenGisType.CurvePolygon:
throw new ParseException(string.Format(Resources.UnsupportedCurvedGeographyType, shape.Type));

default:
throw new ParseException(string.Format(Resources.UnexpectedGeographyType, shape.Type));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public void Read_throws_when_circular_string()
var ex = Assert.Throws<ParseException>(
() => Read("0000000002040300000000000000000000000000000000000000000000000000F03F000000000000F03F0000000000000040000000000000000001000000020000000001000000FFFFFFFF0000000008"));

Assert.Equal(string.Format(Resources.UnexpectedGeographyType, "CircularString"), ex.Message);
Assert.Equal(string.Format(Resources.UnsupportedCurvedGeographyType, "CircularString"), ex.Message);
}

[Fact]
Expand All @@ -176,7 +176,7 @@ public void Read_throws_when_compound_curve()
var ex = Assert.Throws<ParseException>(
() => Read("0000000002040400000000000000000000000000000000000000000000000000F03F00000000000000000000000000000040000000000000F03F0000000000000840000000000000000001000000030000000001000000FFFFFFFF0000000009020000000203"));

Assert.Equal(string.Format(Resources.UnexpectedGeographyType, "CompoundCurve"), ex.Message);
Assert.Equal(string.Format(Resources.UnsupportedCurvedGeographyType, "CompoundCurve"), ex.Message);
}

[Fact]
Expand All @@ -185,7 +185,7 @@ public void Read_throws_when_curve_polygon()
var ex = Assert.Throws<ParseException>(
() => Read("000000000204050000000000000000000040000000000000F03F000000000000F03F00000000000000400000000000000000000000000000F03F000000000000F03F00000000000000000000000000000040000000000000F03F01000000020000000001000000FFFFFFFF000000000A"));

Assert.Equal(string.Format(Resources.UnexpectedGeographyType, "CurvePolygon"), ex.Message);
Assert.Equal(string.Format(Resources.UnsupportedCurvedGeographyType, "CurvePolygon"), ex.Message);
}

[Fact]
Expand Down

0 comments on commit 4da3e7a

Please sign in to comment.