I know how to compose a SqlGeometry
using SqlGeometryBuilder
, for example:
// using Microsoft.SqlServer.Types;
SqlGeometryBuilder geometryBuilder = new SqlGeometryBuilder();
geometryBuilder.SetSrid(…);
geometryBuilder.BeginGeometry(OpenGisGeometryType.Polygon);
geometryBuilder.BeginFigure(0, 0);
geometryBuilder.AddLine(…);
…
geometryBuilder.EndFigure();
geometryBuilder.EndGeometry();
SqlGeometry geometry = geometryBuilder.ConstructedGeometry;
Once a SqlGeometry
is built, it's pretty much an opaque object, and inspecting its constituent parts (e.g. the line segments its boundary is made up from, and those lines' end points) using the ST…
methods methods (STNumPoints
, STPointN
, STNumCurves
, STCurveN
, STBoundary
, etc.) feels a little cumbersome to me.
Is there something in Microsoft.SqlServer.Types
or the .NET Framework Class Library that is the logical opposite of SqlGeometryBuilder
, i.e. something that I could use to decompose a SqlGeometry
into its constituent parts? I imagine that what I am looking for might possibly make use of the visitor pattern.