C# sample with IGeometryServer2.cut

345
2
07-25-2011 05:30 AM
GuillaumeMOCCAND
New Contributor III
Dear all,

Does anyone has a sample code in C# for IGeometryServer2.cut(...) ?

Thanks in advance.

Guillaume
0 Kudos
2 Replies
SebastianKrings
Occasional Contributor
I am also interested in it.
0 Kudos
JohnHauck
Occasional Contributor II
What part of this is tripping things up from your tests? Here is a simple example that I hope will help get the ball rolling:

object beforeAfter = Type.Missing;

ISpatialReference sr = CreateHighPrecisionSpatialReference(4326,false,false);

IPointCollection pc = new PolylineClass();
pc.AddPoint(new PointClass() { X = 0, Y = 0, SpatialReference = sr }, beforeAfter, beforeAfter);
pc.AddPoint(new PointClass() { X = 10, Y = 10, SpatialReference = sr }, beforeAfter, beforeAfter);
IPolyline polyline1 = (IPolyline)pc;

IPointCollection pc2 = new PolylineClass();
pc2.AddPoint(new PointClass() { X = -5, Y = 5, SpatialReference = sr }, beforeAfter, beforeAfter);
pc2.AddPoint(new PointClass() { X = 5, Y = 5, SpatialReference = sr }, beforeAfter, beforeAfter);
IPolyline polyline2 = (IPolyline)pc2;

if (((ITopologicalOperator)pc).IsSimple)
{
    ILongArray la;

    IGeometryArray targetArray = new GeometryArrayClass();
    targetArray.Add(polyline1);

    IGeometryServer2 geomServer = new GeometryServerClass();
    IGeometryArray outGeomArray = geomServer.Cut(sr, targetArray, polyline2, out la);
}
0 Kudos