public virtual void TestInsertPointsFromArray() { { // Test forward insertion of an array of Point2D // ArrayOf(Point2D) arr = new ArrayOf(Point2D)(5); // arr[0].SetCoords(10, 1); // arr[1].SetCoords(15, 20); // arr[2].SetCoords(300, 14); // arr[3].SetCoords(314, 217); // arr[4].SetCoords(60, 144); com.esri.core.geometry.Polygon poly1 = new com.esri.core.geometry.Polygon(); poly1.StartPath(1, 17); poly1.LineTo(1, 207); poly1.LineTo(3, 147); poly1.LineTo(6, 1447); poly1.StartPath(1000, 17); poly1.LineTo(1250, 207); poly1.LineTo(300, 147); poly1.LineTo(6000, 1447); NUnit.Framework.Assert.IsTrue(poly1.GetPathCount() == 2); NUnit.Framework.Assert.IsTrue(poly1.GetPathStart(1) == 4); NUnit.Framework.Assert.IsTrue(poly1.IsClosedPath(0)); NUnit.Framework.Assert.IsTrue(poly1.IsClosedPath(1)); } { } }
public virtual void TestInsertPoints() { { // forward insertion com.esri.core.geometry.Polygon poly = new com.esri.core.geometry.Polygon(); poly.StartPath(10, 1); poly.LineTo(15, 20); poly.LineTo(30, 14); poly.LineTo(60, 144); poly.StartPath(10, 1); poly.LineTo(15, 20); poly.LineTo(300, 14); poly.LineTo(314, 217); poly.LineTo(60, 144); poly.StartPath(10, 1); poly.LineTo(125, 20); poly.LineTo(30, 14); poly.LineTo(600, 144); com.esri.core.geometry.Polygon poly1 = new com.esri.core.geometry.Polygon(); poly1.StartPath(1, 17); poly1.LineTo(1, 207); poly1.LineTo(3, 147); poly1.LineTo(6, 1447); poly1.StartPath(1000, 17); poly1.LineTo(1250, 207); poly1.LineTo(300, 147); poly1.LineTo(6000, 1447); poly1.InsertPoints(1, 2, poly, 1, 1, 3, true); // forward NUnit.Framework.Assert.IsTrue(poly1.GetPathCount() == 2); NUnit.Framework.Assert.IsTrue(poly1.GetPathStart(1) == 4); NUnit.Framework.Assert.IsTrue(poly1.IsClosedPath(0)); NUnit.Framework.Assert.IsTrue(poly1.IsClosedPath(1)); NUnit.Framework.Assert.IsTrue(poly1.GetPointCount() == 11); NUnit.Framework.Assert.IsTrue(poly1.GetPathSize(1) == 7); } { // Point2D ptOut; // ptOut = poly1.getXY(5); // assertTrue(ptOut.x == 1250 && ptOut.y == 207); // ptOut = poly1.getXY(6); // assertTrue(ptOut.x == 15 && ptOut.y == 20); // ptOut = poly1.getXY(7); // assertTrue(ptOut.x == 300 && ptOut.y == 14); // ptOut = poly1.getXY(8); // assertTrue(ptOut.x == 314 && ptOut.y == 217); // ptOut = poly1.getXY(9); // assertTrue(ptOut.x == 300 && ptOut.y == 147); // ptOut = poly1.getXY(10); // assertTrue(ptOut.x == 6000 && ptOut.y == 1447); // reverse insertion com.esri.core.geometry.Polygon poly = new com.esri.core.geometry.Polygon(); poly.StartPath(10, 1); poly.LineTo(15, 20); poly.LineTo(30, 14); poly.LineTo(60, 144); poly.StartPath(10, 1); poly.LineTo(15, 20); poly.LineTo(300, 14); poly.LineTo(314, 217); poly.LineTo(60, 144); poly.StartPath(10, 1); poly.LineTo(125, 20); poly.LineTo(30, 14); poly.LineTo(600, 144); com.esri.core.geometry.Polygon poly1 = new com.esri.core.geometry.Polygon(); poly1.StartPath(1, 17); poly1.LineTo(1, 207); poly1.LineTo(3, 147); poly1.LineTo(6, 1447); poly1.StartPath(1000, 17); poly1.LineTo(1250, 207); poly1.LineTo(300, 147); poly1.LineTo(6000, 1447); poly1.InsertPoints(1, 2, poly, 1, 1, 3, false); // reverse NUnit.Framework.Assert.IsTrue(poly1.GetPathCount() == 2); NUnit.Framework.Assert.IsTrue(poly1.GetPathStart(1) == 4); NUnit.Framework.Assert.IsTrue(poly1.IsClosedPath(0)); NUnit.Framework.Assert.IsTrue(poly1.IsClosedPath(1)); NUnit.Framework.Assert.IsTrue(poly1.GetPointCount() == 11); NUnit.Framework.Assert.IsTrue(poly1.GetPathSize(1) == 7); } }
public virtual void TestInsertPath() { com.esri.core.geometry.Polygon poly = new com.esri.core.geometry.Polygon(); poly.StartPath(10, 1); poly.LineTo(15, 20); poly.LineTo(30, 14); poly.LineTo(60, 144); poly.StartPath(12, 2); poly.LineTo(16, 21); poly.LineTo(301, 15); poly.LineTo(61, 145); poly.StartPath(13, 3); poly.LineTo(126, 22); poly.LineTo(31, 16); poly.LineTo(601, 146); // poly.setAttribute(enum_value2(VertexDescription, Semantics, Z), 0, 0, // 2); // poly.setAttribute(enum_value2(VertexDescription, Semantics, Z), 1, 0, // 3); // poly.setAttribute(enum_value2(VertexDescription, Semantics, Z), 2, 0, // 5); // poly.setAttribute(enum_value2(VertexDescription, Semantics, Z), 3, 0, // 7); // poly.setAttribute(enum_value2(VertexDescription, Semantics, Z), 4, 0, // 11); // poly.setAttribute(enum_value2(VertexDescription, Semantics, Z), 5, 0, // 13); // poly.setAttribute(enum_value2(VertexDescription, Semantics, Z), 6, 0, // 17); // poly.setAttribute(enum_value2(VertexDescription, Semantics, Z), 7, 0, // 19); // poly.setAttribute(enum_value2(VertexDescription, Semantics, Z), 8, 0, // 23); // poly.setAttribute(enum_value2(VertexDescription, Semantics, Z), 9, 0, // 29); // poly.setAttribute(enum_value2(VertexDescription, Semantics, Z), 10, // 0, 31); // poly.setAttribute(enum_value2(VertexDescription, Semantics, Z), 11, // 0, 37); com.esri.core.geometry.Polygon poly2 = new com.esri.core.geometry.Polygon(); poly2.StartPath(12, 2); poly2.LineTo(16, 21); poly2.LineTo(301, 15); poly2.LineTo(61, 145); poly.InsertPath(0, poly2, 0, false); NUnit.Framework.Assert.IsTrue(poly.GetPathCount() == 4); NUnit.Framework.Assert.IsTrue(poly.GetPathStart(0) == 0); NUnit.Framework.Assert.IsTrue(poly.GetPathStart(1) == 4); NUnit.Framework.Assert.IsTrue(poly.GetPathStart(2) == 8); NUnit.Framework.Assert.IsTrue(poly.GetPathStart(3) == 12); NUnit.Framework.Assert.IsTrue(poly.GetPointCount() == 16); com.esri.core.geometry.Point2D pt0 = poly.GetXY(0); NUnit.Framework.Assert.IsTrue(pt0.x == 12 && pt0.y == 2); com.esri.core.geometry.Point2D pt1 = poly.GetXY(1); NUnit.Framework.Assert.IsTrue(pt1.x == 61 && pt1.y == 145); com.esri.core.geometry.Point2D pt2 = poly.GetXY(2); NUnit.Framework.Assert.IsTrue(pt2.x == 301 && pt2.y == 15); com.esri.core.geometry.Point2D pt3 = poly.GetXY(3); NUnit.Framework.Assert.IsTrue(pt3.x == 16 && pt3.y == 21); com.esri.core.geometry.Point pt2d = new com.esri.core.geometry.Point(-27, -27); poly.InsertPoint(1, 0, pt2d); NUnit.Framework.Assert.IsTrue(poly.GetPathCount() == 4); NUnit.Framework.Assert.IsTrue(poly.GetPathStart(0) == 0); NUnit.Framework.Assert.IsTrue(poly.GetPathStart(1) == 4); NUnit.Framework.Assert.IsTrue(poly.GetPathStart(2) == 9); NUnit.Framework.Assert.IsTrue(poly.GetPathStart(3) == 13); NUnit.Framework.Assert.IsTrue(poly.GetPointCount() == 17); }
public virtual void TestReversepath() { com.esri.core.geometry.Polygon poly = new com.esri.core.geometry.Polygon(); poly.StartPath(10, 1); poly.LineTo(15, 20); poly.LineTo(30, 14); poly.LineTo(60, 144); poly.StartPath(10, 1); poly.LineTo(15, 20); poly.LineTo(300, 14); poly.LineTo(60, 144); poly.StartPath(10, 1); poly.LineTo(125, 20); poly.LineTo(30, 14); poly.LineTo(600, 144); // poly.setAttribute(enum_value2(VertexDescription, Semantics, Z), 0, 0, // 2); // poly.setAttribute(enum_value2(VertexDescription, Semantics, Z), 1, 0, // 3); // poly.setAttribute(enum_value2(VertexDescription, Semantics, Z), 2, 0, // 5); // poly.setAttribute(enum_value2(VertexDescription, Semantics, Z), 3, 0, // 7); // poly.setAttribute(enum_value2(VertexDescription, Semantics, Z), 4, 0, // 11); // poly.setAttribute(enum_value2(VertexDescription, Semantics, Z), 5, 0, // 13); // poly.setAttribute(enum_value2(VertexDescription, Semantics, Z), 6, 0, // 17); // poly.setAttribute(enum_value2(VertexDescription, Semantics, Z), 7, 0, // 19); // poly.setAttribute(enum_value2(VertexDescription, Semantics, Z), 8, 0, // 23); // poly.setAttribute(enum_value2(VertexDescription, Semantics, Z), 9, 0, // 29); // poly.setAttribute(enum_value2(VertexDescription, Semantics, Z), 10, // 0, 31); // poly.setAttribute(enum_value2(VertexDescription, Semantics, Z), 11, // 0, 37); poly.ReversePath(1); NUnit.Framework.Assert.IsTrue(poly.GetPathCount() == 3); NUnit.Framework.Assert.IsTrue(poly.GetPathStart(1) == 4); NUnit.Framework.Assert.IsTrue(poly.IsClosedPath(0)); NUnit.Framework.Assert.IsTrue(poly.IsClosedPath(1)); com.esri.core.geometry.Point ptOut = poly.GetPoint(4); NUnit.Framework.Assert.IsTrue(ptOut.GetX() == 10 && ptOut.GetY() == 1); }
public virtual void TestRemovepath() { com.esri.core.geometry.Polygon poly = new com.esri.core.geometry.Polygon(); poly.StartPath(10, 1); poly.LineTo(15, 20); poly.LineTo(30, 14); poly.LineTo(60, 144); poly.StartPath(10, 1); poly.LineTo(15, 20); poly.LineTo(300, 14); poly.LineTo(60, 144); poly.StartPath(10, 1); poly.LineTo(125, 20); poly.LineTo(30, 14); poly.LineTo(600, 144); // poly->SetAttribute(enum_value2(VertexDescription, Semantics, Z), 0, // 0, 2); // poly->SetAttribute(enum_value2(VertexDescription, Semantics, Z), 1, // 0, 3); // poly->SetAttribute(enum_value2(VertexDescription, Semantics, Z), 2, // 0, 5); // poly->SetAttribute(enum_value2(VertexDescription, Semantics, Z), 3, // 0, 7); // poly->SetAttribute(enum_value2(VertexDescription, Semantics, Z), 4, // 0, 11); // poly->SetAttribute(enum_value2(VertexDescription, Semantics, Z), 5, // 0, 13); // poly->SetAttribute(enum_value2(VertexDescription, Semantics, Z), 6, // 0, 17); // poly->SetAttribute(enum_value2(VertexDescription, Semantics, Z), 7, // 0, 19); // poly->SetAttribute(enum_value2(VertexDescription, Semantics, Z), 8, // 0, 23); // poly->SetAttribute(enum_value2(VertexDescription, Semantics, Z), 9, // 0, 29); // poly->SetAttribute(enum_value2(VertexDescription, Semantics, Z), 10, // 0, 31); // poly->SetAttribute(enum_value2(VertexDescription, Semantics, Z), 11, // 0, 37); poly.RemovePath(1); NUnit.Framework.Assert.IsTrue(poly.GetPathCount() == 2); NUnit.Framework.Assert.IsTrue(poly.GetPathStart(1) == 4); NUnit.Framework.Assert.IsTrue(poly.IsClosedPath(0)); NUnit.Framework.Assert.IsTrue(poly.IsClosedPath(1)); com.esri.core.geometry.Point ptOut = poly.GetPoint(4); NUnit.Framework.Assert.IsTrue(ptOut.GetX() == 10 && ptOut.GetY() == 1); poly.RemovePath(0); poly.RemovePath(0); NUnit.Framework.Assert.IsTrue(poly.GetPathCount() == 0); com.esri.core.geometry.Polygon poly2 = new com.esri.core.geometry.Polygon(); poly2.StartPath(0, 0); poly2.LineTo(0, 10); poly2.LineTo(10, 10); poly2.StartPath(1, 1); poly2.LineTo(2, 2); poly2.RemovePath(0); // poly2->StartPath(0, 0); poly2.LineTo(0, 10); poly2.LineTo(10, 10); // Polygon polygon2 = new Polygon(); // polygon2.addPath(poly, -1, true); // polygon2.addPath(poly, -1, true); // polygon2.addPath(poly, -1, true); // assertTrue(polygon2.getPathCount() == 3); // polygon2.removePath(0); // polygon2.removePath(0); // polygon2.removePath(0); // assertTrue(polygon2.getPathCount() == 0); // polygon2.addPath(poly, -1, true); // Point point1 = new Point(); // Point point2 = new Point(); // point1.setX(0); // point1.setY(0); // point2.setX(0); // point2.setY(0); // polygon2.addPath(poly2, 0, true); // polygon2.removePath(0); // polygon2.insertPoint(0, 0, point1); // polygon2.insertPoint(0, 0, point2); // assertTrue(polygon2.getPathCount() == 1); // assertTrue(polygon2.getPointCount() == 2); com.esri.core.geometry.Polygon polygon3 = new com.esri.core.geometry.Polygon(); polygon3.StartPath(0, 0); polygon3.LineTo(0, 10); polygon3.LineTo(10, 10); double area = polygon3.CalculateArea2D(); polygon3.RemovePath(0); polygon3.StartPath(0, 0); polygon3.LineTo(0, 10); polygon3.LineTo(10, 10); area = polygon3.CalculateArea2D(); NUnit.Framework.Assert.IsTrue(area > 0.0); }
public virtual void TestAddpath() { com.esri.core.geometry.Polygon poly = new com.esri.core.geometry.Polygon(); poly.StartPath(10, 1); poly.LineTo(15, 20); poly.LineTo(30, 14); poly.LineTo(60, 144); poly.StartPath(10, 1); poly.LineTo(15, 20); poly.LineTo(300, 14); poly.LineTo(60, 144); poly.StartPath(10, 1); poly.LineTo(125, 20); poly.LineTo(30, 14); poly.LineTo(600, 144); com.esri.core.geometry.Polygon poly1 = new com.esri.core.geometry.Polygon(); poly1.AddPath(poly, 2, true); poly1.AddPath(poly, 0, true); NUnit.Framework.Assert.IsTrue(poly1.GetPathCount() == 2); NUnit.Framework.Assert.IsTrue(poly1.GetPathStart(1) == 4); NUnit.Framework.Assert.IsTrue(poly1.IsClosedPath(0)); NUnit.Framework.Assert.IsTrue(poly1.IsClosedPath(1)); com.esri.core.geometry.Point ptOut = poly1.GetPoint(6); NUnit.Framework.Assert.IsTrue(ptOut.GetX() == 30 && ptOut.GetY() == 14); }