Exemple #1
0
        public static void TestPolygon9(com.epl.geometry.SpatialReference spatialReference)
        {
            com.epl.geometry.OperatorFactoryLocal engine = com.epl.geometry.OperatorFactoryLocal.GetInstance();
            com.epl.geometry.OperatorCut          opCut  = (com.epl.geometry.OperatorCut)engine.GetOperator(com.epl.geometry.Operator.Type.Cut);
            com.epl.geometry.Polygon cut;
            int    path_count;
            int    point_count;
            double area;

            com.epl.geometry.Polygon        polygon9 = MakePolygon9();
            com.epl.geometry.Polyline       cutter9  = MakePolygonCutter9();
            com.epl.geometry.GeometryCursor cursor   = opCut.Execute(false, polygon9, cutter9, spatialReference, null);
            cut         = (com.epl.geometry.Polygon)cursor.Next();
            path_count  = cut.GetPathCount();
            point_count = cut.GetPointCount();
            area        = cut.CalculateArea2D();
            NUnit.Framework.Assert.IsTrue(path_count == 3);
            NUnit.Framework.Assert.IsTrue(point_count == 12);
            NUnit.Framework.Assert.IsTrue(area == 150);
            cut         = (com.epl.geometry.Polygon)cursor.Next();
            path_count  = cut.GetPathCount();
            point_count = cut.GetPointCount();
            area        = cut.CalculateArea2D();
            NUnit.Framework.Assert.IsTrue(path_count == 3);
            NUnit.Framework.Assert.IsTrue(point_count == 12);
            NUnit.Framework.Assert.IsTrue(area == 150);
            cut = (com.epl.geometry.Polygon)cursor.Next();
            NUnit.Framework.Assert.IsTrue(cut == null);
        }
Exemple #2
0
        public static void TestConsiderTouch2(com.epl.geometry.SpatialReference spatialReference)
        {
            com.epl.geometry.OperatorFactoryLocal engine    = com.epl.geometry.OperatorFactoryLocal.GetInstance();
            com.epl.geometry.OperatorCut          opCut     = (com.epl.geometry.OperatorCut)engine.GetOperator(com.epl.geometry.Operator.Type.Cut);
            com.epl.geometry.Polyline             polyline2 = MakePolyline2();
            com.epl.geometry.Polyline             cutter2   = MakePolylineCutter2();
            com.epl.geometry.GeometryCursor       cursor    = opCut.Execute(true, polyline2, cutter2, spatialReference, null);
            com.epl.geometry.Polyline             cut;
            int    pathCount;
            int    segmentCount;
            double length;

            cut          = (com.epl.geometry.Polyline)cursor.Next();
            pathCount    = cut.GetPathCount();
            segmentCount = cut.GetSegmentCount();
            length       = cut.CalculateLength2D();
            NUnit.Framework.Assert.IsTrue(pathCount == 4);
            NUnit.Framework.Assert.IsTrue(segmentCount == 4);
            NUnit.Framework.Assert.IsTrue(System.Math.Abs(length - 5.74264068) <= 0.001);
            cut          = (com.epl.geometry.Polyline)cursor.Next();
            pathCount    = cut.GetPathCount();
            segmentCount = cut.GetSegmentCount();
            length       = cut.CalculateLength2D();
            NUnit.Framework.Assert.IsTrue(pathCount == 6);
            NUnit.Framework.Assert.IsTrue(segmentCount == 8);
            NUnit.Framework.Assert.IsTrue(length == 6.75);
            cut          = (com.epl.geometry.Polyline)cursor.Next();
            pathCount    = cut.GetPathCount();
            segmentCount = cut.GetSegmentCount();
            length       = cut.CalculateLength2D();
            NUnit.Framework.Assert.IsTrue(pathCount == 1);
            NUnit.Framework.Assert.IsTrue(segmentCount == 1);
            NUnit.Framework.Assert.IsTrue(System.Math.Abs(length - 0.5) <= 0.001);
            cut          = (com.epl.geometry.Polyline)cursor.Next();
            pathCount    = cut.GetPathCount();
            segmentCount = cut.GetSegmentCount();
            length       = cut.CalculateLength2D();
            NUnit.Framework.Assert.IsTrue(pathCount == 1);
            NUnit.Framework.Assert.IsTrue(segmentCount == 1);
            NUnit.Framework.Assert.IsTrue(System.Math.Abs(length - 0.25) <= 0.001);
            cut          = (com.epl.geometry.Polyline)cursor.Next();
            pathCount    = cut.GetPathCount();
            segmentCount = cut.GetSegmentCount();
            length       = cut.CalculateLength2D();
            NUnit.Framework.Assert.IsTrue(pathCount == 1);
            NUnit.Framework.Assert.IsTrue(segmentCount == 1);
            NUnit.Framework.Assert.IsTrue(System.Math.Abs(length - 1) <= 0.001);
            cut          = (com.epl.geometry.Polyline)cursor.Next();
            pathCount    = cut.GetPathCount();
            segmentCount = cut.GetSegmentCount();
            length       = cut.CalculateLength2D();
            NUnit.Framework.Assert.IsTrue(pathCount == 1);
            NUnit.Framework.Assert.IsTrue(segmentCount == 1);
            NUnit.Framework.Assert.IsTrue(System.Math.Abs(length - 1.41421356) <= 0.001);
            cut = (com.epl.geometry.Polyline)cursor.Next();
            NUnit.Framework.Assert.IsTrue(cut == null);
        }
