public static void Test5() { com.esri.core.geometry.Polygon poly = new com.esri.core.geometry.Polygon(); poly.StartPath(0, 0); poly.LineTo(0, 1); poly.LineTo(1, 1); poly.LineTo(1, 0); poly.StartPath(2, 0); poly.LineTo(2, 1); poly.LineTo(3, 1); poly.LineTo(3, 0); poly.SetAttribute(com.esri.core.geometry.VertexDescription.Semantics.M, 1, 0, 1); poly.SetAttribute(com.esri.core.geometry.VertexDescription.Semantics.M, 3, 0, 3); poly.SetAttribute(com.esri.core.geometry.VertexDescription.Semantics.M, 6, 0, 1); poly.SetAttribute(com.esri.core.geometry.VertexDescription.Semantics.M, 5, 0, 4); poly.InterpolateAttributes(com.esri.core.geometry.VertexDescription.Semantics.M, 0, 3, 1); poly.InterpolateAttributes(com.esri.core.geometry.VertexDescription.Semantics.M, 0, 1, 3); poly.InterpolateAttributes(com.esri.core.geometry.VertexDescription.Semantics.M, 1, 2, 1); NUnit.Framework.Assert.IsTrue(poly.GetAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics.M, 0, 0) == 2); NUnit.Framework.Assert.IsTrue(poly.GetAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics.M, 1, 0) == 1); NUnit.Framework.Assert.IsTrue(poly.GetAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics.M, 2, 0) == 2); NUnit.Framework.Assert.IsTrue(poly.GetAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics.M, 3, 0) == 3); NUnit.Framework.Assert.IsTrue(poly.GetAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics.M, 4, 0) == 3); NUnit.Framework.Assert.IsTrue(poly.GetAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics.M, 5, 0) == 4); NUnit.Framework.Assert.IsTrue(poly.GetAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics.M, 6, 0) == 1); NUnit.Framework.Assert.IsTrue(poly.GetAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics.M, 7, 0) == 2); }
public virtual void TestIntersectionPolylinePolygon() { { com.esri.core.geometry.Polygon polygon = new com.esri.core.geometry.Polygon(); polygon.StartPath(0, 0); polygon.LineTo(0, 10); polygon.LineTo(20, 10); polygon.LineTo(20, 0); polygon.AddAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z); polygon.SetAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z, 0, 0, 3); polygon.SetAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z, 3, 0, 3); polygon.InterpolateAttributes(0, 0, 3); com.esri.core.geometry.Polyline polyline = new com.esri.core.geometry.Polyline(); polyline.StartPath(0, 10); polyline.LineTo(5, 5); polyline.LineTo(6, 4); polyline.LineTo(7, -1); polyline.AddAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z); polyline.SetAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z, 0, 0, 5); polyline.SetAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z, 3, 0, 5); polyline.InterpolateAttributes(0, 0, 0, 3); // OperatorFactoryLocal projEnv = // OperatorFactoryLocal.getInstance(); com.esri.core.geometry.OperatorIntersection operatorIntersection = (com.esri.core.geometry.OperatorIntersection)projEnv.GetOperator(com.esri.core.geometry.Operator.Type.Intersection); com.esri.core.geometry.Geometry geom = operatorIntersection.Execute(polyline, polygon, null, null); NUnit.Framework.Assert.IsTrue(!geom.IsEmpty()); com.esri.core.geometry.Polyline poly = (com.esri.core.geometry.Polyline)(geom); for (int i = 0; i < poly.GetPointCount(); i++) { NUnit.Framework.Assert.IsTrue(poly.GetAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics.Z, i, 0) == 5); } } { // std::shared_ptr<Operator_export_to_JSON> jsonExport = // (Operator_export_to_JSON>)Operator_factory_local::get_instance().get_operator(Operator::Operator_type::export_to_JSON); // std::string str = jsonExport.execute(0, geom, null, null); // OutputDebugStringA(str.c_str()); // OutputDebugString(L"\n"); // assertTrue(str=="{\"paths\":[[[0,10],[5,5],[6,4],[6.7999999999999998,4.4408922169635528e-016]]]}"); com.esri.core.geometry.Polygon polygon = new com.esri.core.geometry.Polygon(); polygon.StartPath(0, 0); polygon.LineTo(0, 10); polygon.LineTo(20, 10); polygon.LineTo(20, 0); polygon.AddAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z); polygon.SetAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z, 0, 0, 3); polygon.SetAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z, 3, 0, 3); polygon.InterpolateAttributes(0, 0, 3); com.esri.core.geometry.Polyline polyline = new com.esri.core.geometry.Polyline(); polyline.StartPath(0, 10); polyline.LineTo(20, 0); polyline.LineTo(5, 5); polyline.AddAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z); polyline.SetAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z, 0, 0, 5); polyline.SetAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z, 1, 0, 5); polyline.SetAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z, 2, 0, 5); // OperatorFactoryLocal projEnv = // OperatorFactoryLocal.getInstance(); com.esri.core.geometry.OperatorIntersection operatorIntersection = (com.esri.core.geometry.OperatorIntersection)projEnv.GetOperator(com.esri.core.geometry.Operator.Type.Intersection); com.esri.core.geometry.Geometry geom = operatorIntersection.Execute(polyline, polygon, null, null); NUnit.Framework.Assert.IsTrue(!geom.IsEmpty()); com.esri.core.geometry.Polyline poly = (com.esri.core.geometry.Polyline)(geom); for (int i = 0; i < poly.GetPointCount(); i++) { NUnit.Framework.Assert.IsTrue(poly.GetAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics.Z, i, 0) == 5); } } { // Operator_export_to_JSON> jsonExport = // (Operator_export_to_JSON>)Operator_factory_local::get_instance().get_operator(Operator::Operator_type::export_to_JSON); // std::string str = jsonExport.execute(0, geom, null, null); // OutputDebugStringA(str.c_str()); // OutputDebugString(L"\n"); // assertTrue(str=="{\"paths\":[[[0,10],[20,0],[5,5]]]}"); com.esri.core.geometry.Polygon polygon = new com.esri.core.geometry.Polygon(); polygon.StartPath(0, 0); polygon.LineTo(0, 10); polygon.LineTo(20, 10); polygon.LineTo(20, 0); polygon.AddAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z); polygon.SetAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z, 0, 0, 3); polygon.SetAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z, 3, 0, 3); polygon.InterpolateAttributes(0, 0, 3); com.esri.core.geometry.Polyline polyline = new com.esri.core.geometry.Polyline(); polyline.StartPath(0, 0); polyline.LineTo(0, 10); polyline.LineTo(20, 10); polyline.AddAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z); polyline.SetAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z, 0, 0, 5); polyline.SetAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z, 1, 0, 5); polyline.SetAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z, 2, 0, 5); // OperatorFactoryLocal projEnv = // OperatorFactoryLocal.getInstance(); com.esri.core.geometry.OperatorIntersection operatorIntersection = (com.esri.core.geometry.OperatorIntersection)projEnv.GetOperator(com.esri.core.geometry.Operator.Type.Intersection); com.esri.core.geometry.Geometry geom = operatorIntersection.Execute(polyline, polygon, null, null); NUnit.Framework.Assert.IsTrue(!geom.IsEmpty()); com.esri.core.geometry.Polyline poly = (com.esri.core.geometry.Polyline)(geom); for (int i = 0; i < poly.GetPointCount(); i++) { NUnit.Framework.Assert.IsTrue(poly.GetAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics.Z, i, 0) == 5); } } { // Operator_export_to_JSON> jsonExport = // (Operator_export_to_JSON>)Operator_factory_local::get_instance().get_operator(Operator::Operator_type::export_to_JSON); // std::string str = jsonExport.execute(0, geom, null, null); // OutputDebugStringA(str.c_str()); // OutputDebugString(L"\n"); // assertTrue(str=="{\"paths\":[[[0,0],[0,10],[20,10]]]}"); com.esri.core.geometry.Polygon polygon = new com.esri.core.geometry.Polygon(); polygon.StartPath(0, 0); polygon.LineTo(0, 10); polygon.LineTo(20, 10); polygon.LineTo(20, 0); com.esri.core.geometry.Polyline polyline = new com.esri.core.geometry.Polyline(); polyline.StartPath(3, -1); polyline.LineTo(17, 1); polyline.LineTo(10, 8); polyline.LineTo(-1, 5); polyline.AddAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z); polyline.SetAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z, 0, 0, 5); polyline.SetAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z, 1, 0, 5); polyline.SetAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z, 2, 0, 5); polyline.SetAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z, 3, 0, 5); // OperatorFactoryLocal projEnv = // OperatorFactoryLocal.getInstance(); com.esri.core.geometry.OperatorIntersection operatorIntersection = (com.esri.core.geometry.OperatorIntersection)projEnv.GetOperator(com.esri.core.geometry.Operator.Type.Intersection); com.esri.core.geometry.Geometry geom = operatorIntersection.Execute(polyline, polygon, null, null); NUnit.Framework.Assert.IsTrue(!geom.IsEmpty()); com.esri.core.geometry.Polyline poly = (com.esri.core.geometry.Polyline)geom; for (int i = 0; i < poly.GetPointCount(); i++) { NUnit.Framework.Assert.IsTrue(poly.GetAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics.Z, i, 0) == 5); } } { // Operator_export_to_JSON> jsonExport = // (Operator_export_to_JSON>)Operator_factory_local::get_instance().get_operator(Operator::Operator_type::export_to_JSON); // std::string str = jsonExport.execute(0, geom, null, null); // OutputDebugStringA(str.c_str()); // OutputDebugString(L"\n"); // assertTrue(str=="{\"paths\":[[[10,0],[17,1],[10,8],[4.7377092701401439e-024,5.2727272727272734]]]}"); com.esri.core.geometry.Polygon polygon = new com.esri.core.geometry.Polygon(); polygon.StartPath(0, 0); polygon.LineTo(0, 10); polygon.LineTo(20, 10); polygon.LineTo(20, 0); com.esri.core.geometry.Polyline polyline = new com.esri.core.geometry.Polyline(); polyline.StartPath(0, 15); polyline.LineTo(3, -1); polyline.LineTo(17, 1); polyline.LineTo(10, 8); polyline.LineTo(-1, 5); polyline.AddAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z); polyline.SetAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z, 0, 0, 5); polyline.SetAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z, 4, 0, 5); polyline.InterpolateAttributes(0, 0, 0, 4); com.esri.core.geometry.OperatorIntersection operatorIntersection = (com.esri.core.geometry.OperatorIntersection)projEnv.GetOperator(com.esri.core.geometry.Operator.Type.Intersection); com.esri.core.geometry.Geometry geom = operatorIntersection.Execute(polyline, polygon, null, null); NUnit.Framework.Assert.IsTrue(!geom.IsEmpty()); com.esri.core.geometry.Polyline poly = (com.esri.core.geometry.Polyline)geom; for (int i = 0; i < poly.GetPointCount(); i++) { NUnit.Framework.Assert.IsTrue(poly.GetAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics.Z, i, 0) == 5); } } { // Operator_export_to_JSON> jsonExport = // (Operator_export_to_JSON>)Operator_factory_local::get_instance().get_operator(Operator::Operator_type::export_to_JSON); // std::string str = jsonExport.execute(0, geom, null, null); // OutputDebugStringA(str.c_str()); // OutputDebugString(L"\n"); // assertTrue(str=="{\"paths\":[[[0.9375,10],[2.8125,9.476226333847234e-024]],[[10,0],[17,1],[10,8],[4.7377092701401439e-024,5.2727272727272734]]]}"); com.esri.core.geometry.Polygon polygon = new com.esri.core.geometry.Polygon(); polygon.StartPath(0, 0); polygon.LineTo(0, 10); polygon.LineTo(20, 10); polygon.LineTo(20, 0); com.esri.core.geometry.Polyline polyline = new com.esri.core.geometry.Polyline(); polyline.StartPath(5, 5); polyline.LineTo(1, 1); polyline.LineTo(-1, 1); polyline.LineTo(-1, 10); polyline.LineTo(0, 10); polyline.LineTo(6, 6); polyline.AddAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z); polyline.SetAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z, 0, 0, 5); polyline.SetAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z, 5, 0, 5); polyline.InterpolateAttributes(0, 0, 0, 5); // OperatorFactoryLocal projEnv = // OperatorFactoryLocal.getInstance(); com.esri.core.geometry.OperatorIntersection operatorIntersection = (com.esri.core.geometry.OperatorIntersection)projEnv.GetOperator(com.esri.core.geometry.Operator.Type.Intersection); com.esri.core.geometry.Geometry geom = operatorIntersection.Execute(polyline, polygon, null, null); NUnit.Framework.Assert.IsTrue(!geom.IsEmpty()); com.esri.core.geometry.Polyline poly = (com.esri.core.geometry.Polyline)geom; for (int i = 0; i < poly.GetPointCount(); i++) { NUnit.Framework.Assert.IsTrue(poly.GetAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics.Z, i, 0) == 5); } } { // Operator_export_to_JSON> jsonExport = // (Operator_export_to_JSON>)Operator_factory_local::get_instance().get_operator(Operator::Operator_type::export_to_JSON); // std::string str = jsonExport.execute(0, geom, null, null); // OutputDebugStringA(str.c_str()); // OutputDebugString(L"\n"); // assertTrue(str=="{\"paths\":[[[5,5],[1,1],[4.738113166923617e-023,1]],[[0,10],[6,6]]]}"); com.esri.core.geometry.Polygon polygon = new com.esri.core.geometry.Polygon(); polygon.StartPath(0, 0); polygon.LineTo(0, 10); polygon.LineTo(20, 10); polygon.LineTo(20, 0); com.esri.core.geometry.Polyline polyline = new com.esri.core.geometry.Polyline(); polyline.StartPath(0, 15); polyline.LineTo(3, -1); polyline.LineTo(17, 1); polyline.LineTo(10, 8); polyline.LineTo(-1, 5); polyline.StartPath(19, 15); polyline.LineTo(29, 9); polyline.StartPath(19, 15); polyline.LineTo(29, 9); polyline.StartPath(5, 5); polyline.LineTo(1, 1); polyline.LineTo(-1, 1); polyline.LineTo(-1, 10); polyline.LineTo(0, 10); polyline.LineTo(6, 6); polyline.AddAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z); polyline.SetAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z, 0, 0, 5); polyline.SetAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z, 14, 0, 5); polyline.InterpolateAttributes(0, 0, 3, 5); // OperatorFactoryLocal projEnv = // OperatorFactoryLocal.getInstance(); com.esri.core.geometry.OperatorIntersection operatorIntersection = (com.esri.core.geometry.OperatorIntersection)projEnv.GetOperator(com.esri.core.geometry.Operator.Type.Intersection); com.esri.core.geometry.Geometry geom = operatorIntersection.Execute(polyline, polygon, null, null); NUnit.Framework.Assert.IsTrue(!geom.IsEmpty()); com.esri.core.geometry.Polyline poly = (com.esri.core.geometry.Polyline)geom; for (int i = 0; i < poly.GetPointCount(); i++) { NUnit.Framework.Assert.IsTrue(poly.GetAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics.Z, i, 0) == 5); } } }