public virtual void TestInsertPoint() { 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.Point pt = new com.esri.core.geometry.Point(-33, -34); poly.InsertPoint(1, 1, pt); pt = poly.GetPoint(4); NUnit.Framework.Assert.IsTrue(pt.GetX() == 10 && pt.GetY() == 1); pt = poly.GetPoint(5); NUnit.Framework.Assert.IsTrue(pt.GetX() == -33 && pt.GetY() == -34); pt = poly.GetPoint(6); NUnit.Framework.Assert.IsTrue(pt.GetX() == 15 && pt.GetY() == 20); NUnit.Framework.Assert.IsTrue(poly.GetPointCount() == 14); NUnit.Framework.Assert.IsTrue(poly.GetPathSize(1) == 6); NUnit.Framework.Assert.IsTrue(poly.GetPathSize(2) == 4); NUnit.Framework.Assert.IsTrue(poly.GetPathCount() == 3); }
public virtual void TestRemovePoint() { 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); poly.RemovePoint(1, 1); com.esri.core.geometry.Point pt; pt = poly.GetPoint(4); NUnit.Framework.Assert.IsTrue(pt.GetX() == 10 && pt.GetY() == 1); pt = poly.GetPoint(5); NUnit.Framework.Assert.IsTrue(pt.GetX() == 300 && pt.GetY() == 14); NUnit.Framework.Assert.IsTrue(poly.GetPointCount() == 12); NUnit.Framework.Assert.IsTrue(poly.GetPathSize(0) == 4); NUnit.Framework.Assert.IsTrue(poly.GetPathSize(1) == 4); NUnit.Framework.Assert.IsTrue(poly.GetPathSize(2) == 4); }
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 TestAddpath2() { com.esri.core.geometry.Polygon polygon = new com.esri.core.geometry.Polygon(); polygon.StartPath(-179, 34); polygon.LineTo(-154, 34); polygon.LineTo(-179, 36); polygon.LineTo(-180, 90); polygon.LineTo(180, 90); polygon.LineTo(180, 36); polygon.LineTo(70, 46); polygon.LineTo(-76, 80); polygon.LineTo(12, 38); polygon.LineTo(-69, 51); polygon.LineTo(-95, 29); polygon.LineTo(-105, 7); polygon.LineTo(-112, -27); polygon.LineTo(-149, -11); polygon.LineTo(-149, -11); polygon.LineTo(-166, -4); polygon.LineTo(-179, 5); com.esri.core.geometry.Polyline polyline = new com.esri.core.geometry.Polyline(); polyline.StartPath(180, 5); polyline.LineTo(140, 34); polyline.LineTo(180, 34); polygon.AddPath(polyline, 0, true); com.esri.core.geometry.Point startpoint = polygon.GetPoint(17); NUnit.Framework.Assert.IsTrue(startpoint.GetX() == 180 && startpoint.GetY() == 5); }
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); }
public virtual void TestReplaceNaNs() { { com.esri.core.geometry.MultiPoint mp = new com.esri.core.geometry.MultiPoint(); com.esri.core.geometry.Point pt = new com.esri.core.geometry.Point(); pt.SetXY(1, 2); pt.SetZ(double.NaN); mp.Add(pt); pt = new com.esri.core.geometry.Point(); pt.SetXY(11, 12); pt.SetZ(3); mp.Add(pt); mp.ReplaceNaNs(com.esri.core.geometry.VertexDescription.Semantics.Z, 5); NUnit.Framework.Assert.IsTrue(mp.GetPoint(0).Equals(new com.esri.core.geometry.Point(1, 2, 5))); NUnit.Framework.Assert.IsTrue(mp.GetPoint(1).Equals(new com.esri.core.geometry.Point(11, 12, 3))); } { com.esri.core.geometry.Polygon mp = new com.esri.core.geometry.Polygon(); com.esri.core.geometry.Point pt = new com.esri.core.geometry.Point(); pt.SetXY(1, 2); pt.SetZ(double.NaN); mp.StartPath(pt); pt = new com.esri.core.geometry.Point(); pt.SetXY(11, 12); pt.SetZ(3); mp.LineTo(pt); mp.ReplaceNaNs(com.esri.core.geometry.VertexDescription.Semantics.Z, 5); NUnit.Framework.Assert.IsTrue(mp.GetPoint(0).Equals(new com.esri.core.geometry.Point(1, 2, 5))); NUnit.Framework.Assert.IsTrue(mp.GetPoint(1).Equals(new com.esri.core.geometry.Point(11, 12, 3))); } { com.esri.core.geometry.Polygon mp = new com.esri.core.geometry.Polygon(); com.esri.core.geometry.Point pt = new com.esri.core.geometry.Point(); pt.SetXY(1, 2); pt.SetM(double.NaN); mp.StartPath(pt); pt = new com.esri.core.geometry.Point(); pt.SetXY(11, 12); pt.SetM(3); mp.LineTo(pt); mp.ReplaceNaNs(com.esri.core.geometry.VertexDescription.Semantics.M, 5); com.esri.core.geometry.Point p = new com.esri.core.geometry.Point(1, 2); p.SetM(5); bool b = mp.GetPoint(0).Equals(p); NUnit.Framework.Assert.IsTrue(b); p = new com.esri.core.geometry.Point(11, 12); p.SetM(3); b = mp.GetPoint(1).Equals(p); NUnit.Framework.Assert.IsTrue(b); } }