Exemple #3
0
        public static void TestConsiderTouch1(com.epl.geometry.SpatialReference spatialReference)
        {
            com.epl.geometry.OperatorFactoryLocal engine    = com.epl.geometry.OperatorFactoryLocal.GetInstance();
            com.epl.geometry.OperatorCut          opCut     = (com.epl.geometry.OperatorCut)engine.GetOperator(com.epl.geometry.Operator.Type.Cut);
            com.epl.geometry.Polyline             polyline1 = MakePolyline1();
            com.epl.geometry.Polyline             cutter1   = MakePolylineCutter1();
            com.epl.geometry.GeometryCursor       cursor    = opCut.Execute(true, polyline1, cutter1, spatialReference, null);
            com.epl.geometry.Polyline             cut;
            int    pathCount;
            int    segmentCount;
            double length;

            cut          = (com.epl.geometry.Polyline)cursor.Next();
            pathCount    = cut.GetPathCount();
            segmentCount = cut.GetSegmentCount();
            length       = cut.CalculateLength2D();
            NUnit.Framework.Assert.IsTrue(pathCount == 4);
            NUnit.Framework.Assert.IsTrue(segmentCount == 4);
            NUnit.Framework.Assert.IsTrue(length == 6);
            cut          = (com.epl.geometry.Polyline)cursor.Next();
            pathCount    = cut.GetPathCount();
            segmentCount = cut.GetSegmentCount();
            length       = cut.CalculateLength2D();
            NUnit.Framework.Assert.IsTrue(pathCount == 6);
            NUnit.Framework.Assert.IsTrue(segmentCount == 8);
            NUnit.Framework.Assert.IsTrue(length == 12);
            cut          = (com.epl.geometry.Polyline)cursor.Next();
            pathCount    = cut.GetPathCount();
            segmentCount = cut.GetSegmentCount();
            length       = cut.CalculateLength2D();
            NUnit.Framework.Assert.IsTrue(pathCount == 1);
            NUnit.Framework.Assert.IsTrue(segmentCount == 1);
            NUnit.Framework.Assert.IsTrue(length == 1);
            cut          = (com.epl.geometry.Polyline)cursor.Next();
            pathCount    = cut.GetPathCount();
            segmentCount = cut.GetSegmentCount();
            length       = cut.CalculateLength2D();
            NUnit.Framework.Assert.IsTrue(pathCount == 1);
            NUnit.Framework.Assert.IsTrue(segmentCount == 1);
            NUnit.Framework.Assert.IsTrue(length == 1);
            cut = (com.epl.geometry.Polyline)cursor.Next();
            NUnit.Framework.Assert.IsTrue(cut == null);
        }
Exemple #4
0
 /// <summary>Calculates the cut geometry from a target geometry using a polyline.</summary>
 /// <remarks>
 /// Calculates the cut geometry from a target geometry using a polyline. For
 /// Polylines, all left cuts will be grouped together in the first Geometry,
 /// Right cuts and coincident cuts are grouped in the second Geometry, and
 /// each undefined cut, along with any uncut parts, are output as separate
 /// Polylines. For Polygons, all left cuts are grouped in the first Polygon,
 /// all right cuts are in the second Polygon, and each undefined cut, along
 /// with any left-over parts after cutting, are output as a separate Polygon.
 /// If there were no cuts then the array will be empty. An undefined cut will
 /// only be produced if a left cut or right cut was produced, and there was a
 /// part left over after cutting or a cut is bounded to the left and right of
 /// the cutter.
 /// See OperatorCut.
 /// </remarks>
 /// <param name="cuttee">The geometry to be cut.</param>
 /// <param name="cutter">The polyline to cut the geometry.</param>
 /// <param name="spatialReference">The spatial reference of the geometries.</param>
 /// <returns>An array of geometries created from cutting.</returns>
 public static com.epl.geometry.Geometry[] Cut(com.epl.geometry.Geometry cuttee, com.epl.geometry.Polyline cutter, com.epl.geometry.SpatialReference spatialReference)
 {
     if (cuttee == null || cutter == null)
     {
         return(null);
     }
     com.epl.geometry.OperatorCut    op     = (com.epl.geometry.OperatorCut)factory.GetOperator(com.epl.geometry.Operator.Type.Cut);
     com.epl.geometry.GeometryCursor cursor = op.Execute(true, cuttee, cutter, spatialReference, null);
     System.Collections.Generic.List <com.epl.geometry.Geometry> cutsList = new System.Collections.Generic.List <com.epl.geometry.Geometry>();
     com.epl.geometry.Geometry geometry;
     while ((geometry = cursor.Next()) != null)
     {
         if (!geometry.IsEmpty())
         {
             cutsList.Add(geometry);
         }
     }
     return(cutsList.ToArray());
 }