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); }