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 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 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 TestBug1() { com.esri.core.geometry.Polygon pg = new com.esri.core.geometry.Polygon(); pg.StartPath(-130, 40); for (int i = 0; i < 1000; i++) { pg.LineTo(-70, 40); } for (int i_1 = 0; i_1 < 999; i_1++) { pg.RemovePoint(0, pg.GetPointCount() - 1); } pg.LineTo(-70, 40); }
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); }