public virtual void TestCreation1() { // Simple area and length calcul test com.esri.core.geometry.Polygon poly = new com.esri.core.geometry.Polygon(); int number = poly.GetStateFlag(); com.esri.core.geometry.Envelope env = new com.esri.core.geometry.Envelope(1000, 2000, 1010, 2010); env.ToString(); poly.AddEnvelope(env, false); poly.ToString(); number = poly.GetStateFlag(); NUnit.Framework.Assert.IsTrue(System.Math.Abs(poly.CalculateArea2D() - 100) < 1e-12); NUnit.Framework.Assert.IsTrue(System.Math.Abs(poly.CalculateLength2D() - 40) < 1e-12); poly.SetEmpty(); number = poly.GetStateFlag(); poly.AddEnvelope(env, true); number = poly.GetStateFlag(); NUnit.Framework.Assert.IsTrue(System.Math.Abs(poly.CalculateArea2D() + 100) < 1e-12); number = poly.GetStateFlag(); }
public static void TestPointTypes() { com.esri.core.geometry.OperatorFactoryLocal engine = com.esri.core.geometry.OperatorFactoryLocal.GetInstance(); com.esri.core.geometry.OperatorDifference difference = (com.esri.core.geometry.OperatorDifference)engine.GetOperator(com.esri.core.geometry.Operator.Type.Difference); com.esri.core.geometry.OperatorSymmetricDifference sym_difference = (com.esri.core.geometry.OperatorSymmetricDifference)engine.GetOperator(com.esri.core.geometry.Operator.Type.SymmetricDifference); { // point/point com.esri.core.geometry.Point point_1 = new com.esri.core.geometry.Point(); com.esri.core.geometry.Point point_2 = new com.esri.core.geometry.Point(); point_1.SetXY(0, 0); point_2.SetXY(0.000000009, 0.000000009); com.esri.core.geometry.Point differenced = (com.esri.core.geometry.Point)(difference.Execute(point_1, point_2, com.esri.core.geometry.SpatialReference.Create(4326), null)); NUnit.Framework.Assert.IsTrue(differenced.IsEmpty()); com.esri.core.geometry.MultiPoint sym_differenced = (com.esri.core.geometry.MultiPoint)(sym_difference.Execute(point_1, point_2, com.esri.core.geometry.SpatialReference.Create(4326), null)); NUnit.Framework.Assert.IsTrue(sym_differenced.IsEmpty()); } { // point/point com.esri.core.geometry.Point point_1 = new com.esri.core.geometry.Point(); com.esri.core.geometry.Point point_2 = new com.esri.core.geometry.Point(); point_1.SetXY(0, 0); point_2.SetXY(0.000000009, 0.0); com.esri.core.geometry.Point differenced = (com.esri.core.geometry.Point)(difference.Execute(point_1, point_2, com.esri.core.geometry.SpatialReference.Create(4326), null)); NUnit.Framework.Assert.IsTrue(differenced.IsEmpty()); com.esri.core.geometry.MultiPoint sym_differenced = (com.esri.core.geometry.MultiPoint)(sym_difference.Execute(point_1, point_2, com.esri.core.geometry.SpatialReference.Create(4326), null)); NUnit.Framework.Assert.IsTrue(sym_differenced.IsEmpty()); } { // point/point com.esri.core.geometry.Point point_1 = new com.esri.core.geometry.Point(); com.esri.core.geometry.Point point_2 = new com.esri.core.geometry.Point(); point_1.SetXY(0, 0); point_2.SetXY(0.00000002, 0.00000002); com.esri.core.geometry.Point differenced_1 = (com.esri.core.geometry.Point)(difference.Execute(point_1, point_2, com.esri.core.geometry.SpatialReference.Create(4326), null)); NUnit.Framework.Assert.IsTrue(!differenced_1.IsEmpty()); com.esri.core.geometry.Point differenced_2 = (com.esri.core.geometry.Point)(difference.Execute(point_2, point_1, com.esri.core.geometry.SpatialReference.Create(4326), null)); NUnit.Framework.Assert.IsTrue(!differenced_2.IsEmpty()); com.esri.core.geometry.MultiPoint sym_differenced = (com.esri.core.geometry.MultiPoint)(sym_difference.Execute(point_1, point_2, com.esri.core.geometry.SpatialReference.Create(4326), null)); NUnit.Framework.Assert.IsTrue(!sym_differenced.IsEmpty()); NUnit.Framework.Assert.IsTrue(sym_differenced.GetXY(0).x == 0 && sym_differenced.GetXY(0).y == 0); NUnit.Framework.Assert.IsTrue(sym_differenced.GetXY(1).x == 0.00000002 && sym_differenced.GetXY(1).y == 0.00000002); } { // multi_point/point com.esri.core.geometry.MultiPoint multi_point_1 = new com.esri.core.geometry.MultiPoint(); com.esri.core.geometry.Point point_2 = new com.esri.core.geometry.Point(); multi_point_1.Add(0, 0); multi_point_1.Add(1, 1); point_2.SetXY(0.000000009, 0.000000009); com.esri.core.geometry.MultiPoint differenced_1 = (com.esri.core.geometry.MultiPoint)(difference.Execute(multi_point_1, point_2, com.esri.core.geometry.SpatialReference.Create(4326), null)); NUnit.Framework.Assert.IsTrue(!differenced_1.IsEmpty()); NUnit.Framework.Assert.IsTrue(differenced_1.GetPointCount() == 1); NUnit.Framework.Assert.IsTrue(differenced_1.GetXY(0).x == 1 && differenced_1.GetXY(0).y == 1); com.esri.core.geometry.Point differenced_2 = (com.esri.core.geometry.Point)(difference.Execute(point_2, multi_point_1, com.esri.core.geometry.SpatialReference.Create(4326), null)); NUnit.Framework.Assert.IsTrue(differenced_2.IsEmpty()); } { // multi_point/point com.esri.core.geometry.MultiPoint multi_point_1 = new com.esri.core.geometry.MultiPoint(); com.esri.core.geometry.Point point_2 = new com.esri.core.geometry.Point(); multi_point_1.Add(0, 0); multi_point_1.Add(1, 1); point_2.SetXY(0.000000009, 0.0); com.esri.core.geometry.MultiPoint differenced_1 = (com.esri.core.geometry.MultiPoint)(difference.Execute(multi_point_1, point_2, com.esri.core.geometry.SpatialReference.Create(4326), null)); NUnit.Framework.Assert.IsTrue(!differenced_1.IsEmpty()); NUnit.Framework.Assert.IsTrue(differenced_1.GetXY(0).x == 1.0 && differenced_1.GetXY(0).y == 1.0); com.esri.core.geometry.Point differenced_2 = (com.esri.core.geometry.Point)(difference.Execute(point_2, multi_point_1, com.esri.core.geometry.SpatialReference.Create(4326), null)); NUnit.Framework.Assert.IsTrue(differenced_2.IsEmpty()); com.esri.core.geometry.MultiPoint sym_differenced = (com.esri.core.geometry.MultiPoint)(sym_difference.Execute(multi_point_1, point_2, com.esri.core.geometry.SpatialReference.Create(4326), null)); NUnit.Framework.Assert.IsTrue(!sym_differenced.IsEmpty()); NUnit.Framework.Assert.IsTrue(sym_differenced.GetPointCount() == 1); NUnit.Framework.Assert.IsTrue(sym_differenced.GetXY(0).x == 1 && sym_differenced.GetXY(0).y == 1); } { // multi_point/point com.esri.core.geometry.MultiPoint multi_point_1 = new com.esri.core.geometry.MultiPoint(); com.esri.core.geometry.Point point_2 = new com.esri.core.geometry.Point(); multi_point_1.Add(0, 0); multi_point_1.Add(0, 0); point_2.SetXY(0.000000009, 0.0); com.esri.core.geometry.MultiPoint differenced_1 = (com.esri.core.geometry.MultiPoint)(difference.Execute(multi_point_1, point_2, com.esri.core.geometry.SpatialReference.Create(4326), null)); NUnit.Framework.Assert.IsTrue(differenced_1.IsEmpty()); com.esri.core.geometry.MultiPoint sym_differenced = (com.esri.core.geometry.MultiPoint)(sym_difference.Execute(multi_point_1, point_2, com.esri.core.geometry.SpatialReference.Create(4326), null)); NUnit.Framework.Assert.IsTrue(sym_differenced.IsEmpty()); } { // multi_point/polygon com.esri.core.geometry.MultiPoint multi_point_1 = new com.esri.core.geometry.MultiPoint(); com.esri.core.geometry.Polygon polygon_2 = new com.esri.core.geometry.Polygon(); multi_point_1.Add(0, 0); multi_point_1.Add(0, 0); multi_point_1.Add(2, 2); polygon_2.StartPath(-1, -1); polygon_2.LineTo(-1, 1); polygon_2.LineTo(1, 1); polygon_2.LineTo(1, -1); com.esri.core.geometry.MultiPoint differenced_1 = (com.esri.core.geometry.MultiPoint)(difference.Execute(multi_point_1, polygon_2, com.esri.core.geometry.SpatialReference.Create(4326), null)); NUnit.Framework.Assert.IsTrue(!differenced_1.IsEmpty()); NUnit.Framework.Assert.IsTrue(differenced_1.GetPointCount() == 1); NUnit.Framework.Assert.IsTrue(differenced_1.GetXY(0).x == 2 && differenced_1.GetXY(0).y == 2); } { // multi_point/polygon com.esri.core.geometry.MultiPoint multi_point_1 = new com.esri.core.geometry.MultiPoint(); com.esri.core.geometry.Polygon polygon_2 = new com.esri.core.geometry.Polygon(); multi_point_1.Add(0, 0); multi_point_1.Add(0, 0); multi_point_1.Add(1, 1); polygon_2.StartPath(-1, -1); polygon_2.LineTo(-1, 1); polygon_2.LineTo(1, 1); polygon_2.LineTo(1, -1); com.esri.core.geometry.MultiPoint differenced_1 = (com.esri.core.geometry.MultiPoint)(difference.Execute(multi_point_1, polygon_2, com.esri.core.geometry.SpatialReference.Create(4326), null)); NUnit.Framework.Assert.IsTrue(differenced_1.IsEmpty()); } { // multi_point/envelope com.esri.core.geometry.MultiPoint multi_point_1 = new com.esri.core.geometry.MultiPoint(); com.esri.core.geometry.Envelope envelope_2 = new com.esri.core.geometry.Envelope(); multi_point_1.Add(-2, 0); multi_point_1.Add(0, 2); multi_point_1.Add(2, 0); multi_point_1.Add(0, -2); envelope_2.SetCoords(-1, -1, 1, 1); com.esri.core.geometry.MultiPoint differenced_1 = (com.esri.core.geometry.MultiPoint)(difference.Execute(multi_point_1, envelope_2, com.esri.core.geometry.SpatialReference.Create(4326), null)); NUnit.Framework.Assert.IsTrue(!differenced_1.IsEmpty() && differenced_1 == multi_point_1); } { // multi_point/polygon com.esri.core.geometry.MultiPoint multi_point_1 = new com.esri.core.geometry.MultiPoint(); com.esri.core.geometry.Polygon polygon_2 = new com.esri.core.geometry.Polygon(); multi_point_1.Add(2, 2); multi_point_1.Add(2, 2); multi_point_1.Add(-2, -2); polygon_2.StartPath(-1, -1); polygon_2.LineTo(-1, 1); polygon_2.LineTo(1, 1); polygon_2.LineTo(1, -1); com.esri.core.geometry.MultiPoint differenced_1 = (com.esri.core.geometry.MultiPoint)(difference.Execute(multi_point_1, polygon_2, com.esri.core.geometry.SpatialReference.Create(4326), null)); NUnit.Framework.Assert.IsTrue(!differenced_1.IsEmpty() && differenced_1 == multi_point_1); } { // point/polygon com.esri.core.geometry.Point point_1 = new com.esri.core.geometry.Point(); com.esri.core.geometry.Polygon polygon_2 = new com.esri.core.geometry.Polygon(); point_1.SetXY(0, 0); polygon_2.StartPath(-1, -1); polygon_2.LineTo(-1, 1); polygon_2.LineTo(1, 1); polygon_2.LineTo(1, -1); com.esri.core.geometry.Point differenced_1 = (com.esri.core.geometry.Point)(difference.Execute(point_1, polygon_2, com.esri.core.geometry.SpatialReference.Create(4326), null)); NUnit.Framework.Assert.IsTrue(differenced_1.IsEmpty()); polygon_2.SetEmpty(); polygon_2.StartPath(1, 1); polygon_2.LineTo(1, 2); polygon_2.LineTo(2, 2); polygon_2.LineTo(2, 1); differenced_1 = (com.esri.core.geometry.Point)(difference.Execute(point_1, polygon_2, com.esri.core.geometry.SpatialReference.Create(4326), null)); NUnit.Framework.Assert.IsTrue(!differenced_1.IsEmpty()); NUnit.Framework.Assert.IsTrue(differenced_1 == point_1); } { // point/polygon com.esri.core.geometry.Point point_1 = new com.esri.core.geometry.Point(); com.esri.core.geometry.Polygon polygon_2 = new com.esri.core.geometry.Polygon(); point_1.SetXY(0, 0); polygon_2.StartPath(1, 0); polygon_2.LineTo(0, 1); polygon_2.LineTo(1, 1); com.esri.core.geometry.Point differenced_1 = (com.esri.core.geometry.Point)(difference.Execute(point_1, polygon_2, com.esri.core.geometry.SpatialReference.Create(4326), null)); NUnit.Framework.Assert.IsTrue(!differenced_1.IsEmpty()); NUnit.Framework.Assert.IsTrue(differenced_1 == point_1); point_1.SetEmpty(); point_1.SetXY(0.5, 0.5); polygon_2.SetEmpty(); polygon_2.StartPath(1, 0); polygon_2.LineTo(0, 1); polygon_2.LineTo(1, 1); differenced_1 = (com.esri.core.geometry.Point)(difference.Execute(point_1, polygon_2, com.esri.core.geometry.SpatialReference.Create(4326), null)); NUnit.Framework.Assert.IsTrue(differenced_1.IsEmpty()); } { // point/envelope com.esri.core.geometry.Point point_1 = new com.esri.core.geometry.Point(); com.esri.core.geometry.Envelope envelope_2 = new com.esri.core.geometry.Envelope(); point_1.SetXY(0, 0); envelope_2.SetCoords(-1, -1, 1, 1); com.esri.core.geometry.Point differenced_1 = (com.esri.core.geometry.Point)(difference.Execute(point_1, envelope_2, com.esri.core.geometry.SpatialReference.Create(4326), null)); NUnit.Framework.Assert.IsTrue(differenced_1.IsEmpty()); envelope_2.SetEmpty(); envelope_2.SetCoords(1, 1, 2, 2); differenced_1 = (com.esri.core.geometry.Point)(difference.Execute(point_1, envelope_2, com.esri.core.geometry.SpatialReference.Create(4326), null)); NUnit.Framework.Assert.IsTrue(!differenced_1.IsEmpty()); NUnit.Framework.Assert.IsTrue(differenced_1 == point_1); } { // point/polyline com.esri.core.geometry.Point point_1 = new com.esri.core.geometry.Point(); com.esri.core.geometry.Polyline polyline_2 = new com.esri.core.geometry.Polyline(); point_1.SetXY(0, 0); polyline_2.StartPath(-1, 0); polyline_2.LineTo(1, 0); com.esri.core.geometry.Point differenced_1 = (com.esri.core.geometry.Point)(difference.Execute(point_1, polyline_2, com.esri.core.geometry.SpatialReference.Create(4326), null)); NUnit.Framework.Assert.IsTrue(differenced_1.IsEmpty()); polyline_2.SetEmpty(); polyline_2.StartPath(1, 0); polyline_2.LineTo(2, 0); differenced_1 = (com.esri.core.geometry.Point)(difference.Execute(point_1, polyline_2, com.esri.core.geometry.SpatialReference.Create(4326), null)); NUnit.Framework.Assert.IsTrue(!differenced_1.IsEmpty()); NUnit.Framework.Assert.IsTrue(differenced_1 == point_1); polyline_2.SetEmpty(); polyline_2.StartPath(-1, -1); polyline_2.LineTo(-1, 1); polyline_2.LineTo(1, 1); polyline_2.LineTo(1, -1); differenced_1 = (com.esri.core.geometry.Point)(difference.Execute(point_1, polyline_2, com.esri.core.geometry.SpatialReference.Create(4326), null)); NUnit.Framework.Assert.IsTrue(!differenced_1.IsEmpty()); NUnit.Framework.Assert.IsTrue(differenced_1 == point_1); } }
public static void TestEditShape_() { { // std::shared_ptr<Esri_runtimecore::Geometry::Polygon> poly_base_6 // = std::make_shared<Esri_runtimecore::Geometry::Polygon>(); // Single part polygon com.esri.core.geometry.Polygon poly = new com.esri.core.geometry.Polygon(); poly.StartPath(10, 10); poly.LineTo(10, 12); poly.LineTo(14, 15); poly.LineTo(10, 11); com.esri.core.geometry.EditShape editShape = new com.esri.core.geometry.EditShape(); int geom = editShape.AddGeometry(poly); com.esri.core.geometry.Polygon poly2 = (com.esri.core.geometry.Polygon)editShape.GetGeometry(geom); NUnit.Framework.Assert.IsTrue(poly.Equals(poly2)); } { // Two part poly com.esri.core.geometry.Polygon poly = new com.esri.core.geometry.Polygon(); poly.StartPath(10, 10); poly.LineTo(10, 12); poly.LineTo(14, 15); poly.LineTo(10, 11); poly.StartPath(100, 10); poly.LineTo(100, 12); poly.LineTo(14, 150); poly.LineTo(10, 101); poly.LineTo(100, 11); com.esri.core.geometry.EditShape editShape = new com.esri.core.geometry.EditShape(); int geom = editShape.AddGeometry(poly); com.esri.core.geometry.Polygon poly2 = (com.esri.core.geometry.Polygon)editShape.GetGeometry(geom); NUnit.Framework.Assert.IsTrue(poly.Equals(poly2)); } { // Single part polyline com.esri.core.geometry.Polyline poly = new com.esri.core.geometry.Polyline(); poly.StartPath(10, 10); poly.LineTo(10, 12); poly.LineTo(14, 15); poly.LineTo(10, 11); com.esri.core.geometry.EditShape editShape = new com.esri.core.geometry.EditShape(); int geom = editShape.AddGeometry(poly); com.esri.core.geometry.Polyline poly2 = (com.esri.core.geometry.Polyline)editShape.GetGeometry(geom); NUnit.Framework.Assert.IsTrue(poly.Equals(poly2)); } { // Two part poly com.esri.core.geometry.Polyline poly = new com.esri.core.geometry.Polyline(); poly.StartPath(10, 10); poly.LineTo(10, 12); poly.LineTo(14, 15); poly.LineTo(10, 11); poly.StartPath(100, 10); poly.LineTo(100, 12); poly.LineTo(14, 150); poly.LineTo(10, 101); poly.LineTo(100, 11); com.esri.core.geometry.EditShape editShape = new com.esri.core.geometry.EditShape(); int geom = editShape.AddGeometry(poly); com.esri.core.geometry.Polyline poly2 = (com.esri.core.geometry.Polyline)editShape.GetGeometry(geom); NUnit.Framework.Assert.IsTrue(poly.Equals(poly2)); } { // Five part poly. Close one of parts to test if it works. com.esri.core.geometry.Polyline poly = new com.esri.core.geometry.Polyline(); poly.StartPath(10, 10); poly.LineTo(10, 12); poly.LineTo(14, 15); poly.LineTo(10, 11); poly.StartPath(100, 10); poly.LineTo(100, 12); poly.LineTo(14, 150); poly.LineTo(10, 101); poly.LineTo(100, 11); poly.StartPath(1100, 101); poly.LineTo(1300, 132); poly.LineTo(144, 150); poly.LineTo(106, 1051); poly.LineTo(1600, 161); poly.StartPath(100, 190); poly.LineTo(1800, 192); poly.LineTo(184, 8150); poly.LineTo(1080, 181); poly.StartPath(1030, 10); poly.LineTo(1300, 132); poly.LineTo(314, 3150); poly.LineTo(310, 1301); poly.LineTo(3100, 311); com.esri.core.geometry.EditShape editShape = new com.esri.core.geometry.EditShape(); int geom = editShape.AddGeometry(poly); editShape.SetClosedPath(editShape.GetNextPath(editShape.GetFirstPath(geom)), true); ((com.esri.core.geometry.MultiPathImpl)poly._getImpl()).ClosePathWithLine(1); com.esri.core.geometry.Polyline poly2 = (com.esri.core.geometry.Polyline)editShape.GetGeometry(geom); NUnit.Framework.Assert.IsTrue(poly.Equals(poly2)); } { // Test erase com.esri.core.geometry.Polyline poly = new com.esri.core.geometry.Polyline(); poly.StartPath(10, 10); poly.LineTo(10, 12); poly.LineTo(314, 3150); poly.LineTo(310, 1301); poly.LineTo(3100, 311); com.esri.core.geometry.EditShape editShape = new com.esri.core.geometry.EditShape(); int geom = editShape.AddGeometry(poly); int vertex = editShape.GetFirstVertex(editShape.GetFirstPath(geom)); vertex = editShape.RemoveVertex(vertex, true); vertex = editShape.GetNextVertex(vertex); editShape.RemoveVertex(vertex, true); com.esri.core.geometry.Polyline poly2 = (com.esri.core.geometry.Polyline)editShape.GetGeometry(geom); poly.SetEmpty(); poly.StartPath(10, 12); poly.LineTo(310, 1301); poly.LineTo(3100, 311); NUnit.Framework.Assert.IsTrue(poly.Equals(poly2)); } { // Test erase com.esri.core.geometry.Polygon poly = new com.esri.core.geometry.Polygon(); poly.StartPath(10, 10); poly.LineTo(10, 12); poly.LineTo(314, 3150); poly.LineTo(310, 1301); poly.LineTo(3100, 311); com.esri.core.geometry.EditShape editShape = new com.esri.core.geometry.EditShape(); int geom = editShape.AddGeometry(poly); int vertex = editShape.GetFirstVertex(editShape.GetFirstPath(geom)); vertex = editShape.RemoveVertex(vertex, true); vertex = editShape.GetNextVertex(vertex); editShape.RemoveVertex(vertex, true); com.esri.core.geometry.Polygon poly2 = (com.esri.core.geometry.Polygon)editShape.GetGeometry(geom); poly.SetEmpty(); poly.StartPath(10, 12); poly.LineTo(310, 1301); poly.LineTo(3100, 311); NUnit.Framework.Assert.IsTrue(poly.Equals(poly2)); } { // Test Filter Close Points com.esri.core.geometry.Polygon poly = new com.esri.core.geometry.Polygon(); poly.StartPath(10, 10); poly.LineTo(10, 10.001); poly.LineTo(10.001, 10); com.esri.core.geometry.EditShape editShape = new com.esri.core.geometry.EditShape(); int geom = editShape.AddGeometry(poly); editShape.FilterClosePoints(0.002, true, false); com.esri.core.geometry.Polygon poly2 = (com.esri.core.geometry.Polygon)editShape.GetGeometry(geom); NUnit.Framework.Assert.IsTrue(poly2.IsEmpty()); } { // Test Filter Close Points com.esri.core.geometry.Polygon poly = new com.esri.core.geometry.Polygon(); poly.StartPath(10, 10); poly.LineTo(10, 10.0025); poly.LineTo(11.0, 10); com.esri.core.geometry.EditShape editShape = new com.esri.core.geometry.EditShape(); int geom = editShape.AddGeometry(poly); editShape.FilterClosePoints(0.002, true, false); com.esri.core.geometry.Polygon poly2 = (com.esri.core.geometry.Polygon)editShape.GetGeometry(geom); NUnit.Framework.Assert.IsTrue(!poly2.IsEmpty()); } { // Test Filter Close Points com.esri.core.geometry.Polygon poly = new com.esri.core.geometry.Polygon(); poly.StartPath(10, 10); poly.LineTo(10, 10.001); poly.LineTo(11.0, 10); com.esri.core.geometry.EditShape editShape = new com.esri.core.geometry.EditShape(); int geom = editShape.AddGeometry(poly); editShape.FilterClosePoints(0.002, true, false); com.esri.core.geometry.Polygon poly2 = (com.esri.core.geometry.Polygon)editShape.GetGeometry(geom); NUnit.Framework.Assert.IsTrue(poly2.IsEmpty()); } { // Test attribute splitting 1 com.esri.core.geometry.Polyline polyline = new com.esri.core.geometry.Polyline(); polyline.StartPath(0, 0); polyline.LineTo(1, 1); polyline.LineTo(2, 2); polyline.LineTo(3, 3); polyline.LineTo(4, 4); polyline.StartPath(5, 5); polyline.LineTo(6, 6); polyline.LineTo(7, 7); polyline.LineTo(8, 8); polyline.LineTo(9, 9); polyline.AddAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z); polyline.SetAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z, 0, 0, 4); polyline.SetAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z, 1, 0, 8); polyline.SetAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z, 2, 0, 12); polyline.SetAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z, 3, 0, 16); polyline.SetAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z, 4, 0, 20); polyline.SetAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z, 5, 0, 22); polyline.SetAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z, 6, 0, 26); polyline.SetAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z, 7, 0, 30); polyline.SetAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z, 8, 0, 34); polyline.SetAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z, 9, 0, 38); com.esri.core.geometry.EditShape shape = new com.esri.core.geometry.EditShape(); int geometry = shape.AddGeometry(polyline); com.esri.core.geometry.AttributeStreamOfInt32 vertex_handles = new com.esri.core.geometry.AttributeStreamOfInt32(0); for (int path = shape.GetFirstPath(geometry); path != -1; path = shape.GetNextPath(path)) { for (int vertex = shape.GetFirstVertex(path); vertex != -1; vertex = shape.GetNextVertex(vertex)) { if (vertex != shape.GetLastVertex(path)) { vertex_handles.Add(vertex); } } } double[] t = new double[1]; for (int i = 0; i < vertex_handles.Size(); i++) { int vertex = vertex_handles.Read(i); t[0] = 0.5; shape.SplitSegment(vertex, t, 1); } com.esri.core.geometry.Polyline chopped_polyline = (com.esri.core.geometry.Polyline)shape.GetGeometry(geometry); NUnit.Framework.Assert.IsTrue(chopped_polyline.GetPointCount() == 18); double att_ = 4; for (int i_1 = 0; i_1 < 18; i_1++) { double att = chopped_polyline.GetAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics.Z, i_1, 0); NUnit.Framework.Assert.IsTrue(att == att_); att_ += 2; } } { // Test attribute splitting 2 com.esri.core.geometry.Polyline line1 = new com.esri.core.geometry.Polyline(); com.esri.core.geometry.Polyline line2 = new com.esri.core.geometry.Polyline(); line1.AddAttribute(com.esri.core.geometry.VertexDescription.Semantics.M); line2.AddAttribute(com.esri.core.geometry.VertexDescription.Semantics.M); line1.StartPath(0, 0); line1.LineTo(10, 10); line2.StartPath(10, 0); line2.LineTo(0, 10); line1.SetAttribute(com.esri.core.geometry.VertexDescription.Semantics.M, 0, 0, 7); line1.SetAttribute(com.esri.core.geometry.VertexDescription.Semantics.M, 1, 0, 17); line2.SetAttribute(com.esri.core.geometry.VertexDescription.Semantics.M, 0, 0, 5); line2.SetAttribute(com.esri.core.geometry.VertexDescription.Semantics.M, 1, 0, 15); com.esri.core.geometry.EditShape shape = new com.esri.core.geometry.EditShape(); int g1 = shape.AddGeometry(line1); int g2 = shape.AddGeometry(line2); com.esri.core.geometry.CrackAndCluster.Execute(shape, 0.001, null, true); com.esri.core.geometry.Polyline chopped_line1 = (com.esri.core.geometry.Polyline)shape.GetGeometry(g1); com.esri.core.geometry.Polyline chopped_line2 = (com.esri.core.geometry.Polyline)shape.GetGeometry(g2); double att1 = chopped_line1.GetAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics.M, 1, 0); double att2 = chopped_line2.GetAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics.M, 1, 0); NUnit.Framework.Assert.IsTrue(att1 == 12); NUnit.Framework.Assert.IsTrue(att2 == 10); } { // Test attribute splitting 3 com.esri.core.geometry.Polygon polygon = new com.esri.core.geometry.Polygon(); polygon.AddAttribute(com.esri.core.geometry.VertexDescription.Semantics.M); polygon.StartPath(0, 0); polygon.LineTo(0, 10); polygon.LineTo(10, 10); polygon.LineTo(10, 0); polygon.SetAttribute(com.esri.core.geometry.VertexDescription.Semantics.M, 0, 0, 7); polygon.SetAttribute(com.esri.core.geometry.VertexDescription.Semantics.M, 1, 0, 17); polygon.SetAttribute(com.esri.core.geometry.VertexDescription.Semantics.M, 2, 0, 23); polygon.SetAttribute(com.esri.core.geometry.VertexDescription.Semantics.M, 3, 0, 43); com.esri.core.geometry.EditShape shape = new com.esri.core.geometry.EditShape(); int geometry = shape.AddGeometry(polygon); com.esri.core.geometry.AttributeStreamOfInt32 vertex_handles = new com.esri.core.geometry.AttributeStreamOfInt32(0); int start_v = shape.GetFirstVertex(shape.GetFirstPath(geometry)); int v = start_v; do { vertex_handles.Add(v); v = shape.GetNextVertex(v); } while (v != start_v); double[] t = new double[1]; for (int i = 0; i < vertex_handles.Size(); i++) { int v1 = vertex_handles.Read(i); t[0] = 0.5; shape.SplitSegment(v1, t, 1); } com.esri.core.geometry.Polygon cut_polygon = (com.esri.core.geometry.Polygon)shape.GetGeometry(geometry); NUnit.Framework.Assert.IsTrue(cut_polygon.GetPointCount() == 8); com.esri.core.geometry.Point2D pt0 = cut_polygon.GetXY(0); double a0 = cut_polygon.GetAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics.M, 0, 0); NUnit.Framework.Assert.IsTrue(a0 == 25); com.esri.core.geometry.Point2D pt1 = cut_polygon.GetXY(1); double a1 = cut_polygon.GetAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics.M, 1, 0); NUnit.Framework.Assert.IsTrue(a1 == 7); com.esri.core.geometry.Point2D pt2 = cut_polygon.GetXY(2); double a2 = cut_polygon.GetAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics.M, 2, 0); NUnit.Framework.Assert.IsTrue(a2 == 12); com.esri.core.geometry.Point2D pt3 = cut_polygon.GetXY(3); double a3 = cut_polygon.GetAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics.M, 3, 0); NUnit.Framework.Assert.IsTrue(a3 == 17); com.esri.core.geometry.Point2D pt4 = cut_polygon.GetXY(4); double a4 = cut_polygon.GetAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics.M, 4, 0); NUnit.Framework.Assert.IsTrue(a4 == 20); com.esri.core.geometry.Point2D pt5 = cut_polygon.GetXY(5); double a5 = cut_polygon.GetAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics.M, 5, 0); NUnit.Framework.Assert.IsTrue(a5 == 23); com.esri.core.geometry.Point2D pt6 = cut_polygon.GetXY(6); double a6 = cut_polygon.GetAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics.M, 6, 0); NUnit.Framework.Assert.IsTrue(a6 == 33); com.esri.core.geometry.Point2D pt7 = cut_polygon.GetXY(7); double a7 = cut_polygon.GetAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics.M, 7, 0); NUnit.Framework.Assert.IsTrue(a7 == 43); } }
public virtual void TestPolygonPolylineDisjoint() { com.esri.core.geometry.OperatorDisjoint disjoint = (com.esri.core.geometry.OperatorDisjoint)(com.esri.core.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.esri.core.geometry.Operator.Type.Disjoint)); com.esri.core.geometry.SpatialReference sr = com.esri.core.geometry.SpatialReference.Create(102100); double tolerance = sr.GetTolerance(com.esri.core.geometry.VertexDescription.Semantics.POSITION); com.esri.core.geometry.Polygon polygon1 = new com.esri.core.geometry.Polygon(); com.esri.core.geometry.Polyline polyline2 = new com.esri.core.geometry.Polyline(); polygon1.StartPath(0, 0); polygon1.LineTo(0, 10); polygon1.LineTo(10, 10); polygon1.LineTo(10, 0); polygon1.StartPath(1, 1); polygon1.LineTo(9, 1); polygon1.LineTo(9, 9); polygon1.LineTo(1, 9); polyline2.StartPath(3, 3); polyline2.LineTo(6, 6); bool res = disjoint.Execute(polyline2, polygon1, sr, null); NUnit.Framework.Assert.IsTrue(res); res = disjoint.Execute(polygon1, polyline2, sr, null); NUnit.Framework.Assert.IsTrue(res); polyline2.StartPath(0, 0); polyline2.LineTo(0, 5); res = disjoint.Execute(polyline2, polygon1, sr, null); NUnit.Framework.Assert.IsTrue(!res); res = disjoint.Execute(polygon1, polyline2, sr, null); NUnit.Framework.Assert.IsTrue(!res); polygon1.SetEmpty(); polyline2.SetEmpty(); polygon1.StartPath(0, 0); polygon1.LineTo(0, 10); polygon1.LineTo(10, 10); polygon1.LineTo(10, 0); polyline2.StartPath(2, 2); polyline2.LineTo(4, 4); com.esri.core.geometry.OperatorFactoryLocal factory = com.esri.core.geometry.OperatorFactoryLocal.GetInstance(); com.esri.core.geometry.OperatorSimplify simplify_op = (com.esri.core.geometry.OperatorSimplify)factory.GetOperator(com.esri.core.geometry.Operator.Type.Simplify); simplify_op.IsSimpleAsFeature(polygon1, sr, null); simplify_op.IsSimpleAsFeature(polyline2, sr, null); res = disjoint.Execute(polyline2, polygon1, sr, null); NUnit.Framework.Assert.IsTrue(!res); res = disjoint.Execute(polygon1, polyline2, sr, null); NUnit.Framework.Assert.IsTrue(!res); }
public virtual void TestPolygonPointRelate() { com.esri.core.geometry.OperatorRelate op = (com.esri.core.geometry.OperatorRelate)(com.esri.core.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.esri.core.geometry.Operator.Type.Relate)); com.esri.core.geometry.SpatialReference sr = com.esri.core.geometry.SpatialReference.Create(4326); bool res; string scl; com.esri.core.geometry.Polygon polygon = new com.esri.core.geometry.Polygon(); com.esri.core.geometry.Point point = new com.esri.core.geometry.Point(); polygon.StartPath(0, 0); polygon.LineTo(0, 10); polygon.LineTo(10, 10); polygon.LineTo(10, 0); point.SetXY(0, 0); scl = "FF20FTFFT"; res = op.Execute(polygon, point, sr, scl, null); NUnit.Framework.Assert.IsTrue(res); polygon.SetEmpty(); polygon.StartPath(0, 0); polygon.LineTo(0, 0); polygon.LineTo(0, 0); scl = "0FFFFFFF2"; res = op.Execute(polygon, point, sr, scl, null); NUnit.Framework.Assert.IsTrue(res); polygon.SetEmpty(); polygon.StartPath(0, 0); polygon.LineTo(0, 1); polygon.LineTo(0, 0); scl = "0F1FFFFF2"; res = op.Execute(polygon, point, sr, scl, null); NUnit.Framework.Assert.IsTrue(res); point.SetXY(-1, 0); scl = "FF1FFF0F2"; res = op.Execute(polygon, point, sr, scl, null); NUnit.Framework.Assert.IsTrue(res); polygon.SetEmpty(); polygon.StartPath(0, 0); polygon.LineTo(0, 10); polygon.LineTo(0, 0); scl = "FF1FFFTFT"; res = op.Execute(polygon, point, sr, scl, null); NUnit.Framework.Assert.IsTrue(res); polygon.SetEmpty(); polygon.StartPath(0, 0); polygon.LineTo(0, 0); polygon.LineTo(0, 0); scl = "FF0FFF0F2"; res = op.Execute(polygon, point, sr, scl, null); NUnit.Framework.Assert.IsTrue(res); }
public virtual void TestPolygonMultiPointRelate() { com.esri.core.geometry.OperatorRelate op = (com.esri.core.geometry.OperatorRelate)(com.esri.core.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.esri.core.geometry.Operator.Type.Relate)); com.esri.core.geometry.SpatialReference sr = com.esri.core.geometry.SpatialReference.Create(4326); bool res; string scl; com.esri.core.geometry.Polygon polygon1 = new com.esri.core.geometry.Polygon(); com.esri.core.geometry.MultiPoint multipoint2 = new com.esri.core.geometry.MultiPoint(); polygon1.StartPath(0, 0); polygon1.LineTo(0, 10); polygon1.LineTo(10, 10); polygon1.LineTo(10, 0); multipoint2.Add(0, 0); multipoint2.Add(5, 5); scl = "TFT0F1FFT"; res = op.Execute(polygon1, multipoint2, sr, scl, null); NUnit.Framework.Assert.IsTrue(res); scl = "T0FFFFT1T"; // transpose of above res = op.Execute(multipoint2, polygon1, sr, scl, null); NUnit.Framework.Assert.IsTrue(res); multipoint2.Add(11, 11); scl = "TFT0F10FT"; res = op.Execute(polygon1, multipoint2, sr, scl, null); NUnit.Framework.Assert.IsTrue(res); multipoint2.Add(0, 5); scl = "TFT0F10FT"; res = op.Execute(polygon1, multipoint2, sr, scl, null); NUnit.Framework.Assert.IsTrue(res); scl = "TFF0F10FT"; res = op.Execute(polygon1, multipoint2, sr, scl, null); NUnit.Framework.Assert.IsTrue(!res); polygon1.SetEmpty(); multipoint2.SetEmpty(); polygon1.StartPath(0, 0); polygon1.LineTo(0, 20); polygon1.LineTo(20, 20); polygon1.LineTo(20, 0); multipoint2.Add(3, 3); multipoint2.Add(5, 5); op.AccelerateGeometry(polygon1, sr, com.esri.core.geometry.Geometry.GeometryAccelerationDegree.enumHot); scl = "TF2FF****"; res = op.Execute(polygon1, multipoint2, sr, scl, null); NUnit.Framework.Assert.IsTrue(res); polygon1.SetEmpty(); multipoint2.SetEmpty(); polygon1.StartPath(4, 0); polygon1.LineTo(0, 4); polygon1.LineTo(4, 8); polygon1.LineTo(8, 4); multipoint2.Add(8, 1); multipoint2.Add(8, 2); op.AccelerateGeometry(polygon1, sr, com.esri.core.geometry.Geometry.GeometryAccelerationDegree.enumHot); scl = "FF2FF10F2"; res = op.Execute(polygon1, multipoint2, sr, scl, null); NUnit.Framework.Assert.IsTrue(res); }
public virtual void TestPolygonPolygonRelate() { com.esri.core.geometry.OperatorRelate op = (com.esri.core.geometry.OperatorRelate)(com.esri.core.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.esri.core.geometry.Operator.Type.Relate)); com.esri.core.geometry.SpatialReference sr = com.esri.core.geometry.SpatialReference.Create(4326); bool res; string scl; com.esri.core.geometry.Polygon polygon1 = new com.esri.core.geometry.Polygon(); com.esri.core.geometry.Polygon polygon2 = new com.esri.core.geometry.Polygon(); polygon1.StartPath(0, 0); polygon1.LineTo(0, 10); polygon1.LineTo(10, 10); polygon1.LineTo(10, 0); polygon2.StartPath(15, 0); polygon2.LineTo(15, 10); polygon2.LineTo(25, 10); polygon2.LineTo(25, 0); scl = "FFTFFT21T"; res = op.Execute(polygon1, polygon2, sr, scl, null); NUnit.Framework.Assert.IsTrue(res); scl = "FFTFFT11T"; res = op.Execute(polygon1, polygon2, sr, scl, null); NUnit.Framework.Assert.IsTrue(!res); polygon2.SetEmpty(); polygon2.StartPath(5, 0); polygon2.LineTo(5, 10); polygon2.LineTo(15, 10); polygon2.LineTo(15, 0); scl = "21TT1121T"; res = op.Execute(polygon1, polygon2, sr, scl, null); NUnit.Framework.Assert.IsTrue(res); polygon2.SetEmpty(); polygon2.StartPath(1, 1); polygon2.LineTo(1, 9); polygon2.LineTo(9, 9); polygon2.LineTo(9, 1); scl = "212FF1FFT"; res = op.Execute(polygon1, polygon2, sr, scl, null); NUnit.Framework.Assert.IsTrue(res); polygon1.SetEmpty(); polygon2.SetEmpty(); polygon1.StartPath(3, 3); polygon1.LineTo(3, 4); polygon1.LineTo(3, 3); polygon2.StartPath(1, 1); polygon2.LineTo(1, 1); scl = "FF1FFF0F2"; res = op.Execute(polygon1, polygon2, sr, scl, null); NUnit.Framework.Assert.IsTrue(res); scl = "FF0FFF1F2"; res = op.Execute(polygon2, polygon1, sr, scl, null); NUnit.Framework.Assert.IsTrue(res); polygon1.SetEmpty(); polygon2.SetEmpty(); polygon1.StartPath(0, 0); polygon1.LineTo(0, 100); polygon1.LineTo(100, 100); polygon1.LineTo(100, 0); polygon2.StartPath(50, 50); polygon2.LineTo(50, 50); polygon2.LineTo(50, 50); op.AccelerateGeometry(polygon1, sr, com.esri.core.geometry.Geometry.GeometryAccelerationDegree.enumHot); scl = "0F2FF1FF2"; res = op.Execute(polygon1, polygon2, sr, scl, null); NUnit.Framework.Assert.IsTrue(res); polygon2.LineTo(51, 50); scl = "1F2FF1FF2"; res = op.Execute(polygon1, polygon2, sr, scl, null); NUnit.Framework.Assert.IsTrue(res); }
public virtual void TestPolygonPolylineRelate() { com.esri.core.geometry.OperatorRelate op = com.esri.core.geometry.OperatorRelate.Local(); com.esri.core.geometry.SpatialReference sr = com.esri.core.geometry.SpatialReference.Create(4326); bool res; string scl; com.esri.core.geometry.Polygon polygon1 = new com.esri.core.geometry.Polygon(); com.esri.core.geometry.Polyline polyline2 = new com.esri.core.geometry.Polyline(); polygon1.StartPath(0, 0); polygon1.LineTo(0, 10); polygon1.LineTo(10, 10); polygon1.LineTo(10, 0); polyline2.StartPath(-10, 0); polyline2.LineTo(0, 0); scl = "FF2F01102"; res = op.Execute(polygon1, polyline2, sr, scl, null); NUnit.Framework.Assert.IsTrue(res); scl = "**1*0110*"; res = op.Execute(polygon1, polyline2, sr, scl, null); NUnit.Framework.Assert.IsTrue(!res); scl = "T***T****"; res = op.Execute(polygon1, polyline2, sr, scl, null); NUnit.Framework.Assert.IsTrue(!res); scl = "FF2FT****"; res = op.Execute(polygon1, polyline2, sr, scl, null); NUnit.Framework.Assert.IsTrue(res); polyline2.SetEmpty(); polyline2.StartPath(0, 0); polyline2.LineTo(10, 0); scl = "**21*1FF*"; res = op.Execute(polygon1, polyline2, sr, scl, null); NUnit.Framework.Assert.IsTrue(res); scl = "F*21*1FF*"; res = op.Execute(polygon1, polyline2, sr, scl, null); NUnit.Framework.Assert.IsTrue(res); scl = "0**1*1FF*"; res = op.Execute(polygon1, polyline2, sr, scl, null); NUnit.Framework.Assert.IsTrue(!res); scl = "F**1*1TF*"; res = op.Execute(polygon1, polyline2, sr, scl, null); NUnit.Framework.Assert.IsTrue(!res); polyline2.SetEmpty(); polyline2.StartPath(1, 1); polyline2.LineTo(5, 5); scl = "TT2******"; res = op.Execute(polygon1, polyline2, sr, scl, null); NUnit.Framework.Assert.IsTrue(res); scl = "1T2FF1FF*"; res = op.Execute(polygon1, polyline2, sr, scl, null); NUnit.Framework.Assert.IsTrue(res); scl = "1T1FF1FF*"; res = op.Execute(polygon1, polyline2, sr, scl, null); NUnit.Framework.Assert.IsTrue(!res); polyline2.SetEmpty(); polyline2.StartPath(5, 5); polyline2.LineTo(15, 5); scl = "1T20F*T0T"; res = op.Execute(polygon1, polyline2, sr, scl, null); NUnit.Framework.Assert.IsTrue(res); polygon1.SetEmpty(); polyline2.SetEmpty(); polygon1.StartPath(2, 0); polygon1.LineTo(0, 2); polygon1.LineTo(2, 4); polygon1.LineTo(4, 2); polyline2.StartPath(1, 2); polyline2.LineTo(3, 2); op.AccelerateGeometry(polygon1, sr, com.esri.core.geometry.Geometry.GeometryAccelerationDegree.enumHot); scl = "TTTFF****"; res = op.Execute(polygon1, polyline2, sr, scl, null); NUnit.Framework.Assert.IsTrue(res); polyline2.SetEmpty(); polyline2.StartPath(5, 2); polyline2.LineTo(7, 2); scl = "FF2FFT***"; res = op.Execute(polygon1, polyline2, sr, scl, null); NUnit.Framework.Assert.IsTrue(res); polygon1.SetEmpty(); polyline2.SetEmpty(); polygon1.StartPath(0, 0); polygon1.LineTo(0, 1); polygon1.LineTo(1, 0); polyline2.StartPath(0, 10); polyline2.LineTo(0, 9); polyline2.StartPath(10, 0); polyline2.LineTo(9, 0); polyline2.StartPath(0, -10); polyline2.LineTo(0, -9); scl = "**2******"; res = op.Execute(polygon1, polyline2, sr, scl, null); NUnit.Framework.Assert.IsTrue(res); polygon1.SetEmpty(); polyline2.SetEmpty(); polygon1.StartPath(0, 0); polygon1.LineTo(0, 1); polygon1.LineTo(0, 0); polyline2.StartPath(0, 10); polyline2.LineTo(0, 9); scl = "**1******"; res = op.Execute(polygon1, polyline2, sr, scl, null); NUnit.Framework.Assert.IsTrue(res); }
public virtual void TestPolygonPolylineCrosses() { com.esri.core.geometry.OperatorCrosses crosses = (com.esri.core.geometry.OperatorCrosses)(com.esri.core.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.esri.core.geometry.Operator.Type.Crosses)); com.esri.core.geometry.SpatialReference sr = com.esri.core.geometry.SpatialReference.Create(102100); double tolerance = sr.GetTolerance(com.esri.core.geometry.VertexDescription.Semantics.POSITION); com.esri.core.geometry.Polygon polygon1 = new com.esri.core.geometry.Polygon(); com.esri.core.geometry.Polyline polyline2 = new com.esri.core.geometry.Polyline(); polygon1.StartPath(0, 0); polygon1.LineTo(0, 10); polygon1.LineTo(10, 10); polygon1.LineTo(10, 0); polyline2.StartPath(5, -5); polyline2.LineTo(5, 15); bool res = crosses.Execute(polygon1, polyline2, sr, null); NUnit.Framework.Assert.IsTrue(res); res = crosses.Execute(polyline2, polygon1, sr, null); NUnit.Framework.Assert.IsTrue(res); polyline2.SetEmpty(); polyline2.StartPath(5, 0); polyline2.LineTo(5, 10); res = crosses.Execute(polygon1, polyline2, sr, null); NUnit.Framework.Assert.IsTrue(!res); res = crosses.Execute(polyline2, polygon1, sr, null); NUnit.Framework.Assert.IsTrue(!res); polygon1.SetEmpty(); polyline2.SetEmpty(); polygon1.StartPath(0, 0); polygon1.LineTo(0, 10); polygon1.LineTo(10, 10); polygon1.LineTo(10, 8); polygon1.LineTo(15, 5); polygon1.LineTo(10, 2); polygon1.LineTo(10, 0); polyline2.StartPath(10, 15); polyline2.LineTo(10, -5); res = crosses.Execute(polygon1, polyline2, sr, null); NUnit.Framework.Assert.IsTrue(res); res = crosses.Execute(polyline2, polygon1, sr, null); NUnit.Framework.Assert.IsTrue(res); }
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); }