public virtual void TestCreation() { // simple create com.esri.core.geometry.Polygon poly = new com.esri.core.geometry.Polygon(); int number = poly.GetStateFlag(); NUnit.Framework.Assert.IsTrue(poly != null); // assertTrue(poly.getClass() == Polygon.class); // assertFalse(poly.getClass() == Envelope.class); NUnit.Framework.Assert.IsTrue(poly.GetType() == com.esri.core.geometry.Geometry.Type.Polygon); NUnit.Framework.Assert.IsTrue(poly.IsEmpty()); NUnit.Framework.Assert.IsTrue(poly.GetPointCount() == 0); NUnit.Framework.Assert.IsTrue(poly.GetPathCount() == 0); number = poly.GetStateFlag(); poly = null; NUnit.Framework.Assert.IsFalse(poly != null); // play with default attributes com.esri.core.geometry.Polygon poly2 = new com.esri.core.geometry.Polygon(); }
public virtual void TestCR177477getPathEnd() { com.esri.core.geometry.Polygon pg = new com.esri.core.geometry.Polygon(); pg.StartPath(-130, 40); pg.LineTo(-70, 40); pg.LineTo(-70, 10); pg.LineTo(-130, 10); pg.StartPath(-60, 40); pg.LineTo(-50, 40); pg.LineTo(-50, 10); pg.LineTo(-60, 10); pg.StartPath(-40, 40); pg.LineTo(-30, 40); pg.LineTo(-30, 10); pg.LineTo(-40, 10); int pathCount = pg.GetPathCount(); NUnit.Framework.Assert.IsTrue(pathCount == 3); // int startIndex = pg.getPathStart(pathCount - 1); // int endIndex = pg.getPathEnd(pathCount - 1); com.esri.core.geometry.Line line = new com.esri.core.geometry.Line(); line.ToString(); line.SetStart(new com.esri.core.geometry.Point(0, 0)); line.SetEnd(new com.esri.core.geometry.Point(1, 0)); line.ToString(); double geoLength = com.esri.core.geometry.GeometryEngine.GeodesicDistanceOnWGS84(new com.esri.core.geometry.Point(0, 0), new com.esri.core.geometry.Point(1, 0)); NUnit.Framework.Assert.IsTrue(System.Math.Abs(geoLength - 111319) < 1); }
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 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 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); }
public static void TestClipOfCoinciding() { com.esri.core.geometry.OperatorFactoryLocal engine = com.esri.core.geometry.OperatorFactoryLocal.GetInstance(); com.esri.core.geometry.OperatorClip clipOp = (com.esri.core.geometry.OperatorClip)engine.GetOperator(com.esri.core.geometry.Operator.Type.Clip); com.esri.core.geometry.Polygon polygon = new com.esri.core.geometry.Polygon(); com.esri.core.geometry.Envelope2D envelopeCR = new com.esri.core.geometry.Envelope2D(); envelopeCR.xmin = -180; envelopeCR.xmax = 180; envelopeCR.ymin = -90; envelopeCR.ymax = 90; polygon.AddEnvelope(envelopeCR, false); com.esri.core.geometry.SpatialReference gcsWGS84 = com.esri.core.geometry.SpatialReference.Create(4326); // CR com.esri.core.geometry.Polygon clippedPolygon = (com.esri.core.geometry.Polygon)clipOp.Execute(polygon, envelopeCR, gcsWGS84, null); NUnit.Framework.Assert.IsTrue(clippedPolygon.GetPathCount() == 1); NUnit.Framework.Assert.IsTrue(clippedPolygon.GetPointCount() == 4); com.esri.core.geometry.OperatorDensifyByLength densifyOp = (com.esri.core.geometry.OperatorDensifyByLength)engine.GetOperator(com.esri.core.geometry.Operator.Type.DensifyByLength); polygon.SetEmpty(); polygon.AddEnvelope(envelopeCR, false); polygon = (com.esri.core.geometry.Polygon)densifyOp.Execute(polygon, 1, null); int pc = polygon.GetPointCount(); int pathc = polygon.GetPathCount(); NUnit.Framework.Assert.IsTrue(pc == 1080); NUnit.Framework.Assert.IsTrue(pathc == 1); clippedPolygon = (com.esri.core.geometry.Polygon)clipOp.Execute(polygon, envelopeCR, gcsWGS84, null); int _pathc = clippedPolygon.GetPathCount(); int _pc = clippedPolygon.GetPointCount(); NUnit.Framework.Assert.IsTrue(_pathc == 1); NUnit.Framework.Assert.IsTrue(_pc == pc); }