public virtual void TestUnionTickTock() { com.esri.core.geometry.Polygon poly1 = new com.esri.core.geometry.Polygon(); poly1.StartPath(0, 0); poly1.LineTo(0, 10); poly1.LineTo(10, 10); poly1.LineTo(10, 0); com.esri.core.geometry.Polygon poly2 = new com.esri.core.geometry.Polygon(); poly2.StartPath(10.5, 4); poly2.LineTo(10.5, 8); poly2.LineTo(14, 10); com.esri.core.geometry.Transformation2D trans = new com.esri.core.geometry.Transformation2D(); com.esri.core.geometry.Polygon poly3 = (com.esri.core.geometry.Polygon)poly1.Copy(); trans.SetShift(2, 3); poly3.ApplyTransformation(trans); com.esri.core.geometry.Polygon poly4 = (com.esri.core.geometry.Polygon)poly1.Copy(); trans.SetShift(-2, -3); poly4.ApplyTransformation(trans); // Create com.esri.core.geometry.ListeningGeometryCursor gc = new com.esri.core.geometry.ListeningGeometryCursor(); com.esri.core.geometry.GeometryCursor ticktock = com.esri.core.geometry.OperatorUnion.Local().Execute(gc, null, null); // Use tick-tock to push a geometry and do a piece of work. gc.Tick(poly1); ticktock.Tock(); gc.Tick(poly2); gc.Tick(poly3); // skiped one tock just for testing. ticktock.Tock(); gc.Tick(poly4); ticktock.Tock(); // Get the result com.esri.core.geometry.Geometry result = ticktock.Next(); // Use ListeningGeometryCursor to put all geometries in. com.esri.core.geometry.ListeningGeometryCursor gc2 = new com.esri.core.geometry.ListeningGeometryCursor(); gc2.Tick(poly1); gc2.Tick(poly2); gc2.Tick(poly3); gc2.Tick(poly4); com.esri.core.geometry.GeometryCursor res = com.esri.core.geometry.OperatorUnion.Local().Execute(gc2, null, null); // Calling next will process all geometries at once. com.esri.core.geometry.Geometry result2 = res.Next(); NUnit.Framework.Assert.IsTrue(result.Equals(result2)); }
public virtual void TestHullTickTock() { com.esri.core.geometry.Polygon geom1 = new com.esri.core.geometry.Polygon(); com.esri.core.geometry.Polygon geom2 = new com.esri.core.geometry.Polygon(); com.esri.core.geometry.Point geom3 = new com.esri.core.geometry.Point(); com.esri.core.geometry.Line geom4 = new com.esri.core.geometry.Line(); com.esri.core.geometry.Envelope geom5 = new com.esri.core.geometry.Envelope(); com.esri.core.geometry.MultiPoint geom6 = new com.esri.core.geometry.MultiPoint(); // polygon geom1.StartPath(0, 0); geom1.LineTo(0, 0); geom1.LineTo(5, 11); geom1.LineTo(5, 11); geom1.LineTo(10, 0); geom1.LineTo(10, 0); // polygon geom2.StartPath(0, 5); geom2.LineTo(0, 5); geom2.LineTo(10, 5); geom2.LineTo(10, 5); geom2.LineTo(5, -5); geom2.LineTo(5, -5); // point geom3.SetXY(15, 1.25); // segment geom4.SetEndXY(-5, 1.25); geom4.SetStartXY(0, 0); // envelope geom5.SetCoords(0, 0, 5, 10); // multi_point geom6.Add(10, 5); geom6.Add(10, 10); // Create com.esri.core.geometry.ListeningGeometryCursor gc = new com.esri.core.geometry.ListeningGeometryCursor(); com.esri.core.geometry.GeometryCursor ticktock = com.esri.core.geometry.OperatorConvexHull.Local().Execute(gc, true, null); // Use tick-tock to push a geometry and do a piece of work. gc.Tick(geom1); ticktock.Tock(); gc.Tick(geom2); ticktock.Tock(); gc.Tick(geom3); // skiped one tock just for testing. ticktock.Tock(); gc.Tick(geom4); ticktock.Tock(); gc.Tick(geom5); ticktock.Tock(); gc.Tick(geom6); ticktock.Tock(); // Get the result com.esri.core.geometry.Geometry result = ticktock.Next(); com.esri.core.geometry.Polygon convex_hull = (com.esri.core.geometry.Polygon)result; NUnit.Framework.Assert.IsTrue(com.esri.core.geometry.OperatorConvexHull.Local().IsConvex(convex_hull, null)); com.esri.core.geometry.Point2D p1 = convex_hull.GetXY(0); com.esri.core.geometry.Point2D p2 = convex_hull.GetXY(1); com.esri.core.geometry.Point2D p3 = convex_hull.GetXY(2); com.esri.core.geometry.Point2D p4 = convex_hull.GetXY(3); com.esri.core.geometry.Point2D p5 = convex_hull.GetXY(4); com.esri.core.geometry.Point2D p6 = convex_hull.GetXY(5); NUnit.Framework.Assert.IsTrue(p1.x == 5.0 && p1.y == 11.0); NUnit.Framework.Assert.IsTrue(p2.x == 10.0 && p2.y == 10); NUnit.Framework.Assert.IsTrue(p3.x == 15.0 && p3.y == 1.25); NUnit.Framework.Assert.IsTrue(p4.x == 5.0 && p4.y == -5.0); NUnit.Framework.Assert.IsTrue(p5.x == -5.0 && p5.y == 1.25); NUnit.Framework.Assert.IsTrue(p6.x == 0.0 && p6.y == 10.0); }