public virtual void TestOffsetPoint() { try { com.esri.core.geometry.Point point = new com.esri.core.geometry.Point(); point.SetXY(0, 0); com.esri.core.geometry.OperatorOffset offset = (com.esri.core.geometry.OperatorOffset)com.esri.core.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.esri.core.geometry.Operator.Type.Offset); com.esri.core.geometry.Geometry outputGeom = offset.Execute(point, null, 2, com.esri.core.geometry.OperatorOffset.JoinType.Round, 2, 0, null); NUnit.Framework.Assert.IsNull(outputGeom); } catch (System.Exception) { } try { com.esri.core.geometry.MultiPoint mp = new com.esri.core.geometry.MultiPoint(); mp.Add(0, 0); mp.Add(10, 10); com.esri.core.geometry.OperatorOffset offset = (com.esri.core.geometry.OperatorOffset)com.esri.core.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.esri.core.geometry.Operator.Type.Offset); com.esri.core.geometry.Geometry outputGeom = offset.Execute(mp, null, 2, com.esri.core.geometry.OperatorOffset.JoinType.Round, 2, 0, null); NUnit.Framework.Assert.IsNull(outputGeom); } catch (System.Exception) { } }
public virtual void TestPt() { com.esri.core.geometry.Point pt = new com.esri.core.geometry.Point(); NUnit.Framework.Assert.IsTrue(pt.IsEmpty()); pt.SetXY(10, 2); NUnit.Framework.Assert.IsFalse(pt.IsEmpty()); pt.ToString(); }
public static void TestUnion_() { com.esri.core.geometry.Point pt = new com.esri.core.geometry.Point(10, 20); com.esri.core.geometry.Point pt2 = new com.esri.core.geometry.Point(); pt2.SetXY(10, 10); com.esri.core.geometry.Envelope env1 = new com.esri.core.geometry.Envelope(10, 10, 30, 50); com.esri.core.geometry.Envelope env2 = new com.esri.core.geometry.Envelope(30, 10, 60, 50); com.esri.core.geometry.Geometry[] geomArray = new com.esri.core.geometry.Geometry[] { env1, env2 }; com.esri.core.geometry.SimpleGeometryCursor inputGeometries = new com.esri.core.geometry.SimpleGeometryCursor(geomArray); com.esri.core.geometry.OperatorUnion union = (com.esri.core.geometry.OperatorUnion)com.esri.core.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.esri.core.geometry.Operator.Type.Union); com.esri.core.geometry.SpatialReference sr = com.esri.core.geometry.SpatialReference.Create(4326); com.esri.core.geometry.GeometryCursor outputCursor = union.Execute(inputGeometries, sr, null); com.esri.core.geometry.Geometry result = outputCursor.Next(); }
public virtual void TestRotationInvariance() { com.esri.core.geometry.Point pt_0 = new com.esri.core.geometry.Point(10, 40); com.esri.core.geometry.Point pt_1 = new com.esri.core.geometry.Point(20, 60); com.esri.core.geometry.Point pt_2 = new com.esri.core.geometry.Point(20, 40); double length = 0.0; length += com.esri.core.geometry.GeometryEngine.GeodesicDistanceOnWGS84(pt_0, pt_1); length += com.esri.core.geometry.GeometryEngine.GeodesicDistanceOnWGS84(pt_1, pt_2); length += com.esri.core.geometry.GeometryEngine.GeodesicDistanceOnWGS84(pt_2, pt_0); NUnit.Framework.Assert.IsTrue(System.Math.Abs(length - 5409156.3896271614) < 1e-13 * 5409156.3896271614); for (int i = -540; i < 540; i += 5) { pt_0.SetXY(i + 10, 40); pt_1.SetXY(i + 20, 60); pt_2.SetXY(i + 20, 40); length = 0.0; length += com.esri.core.geometry.GeometryEngine.GeodesicDistanceOnWGS84(pt_0, pt_1); length += com.esri.core.geometry.GeometryEngine.GeodesicDistanceOnWGS84(pt_1, pt_2); length += com.esri.core.geometry.GeometryEngine.GeodesicDistanceOnWGS84(pt_2, pt_0); NUnit.Framework.Assert.IsTrue(System.Math.Abs(length - 5409156.3896271614) < 1e-13 * 5409156.3896271614); } }
public virtual void TestPoint() { com.esri.core.geometry.Point pt = new com.esri.core.geometry.Point(); pt.SetXY(100, 200); NUnit.Framework.Assert.IsFalse(pt.HasAttribute(com.esri.core.geometry.VertexDescription.Semantics.M)); pt.AddAttribute(com.esri.core.geometry.VertexDescription.Semantics.M); NUnit.Framework.Assert.IsTrue(pt.HasAttribute(com.esri.core.geometry.VertexDescription.Semantics.M)); NUnit.Framework.Assert.IsTrue(double.IsNaN(pt.GetM())); pt.SetAttribute(com.esri.core.geometry.VertexDescription.Semantics.M, 0, 13); NUnit.Framework.Assert.IsTrue(pt.GetM() == 13); pt.AddAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z); NUnit.Framework.Assert.IsTrue(pt.GetZ() == 0); NUnit.Framework.Assert.IsTrue(pt.GetM() == 13); pt.SetAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z, 0, 11); NUnit.Framework.Assert.IsTrue(pt.GetZ() == 11); NUnit.Framework.Assert.IsTrue(pt.GetM() == 13); pt.AddAttribute(com.esri.core.geometry.VertexDescription.Semantics.ID); NUnit.Framework.Assert.IsTrue(pt.GetID() == 0); NUnit.Framework.Assert.IsTrue(pt.GetZ() == 11); NUnit.Framework.Assert.IsTrue(pt.GetM() == 13); pt.SetAttribute(com.esri.core.geometry.VertexDescription.Semantics.ID, 0, 1); NUnit.Framework.Assert.IsTrue(pt.GetID() == 1); NUnit.Framework.Assert.IsTrue(pt.GetZ() == 11); NUnit.Framework.Assert.IsTrue(pt.GetM() == 13); pt.DropAttribute(com.esri.core.geometry.VertexDescription.Semantics.M); NUnit.Framework.Assert.IsTrue(pt.GetID() == 1); NUnit.Framework.Assert.IsTrue(pt.GetZ() == 11); NUnit.Framework.Assert.IsFalse(pt.HasAttribute(com.esri.core.geometry.VertexDescription.Semantics.M)); com.esri.core.geometry.Point pt1 = new com.esri.core.geometry.Point(); NUnit.Framework.Assert.IsFalse(pt1.HasAttribute(com.esri.core.geometry.VertexDescription.Semantics.M)); NUnit.Framework.Assert.IsFalse(pt1.HasAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z)); NUnit.Framework.Assert.IsFalse(pt1.HasAttribute(com.esri.core.geometry.VertexDescription.Semantics.ID)); pt1.MergeVertexDescription(pt.GetDescription()); NUnit.Framework.Assert.IsFalse(pt1.HasAttribute(com.esri.core.geometry.VertexDescription.Semantics.M)); NUnit.Framework.Assert.IsTrue(pt1.HasAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z)); NUnit.Framework.Assert.IsTrue(pt1.HasAttribute(com.esri.core.geometry.VertexDescription.Semantics.ID)); }
public virtual void TestPolylinePointDisjoint() { 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.OperatorContains contains = (com.esri.core.geometry.OperatorContains)(com.esri.core.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.esri.core.geometry.Operator.Type.Contains)); 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.Polyline polyline1 = new com.esri.core.geometry.Polyline(); com.esri.core.geometry.Point point2 = new com.esri.core.geometry.Point(); polyline1.StartPath(0, 0); polyline1.LineTo(2, 0); polyline1.LineTo(4, 2); point2.SetXY(1, 1); bool res = disjoint.Execute(polyline1, point2, sr, null); NUnit.Framework.Assert.IsTrue(res); res = disjoint.Execute(point2, polyline1, sr, null); NUnit.Framework.Assert.IsTrue(res); res = contains.Execute(polyline1, point2, sr, null); NUnit.Framework.Assert.IsTrue(!res); res = contains.Execute(point2, polyline1, sr, null); NUnit.Framework.Assert.IsTrue(!res); point2.SetXY(4, 2); polyline1 = (com.esri.core.geometry.Polyline)com.esri.core.geometry.OperatorDensifyByLength.Local().Execute(polyline1, 0.1, null); disjoint.AccelerateGeometry(polyline1, sr, com.esri.core.geometry.Geometry.GeometryAccelerationDegree.enumHot); res = disjoint.Execute(polyline1, point2, sr, null); NUnit.Framework.Assert.IsTrue(!res); res = disjoint.Execute(point2, polyline1, sr, null); NUnit.Framework.Assert.IsTrue(!res); res = contains.Execute(polyline1, point2, sr, null); NUnit.Framework.Assert.IsTrue(!res); res = contains.Execute(point2, polyline1, sr, null); NUnit.Framework.Assert.IsTrue(!res); polyline1.SetEmpty(); point2.SetEmpty(); polyline1.StartPath(659062.37370000035, 153070.85220000148); polyline1.LineTo(660916.47940000147, 151481.10269999877); point2.SetXY(659927.85020000115, 152328.77430000156); res = contains.Execute(polyline1, point2, com.esri.core.geometry.SpatialReference.Create(54004), null); NUnit.Framework.Assert.IsTrue(res); }
public virtual void TestPointPointEquals() { com.esri.core.geometry.OperatorEquals equals = (com.esri.core.geometry.OperatorEquals)(com.esri.core.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.esri.core.geometry.Operator.Type.Equals)); com.esri.core.geometry.OperatorWithin within = (com.esri.core.geometry.OperatorWithin)(com.esri.core.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.esri.core.geometry.Operator.Type.Within)); com.esri.core.geometry.OperatorContains contains = (com.esri.core.geometry.OperatorContains)(com.esri.core.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.esri.core.geometry.Operator.Type.Contains)); 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.Point point1 = new com.esri.core.geometry.Point(); com.esri.core.geometry.Point point2 = new com.esri.core.geometry.Point(); point1.SetXY(2, 2); point2.SetXY(2, 2); bool res = equals.Execute(point1, point2, sr, null); NUnit.Framework.Assert.IsTrue(res); res = equals.Execute(point2, point1, sr, null); NUnit.Framework.Assert.IsTrue(res); res = within.Execute(point1, point2, sr, null); NUnit.Framework.Assert.IsTrue(res); res = within.Execute(point2, point1, sr, null); NUnit.Framework.Assert.IsTrue(res); res = contains.Execute(point1, point2, sr, null); NUnit.Framework.Assert.IsTrue(res); res = contains.Execute(point2, point1, sr, null); NUnit.Framework.Assert.IsTrue(res); res = disjoint.Execute(point1, point2, sr, null); NUnit.Framework.Assert.IsTrue(!res); res = disjoint.Execute(point2, point1, sr, null); NUnit.Framework.Assert.IsTrue(!res); point2.SetXY(2, 3); res = equals.Execute(point1, point2, sr, null); NUnit.Framework.Assert.IsTrue(!res); res = equals.Execute(point2, point1, sr, null); NUnit.Framework.Assert.IsTrue(!res); res = within.Execute(point1, point2, sr, null); NUnit.Framework.Assert.IsTrue(!res); res = within.Execute(point2, point1, sr, null); NUnit.Framework.Assert.IsTrue(!res); res = contains.Execute(point1, point2, sr, null); NUnit.Framework.Assert.IsTrue(!res); res = contains.Execute(point2, point1, sr, null); NUnit.Framework.Assert.IsTrue(!res); res = disjoint.Execute(point1, point2, sr, null); NUnit.Framework.Assert.IsTrue(res); res = disjoint.Execute(point2, point1, sr, null); NUnit.Framework.Assert.IsTrue(res); }
public virtual void TestMultiPointPointEquals() { com.esri.core.geometry.OperatorEquals equals = (com.esri.core.geometry.OperatorEquals)(com.esri.core.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.esri.core.geometry.Operator.Type.Equals)); com.esri.core.geometry.OperatorWithin within = (com.esri.core.geometry.OperatorWithin)(com.esri.core.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.esri.core.geometry.Operator.Type.Within)); 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.MultiPoint multipoint1 = new com.esri.core.geometry.MultiPoint(); com.esri.core.geometry.Point point2 = new com.esri.core.geometry.Point(); multipoint1.Add(2, 2); multipoint1.Add(2, 2); point2.SetXY(2, 2); WiggleGeometry(multipoint1, 0.001, 123); bool res = equals.Execute(multipoint1, point2, sr, null); NUnit.Framework.Assert.IsTrue(res); res = equals.Execute(point2, multipoint1, sr, null); NUnit.Framework.Assert.IsTrue(res); res = within.Execute(multipoint1, point2, sr, null); NUnit.Framework.Assert.IsTrue(res); res = within.Execute(point2, multipoint1, sr, null); NUnit.Framework.Assert.IsTrue(res); multipoint1.Add(4, 4); res = equals.Execute(multipoint1, point2, sr, null); NUnit.Framework.Assert.IsTrue(!res); res = equals.Execute(point2, multipoint1, sr, null); NUnit.Framework.Assert.IsTrue(!res); res = within.Execute(multipoint1, point2, sr, null); NUnit.Framework.Assert.IsTrue(!res); res = within.Execute(point2, multipoint1, sr, null); NUnit.Framework.Assert.IsTrue(res); }
public virtual void TestPolylinePointRelate() { 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.Polyline polyline = new com.esri.core.geometry.Polyline(); com.esri.core.geometry.Point point = new com.esri.core.geometry.Point(); polyline.StartPath(0, 2); polyline.LineTo(0, 4); point.SetXY(0, 3); scl = "0F1FF0FF2"; res = op.Execute(polyline, point, sr, scl, null); NUnit.Framework.Assert.IsTrue(res); point.SetXY(1, 3); scl = "FF1FF00F2"; res = op.Execute(polyline, point, sr, scl, null); NUnit.Framework.Assert.IsTrue(res); polyline.LineTo(4, 4); polyline.LineTo(4, 2); polyline.LineTo(0, 2); // no bounadry point.SetXY(0, 3); scl = "0F1FFFFF2"; res = op.Execute(polyline, point, sr, scl, null); NUnit.Framework.Assert.IsTrue(res); scl = "0F1FFFFF2"; res = op.Execute(polyline, point, sr, scl, null); NUnit.Framework.Assert.IsTrue(res); point.SetXY(1, 3); scl = "FF1FFF0F2"; res = op.Execute(polyline, point, sr, scl, null); NUnit.Framework.Assert.IsTrue(res); point.SetXY(10, 10); scl = "FF1FFF0F2"; res = op.Execute(polyline, point, sr, scl, null); NUnit.Framework.Assert.IsTrue(res); polyline.SetEmpty(); point.SetEmpty(); polyline.StartPath(10, 10); polyline.LineTo(10, 10); point.SetXY(10, 10); scl = "0FFFFFFF2"; res = op.Execute(polyline, point, sr, scl, null); NUnit.Framework.Assert.IsTrue(res); polyline.StartPath(12, 12); polyline.LineTo(12, 12); scl = "0F0FFFFF2"; res = op.Execute(polyline, point, sr, scl, null); NUnit.Framework.Assert.IsTrue(res); polyline.SetEmpty(); point.SetEmpty(); polyline.StartPath(10, 10); polyline.LineTo(10, 10); point.SetXY(0, 0); scl = "FF0FFF0F2"; res = op.Execute(polyline, point, sr, scl, 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 static void TestCreation() { { // simple create com.esri.core.geometry.MultiPoint mpoint = new com.esri.core.geometry.MultiPoint(); NUnit.Framework.Assert.IsTrue(mpoint.GetType() == Geometry.Type.MultiPoint); // assertFalse(mpoint.getClass() == Polyline.class); NUnit.Framework.Assert.IsTrue(mpoint != null); NUnit.Framework.Assert.IsTrue(mpoint.GetType() == com.esri.core.geometry.Geometry.Type.MultiPoint); NUnit.Framework.Assert.IsTrue(mpoint.IsEmpty()); NUnit.Framework.Assert.IsTrue(mpoint.GetPointCount() == 0); mpoint = null; NUnit.Framework.Assert.IsFalse(mpoint != null); } { // play with default attributes com.esri.core.geometry.MultiPoint mpoint = new com.esri.core.geometry.MultiPoint(); SimpleTest(mpoint); } { // simple create 2D com.esri.core.geometry.MultiPoint mpoint = new com.esri.core.geometry.MultiPoint(); NUnit.Framework.Assert.IsTrue(mpoint != null); com.esri.core.geometry.MultiPoint mpoint1 = new com.esri.core.geometry.MultiPoint(); NUnit.Framework.Assert.IsTrue(mpoint1 != null); mpoint.SetEmpty(); com.esri.core.geometry.Point pt = new com.esri.core.geometry.Point(0, 0); mpoint.Add(pt); com.esri.core.geometry.Point pt3 = mpoint.GetPoint(0); NUnit.Framework.Assert.IsTrue(pt3.GetX() == 0 && pt3.GetY() == 0); // assertFalse(mpoint->HasAttribute(VertexDescription::Semantics::Z)); // pt3.setZ(115.0); mpoint.SetPoint(0, pt3); pt3 = mpoint.GetPoint(0); NUnit.Framework.Assert.IsTrue(pt3.GetX() == 0 && pt3.GetY() == 0); } { /* && pt3.getZ() == 115 */ // assertTrue(mpoint->HasAttribute(VertexDescription::Semantics::Z)); // CompareGeometryContent(mpoint, &pt, 1); // move 3d com.esri.core.geometry.MultiPoint mpoint = new com.esri.core.geometry.MultiPoint(); NUnit.Framework.Assert.IsTrue(mpoint != null); com.esri.core.geometry.Point pt = new com.esri.core.geometry.Point(0, 0); mpoint.Add(pt); com.esri.core.geometry.Point pt3 = mpoint.GetPoint(0); NUnit.Framework.Assert.IsTrue(pt3.GetX() == 0 && pt3.GetY() == 0); } { /* && pt3.getZ() == 0 */ // test QueryInterval com.esri.core.geometry.MultiPoint mpoint = new com.esri.core.geometry.MultiPoint(); com.esri.core.geometry.Point pt1 = new com.esri.core.geometry.Point(0.0, 0.0); // pt1.setZ(-1.0); com.esri.core.geometry.Point pt2 = new com.esri.core.geometry.Point(0.0, 0.0); // pt2.setZ(1.0); mpoint.Add(pt1); mpoint.Add(pt2); // Envelope1D e = // mpoint->QueryInterval(enum_value2(VertexDescription, Semantics, // Z), 0); com.esri.core.geometry.Envelope e = new com.esri.core.geometry.Envelope(); mpoint.QueryEnvelope(e); } { // assertTrue(e.get == -1.0 && e.vmax == 1.0); com.esri.core.geometry.MultiPoint geom = new com.esri.core.geometry.MultiPoint(); } { // int sz = sizeof(openString) / sizeof(openString[0]); // for (int i = 0; i < sz; i++) // geom.add(openString[i]); // CompareGeometryContent(geom, openString, sz); com.esri.core.geometry.MultiPoint geom = new com.esri.core.geometry.MultiPoint(); } { // int sz = sizeof(openString) / sizeof(openString[0]); // Point point = GCNEW Point; // for (int i = 0; i < sz; i++) // { // point.setXY(openString[i]); // geom.add(point); // } // CompareGeometryContent(geom, openString, sz); // Test AddPoints com.esri.core.geometry.MultiPoint geom = new com.esri.core.geometry.MultiPoint(); } { // int sz = sizeof(openString) / sizeof(openString[0]); // geom.addPoints(openString, sz, 0, -1); // CompareGeometryContent((MultiVertexGeometry)geom, openString, // sz); // Test InsertPoint(Point2D) com.esri.core.geometry.MultiPoint mpoint = new com.esri.core.geometry.MultiPoint(); com.esri.core.geometry.Point pt0 = new com.esri.core.geometry.Point(0.0, 0.0); // pt0.setZ(-1.0); // pt0.setID(7); com.esri.core.geometry.Point pt1 = new com.esri.core.geometry.Point(0.0, 0.0); // pt1.setZ(1.0); // pt1.setID(11); com.esri.core.geometry.Point pt2 = new com.esri.core.geometry.Point(0.0, 1.0); // pt2.setZ(1.0); // pt2.setID(13); mpoint.Add(pt0); mpoint.Add(pt1); mpoint.Add(pt2); com.esri.core.geometry.Point pt3 = new com.esri.core.geometry.Point(-11.0, -13.0); mpoint.Add(pt3); mpoint.InsertPoint(1, pt3); NUnit.Framework.Assert.IsTrue(mpoint.GetPointCount() == 5); com.esri.core.geometry.Point pt; pt = mpoint.GetPoint(0); NUnit.Framework.Assert.IsTrue(pt.GetX() == pt0.GetX() && pt.GetY() == pt0.GetY()); /* * && * pt. * getZ * () == * pt0 * .getZ * () */ pt = mpoint.GetPoint(1); NUnit.Framework.Assert.IsTrue(pt.GetX() == pt3.GetX() && pt.GetY() == pt3.GetY()); pt = mpoint.GetPoint(2); NUnit.Framework.Assert.IsTrue(pt.GetX() == pt1.GetX() && pt.GetY() == pt1.GetY()); /* * && * pt. * getZ * () == * pt1 * .getZ * () */ pt = mpoint.GetPoint(3); NUnit.Framework.Assert.IsTrue(pt.GetX() == pt2.GetX() && pt.GetY() == pt2.GetY()); /* * && * pt. * getZ * () == * pt2 * .getZ * () */ com.esri.core.geometry.Point point = new com.esri.core.geometry.Point(); point.SetXY(17.0, 19.0); // point.setID(12); // point.setM(5); mpoint.InsertPoint(2, point); mpoint.Add(point); NUnit.Framework.Assert.IsTrue(mpoint.GetPointCount() == 7); } // double m; // int id; // pt = mpoint.getXYZ(2); // assertTrue(pt.x == 17.0 && pt.y == 19.0 && pt.z == defaultZ); // m = mpoint.getAttributeAsDbl(enum_value2(VertexDescription, // Semantics, M), 2, 0); // assertTrue(m == 5); // id = mpoint.getAttributeAsInt(enum_value2(VertexDescription, // Semantics, ID), 2, 0); // assertTrue(id == 23); // // pt = mpoint.getXYZ(3); // assertTrue(pt.x == pt1.x && pt.y == pt1.y && pt.z == pt1.z); // m = mpoint.getAttributeAsDbl(enum_value2(VertexDescription, // Semantics, M), 3, 0); // assertTrue(NumberUtils::IsNaN(m)); // id = mpoint.getAttributeAsInt(enum_value2(VertexDescription, // Semantics, ID), 3, 0); // assertTrue(id == 11); com.esri.core.geometry.MultiPoint mpoint_1 = new com.esri.core.geometry.MultiPoint(); com.esri.core.geometry.Point pt0_1 = new com.esri.core.geometry.Point(0.0, 0.0, -1.0); com.esri.core.geometry.Point pt1_1 = new com.esri.core.geometry.Point(0.0, 0.0, 1.0); com.esri.core.geometry.Point pt2_1 = new com.esri.core.geometry.Point(0.0, 1.0, 1.0); mpoint_1.Add(pt0_1); mpoint_1.Add(pt1_1); mpoint_1.Add(pt2_1); mpoint_1.RemovePoint(1); com.esri.core.geometry.Point pt_1; pt_1 = mpoint_1.GetPoint(0); NUnit.Framework.Assert.IsTrue(pt_1.GetX() == pt0_1.GetX() && pt_1.GetY() == pt0_1.GetY()); pt_1 = mpoint_1.GetPoint(1); NUnit.Framework.Assert.IsTrue(pt_1.GetX() == pt2_1.GetX() && pt_1.GetY() == pt2_1.GetY()); NUnit.Framework.Assert.IsTrue(mpoint_1.GetPointCount() == 2); }
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 TestReplaceNaNs() { com.esri.core.geometry.Envelope env = new com.esri.core.geometry.Envelope(); com.esri.core.geometry.Point pt = new com.esri.core.geometry.Point(); pt.SetXY(1, 2); pt.SetZ(double.NaN); pt.QueryEnvelope(env); pt.ReplaceNaNs(com.esri.core.geometry.VertexDescription.Semantics.Z, 5); NUnit.Framework.Assert.IsTrue(pt.Equals(new com.esri.core.geometry.Point(1, 2, 5))); NUnit.Framework.Assert.IsTrue(env.HasZ()); NUnit.Framework.Assert.IsTrue(env.QueryInterval(com.esri.core.geometry.VertexDescription.Semantics.Z, 0).IsEmpty()); env.ReplaceNaNs(com.esri.core.geometry.VertexDescription.Semantics.Z, 5); NUnit.Framework.Assert.IsTrue(env.QueryInterval(com.esri.core.geometry.VertexDescription.Semantics.Z, 0).Equals(new com.esri.core.geometry.Envelope1D(5, 5))); }
public virtual void TestCopy() { com.esri.core.geometry.Point pt = new com.esri.core.geometry.Point(); com.esri.core.geometry.Point copyPt = (com.esri.core.geometry.Point)pt.Copy(); NUnit.Framework.Assert.IsTrue(copyPt.Equals(pt)); pt.SetXY(11, 13); copyPt = (com.esri.core.geometry.Point)pt.Copy(); NUnit.Framework.Assert.IsTrue(copyPt.Equals(pt)); NUnit.Framework.Assert.IsTrue(copyPt.GetXY().IsEqual(new com.esri.core.geometry.Point2D(11, 13))); NUnit.Framework.Assert.IsTrue(copyPt.GetXY().Equals((object)new com.esri.core.geometry.Point2D(11, 13))); }
public virtual void TestIsSimpleBasicsPoint() { bool result; // point is always simple com.esri.core.geometry.Point pt = new com.esri.core.geometry.Point(); result = simplifyOp.IsSimpleAsFeature(pt, sr4326, false, null, null); NUnit.Framework.Assert.IsTrue(result); pt.SetXY(0, 0); result = simplifyOp.IsSimpleAsFeature(pt, sr4326, false, null, null); NUnit.Framework.Assert.IsTrue(result); pt.SetXY(100000, 10000); result = simplifyOp.IsSimpleAsFeature(pt, sr4326, false, null, null); NUnit.Framework.Assert.IsTrue(result); }
public static com.esri.core.geometry.MultiPoint MakeMultiPoint() { com.esri.core.geometry.MultiPoint mpoint = new com.esri.core.geometry.MultiPoint(); com.esri.core.geometry.Point pt1 = new com.esri.core.geometry.Point(); pt1.SetXY(0, 0); pt1.SetZ(-1); com.esri.core.geometry.Point pt2 = new com.esri.core.geometry.Point(); pt2.SetXY(0, 0); pt2.SetZ(1); com.esri.core.geometry.Point pt3 = new com.esri.core.geometry.Point(); pt3.SetXY(0, 1); pt3.SetZ(1); mpoint.Add(pt1); mpoint.Add(pt2); mpoint.Add(pt3); mpoint.SetAttribute(com.esri.core.geometry.VertexDescription.Semantics.ID, 0, 0, 7); mpoint.SetAttribute(com.esri.core.geometry.VertexDescription.Semantics.ID, 1, 0, 11); mpoint.SetAttribute(com.esri.core.geometry.VertexDescription.Semantics.ID, 2, 0, 13); return mpoint; }
public static com.esri.core.geometry.Point MakePoint() { com.esri.core.geometry.Point point = new com.esri.core.geometry.Point(); point.SetXY(11, 13); point.SetZ(32); point.SetM(243); point.SetID(1024); return point; }
public virtual void TestReplaceNaNs() { { com.esri.core.geometry.MultiPoint mp = new com.esri.core.geometry.MultiPoint(); com.esri.core.geometry.Point pt = new com.esri.core.geometry.Point(); pt.SetXY(1, 2); pt.SetZ(double.NaN); mp.Add(pt); pt = new com.esri.core.geometry.Point(); pt.SetXY(11, 12); pt.SetZ(3); mp.Add(pt); mp.ReplaceNaNs(com.esri.core.geometry.VertexDescription.Semantics.Z, 5); NUnit.Framework.Assert.IsTrue(mp.GetPoint(0).Equals(new com.esri.core.geometry.Point(1, 2, 5))); NUnit.Framework.Assert.IsTrue(mp.GetPoint(1).Equals(new com.esri.core.geometry.Point(11, 12, 3))); } { com.esri.core.geometry.Polygon mp = new com.esri.core.geometry.Polygon(); com.esri.core.geometry.Point pt = new com.esri.core.geometry.Point(); pt.SetXY(1, 2); pt.SetZ(double.NaN); mp.StartPath(pt); pt = new com.esri.core.geometry.Point(); pt.SetXY(11, 12); pt.SetZ(3); mp.LineTo(pt); mp.ReplaceNaNs(com.esri.core.geometry.VertexDescription.Semantics.Z, 5); NUnit.Framework.Assert.IsTrue(mp.GetPoint(0).Equals(new com.esri.core.geometry.Point(1, 2, 5))); NUnit.Framework.Assert.IsTrue(mp.GetPoint(1).Equals(new com.esri.core.geometry.Point(11, 12, 3))); } { com.esri.core.geometry.Polygon mp = new com.esri.core.geometry.Polygon(); com.esri.core.geometry.Point pt = new com.esri.core.geometry.Point(); pt.SetXY(1, 2); pt.SetM(double.NaN); mp.StartPath(pt); pt = new com.esri.core.geometry.Point(); pt.SetXY(11, 12); pt.SetM(3); mp.LineTo(pt); mp.ReplaceNaNs(com.esri.core.geometry.VertexDescription.Semantics.M, 5); com.esri.core.geometry.Point p = new com.esri.core.geometry.Point(1, 2); p.SetM(5); bool b = mp.GetPoint(0).Equals(p); NUnit.Framework.Assert.IsTrue(b); p = new com.esri.core.geometry.Point(11, 12); p.SetM(3); b = mp.GetPoint(1).Equals(p); NUnit.Framework.Assert.IsTrue(b); } }
public virtual void TestMultiPointPointDisjoint() { 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.OperatorContains contains = (com.esri.core.geometry.OperatorContains)(com.esri.core.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.esri.core.geometry.Operator.Type.Contains)); 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.MultiPoint multipoint1 = new com.esri.core.geometry.MultiPoint(); com.esri.core.geometry.Point point2 = new com.esri.core.geometry.Point(); multipoint1.Add(2, 2); multipoint1.Add(2, 5); multipoint1.Add(4, 1); multipoint1.Add(4, 4); multipoint1.Add(4, 7); multipoint1.Add(6, 2); multipoint1.Add(6, 6); multipoint1.Add(4, 1); multipoint1.Add(6, 6); point2.SetXY(2, 6); bool res = disjoint.Execute(multipoint1, point2, sr, null); NUnit.Framework.Assert.IsTrue(res); res = disjoint.Execute(point2, multipoint1, sr, null); NUnit.Framework.Assert.IsTrue(res); res = contains.Execute(multipoint1, point2, sr, null); NUnit.Framework.Assert.IsTrue(!res); res = contains.Execute(point2, multipoint1, sr, null); NUnit.Framework.Assert.IsTrue(!res); multipoint1.Add(2, 6); res = disjoint.Execute(multipoint1, point2, sr, null); NUnit.Framework.Assert.IsTrue(!res); res = disjoint.Execute(point2, multipoint1, sr, null); NUnit.Framework.Assert.IsTrue(!res); res = contains.Execute(multipoint1, point2, sr, null); NUnit.Framework.Assert.IsTrue(res); res = contains.Execute(point2, multipoint1, sr, null); NUnit.Framework.Assert.IsTrue(!res); }
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 TestHullTickTock() { com.esri.core.geometry.Polygon geom1 = new com.esri.core.geometry.Polygon(); com.esri.core.geometry.Polygon geom2 = new com.esri.core.geometry.Polygon(); com.esri.core.geometry.Point geom3 = new com.esri.core.geometry.Point(); com.esri.core.geometry.Line geom4 = new com.esri.core.geometry.Line(); com.esri.core.geometry.Envelope geom5 = new com.esri.core.geometry.Envelope(); com.esri.core.geometry.MultiPoint geom6 = new com.esri.core.geometry.MultiPoint(); // polygon geom1.StartPath(0, 0); geom1.LineTo(0, 0); geom1.LineTo(5, 11); geom1.LineTo(5, 11); geom1.LineTo(10, 0); geom1.LineTo(10, 0); // polygon geom2.StartPath(0, 5); geom2.LineTo(0, 5); geom2.LineTo(10, 5); geom2.LineTo(10, 5); geom2.LineTo(5, -5); geom2.LineTo(5, -5); // point geom3.SetXY(15, 1.25); // segment geom4.SetEndXY(-5, 1.25); geom4.SetStartXY(0, 0); // envelope geom5.SetCoords(0, 0, 5, 10); // multi_point geom6.Add(10, 5); geom6.Add(10, 10); // Create com.esri.core.geometry.ListeningGeometryCursor gc = new com.esri.core.geometry.ListeningGeometryCursor(); com.esri.core.geometry.GeometryCursor ticktock = com.esri.core.geometry.OperatorConvexHull.Local().Execute(gc, true, null); // Use tick-tock to push a geometry and do a piece of work. gc.Tick(geom1); ticktock.Tock(); gc.Tick(geom2); ticktock.Tock(); gc.Tick(geom3); // skiped one tock just for testing. ticktock.Tock(); gc.Tick(geom4); ticktock.Tock(); gc.Tick(geom5); ticktock.Tock(); gc.Tick(geom6); ticktock.Tock(); // Get the result com.esri.core.geometry.Geometry result = ticktock.Next(); com.esri.core.geometry.Polygon convex_hull = (com.esri.core.geometry.Polygon)result; NUnit.Framework.Assert.IsTrue(com.esri.core.geometry.OperatorConvexHull.Local().IsConvex(convex_hull, null)); com.esri.core.geometry.Point2D p1 = convex_hull.GetXY(0); com.esri.core.geometry.Point2D p2 = convex_hull.GetXY(1); com.esri.core.geometry.Point2D p3 = convex_hull.GetXY(2); com.esri.core.geometry.Point2D p4 = convex_hull.GetXY(3); com.esri.core.geometry.Point2D p5 = convex_hull.GetXY(4); com.esri.core.geometry.Point2D p6 = convex_hull.GetXY(5); NUnit.Framework.Assert.IsTrue(p1.x == 5.0 && p1.y == 11.0); NUnit.Framework.Assert.IsTrue(p2.x == 10.0 && p2.y == 10); NUnit.Framework.Assert.IsTrue(p3.x == 15.0 && p3.y == 1.25); NUnit.Framework.Assert.IsTrue(p4.x == 5.0 && p4.y == -5.0); NUnit.Framework.Assert.IsTrue(p5.x == -5.0 && p5.y == 1.25); NUnit.Framework.Assert.IsTrue(p6.x == 0.0 && p6.y == 10.0); }
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); }
private static com.esri.core.geometry.Point MakePoint() { com.esri.core.geometry.Point point = new com.esri.core.geometry.Point(); com.esri.core.geometry.Point2D pt = new com.esri.core.geometry.Point2D(); pt.SetCoords(0, 15); point.SetXY(pt); return point; }
public virtual void TestPolylinePointTouches() { com.esri.core.geometry.OperatorTouches touches = (com.esri.core.geometry.OperatorTouches)(com.esri.core.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.esri.core.geometry.Operator.Type.Touches)); 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.Polyline polyline1 = new com.esri.core.geometry.Polyline(); com.esri.core.geometry.Point point2 = new com.esri.core.geometry.Point(); polyline1.StartPath(0, 0); polyline1.LineTo(2, 0); polyline1.StartPath(2, 1); polyline1.LineTo(2, -1); point2.SetXY(2, 0); bool res = touches.Execute(polyline1, point2, sr, null); NUnit.Framework.Assert.IsTrue(res); res = touches.Execute(point2, polyline1, sr, null); NUnit.Framework.Assert.IsTrue(res); }
public virtual void TestPointPointRelate() { 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.Point p1 = new com.esri.core.geometry.Point(); com.esri.core.geometry.Point p2 = new com.esri.core.geometry.Point(); p1.SetXY(0, 0); p2.SetXY(0, 0); scl = "T********"; res = op.Execute(p1, p2, sr, scl, null); NUnit.Framework.Assert.IsTrue(res); p1.SetXY(0, 0); p2.SetXY(1, 0); res = op.Execute(p1, p2, null, scl, null); NUnit.Framework.Assert.IsTrue(!res); p1.SetEmpty(); p2.SetEmpty(); scl = "*********"; res = op.Execute(p1, p2, null, scl, null); NUnit.Framework.Assert.IsTrue(res); scl = "FFFFFFFFF"; res = op.Execute(p1, p2, null, scl, null); NUnit.Framework.Assert.IsTrue(res); scl = "FFFFFFFFT"; res = op.Execute(p1, p2, null, scl, null); NUnit.Framework.Assert.IsTrue(!res); }
public static com.esri.core.geometry.Point MakePoint2() { com.esri.core.geometry.Point point = new com.esri.core.geometry.Point(); com.esri.core.geometry.Point2D pt = new com.esri.core.geometry.Point2D(); pt.SetCoords(7, 7); point.SetXY(pt); return point; }
public static void TestMergeCursor() { com.esri.core.geometry.OperatorConvexHull bounding = (com.esri.core.geometry.OperatorConvexHull)com.esri.core.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.esri.core.geometry.Operator.Type.ConvexHull); com.esri.core.geometry.Polygon geom1 = new com.esri.core.geometry.Polygon(); com.esri.core.geometry.Polygon geom2 = new com.esri.core.geometry.Polygon(); com.esri.core.geometry.Point geom3 = new com.esri.core.geometry.Point(); com.esri.core.geometry.Line geom4 = new com.esri.core.geometry.Line(); com.esri.core.geometry.Envelope geom5 = new com.esri.core.geometry.Envelope(); com.esri.core.geometry.MultiPoint geom6 = new com.esri.core.geometry.MultiPoint(); // polygon geom1.StartPath(0, 0); geom1.LineTo(0, 0); geom1.LineTo(5, 11); geom1.LineTo(5, 11); geom1.LineTo(10, 0); geom1.LineTo(10, 0); // polygon geom2.StartPath(0, 5); geom2.LineTo(0, 5); geom2.LineTo(10, 5); geom2.LineTo(10, 5); geom2.LineTo(5, -5); geom2.LineTo(5, -5); // point geom3.SetXY(15, 1.25); // segment geom4.SetEndXY(-5, 1.25); geom4.SetStartXY(0, 0); // envelope geom5.SetCoords(0, 0, 5, 10); // multi_point geom6.Add(10, 5); geom6.Add(10, 10); // create cursor com.esri.core.geometry.Geometry[] geoms = new com.esri.core.geometry.Geometry[6]; geoms[0] = geom1; geoms[1] = geom2; geoms[2] = geom3; geoms[3] = geom4; geoms[4] = geom5; geoms[5] = geom6; com.esri.core.geometry.GeometryCursor cursor = new com.esri.core.geometry.SimpleGeometryCursor(geoms); // create convex hull from the cursor with b_merge set to true com.esri.core.geometry.GeometryCursor convex_hull_curs = bounding.Execute(cursor, true, null); com.esri.core.geometry.Polygon convex_hull = (com.esri.core.geometry.Polygon)(convex_hull_curs.Next()); NUnit.Framework.Assert.IsTrue(convex_hull_curs.Next() == null); NUnit.Framework.Assert.IsTrue(bounding.IsConvex(convex_hull, null)); com.esri.core.geometry.Point2D p1 = convex_hull.GetXY(0); com.esri.core.geometry.Point2D p2 = convex_hull.GetXY(1); com.esri.core.geometry.Point2D p3 = convex_hull.GetXY(2); com.esri.core.geometry.Point2D p4 = convex_hull.GetXY(3); com.esri.core.geometry.Point2D p5 = convex_hull.GetXY(4); com.esri.core.geometry.Point2D p6 = convex_hull.GetXY(5); NUnit.Framework.Assert.IsTrue(p1.x == 5.0 && p1.y == 11.0); NUnit.Framework.Assert.IsTrue(p2.x == 10.0 && p2.y == 10); NUnit.Framework.Assert.IsTrue(p3.x == 15.0 && p3.y == 1.25); NUnit.Framework.Assert.IsTrue(p4.x == 5.0 && p4.y == -5.0); NUnit.Framework.Assert.IsTrue(p5.x == -5.0 && p5.y == 1.25); NUnit.Framework.Assert.IsTrue(p6.x == 0.0 && p6.y == 10.0); // Test GeometryEngine com.esri.core.geometry.Geometry[] merged_hull = com.esri.core.geometry.GeometryEngine.ConvexHull(geoms, true); convex_hull = (com.esri.core.geometry.Polygon)merged_hull[0]; p1 = convex_hull.GetXY(0); p2 = convex_hull.GetXY(1); p3 = convex_hull.GetXY(2); p4 = convex_hull.GetXY(3); p5 = convex_hull.GetXY(4); p6 = convex_hull.GetXY(5); NUnit.Framework.Assert.IsTrue(p1.x == 5.0 && p1.y == 11.0); NUnit.Framework.Assert.IsTrue(p2.x == 10.0 && p2.y == 10); NUnit.Framework.Assert.IsTrue(p3.x == 15.0 && p3.y == 1.25); NUnit.Framework.Assert.IsTrue(p4.x == 5.0 && p4.y == -5.0); NUnit.Framework.Assert.IsTrue(p5.x == -5.0 && p5.y == 1.25); NUnit.Framework.Assert.IsTrue(p6.x == 0.0 && p6.y == 10.0); }