public virtual void TestTouchOnPolygons() { com.esri.core.geometry.Polygon pg = new com.esri.core.geometry.Polygon(); pg.StartPath(new com.esri.core.geometry.Point(-130, 10)); pg.LineTo(-131, 15); pg.LineTo(-140, 20); com.esri.core.geometry.Polygon pg2 = new com.esri.core.geometry.Polygon(); pg2.StartPath(new com.esri.core.geometry.Point(-130, 10)); pg2.LineTo(-131, 15); pg2.LineTo(-120, 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(pg, pg2, sr); isTouched2 = com.esri.core.geometry.GeometryEngine.Touches(pg2, pg, sr); } catch (System.ArgumentException) { isTouched = false; isTouched2 = false; } NUnit.Framework.Assert.AreEqual(isTouched && isTouched2, true); }
public virtual void TestEqualsOnPolygons() { com.esri.core.geometry.SpatialReference sr = com.esri.core.geometry.SpatialReference.Create(4326); com.esri.core.geometry.Polygon baseMp = new com.esri.core.geometry.Polygon(); com.esri.core.geometry.Polygon compMp = new com.esri.core.geometry.Polygon(); 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 static void Test1() { 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.Polygon poly = new com.esri.core.geometry.Polygon(); poly.StartPath(0, 0); poly.LineTo(1, 1); poly.LineTo(2, 0); poly.LineTo(3, 2); poly.LineTo(4, 1); poly.LineTo(5, 0); poly.LineTo(5, 10); poly.LineTo(0, 10); com.esri.core.geometry.Geometry geom = op.Execute(poly, 2, true, null); com.esri.core.geometry.Polygon p = (com.esri.core.geometry.Polygon)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.Polygon)geom1; points = p.GetCoordinates2D(); NUnit.Framework.Assert.IsTrue(points.Length == 3); NUnit.Framework.Assert.IsTrue(points[0].x == 0 && points[0].y == 0); NUnit.Framework.Assert.IsTrue(points[1].x == 5 && points[1].y == 10); NUnit.Framework.Assert.IsTrue(points[2].x == 5 && points[2].y == 10); geom1 = op.Execute(geom, 5, true, null); p = (com.esri.core.geometry.Polygon)geom1; points = p.GetCoordinates2D(); NUnit.Framework.Assert.IsTrue(points.Length == 0); }
public virtual com.esri.core.geometry.Polygon MakeNonSimplePolygon2() { //MapGeometry mg = OperatorFactoryLocal.loadGeometryFromJSONFileDbg("c:/temp/simplify_polygon_gnomonic.txt"); //Geometry res = OperatorSimplify.local().execute(mg.getGeometry(), mg.getSpatialReference(), true, null); com.esri.core.geometry.Polygon poly = new com.esri.core.geometry.Polygon(); poly.StartPath(0, 0); poly.LineTo(0, 15); poly.LineTo(15, 15); poly.LineTo(15, 0); // This is an interior ring but it is clockwise poly.StartPath(5, 5); poly.LineTo(5, 6); poly.LineTo(6, 6); poly.LineTo(6, 5); return poly; }
public static void TestDistanceBetweenHugeGeometries() { /* const */ int N = 1000; // Should be even /* const */ double theoreticalDistance = 0.77; com.esri.core.geometry.Polygon poly = new com.esri.core.geometry.Polygon(); com.esri.core.geometry.Polygon poly2 = new com.esri.core.geometry.Polygon(); double theta = 0.0; double thetaPlusPi = System.Math.PI; double dTheta = 2.0 * System.Math.PI / N; double distance; poly.StartPath(System.Math.Cos(theta), System.Math.Sin(theta)); // Add something so that poly2's bounding box is in poly's. Deleting // this should not affect answer. poly.LineTo(1.0, 1.5 + theoreticalDistance); poly.LineTo(3.5 + theoreticalDistance, 1.5 + theoreticalDistance); poly.LineTo(3.5 + theoreticalDistance, 2.0 + theoreticalDistance); poly.LineTo(0.95, 2.0 + theoreticalDistance); // /////////////////////////////////////////////////////////// poly2.StartPath(2.0 + theoreticalDistance + System.Math.Cos(thetaPlusPi), System.Math.Sin(thetaPlusPi)); for (double i = 1; i < N; i++) { theta += dTheta; thetaPlusPi += dTheta; poly.LineTo(System.Math.Cos(theta), System.Math.Sin(theta)); poly2.LineTo(2.0 + theoreticalDistance + System.Math.Cos(thetaPlusPi), System.Math.Sin(thetaPlusPi)); } distance = com.esri.core.geometry.GeometryEngine.Distance(poly, poly2, null); NUnit.Framework.Assert.IsTrue(System.Math.Abs(distance - theoreticalDistance) < 1.0e-10); }
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); }
// done /* * ------------>---------------->--------------- | | | (1) | | | | --->--- * ------->------- | | | | | (5) | | | | | | --<-- | | | | (2) | | | | | | | * | | | | (4) | | | | | | | -->-- | | --<-- | ---<--- | | | | | | * -------<------- | | (3) | -------------<---------------<--------------- * -->-- */ // Bowtie case with vertices at intersection public virtual com.esri.core.geometry.Polygon MakeNonSimplePolygon5() { com.esri.core.geometry.Polygon poly = new com.esri.core.geometry.Polygon(); poly.StartPath(10, 0); poly.LineTo(0, 0); poly.LineTo(5, 5); poly.LineTo(10, 10); poly.LineTo(0, 10); poly.LineTo(5, 5); return poly; }
public static void TestDistanceBetweenTriangles() { double distance; com.esri.core.geometry.Polygon poly = new com.esri.core.geometry.Polygon(); com.esri.core.geometry.Polygon poly2 = new com.esri.core.geometry.Polygon(); poly.StartPath(0.0, 0.0); poly.LineTo(1.0, 2.0); poly.LineTo(0.0, 2.0); double xSeparation = 0.1; double ySeparation = 0.1; poly2.StartPath(xSeparation + 1.0, 2.0 - ySeparation); poly2.LineTo(xSeparation + 2.0, 2.0 - ySeparation); poly2.LineTo(xSeparation + 2.0, 4.0 - ySeparation); distance = com.esri.core.geometry.GeometryEngine.Distance(poly, poly2, null); NUnit.Framework.Assert.IsTrue(0.0 < distance && distance < xSeparation + ySeparation); }
public static void TestProximity2D_3() { com.esri.core.geometry.OperatorFactoryLocal factory = com.esri.core.geometry.OperatorFactoryLocal.GetInstance(); com.esri.core.geometry.OperatorProximity2D proximity = (com.esri.core.geometry.OperatorProximity2D)factory.GetOperator(com.esri.core.geometry.Operator.Type.Proximity2D); com.esri.core.geometry.Polygon polygon = new com.esri.core.geometry.Polygon(); polygon.StartPath(new com.esri.core.geometry.Point(-120, 22)); polygon.LineTo(new com.esri.core.geometry.Point(-120, 10)); polygon.LineTo(new com.esri.core.geometry.Point(-110, 10)); polygon.LineTo(new com.esri.core.geometry.Point(-110, 22)); com.esri.core.geometry.Point point = new com.esri.core.geometry.Point(); point.SetXY(-110, 20); com.esri.core.geometry.Proximity2DResult result = proximity.GetNearestCoordinate(polygon, point, false); com.esri.core.geometry.Point point2 = new com.esri.core.geometry.Point(); point2.SetXY(-120, 12); com.esri.core.geometry.Proximity2DResult[] results = proximity.GetNearestVertices(polygon, point2, 10, 12); }
internal virtual com.esri.core.geometry.Polygon MakePolygon() { com.esri.core.geometry.Polygon poly = new com.esri.core.geometry.Polygon(); poly.StartPath(3, -2); poly.LineTo(2, -1); poly.LineTo(3, 0); poly.LineTo(4, 0); poly.StartPath(1.75, 1); poly.LineTo(0.75, 2); poly.LineTo(1.75, 3); poly.LineTo(2.25, 2.5); poly.LineTo(2.75, 2); poly.StartPath(3, 2.5); poly.LineTo(2.5, 3); poly.LineTo(2, 3.5); poly.LineTo(3, 4.5); poly.LineTo(4, 3.5); poly.StartPath(4.75, 1); poly.LineTo(3.75, 2); poly.LineTo(4, 2.25); poly.LineTo(4.75, 3); poly.LineTo(5.75, 2); return poly; }
internal virtual com.esri.core.geometry.Polygon MakePolygon2() { com.esri.core.geometry.Polygon poly = new com.esri.core.geometry.Polygon(); poly.StartPath(0, 0); poly.LineTo(0, 10); poly.LineTo(10, 10); poly.LineTo(10, 0); return poly; }
public virtual void TestTouchesBetweenMultipartPolygons2() { com.esri.core.geometry.SpatialReference sr = com.esri.core.geometry.SpatialReference.Create(4326); com.esri.core.geometry.Polygon pl = new com.esri.core.geometry.Polygon(); pl.StartPath(2, 4); pl.LineTo(1, 9); pl.LineTo(2, 6); pl.StartPath(2, 9); pl.LineTo(6, 14); pl.LineTo(6, 12); com.esri.core.geometry.Polygon compPl = new com.esri.core.geometry.Polygon(); 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.AreEqual(isTouched, true); }
public virtual void TestTouchPolygonPolygon() { com.esri.core.geometry.OperatorTouches operatorTouches = (com.esri.core.geometry.OperatorTouches)(com.esri.core.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.esri.core.geometry.Operator.Type.Touches)); com.esri.core.geometry.Polygon pg = new com.esri.core.geometry.Polygon(); pg.StartPath(-130, 10); pg.LineTo(-131, 15); pg.LineTo(-140, 20); com.esri.core.geometry.Polygon pg2 = new com.esri.core.geometry.Polygon(); pg2.StartPath(-130, 10); pg2.LineTo(-131, 15); pg2.LineTo(-120, 20); com.esri.core.geometry.SpatialReference sr = com.esri.core.geometry.SpatialReference.Create(4326); bool isTouched; bool isTouched2; isTouched = operatorTouches.Execute(pg, pg2, sr, null); isTouched2 = operatorTouches.Execute(pg2, pg, sr, null); NUnit.Framework.Assert.IsTrue(isTouched && isTouched2); }
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 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 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 TestDisjointRelationFalse() { { com.esri.core.geometry.OperatorDisjoint op = (com.esri.core.geometry.OperatorDisjoint)(com.esri.core.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.esri.core.geometry.Operator.Type.Disjoint)); com.esri.core.geometry.Envelope env1 = new com.esri.core.geometry.Envelope(50, 50, 150, 150); com.esri.core.geometry.Envelope env2 = new com.esri.core.geometry.Envelope(25, 25, 175, 175); bool result = op.Execute(env1, env2, com.esri.core.geometry.SpatialReference.Create(4326), null); NUnit.Framework.Assert.IsTrue(!result); } { com.esri.core.geometry.OperatorIntersects op = (com.esri.core.geometry.OperatorIntersects)(com.esri.core.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.esri.core.geometry.Operator.Type.Intersects)); com.esri.core.geometry.Envelope env1 = new com.esri.core.geometry.Envelope(50, 50, 150, 150); com.esri.core.geometry.Envelope env2 = new com.esri.core.geometry.Envelope(25, 25, 175, 175); bool result = op.Execute(env1, env2, com.esri.core.geometry.SpatialReference.Create(4326), null); NUnit.Framework.Assert.IsTrue(result); } { com.esri.core.geometry.OperatorContains op = (com.esri.core.geometry.OperatorContains)(com.esri.core.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.esri.core.geometry.Operator.Type.Contains)); com.esri.core.geometry.Envelope env1 = new com.esri.core.geometry.Envelope(100, 175, 200, 225); com.esri.core.geometry.Polyline polyline = new com.esri.core.geometry.Polyline(); polyline.StartPath(200, 175); polyline.LineTo(200, 225); polyline.LineTo(125, 200); bool result = op.Execute(env1, polyline, com.esri.core.geometry.SpatialReference.Create(4326), null); NUnit.Framework.Assert.IsTrue(result); } { com.esri.core.geometry.OperatorTouches op = (com.esri.core.geometry.OperatorTouches)(com.esri.core.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.esri.core.geometry.Operator.Type.Touches)); com.esri.core.geometry.Envelope env1 = new com.esri.core.geometry.Envelope(100, 200, 400, 400); com.esri.core.geometry.Polyline polyline = new com.esri.core.geometry.Polyline(); polyline.StartPath(300, 60); polyline.LineTo(300, 200); polyline.LineTo(400, 50); bool result = op.Execute(env1, polyline, com.esri.core.geometry.SpatialReference.Create(4326), null); NUnit.Framework.Assert.IsTrue(result); } { com.esri.core.geometry.OperatorTouches op = (com.esri.core.geometry.OperatorTouches)(com.esri.core.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.esri.core.geometry.Operator.Type.Touches)); com.esri.core.geometry.Envelope env1 = new com.esri.core.geometry.Envelope(50, 50, 150, 150); com.esri.core.geometry.Polyline polyline = new com.esri.core.geometry.Polyline(); polyline.StartPath(100, 20); polyline.LineTo(100, 50); polyline.LineTo(150, 10); bool result = op.Execute(polyline, env1, com.esri.core.geometry.SpatialReference.Create(4326), null); NUnit.Framework.Assert.IsTrue(result); } { com.esri.core.geometry.OperatorDisjoint op = (com.esri.core.geometry.OperatorDisjoint)(com.esri.core.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.esri.core.geometry.Operator.Type.Disjoint)); com.esri.core.geometry.Polygon polygon = new com.esri.core.geometry.Polygon(); com.esri.core.geometry.Polyline polyline = new com.esri.core.geometry.Polyline(); polygon.StartPath(0, 0); polygon.LineTo(0, 10); polygon.LineTo(10, 10); polygon.LineTo(10, 0); polyline.StartPath(-5, 4); polyline.LineTo(5, -6); bool result = op.Execute(polyline, polygon, com.esri.core.geometry.SpatialReference.Create(4326), null); NUnit.Framework.Assert.IsTrue(result); } }
public virtual void TestPointAndPolygon3() { com.esri.core.geometry.Point basePl = new com.esri.core.geometry.Point(-121, 20); com.esri.core.geometry.Polygon compPl = new com.esri.core.geometry.Polygon(); 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(), -121, 0.1E7); NUnit.Framework.Assert.AreEqual(ip.GetY(), 20, 0.1E7); }
public static com.esri.core.geometry.Polygon MakePolygon2() { com.esri.core.geometry.Polygon poly = new com.esri.core.geometry.Polygon(); poly.StartPath(5, 5); poly.LineTo(5, 15); poly.LineTo(15, 15); poly.LineTo(15, 5); return poly; }
public virtual void TestPointAndPolygon2() { com.esri.core.geometry.Point basePl = new com.esri.core.geometry.Point(-115, 20); com.esri.core.geometry.Polygon compPl = new com.esri.core.geometry.Polygon(); 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 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 TestProximity_2D_1() { com.esri.core.geometry.OperatorFactoryLocal engine = com.esri.core.geometry.OperatorFactoryLocal.GetInstance(); com.esri.core.geometry.OperatorProximity2D proximityOp = (com.esri.core.geometry.OperatorProximity2D)engine.GetOperator(com.esri.core.geometry.Operator.Type.Proximity2D); com.esri.core.geometry.Point inputPoint = new com.esri.core.geometry.Point(3, 2); com.esri.core.geometry.Point point0 = new com.esri.core.geometry.Point(2.75, 2); // Point point1 = new Point(3, 2.5); // Point point2 = new Point(3.75, 2); // Point point3 = new Point(2.25, 2.5); // Point point4 = new Point(4, 2.25); // GetNearestVertices for Polygon (Native and DotNet) com.esri.core.geometry.Polygon polygon = MakePolygon(); com.esri.core.geometry.Proximity2DResult[] resultArray = com.esri.core.geometry.GeometryEngine.GetNearestVertices(polygon, inputPoint, 2.0, 8); NUnit.Framework.Assert.IsTrue(resultArray.Length == 8); double lastdistance; double distance; com.esri.core.geometry.Proximity2DResult result0 = resultArray[0]; lastdistance = result0.GetDistance(); NUnit.Framework.Assert.IsTrue(lastdistance <= 2.0); com.esri.core.geometry.Proximity2DResult result1 = resultArray[1]; distance = result1.GetDistance(); NUnit.Framework.Assert.IsTrue(distance <= 2.0 && distance >= lastdistance); lastdistance = distance; com.esri.core.geometry.Proximity2DResult result2 = resultArray[2]; distance = result2.GetDistance(); NUnit.Framework.Assert.IsTrue(distance <= 2.0 && distance >= lastdistance); lastdistance = distance; com.esri.core.geometry.Proximity2DResult result3 = resultArray[3]; distance = result3.GetDistance(); NUnit.Framework.Assert.IsTrue(distance <= 2.0 && distance >= lastdistance); lastdistance = distance; com.esri.core.geometry.Proximity2DResult result4 = resultArray[4]; distance = result4.GetDistance(); NUnit.Framework.Assert.IsTrue(distance <= 2.0 && distance >= lastdistance); lastdistance = distance; com.esri.core.geometry.Proximity2DResult result5 = resultArray[5]; distance = result5.GetDistance(); NUnit.Framework.Assert.IsTrue(distance <= 2.0 && distance >= lastdistance); lastdistance = distance; com.esri.core.geometry.Proximity2DResult result6 = resultArray[6]; distance = result6.GetDistance(); NUnit.Framework.Assert.IsTrue(distance <= 2.0 && distance >= lastdistance); lastdistance = distance; com.esri.core.geometry.Proximity2DResult result7 = resultArray[7]; distance = result7.GetDistance(); NUnit.Framework.Assert.IsTrue(distance <= 2.0 && distance >= lastdistance); // lastdistance = distance; // Point[] coordinates = polygon.get.getCoordinates2D(); // int pointCount = polygon.getPointCount(); // // int hits = 0; // for (int i = 0; i < pointCount; i++) // { // Point ipoint = coordinates[i]; // distance = Point::Distance(ipoint, inputPoint); // // if (distance < lastdistance) // hits++; // } // assertTrue(hits < 8); // GetNearestVertices for Point com.esri.core.geometry.Point point = MakePoint(); resultArray = com.esri.core.geometry.GeometryEngine.GetNearestVertices(point, inputPoint, 1.0, 1); NUnit.Framework.Assert.IsTrue(resultArray.Length == 1); result0 = resultArray[0]; com.esri.core.geometry.Point resultPoint0 = result0.GetCoordinate(); NUnit.Framework.Assert.IsTrue(resultPoint0.GetX() == point.GetX() && resultPoint0.GetY() == point.GetY()); // GetNearestVertex for Polygon result0 = com.esri.core.geometry.GeometryEngine.GetNearestVertex(polygon, inputPoint); resultPoint0 = result0.GetCoordinate(); NUnit.Framework.Assert.IsTrue(resultPoint0.GetX() == point0.GetX() && resultPoint0.GetY() == point0.GetY()); // GetNearestVertex for Point result0 = com.esri.core.geometry.GeometryEngine.GetNearestVertex(point, inputPoint); resultPoint0 = result0.GetCoordinate(); NUnit.Framework.Assert.IsTrue(resultPoint0.GetX() == point.GetX() && resultPoint0.GetY() == point.GetY()); // GetNearestCoordinate for Polygon com.esri.core.geometry.Polygon polygon2 = MakePolygon2(); result0 = com.esri.core.geometry.GeometryEngine.GetNearestCoordinate(polygon2, inputPoint, true); resultPoint0 = result0.GetCoordinate(); NUnit.Framework.Assert.IsTrue(resultPoint0.GetX() == inputPoint.GetX() && resultPoint0.GetY() == inputPoint.GetY()); // GetNearestCoordinate for Polyline com.esri.core.geometry.Polyline polyline = MakePolyline(); result0 = com.esri.core.geometry.GeometryEngine.GetNearestCoordinate(polyline, inputPoint, true); resultPoint0 = result0.GetCoordinate(); NUnit.Framework.Assert.IsTrue(resultPoint0.GetX() == 0.0 && resultPoint0.GetY() == 2.0); com.esri.core.geometry.Polygon pp = new com.esri.core.geometry.Polygon(); pp.StartPath(0, 0); pp.LineTo(0, 10); pp.LineTo(10, 10); pp.LineTo(10, 0); inputPoint.SetXY(15, -5); result0 = proximityOp.GetNearestCoordinate(pp, inputPoint, true, true); bool is_right = result0.IsRightSide(); NUnit.Framework.Assert.IsTrue(!is_right); }
public virtual void TestTouchesOnPolylineAndPolygon() { com.esri.core.geometry.SpatialReference sr = com.esri.core.geometry.SpatialReference.Create(4326); com.esri.core.geometry.Polygon basePl = new com.esri.core.geometry.Polygon(); 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)); com.esri.core.geometry.Polyline compPl = new com.esri.core.geometry.Polyline(); compPl.StartPath(new com.esri.core.geometry.Point(-117, 20)); compPl.LineTo(new com.esri.core.geometry.Point(-108, 25)); compPl.LineTo(new com.esri.core.geometry.Point(-100, 20)); compPl.LineTo(new com.esri.core.geometry.Point(-100, 30)); 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 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 virtual void TestTouchesOnPolygonAndEnvelope() { com.esri.core.geometry.SpatialReference sr = com.esri.core.geometry.SpatialReference.Create(4326); com.esri.core.geometry.Polygon basePl = new com.esri.core.geometry.Polygon(); 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)); // 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); }
public static com.esri.core.geometry.Polygon MakePolygon1() { com.esri.core.geometry.Polygon poly = new com.esri.core.geometry.Polygon(); poly.StartPath(0, 0); poly.LineTo(0, 10); poly.LineTo(10, 10); poly.LineTo(10, 0); return poly; }
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 TestBufferPolygon() { com.esri.core.geometry.SpatialReference sr = com.esri.core.geometry.SpatialReference.Create(4326); com.esri.core.geometry.Polygon inputGeom = new com.esri.core.geometry.Polygon(); 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); { 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 == inputGeom); } { com.esri.core.geometry.Geometry result = buffer.Execute(inputGeom, sr, 10, 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() - 20 - 50) < 0.1 && System.Math.Abs(env2D.GetHeight() - 20 - 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 - 104.0) < 10); NUnit.Framework.Assert.IsTrue(simplify.IsSimpleAsFeature(result, sr, null)); } { sr = com.esri.core.geometry.SpatialReference.Create(4326); inputGeom = new com.esri.core.geometry.Polygon(); inputGeom.StartPath(0, 0); inputGeom.LineTo(50, 50); inputGeom.LineTo(50, 0); com.esri.core.geometry.Geometry result = buffer.Execute(inputGeom, sr, -10, 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() - 15.85) < 0.1 && System.Math.Abs(env2D.GetHeight() - 15.85) < 0.1); NUnit.Framework.Assert.IsTrue(System.Math.Abs(env2D.GetCenterX() - 32.07) < 0.1 && System.Math.Abs(env2D.GetCenterY() - 17.93) < 0.1); int pathCount = poly.GetPathCount(); NUnit.Framework.Assert.IsTrue(pathCount == 1); int pointCount = poly.GetPointCount(); NUnit.Framework.Assert.IsTrue(pointCount == 3); NUnit.Framework.Assert.IsTrue(simplify.IsSimpleAsFeature(result, sr, null)); } { sr = com.esri.core.geometry.SpatialReference.Create(4326); inputGeom = new com.esri.core.geometry.Polygon(); inputGeom.StartPath(0, 0); inputGeom.LineTo(0, 50); inputGeom.LineTo(50, 50); inputGeom.LineTo(50, 0); inputGeom.StartPath(10, 10); inputGeom.LineTo(40, 10); inputGeom.LineTo(40, 40); inputGeom.LineTo(10, 40); com.esri.core.geometry.Geometry result = buffer.Execute(inputGeom, sr, -2, 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() + 4 - 50) < 0.1 && System.Math.Abs(env2D.GetHeight() + 4 - 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 - 108) < 10); NUnit.Framework.Assert.IsTrue(simplify.IsSimpleAsFeature(result, sr, null)); } }
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); } }