2 Replies Latest reply on Jul 26, 2011 10:59 AM by jhauck-esristaff

    C# sample with IGeometryServer2.cut

    moccand78
      Dear all,

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

      Thanks in advance.

      Guillaume
        • Re: C# sample with IGeometryServer2.cut
          kaspatoo
          I am also interested in it.
          • Re: C# sample with IGeometryServer2.cut
            jhauck-esristaff
            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);
            }