public virtual void TestIntersectBetweenPolylineAndPolygon() { com.esri.core.geometry.Polyline basePl = new com.esri.core.geometry.Polyline(); basePl.StartPath(new com.esri.core.geometry.Point(-117, 20)); basePl.LineTo(new com.esri.core.geometry.Point(-117, 10)); basePl.LineTo(new com.esri.core.geometry.Point(-130, 10)); basePl.LineTo(new com.esri.core.geometry.Point(-130, 20)); basePl.LineTo(new com.esri.core.geometry.Point(-117, 20)); com.esri.core.geometry.Polygon compPl = new com.esri.core.geometry.Polygon(); compPl.StartPath(-116, 20); compPl.LineTo(-131, 10); compPl.LineTo(-121, 50); com.esri.core.geometry.Geometry intersectGeom = null; int noException = 1; // no exception try { intersectGeom = com.esri.core.geometry.GeometryEngine.Intersect(basePl, compPl, com.esri.core.geometry.SpatialReference.Create(4326)); } catch (System.Exception) { noException = 0; } NUnit.Framework.Assert.IsNotNull(intersectGeom); }
public virtual void TestPointAndPolyline1() { com.esri.core.geometry.Point basePl = new com.esri.core.geometry.Point(-116, 20); com.esri.core.geometry.Polyline compPl = new com.esri.core.geometry.Polyline(); compPl.StartPath(new com.esri.core.geometry.Point(-116, 20)); compPl.LineTo(new com.esri.core.geometry.Point(-131, 10)); compPl.LineTo(new com.esri.core.geometry.Point(-121, 50)); int noException = 1; // no exception com.esri.core.geometry.Geometry intersectGeom = null; try { intersectGeom = com.esri.core.geometry.GeometryEngine.Intersect(basePl, compPl, com.esri.core.geometry.SpatialReference.Create(4326)); } catch (System.Exception) { noException = 0; } NUnit.Framework.Assert.AreEqual(noException, 1); NUnit.Framework.Assert.IsNotNull(intersectGeom); NUnit.Framework.Assert.IsTrue(intersectGeom.GetType() == com.esri.core.geometry.Geometry.Type.Point); com.esri.core.geometry.Point ip = (com.esri.core.geometry.Point)intersectGeom; NUnit.Framework.Assert.AreEqual(ip.GetX(), -116, 0.1E7); NUnit.Framework.Assert.AreEqual(ip.GetY(), 20, 0.1E7); }
public static com.esri.core.geometry.Polyline MakePolyline() { com.esri.core.geometry.Polyline poly = new com.esri.core.geometry.Polyline(); // 0 poly.StartPath(0, 40); poly.LineTo(30, 0); // 1 poly.StartPath(20, 70); poly.LineTo(45, 100); // 2 poly.StartPath(50, 100); poly.LineTo(50, 60); // 3 poly.StartPath(35, 25); poly.LineTo(65, 45); // 4 poly.StartPath(60, 10); poly.LineTo(65, 35); // 5 poly.StartPath(60, 60); poly.LineTo(100, 60); // 6 poly.StartPath(80, 10); poly.LineTo(80, 99); // 7 poly.StartPath(60, 60); poly.LineTo(65, 35); return poly; }
public static void Test2() { com.esri.core.geometry.OperatorFactoryLocal engine = com.esri.core.geometry.OperatorFactoryLocal.GetInstance(); com.esri.core.geometry.OperatorGeneralize op = (com.esri.core.geometry.OperatorGeneralize)engine.GetOperator(com.esri.core.geometry.Operator.Type.Generalize); com.esri.core.geometry.Polyline polyline = new com.esri.core.geometry.Polyline(); polyline.StartPath(0, 0); polyline.LineTo(1, 1); polyline.LineTo(2, 0); polyline.LineTo(3, 2); polyline.LineTo(4, 1); polyline.LineTo(5, 0); polyline.LineTo(5, 10); polyline.LineTo(0, 10); com.esri.core.geometry.Geometry geom = op.Execute(polyline, 2, true, null); com.esri.core.geometry.Polyline p = (com.esri.core.geometry.Polyline)geom; com.esri.core.geometry.Point2D[] points = p.GetCoordinates2D(); NUnit.Framework.Assert.IsTrue(points.Length == 4); NUnit.Framework.Assert.IsTrue(points[0].x == 0 && points[0].y == 0); NUnit.Framework.Assert.IsTrue(points[1].x == 5 && points[1].y == 0); NUnit.Framework.Assert.IsTrue(points[2].x == 5 && points[2].y == 10); NUnit.Framework.Assert.IsTrue(points[3].x == 0 && points[3].y == 10); com.esri.core.geometry.Geometry geom1 = op.Execute(geom, 5, false, null); p = (com.esri.core.geometry.Polyline)geom1; points = p.GetCoordinates2D(); NUnit.Framework.Assert.IsTrue(points.Length == 2); NUnit.Framework.Assert.IsTrue(points[0].x == 0 && points[0].y == 0); NUnit.Framework.Assert.IsTrue(points[1].x == 0 && points[1].y == 10); geom1 = op.Execute(geom, 5, true, null); p = (com.esri.core.geometry.Polyline)geom1; points = p.GetCoordinates2D(); NUnit.Framework.Assert.IsTrue(points.Length == 2); NUnit.Framework.Assert.IsTrue(points[0].x == 0 && points[0].y == 0); NUnit.Framework.Assert.IsTrue(points[1].x == 0 && points[1].y == 10); }
public static void Test2() { com.esri.core.geometry.Polyline poly = new com.esri.core.geometry.Polyline(); poly.StartPath(0, 0); poly.LineTo(0, 1.0 / 3.0); poly.StartPath(0, System.Math.Sqrt(8.0)); poly.LineTo(0, System.Math.Sqrt(10.0)); poly.SetAttribute(com.esri.core.geometry.VertexDescription.Semantics.M, 1, 0, System.Math.Sqrt(3.0)); poly.InterpolateAttributes(com.esri.core.geometry.VertexDescription.Semantics.M, 0, 1, 1, 0); NUnit.Framework.Assert.IsTrue(poly.GetAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics.M, 1, 0) == System.Math.Sqrt(3.0)); NUnit.Framework.Assert.IsTrue(com.esri.core.geometry.NumberUtils.IsNaN(poly.GetAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics.M, 2, 0))); poly.SetAttribute(com.esri.core.geometry.VertexDescription.Semantics.M, 3, 0, System.Math.Sqrt(5.0)); poly.InterpolateAttributes(com.esri.core.geometry.VertexDescription.Semantics.M, 0, 1, 1, 1); NUnit.Framework.Assert.IsTrue(poly.GetAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics.M, 1, 0) == System.Math.Sqrt(3.0)); double a2 = poly.GetAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics.M, 2, 0); NUnit.Framework.Assert.IsTrue(a2 == System.Math.Sqrt(3.0)); NUnit.Framework.Assert.IsTrue(poly.GetAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics.M, 3, 0) == System.Math.Sqrt(5.0)); }
public virtual void TestTouchOnPointAndPolyline() { com.esri.core.geometry.Geometry baseGeom = new com.esri.core.geometry.Point(-130, 10); com.esri.core.geometry.Polyline pl = new com.esri.core.geometry.Polyline(); pl.StartPath(new com.esri.core.geometry.Point(-130, 10)); pl.LineTo(-131, 15); pl.LineTo(-140, 20); com.esri.core.geometry.SpatialReference sr = com.esri.core.geometry.SpatialReference.Create(4326); bool isTouched; bool isTouched2; try { isTouched = com.esri.core.geometry.GeometryEngine.Touches(baseGeom, pl, sr); isTouched2 = com.esri.core.geometry.GeometryEngine.Touches(pl, baseGeom, sr); } catch (System.ArgumentException) { isTouched = false; isTouched2 = false; } NUnit.Framework.Assert.AreEqual(isTouched && isTouched2, true); }
public static void Test1() { com.esri.core.geometry.Polyline poly = new com.esri.core.geometry.Polyline(); poly.StartPath(0, 0); poly.LineTo(0, 1.0 / 3.0); poly.LineTo(0, 2.0 / 3.0); poly.LineTo(0, 4.0 / 3.0); poly.LineTo(0, System.Math.Sqrt(6.0)); poly.LineTo(0, System.Math.Sqrt(7.0)); poly.SetAttribute(com.esri.core.geometry.VertexDescription.Semantics.M, 0, 0, 3); poly.SetAttribute(com.esri.core.geometry.VertexDescription.Semantics.M, 1, 0, 5); poly.SetAttribute(com.esri.core.geometry.VertexDescription.Semantics.M, 2, 0, 7); poly.SetAttribute(com.esri.core.geometry.VertexDescription.Semantics.M, 5, 0, 11); poly.InterpolateAttributes(com.esri.core.geometry.VertexDescription.Semantics.M, 0, 1, 0, 1); NUnit.Framework.Assert.IsTrue(poly.GetAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics.M, 0, 0) == 3); NUnit.Framework.Assert.IsTrue(poly.GetAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics.M, 1, 0) == 5); NUnit.Framework.Assert.IsTrue(poly.GetAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics.M, 2, 0) == 7); NUnit.Framework.Assert.IsTrue(com.esri.core.geometry.NumberUtils.IsNaN(poly.GetAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics.M, 3, 0))); NUnit.Framework.Assert.IsTrue(com.esri.core.geometry.NumberUtils.IsNaN(poly.GetAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics.M, 4, 0))); NUnit.Framework.Assert.IsTrue(poly.GetAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics.M, 5, 0) == 11); poly.InterpolateAttributes(com.esri.core.geometry.VertexDescription.Semantics.M, 0, 1, 0, 2); NUnit.Framework.Assert.IsTrue(poly.GetAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics.M, 0, 0) == 3); NUnit.Framework.Assert.IsTrue(poly.GetAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics.M, 1, 0) == 5); NUnit.Framework.Assert.IsTrue(poly.GetAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics.M, 2, 0) == 7); NUnit.Framework.Assert.IsTrue(com.esri.core.geometry.NumberUtils.IsNaN(poly.GetAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics.M, 3, 0))); NUnit.Framework.Assert.IsTrue(com.esri.core.geometry.NumberUtils.IsNaN(poly.GetAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics.M, 4, 0))); NUnit.Framework.Assert.IsTrue(poly.GetAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics.M, 5, 0) == 11); poly.InterpolateAttributes(com.esri.core.geometry.VertexDescription.Semantics.M, 0, 2, 0, 5); NUnit.Framework.Assert.IsTrue(poly.GetAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics.M, 0, 0) == 3); NUnit.Framework.Assert.IsTrue(poly.GetAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics.M, 1, 0) == 5); NUnit.Framework.Assert.IsTrue(poly.GetAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics.M, 2, 0) == 7); double a3 = poly.GetAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics.M, 3, 0); NUnit.Framework.Assert.IsTrue(a3 > 7 && a3 < 11); double a4 = poly.GetAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics.M, 4, 0); NUnit.Framework.Assert.IsTrue(a4 > a3 && a4 < 11); NUnit.Framework.Assert.IsTrue(poly.GetAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics.M, 5, 0) == 11); poly.StartPath(0, System.Math.Sqrt(8.0)); poly.LineTo(0, System.Math.Sqrt(10.0)); poly.LineTo(0, System.Math.Sqrt(11.0)); }
public virtual void TestTouchesBetweenMultipartPolylines() { com.esri.core.geometry.SpatialReference sr = com.esri.core.geometry.SpatialReference.Create(4326); com.esri.core.geometry.Polyline pl = new com.esri.core.geometry.Polyline(); pl.StartPath(2, 4); pl.LineTo(1, 10); pl.LineTo(6, 12); pl.StartPath(6, 12); pl.LineTo(12, 12); pl.LineTo(9, 9); com.esri.core.geometry.Polyline compPl = new com.esri.core.geometry.Polyline(); compPl.StartPath(2, 4); compPl.LineTo(2, 9); compPl.LineTo(9, 9); compPl.LineTo(9, 4); compPl.StartPath(2, 9); compPl.LineTo(6, 12); compPl.LineTo(9, 10); bool isTouched = com.esri.core.geometry.GeometryEngine.Touches(pl, compPl, sr); NUnit.Framework.Assert.IsTrue(!isTouched); }
public virtual void TestTouchPointLineCR183227() { // Tests CR 183227 com.esri.core.geometry.Geometry baseGeom = new com.esri.core.geometry.Point(-130, 10); com.esri.core.geometry.Polyline pl = new com.esri.core.geometry.Polyline(); // pl.startPath(new Point(-130, 10)); pl.StartPath(-130, 10); pl.LineTo(-131, 15); pl.LineTo(-140, 20); com.esri.core.geometry.SpatialReference sr = com.esri.core.geometry.SpatialReference.Create(4326); bool isTouched; bool isTouched2; isTouched = com.esri.core.geometry.GeometryEngine.Touches(baseGeom, pl, sr); isTouched2 = com.esri.core.geometry.GeometryEngine.Touches(pl, baseGeom, sr); NUnit.Framework.Assert.IsTrue(isTouched && isTouched2); { com.esri.core.geometry.Geometry baseGeom2 = (com.esri.core.geometry.Geometry)new com.esri.core.geometry.Point(-131, 15); bool bIsTouched; bool bIsTouched2; bIsTouched = com.esri.core.geometry.GeometryEngine.Touches(baseGeom2, pl, sr); bIsTouched2 = com.esri.core.geometry.GeometryEngine.Touches(pl, baseGeom2, sr); NUnit.Framework.Assert.IsTrue(!bIsTouched && !bIsTouched2); } }
public virtual void TestTouchesBetweenPointAndLine() { com.esri.core.geometry.SpatialReference sr = com.esri.core.geometry.SpatialReference.Create(4326); com.esri.core.geometry.Point p = new com.esri.core.geometry.Point(2, 4); com.esri.core.geometry.Polyline compPl = new com.esri.core.geometry.Polyline(); compPl.StartPath(2, 4); compPl.LineTo(9, 4); compPl.LineTo(9, 9); compPl.LineTo(2, 9); compPl.LineTo(2, 4); bool isTouched = com.esri.core.geometry.GeometryEngine.Touches(p, compPl, sr); NUnit.Framework.Assert.IsTrue(!isTouched); }
public virtual void TestTouchesBetweenPolylineAndPolygon() { com.esri.core.geometry.SpatialReference sr = com.esri.core.geometry.SpatialReference.Create(4326); com.esri.core.geometry.Polyline pl = new com.esri.core.geometry.Polyline(); pl.StartPath(2, 4); pl.LineTo(1, 10); pl.LineTo(6, 12); com.esri.core.geometry.Polygon compPg = new com.esri.core.geometry.Polygon(); compPg.StartPath(2, 4); compPg.LineTo(2, 9); compPg.LineTo(9, 9); compPg.LineTo(9, 4); compPg.StartPath(2, 9); compPg.LineTo(6, 12); compPg.LineTo(9, 10); bool isTouched = com.esri.core.geometry.GeometryEngine.Touches(pl, compPg, sr); NUnit.Framework.Assert.AreEqual(isTouched, true); }
public static com.esri.core.geometry.Polyline MakePolyline2() { com.esri.core.geometry.Polyline poly = new com.esri.core.geometry.Polyline(); poly.StartPath(-2, 0); poly.LineTo(-1, 0); poly.LineTo(0, 0); poly.LineTo(2, 0); poly.LineTo(4, 2); poly.LineTo(8, 2); poly.LineTo(10, 4); poly.LineTo(12, 4); return poly; }
public virtual void TestRelationTouch() { com.esri.core.geometry.SpatialReference sr = com.esri.core.geometry.SpatialReference.Create(4326); com.esri.core.geometry.Polyline basePl = new com.esri.core.geometry.Polyline(); basePl.StartPath(2, 2); basePl.LineTo(2, 10); com.esri.core.geometry.Polyline compPl = new com.esri.core.geometry.Polyline(); compPl.StartPath(2, 4); compPl.LineTo(9, 4); compPl.LineTo(9, 9); compPl.LineTo(2, 9); compPl.LineTo(2, 4); bool isTouched = false; // GeometryEngine.relation(basePl, compPl, sr, // "G1 TOUCH G2"); NUnit.Framework.Assert.AreEqual(isTouched, false); }
public static com.esri.core.geometry.Polyline MakePolyline1() { com.esri.core.geometry.Polyline poly = new com.esri.core.geometry.Polyline(); poly.StartPath(0, 0); poly.LineTo(15, 15); return poly; }
public static void TestCR254240() { com.esri.core.geometry.OperatorProximity2D proximityOp = com.esri.core.geometry.OperatorProximity2D.Local(); com.esri.core.geometry.Point inputPoint = new com.esri.core.geometry.Point(-12, 12); com.esri.core.geometry.Polyline line = new com.esri.core.geometry.Polyline(); line.StartPath(-10, 0); line.LineTo(0, 0); com.esri.core.geometry.Proximity2DResult result = proximityOp.GetNearestCoordinate(line, inputPoint, false, true); NUnit.Framework.Assert.IsTrue(result.IsRightSide() == false); }
public static com.esri.core.geometry.Polyline MakePolygonCutter9() { com.esri.core.geometry.Polyline poly = new com.esri.core.geometry.Polyline(); poly.StartPath(5, -1); poly.LineTo(5, 51); return poly; }
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 com.esri.core.geometry.Polyline MakePolygonCutter8() { com.esri.core.geometry.Polyline poly = new com.esri.core.geometry.Polyline(); poly.StartPath(10, 10); poly.LineTo(10, 20); poly.LineTo(20, 20); poly.LineTo(20, 10); poly.LineTo(10, 10); return poly; }
public static com.esri.core.geometry.Polyline MakePolygonCutter5() { com.esri.core.geometry.Polyline poly = new com.esri.core.geometry.Polyline(); poly.StartPath(15, 0); poly.LineTo(0, 15); poly.LineTo(15, 30); poly.LineTo(30, 15); poly.LineTo(15, 0); return poly; }
public static com.esri.core.geometry.Polyline MakePolylineCutter2() { com.esri.core.geometry.Polyline poly = new com.esri.core.geometry.Polyline(); poly.StartPath(-1.5, 0); poly.LineTo(-.75, 0); poly.StartPath(-.5, 0); poly.LineTo(1, 0); poly.LineTo(1, 2); poly.LineTo(3, -2); poly.LineTo(4, 2); poly.LineTo(5, -2); poly.LineTo(5, 4); poly.LineTo(8, 2); poly.LineTo(6, 0); poly.LineTo(6, 3); poly.StartPath(9, 5); poly.LineTo(9, 2); poly.LineTo(10, 2); poly.LineTo(10, 5); poly.LineTo(10.5, 5); poly.LineTo(10.5, 3); poly.StartPath(11, 4); poly.LineTo(11, 5); poly.StartPath(12, 5); poly.LineTo(12, 4); return poly; }
public virtual void TestTouchesOnPolylines() { com.esri.core.geometry.SpatialReference sr = com.esri.core.geometry.SpatialReference.Create(4326); com.esri.core.geometry.Polyline basePl = new com.esri.core.geometry.Polyline(); basePl.StartPath(new com.esri.core.geometry.Point(-117, 20)); basePl.LineTo(new com.esri.core.geometry.Point(-100, 20)); basePl.LineTo(new com.esri.core.geometry.Point(-100, 10)); basePl.LineTo(new com.esri.core.geometry.Point(-117, 10)); basePl.LineTo(new com.esri.core.geometry.Point(-117, 20)); com.esri.core.geometry.Polyline compPl = new com.esri.core.geometry.Polyline(); compPl.StartPath(new com.esri.core.geometry.Point(-104, 20)); compPl.LineTo(new com.esri.core.geometry.Point(-108, 25)); compPl.LineTo(new com.esri.core.geometry.Point(-100, 20)); // compPl.lineTo(new Point(-100, 30)); // compPl.lineTo(new Point(-117, 30)); // compPl.lineTo(new Point(-117, 20)); bool isTouched; try { isTouched = com.esri.core.geometry.GeometryEngine.Touches(basePl, compPl, sr); } catch (System.ArgumentException) { isTouched = false; } NUnit.Framework.Assert.AreEqual(isTouched, true); }
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); } }
internal virtual com.esri.core.geometry.Polyline MakePolyline() { com.esri.core.geometry.Polyline poly = new com.esri.core.geometry.Polyline(); poly.StartPath(0, 0); poly.LineTo(0, 10); poly.LineTo(10, 10); poly.LineTo(10, 0); return poly; }
public static com.esri.core.geometry.Polyline MakePolyline1() { com.esri.core.geometry.Polyline poly = new com.esri.core.geometry.Polyline(); poly.StartPath(0, 0); poly.LineTo(2, 0); poly.LineTo(4, 0); poly.LineTo(6, 0); poly.LineTo(8, 0); poly.LineTo(10, 0); poly.LineTo(12, 0); poly.LineTo(14, 0); poly.LineTo(16, 0); poly.LineTo(18, 0); poly.LineTo(20, 0); return poly; }
public virtual void TestPointAndPolyline2() { com.esri.core.geometry.Point basePl = new com.esri.core.geometry.Point(-115, 20); com.esri.core.geometry.Polyline compPl = new com.esri.core.geometry.Polyline(); compPl.StartPath(new com.esri.core.geometry.Point(-116, 20)); compPl.LineTo(new com.esri.core.geometry.Point(-131, 10)); compPl.LineTo(new com.esri.core.geometry.Point(-121, 50)); int noException = 1; // no exception com.esri.core.geometry.Geometry intersectGeom = null; try { intersectGeom = com.esri.core.geometry.GeometryEngine.Intersect(basePl, compPl, com.esri.core.geometry.SpatialReference.Create(4326)); } catch (System.Exception) { noException = 0; } NUnit.Framework.Assert.AreEqual(noException, 1); NUnit.Framework.Assert.IsTrue(intersectGeom.IsEmpty()); }
public static com.esri.core.geometry.Polyline MakePolylineCutter1() { com.esri.core.geometry.Polyline poly = new com.esri.core.geometry.Polyline(); poly.StartPath(1, 0); poly.LineTo(4, 0); poly.StartPath(6, -1); poly.LineTo(6, 1); poly.StartPath(6, 0); poly.LineTo(8, 0); poly.StartPath(9, -1); poly.LineTo(9, 1); poly.StartPath(10, 0); poly.LineTo(12, 0); poly.StartPath(12, 1); poly.LineTo(12, -1); poly.StartPath(12, 0); poly.LineTo(15, 0); poly.StartPath(15, 1); poly.LineTo(15, -1); poly.StartPath(16, 0); poly.LineTo(16, -1); poly.LineTo(17, -1); poly.LineTo(17, 1); poly.LineTo(17, 0); poly.LineTo(18, 0); poly.StartPath(18, 0); poly.LineTo(18, -1); return poly; }
public static void TestDifferenceOnPolyline() { // # * * # // # * @ // # @ * // # * // // /////////////////////////////// // // The polyline drawn in *s represents basePl // The polyline drawn in #s represents compPl // The @ represents their intersection points, so that // the difference polyline will be basePl with two new vertices @ added. com.esri.core.geometry.Polyline basePl = new com.esri.core.geometry.Polyline(); basePl.StartPath(new com.esri.core.geometry.Point(-117, 20)); basePl.LineTo(new com.esri.core.geometry.Point(-130, 10)); basePl.LineTo(new com.esri.core.geometry.Point(-120, 50)); com.esri.core.geometry.Polyline compPl = new com.esri.core.geometry.Polyline(); compPl.StartPath(new com.esri.core.geometry.Point(-116, 20)); compPl.LineTo(new com.esri.core.geometry.Point(-131, 10)); compPl.LineTo(new com.esri.core.geometry.Point(-121, 50)); com.esri.core.geometry.Geometry diffGeom = com.esri.core.geometry.GeometryEngine.Difference(basePl, compPl, com.esri.core.geometry.SpatialReference.Create(4326)); NUnit.Framework.Assert.IsTrue(diffGeom is com.esri.core.geometry.Polyline); com.esri.core.geometry.Polyline diffPolyline = (com.esri.core.geometry.Polyline)diffGeom; int pointCountDiffPolyline = diffPolyline.GetPointCount(); // first line in comp_pl is 3y = 2x + 292 NUnit.Framework.Assert.AreEqual(3 * 20, 2 * (-116) + 292); NUnit.Framework.Assert.AreEqual(3 * 10, 2 * (-131) + 292); // new points should also lie on this line NUnit.Framework.Assert.IsTrue(3.0 * diffPolyline.GetCoordinates2D()[1].y - 2.0 * diffPolyline.GetCoordinates2D()[1].x - 292.0 == 0.0); NUnit.Framework.Assert.IsTrue(3.0 * diffPolyline.GetCoordinates2D()[3].y - 2.0 * diffPolyline.GetCoordinates2D()[3].x - 292.0 == 0.0); for (int i = 0; i < 3; i++) { NUnit.Framework.Assert.IsTrue(basePl.GetCoordinates2D()[i].x == diffPolyline.GetCoordinates2D()[2 * i].x); NUnit.Framework.Assert.IsTrue(basePl.GetCoordinates2D()[i].y == diffPolyline.GetCoordinates2D()[2 * i].y); } NUnit.Framework.Assert.AreEqual(5, pointCountDiffPolyline); }
public virtual void TestEqualsOnPolylines() { com.esri.core.geometry.SpatialReference sr = com.esri.core.geometry.SpatialReference.Create(4326); com.esri.core.geometry.Polyline baseMp = new com.esri.core.geometry.Polyline(); com.esri.core.geometry.Polyline compMp = new com.esri.core.geometry.Polyline(); baseMp.StartPath(-116, 40); baseMp.LineTo(-120, 39); baseMp.LineTo(-121, 10); baseMp.LineTo(-130, 12); baseMp.LineTo(-108, 25); compMp.StartPath(-116, 40); compMp.LineTo(-120, 39); compMp.LineTo(-121, 10); compMp.LineTo(-130, 12); compMp.LineTo(-108, 25); bool isEqual; try { isEqual = com.esri.core.geometry.GeometryEngine.Equals(baseMp, compMp, sr); } catch (System.ArgumentException) { isEqual = false; } NUnit.Framework.Assert.IsTrue(isEqual); }
public virtual void TestBufferPolyline() { com.esri.core.geometry.SpatialReference sr = com.esri.core.geometry.SpatialReference.Create(4326); com.esri.core.geometry.Polyline inputGeom = new com.esri.core.geometry.Polyline(); com.esri.core.geometry.OperatorBuffer buffer = (com.esri.core.geometry.OperatorBuffer)com.esri.core.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.esri.core.geometry.Operator.Type.Buffer); com.esri.core.geometry.OperatorSimplify simplify = (com.esri.core.geometry.OperatorSimplify)com.esri.core.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.esri.core.geometry.Operator.Type.Simplify); inputGeom.StartPath(0, 0); inputGeom.LineTo(50, 50); inputGeom.LineTo(50, 0); inputGeom.LineTo(0, 50); { com.esri.core.geometry.Geometry result = buffer.Execute(inputGeom, sr, 0, null); NUnit.Framework.Assert.IsTrue(result.GetType().Value() == com.esri.core.geometry.Geometry.GeometryType.Polygon); NUnit.Framework.Assert.IsTrue(result.IsEmpty()); } { com.esri.core.geometry.Geometry result = buffer.Execute(inputGeom, sr, -1, null); NUnit.Framework.Assert.IsTrue(result.GetType().Value() == com.esri.core.geometry.Geometry.GeometryType.Polygon); NUnit.Framework.Assert.IsTrue(result.IsEmpty()); } { com.esri.core.geometry.Geometry result = buffer.Execute(inputGeom, sr, 40.0, null); NUnit.Framework.Assert.IsTrue(result.GetType().Value() == com.esri.core.geometry.Geometry.GeometryType.Polygon); com.esri.core.geometry.Polygon poly = (com.esri.core.geometry.Polygon)(result); com.esri.core.geometry.Envelope2D env2D = new com.esri.core.geometry.Envelope2D(); result.QueryEnvelope2D(env2D); NUnit.Framework.Assert.IsTrue(System.Math.Abs(env2D.GetWidth() - 80 - 50) < 0.1 && System.Math.Abs(env2D.GetHeight() - 80 - 50) < 0.1); NUnit.Framework.Assert.IsTrue(System.Math.Abs(env2D.GetCenterX() - 25) < 0.1 && System.Math.Abs(env2D.GetCenterY() - 25) < 0.1); int pathCount = poly.GetPathCount(); NUnit.Framework.Assert.IsTrue(pathCount == 1); int pointCount = poly.GetPointCount(); NUnit.Framework.Assert.IsTrue(System.Math.Abs(pointCount - 171.0) < 10); NUnit.Framework.Assert.IsTrue(simplify.IsSimpleAsFeature(result, sr, null)); } { com.esri.core.geometry.Geometry result = buffer.Execute(inputGeom, sr, 4.0, null); NUnit.Framework.Assert.IsTrue(result.GetType().Value() == com.esri.core.geometry.Geometry.GeometryType.Polygon); com.esri.core.geometry.Polygon poly = (com.esri.core.geometry.Polygon)(result); com.esri.core.geometry.Envelope2D env2D = new com.esri.core.geometry.Envelope2D(); result.QueryEnvelope2D(env2D); NUnit.Framework.Assert.IsTrue(System.Math.Abs(env2D.GetWidth() - 8 - 50) < 0.1 && System.Math.Abs(env2D.GetHeight() - 8 - 50) < 0.1); NUnit.Framework.Assert.IsTrue(System.Math.Abs(env2D.GetCenterX() - 25) < 0.1 && System.Math.Abs(env2D.GetCenterY() - 25) < 0.1); int pathCount = poly.GetPathCount(); NUnit.Framework.Assert.IsTrue(pathCount == 2); int pointCount = poly.GetPointCount(); NUnit.Framework.Assert.IsTrue(System.Math.Abs(pointCount - 186.0) < 10); NUnit.Framework.Assert.IsTrue(simplify.IsSimpleAsFeature(result, sr, null)); } { inputGeom = new com.esri.core.geometry.Polyline(); inputGeom.StartPath(0, 0); inputGeom.LineTo(50, 50); inputGeom.StartPath(50, 0); inputGeom.LineTo(0, 50); com.esri.core.geometry.Geometry result = buffer.Execute(inputGeom, sr, 4.0, null); NUnit.Framework.Assert.IsTrue(result.GetType().Value() == com.esri.core.geometry.Geometry.GeometryType.Polygon); com.esri.core.geometry.Polygon poly = (com.esri.core.geometry.Polygon)(result); com.esri.core.geometry.Envelope2D env2D = new com.esri.core.geometry.Envelope2D(); result.QueryEnvelope2D(env2D); NUnit.Framework.Assert.IsTrue(System.Math.Abs(env2D.GetWidth() - 8 - 50) < 0.1 && System.Math.Abs(env2D.GetHeight() - 8 - 50) < 0.1); NUnit.Framework.Assert.IsTrue(System.Math.Abs(env2D.GetCenterX() - 25) < 0.1 && System.Math.Abs(env2D.GetCenterY() - 25) < 0.1); int pathCount = poly.GetPathCount(); NUnit.Framework.Assert.IsTrue(pathCount == 1); int pointCount = poly.GetPointCount(); NUnit.Framework.Assert.IsTrue(System.Math.Abs(pointCount - 208.0) < 10); NUnit.Framework.Assert.IsTrue(simplify.IsSimpleAsFeature(result, sr, null)); } }
public virtual void TestTouchesOnPolylineAndEnvelope() { com.esri.core.geometry.SpatialReference sr = com.esri.core.geometry.SpatialReference.Create(4326); com.esri.core.geometry.Polyline basePl = new com.esri.core.geometry.Polyline(); basePl.StartPath(new com.esri.core.geometry.Point(-117, 20)); basePl.LineTo(new com.esri.core.geometry.Point(-100, 20)); basePl.LineTo(new com.esri.core.geometry.Point(-100, 10)); basePl.LineTo(new com.esri.core.geometry.Point(-117, 10)); basePl.LineTo(new com.esri.core.geometry.Point(-117, 20)); // Envelope env = new Envelope(new Point(-117,20), 12, 12);//not touched com.esri.core.geometry.Envelope env = new com.esri.core.geometry.Envelope(-100, 20, -80, 30); // touched bool isTouched; try { isTouched = com.esri.core.geometry.GeometryEngine.Touches(basePl, env, sr); } catch (System.ArgumentException) { isTouched = false; } NUnit.Framework.Assert.AreEqual(isTouched, true); }