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 TestCreation2() { com.esri.core.geometry.Polygon poly = new com.esri.core.geometry.Polygon(); int state1 = poly.GetStateFlag(); poly.StartPath(10, 1); poly.LineTo(15, 20); poly.LineTo(30, 14); poly.LineTo(60, 144); poly.ClosePathWithLine(); int state2 = poly.GetStateFlag(); NUnit.Framework.Assert.IsTrue(state2 == state1 + 1); // MultiPathImpl::Pointer mpImpl = // (MultiPathImpl::Pointer)poly->_GetImpl(); // // assertTrue(mpImpl.getPointCount() == 4); // assertTrue(mpImpl.getPathCount() == 1); // AttributeStreamBase xy = // mpImpl.getAttributeStreamRef(enum_value2(VertexDescription, // Semantics, POSITION)); // double x, y; // x = xy.readAsDbl(2 * 2); // y = xy.readAsDbl(2 * 2 + 1); // assertTrue(x == 30); assertTrue(y == 14); // // AttributeStreamOfIndexType parts = mpImpl.getPathStreamRef(); // assertTrue(parts.size() == 2); // assertTrue(parts.read(0) == 0); // assertTrue(parts.read(1) == 4); // assertTrue(mpImpl.isClosedPath(0)); // assertTrue(mpImpl.getSegmentFlagsStreamRef() == NULLPTR); // assertTrue(mpImpl.getSegmentIndexStreamRef() == NULLPTR); // assertTrue(mpImpl.getSegmentDataStreamRef() == NULLPTR); poly.StartPath(20, 13); poly.LineTo(150, 120); poly.LineTo(300, 414); poly.LineTo(610, 14); poly.LineTo(6210, 140); poly.ClosePathWithLine(); // assertTrue(mpImpl.getPointCount() == 9); // assertTrue(mpImpl.getPathCount() == 2); // assertTrue(mpImpl.isClosedPath(1)); // xy = mpImpl.getAttributeStreamRef(enum_value2(VertexDescription, // Semantics, POSITION)); // x = xy.readAsDbl(2 * 3); // y = xy.readAsDbl(2 * 3 + 1); // assertTrue(x == 60); assertTrue(y == 144); // // x = xy.readAsDbl(2 * 6); // y = xy.readAsDbl(2 * 6 + 1); // assertTrue(x == 300); assertTrue(y == 414); // parts = mpImpl.getPathStreamRef(); // assertTrue(parts.size() == 3); // assertTrue(parts.read(0) == 0); // assertTrue(parts.read(1) == 4); // assertTrue(parts.read(2) == 9); // assertTrue(mpImpl.getSegmentIndexStreamRef() == NULLPTR); // assertTrue(mpImpl.getSegmentFlagsStreamRef() == NULLPTR); // assertTrue(mpImpl.getSegmentDataStreamRef() == NULLPTR); poly.StartPath(200, 1333); poly.LineTo(1150, 1120); poly.LineTo(300, 4114); poly.LineTo(6110, 114); poly.LineTo(61210, 1140); NUnit.Framework.Assert.IsTrue(poly.IsClosedPath(2) == true); poly.CloseAllPaths(); NUnit.Framework.Assert.IsTrue(poly.IsClosedPath(2) == true); { com.esri.core.geometry.Polygon poly2 = new com.esri.core.geometry.Polygon(); poly2.StartPath(10, 10); poly2.LineTo(100, 10); poly2.LineTo(100, 100); poly2.LineTo(10, 100); } { com.esri.core.geometry.Polygon poly3 = new com.esri.core.geometry.Polygon(); // create a star (non-simple) poly3.StartPath(1, 0); poly3.LineTo(5, 10); poly3.LineTo(9, 0); poly3.LineTo(0, 6); poly3.LineTo(10, 6); } }
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 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); }