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 testTouchOnPointAndPolygon() { com.esri.core.geometry.Geometry baseGeom = new com.esri.core.geometry.Point(-130, 10); 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.SpatialReference sr = com.esri.core.geometry.SpatialReference .create(4326); bool isTouched; bool isTouched2; try { isTouched = com.esri.core.geometry.GeometryEngine.touches(baseGeom, pg, sr); isTouched2 = com.esri.core.geometry.GeometryEngine.touches(pg, baseGeom, sr); } catch (System.ArgumentException) { isTouched = false; isTouched2 = false; } NUnit.Framework.Assert.AreEqual(isTouched && isTouched2, true); }
public virtual void TestBufferPoint() { com.esri.core.geometry.SpatialReference sr = com.esri.core.geometry.SpatialReference.Create(4326); com.esri.core.geometry.Point inputGeom = new com.esri.core.geometry.Point(12, 120); 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); com.esri.core.geometry.Geometry result = buffer.Execute(inputGeom, sr, 40.0, null); NUnit.Framework.Assert.IsTrue(result.GetType().Value() == com.esri.core.geometry.Geometry.GeometryType.Polygon); com.esri.core.geometry.Polygon poly = (com.esri.core.geometry.Polygon)result; int pathCount = poly.GetPathCount(); NUnit.Framework.Assert.IsTrue(pathCount == 1); int pointCount = poly.GetPointCount(); NUnit.Framework.Assert.IsTrue(System.Math.Abs(pointCount - 100.0) < 10); com.esri.core.geometry.Envelope2D env2D = new com.esri.core.geometry.Envelope2D(); result.QueryEnvelope2D(env2D); NUnit.Framework.Assert.IsTrue(System.Math.Abs(env2D.GetWidth() - 80) < 0.01 && System.Math.Abs(env2D.GetHeight() - 80) < 0.01); NUnit.Framework.Assert.IsTrue(System.Math.Abs(env2D.GetCenterX() - 12) < 0.001 && System.Math.Abs(env2D.GetCenterY() - 120) < 0.001); com.esri.core.geometry.NonSimpleResult nsr = new com.esri.core.geometry.NonSimpleResult(); bool is_simple = simplify.IsSimpleAsFeature(result, sr, true, nsr, null); NUnit.Framework.Assert.IsTrue(is_simple); { result = buffer.Execute(inputGeom, sr, 0, null); NUnit.Framework.Assert.IsTrue(result.GetType().Value() == com.esri.core.geometry.Geometry.GeometryType.Polygon); NUnit.Framework.Assert.IsTrue(result.IsEmpty()); } { result = buffer.Execute(inputGeom, sr, -1, null); NUnit.Framework.Assert.IsTrue(result.GetType().Value() == com.esri.core.geometry.Geometry.GeometryType.Polygon); NUnit.Framework.Assert.IsTrue(result.IsEmpty()); } }
public static void testGetXCorrectCR185697() { com.esri.core.geometry.OperatorFactoryLocal engine = com.esri.core.geometry.OperatorFactoryLocal .getInstance(); com.esri.core.geometry.OperatorClip clipOp = (com.esri.core.geometry.OperatorClip )engine.getOperator(com.esri.core.geometry.Operator.Type.Clip); com.esri.core.geometry.Polyline polylineCR = makePolylineCR(); com.esri.core.geometry.SimpleGeometryCursor polylineCursCR = new com.esri.core.geometry.SimpleGeometryCursor (polylineCR); com.esri.core.geometry.SpatialReference gcsWGS84 = com.esri.core.geometry.SpatialReference .create(4326); com.esri.core.geometry.Envelope2D envelopeCR = new com.esri.core.geometry.Envelope2D (); envelopeCR.xmin = -180; envelopeCR.xmax = 180; envelopeCR.ymin = -90; envelopeCR.ymax = 90; // CR com.esri.core.geometry.Polyline clippedPolylineCR = (com.esri.core.geometry.Polyline )clipOp.execute(polylineCR, envelopeCR, gcsWGS84, null); com.esri.core.geometry.Point pointResult = new com.esri.core.geometry.Point(); clippedPolylineCR.getPointByVal(0, pointResult); NUnit.Framework.Assert.IsTrue(pointResult.getX() == -180); clippedPolylineCR.getPointByVal(1, pointResult); NUnit.Framework.Assert.IsTrue(pointResult.getX() == -90); clippedPolylineCR.getPointByVal(2, pointResult); NUnit.Framework.Assert.IsTrue(pointResult.getX() == 0); clippedPolylineCR.getPointByVal(3, pointResult); NUnit.Framework.Assert.IsTrue(pointResult.getX() == 100); clippedPolylineCR.getPointByVal(4, pointResult); NUnit.Framework.Assert.IsTrue(pointResult.getX() == 170); clippedPolylineCR.getPointByVal(5, pointResult); NUnit.Framework.Assert.IsTrue(pointResult.getX() == 180); }
public virtual void testEnvelope2000() { com.esri.core.geometry.Point[] points = new com.esri.core.geometry.Point[2000]; java.util.Random random = new java.util.Random(69); for (int i = 0; i < 2000; i++) { points[i] = new com.esri.core.geometry.Point(); points[i].setX(random.nextDouble() * 100); points[i].setY(random.nextDouble() * 100); } for (int iter = 0; iter < 2; iter++) { long startTime = Sharpen.Runtime.nanoTime(); com.esri.core.geometry.Envelope geomExtent = new com.esri.core.geometry.Envelope( ); com.esri.core.geometry.Envelope fullExtent = new com.esri.core.geometry.Envelope( ); for (int i_1 = 0; i_1 < 2000; i_1++) { points[i_1].queryEnvelope(geomExtent); fullExtent.merge(geomExtent); } long endTime = Sharpen.Runtime.nanoTime(); } }
public virtual void testPointAndMultiPoint2() { com.esri.core.geometry.Point basePl = new com.esri.core.geometry.Point(-115, 20); com.esri.core.geometry.MultiPoint compPl = new com.esri.core.geometry.MultiPoint( ); compPl.add(new com.esri.core.geometry.Point(-116, 20)); compPl.add(new com.esri.core.geometry.Point(-117, 21)); compPl.add(new com.esri.core.geometry.Point(-118, 20)); compPl.add(new com.esri.core.geometry.Point(-119, 21)); 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 TestPointAndPolyline1() { com.esri.core.geometry.Point basePl = new com.esri.core.geometry.Point(-116, 20); com.esri.core.geometry.Polyline compPl = new com.esri.core.geometry.Polyline(); compPl.StartPath(new com.esri.core.geometry.Point(-116, 20)); compPl.LineTo(new com.esri.core.geometry.Point(-131, 10)); compPl.LineTo(new com.esri.core.geometry.Point(-121, 50)); int noException = 1; // no exception com.esri.core.geometry.Geometry intersectGeom = null; try { intersectGeom = com.esri.core.geometry.GeometryEngine.Intersect(basePl, compPl, com.esri.core.geometry.SpatialReference.Create(4326)); } catch (System.Exception) { noException = 0; } NUnit.Framework.Assert.AreEqual(noException, 1); NUnit.Framework.Assert.IsNotNull(intersectGeom); NUnit.Framework.Assert.IsTrue(intersectGeom.GetType() == com.esri.core.geometry.Geometry.Type.Point); com.esri.core.geometry.Point ip = (com.esri.core.geometry.Point)intersectGeom; NUnit.Framework.Assert.AreEqual(ip.GetX(), -116, 0.1E7); NUnit.Framework.Assert.AreEqual(ip.GetY(), 20, 0.1E7); }
public virtual void testPointGeometryEngine() { com.esri.core.geometry.Point p = new com.esri.core.geometry.Point(10.0, 20.0); string result = com.esri.core.geometry.GeometryEngine.geometryToGeoJson(p); NUnit.Framework.Assert.AreEqual("{\"type\":\"Point\",\"coordinates\":[10.0,20.0]}" , result); }
public virtual void testEqualsOnPoints() { com.esri.core.geometry.SpatialReference sr = com.esri.core.geometry.SpatialReference .create(4326); com.esri.core.geometry.Point p1 = new com.esri.core.geometry.Point(-116, 40); com.esri.core.geometry.Point p2 = new com.esri.core.geometry.Point(-120, 39); com.esri.core.geometry.Point p3 = new com.esri.core.geometry.Point(-121, 10); com.esri.core.geometry.Point p4 = new com.esri.core.geometry.Point(-130, 12); com.esri.core.geometry.Point p5 = new com.esri.core.geometry.Point(-108, 25); com.esri.core.geometry.Point p12 = new com.esri.core.geometry.Point(-116, 40); com.esri.core.geometry.Point p22 = new com.esri.core.geometry.Point(-120, 39); com.esri.core.geometry.Point p32 = new com.esri.core.geometry.Point(-121, 10); com.esri.core.geometry.Point p42 = new com.esri.core.geometry.Point(-130, 12); com.esri.core.geometry.Point p52 = new com.esri.core.geometry.Point(-108, 25); bool isEqual1 = false; bool isEqual2 = false; bool isEqual3 = false; bool isEqual4 = false; bool isEqual5 = false; try { isEqual1 = com.esri.core.geometry.GeometryEngine.equals(p1, p12, sr); isEqual2 = com.esri.core.geometry.GeometryEngine.equals(p1, p12, sr); isEqual3 = com.esri.core.geometry.GeometryEngine.equals(p1, p12, sr); isEqual4 = com.esri.core.geometry.GeometryEngine.equals(p1, p12, sr); isEqual5 = com.esri.core.geometry.GeometryEngine.equals(p1, p12, sr); } catch (System.ArgumentException) { } NUnit.Framework.Assert.IsTrue(isEqual1 && isEqual2 && isEqual3 && isEqual4 && isEqual5 ); }
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 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 TestEqualsOnPoints() { com.esri.core.geometry.SpatialReference sr = com.esri.core.geometry.SpatialReference.Create(4326); com.esri.core.geometry.Point p1 = new com.esri.core.geometry.Point(-116, 40); com.esri.core.geometry.Point p2 = new com.esri.core.geometry.Point(-120, 39); com.esri.core.geometry.Point p3 = new com.esri.core.geometry.Point(-121, 10); com.esri.core.geometry.Point p4 = new com.esri.core.geometry.Point(-130, 12); com.esri.core.geometry.Point p5 = new com.esri.core.geometry.Point(-108, 25); com.esri.core.geometry.Point p12 = new com.esri.core.geometry.Point(-116, 40); com.esri.core.geometry.Point p22 = new com.esri.core.geometry.Point(-120, 39); com.esri.core.geometry.Point p32 = new com.esri.core.geometry.Point(-121, 10); com.esri.core.geometry.Point p42 = new com.esri.core.geometry.Point(-130, 12); com.esri.core.geometry.Point p52 = new com.esri.core.geometry.Point(-108, 25); bool isEqual1 = false; bool isEqual2 = false; bool isEqual3 = false; bool isEqual4 = false; bool isEqual5 = false; try { isEqual1 = com.esri.core.geometry.GeometryEngine.Equals(p1, p12, sr); isEqual2 = com.esri.core.geometry.GeometryEngine.Equals(p1, p12, sr); isEqual3 = com.esri.core.geometry.GeometryEngine.Equals(p1, p12, sr); isEqual4 = com.esri.core.geometry.GeometryEngine.Equals(p1, p12, sr); isEqual5 = com.esri.core.geometry.GeometryEngine.Equals(p1, p12, sr); } catch (System.ArgumentException) { } NUnit.Framework.Assert.IsTrue(isEqual1 && isEqual2 && isEqual3 && isEqual4 && isEqual5); }
public virtual void testTouchPointLineCR183227() { // Tests CR 183227 com.esri.core.geometry.Geometry baseGeom = new com.esri.core.geometry.Point(-130, 10); com.esri.core.geometry.Polyline pl = new com.esri.core.geometry.Polyline(); // pl.startPath(new Point(-130, 10)); pl.startPath(-130, 10); pl.lineTo(-131, 15); pl.lineTo(-140, 20); com.esri.core.geometry.SpatialReference sr = com.esri.core.geometry.SpatialReference .create(4326); bool isTouched; bool isTouched2; isTouched = com.esri.core.geometry.GeometryEngine.touches(baseGeom, pl, sr); isTouched2 = com.esri.core.geometry.GeometryEngine.touches(pl, baseGeom, sr); NUnit.Framework.Assert.IsTrue(isTouched && isTouched2); { com.esri.core.geometry.Geometry baseGeom2 = (com.esri.core.geometry.Geometry) new com.esri.core.geometry.Point(-131, 15); bool bIsTouched; bool bIsTouched2; bIsTouched = com.esri.core.geometry.GeometryEngine.touches(baseGeom2, pl, sr); bIsTouched2 = com.esri.core.geometry.GeometryEngine.touches(pl, baseGeom2, sr); NUnit.Framework.Assert.IsTrue(!bIsTouched && !bIsTouched2); } }
public virtual void testPointAndPolyline1() { com.esri.core.geometry.Point basePl = new com.esri.core.geometry.Point(-116, 20); com.esri.core.geometry.Polyline compPl = new com.esri.core.geometry.Polyline(); compPl.startPath(new com.esri.core.geometry.Point(-116, 20)); compPl.lineTo(new com.esri.core.geometry.Point(-131, 10)); compPl.lineTo(new com.esri.core.geometry.Point(-121, 50)); int noException = 1; // no exception com.esri.core.geometry.Geometry intersectGeom = null; try { intersectGeom = com.esri.core.geometry.GeometryEngine.intersect(basePl, compPl, com.esri.core.geometry.SpatialReference .create(4326)); } catch (System.Exception) { noException = 0; } NUnit.Framework.Assert.AreEqual(noException, 1); NUnit.Framework.Assert.IsNotNull(intersectGeom); NUnit.Framework.Assert.IsTrue(intersectGeom.getType() == com.esri.core.geometry.Geometry.Type .Point); com.esri.core.geometry.Point ip = (com.esri.core.geometry.Point)intersectGeom; NUnit.Framework.Assert.AreEqual(-116, 0.1E7, ip.getX()); NUnit.Framework.Assert.AreEqual(20, 0.1E7, ip.getY()); }
public virtual void testGeometryOperationSupport() { com.esri.core.geometry.Geometry baseGeom = new com.esri.core.geometry.Point(-130, 10); com.esri.core.geometry.Geometry comparisonGeom = new com.esri.core.geometry.Point (-130, 10); com.esri.core.geometry.SpatialReference sr = com.esri.core.geometry.SpatialReference .create(4326); com.esri.core.geometry.Geometry diffGeom = null; int noException = 1; // no exception try { diffGeom = com.esri.core.geometry.GeometryEngine.difference(baseGeom, comparisonGeom , sr); } catch (System.ArgumentException) { noException = 0; } catch (com.esri.core.geometry.GeometryException) { noException = 0; } NUnit.Framework.Assert.AreEqual(noException, 1); }
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 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(10, 20); point.setXY(pt); return(point); }
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 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 TestDistanceBetweenPointAndEnvelope() { com.esri.core.geometry.Envelope env = new com.esri.core.geometry.Envelope(23, 23, 23, 23); com.esri.core.geometry.Point pt = new com.esri.core.geometry.Point(30, 30); double dist = com.esri.core.geometry.GeometryEngine.Distance(env, pt, null); // expect just under 10. NUnit.Framework.Assert.IsTrue(System.Math.Abs(dist - 9.8994949) < 0.0001); }
public virtual void testEmptyPoint() { com.esri.core.geometry.Point p = new com.esri.core.geometry.Point(); com.esri.core.geometry.OperatorExportToGeoJson exporter = (com.esri.core.geometry.OperatorExportToGeoJson )factory.getOperator(com.esri.core.geometry.Operator.Type.ExportToGeoJson); string result = exporter.execute(p); NUnit.Framework.Assert.AreEqual("{\"type\":\"Point\",\"coordinates\":null}", result ); }
public virtual void testOGCPoint() { com.esri.core.geometry.Point p = new com.esri.core.geometry.Point(10.0, 20.0); com.esri.core.geometry.ogc.OGCGeometry ogcPoint = new com.esri.core.geometry.ogc.OGCPoint (p, null); string result = ogcPoint.asGeoJson(); NUnit.Framework.Assert.AreEqual("{\"type\":\"Point\",\"coordinates\":[10.0,20.0]}" , result); }
public static void testDistanceBetweenPointAndEnvelope() { com.esri.core.geometry.Envelope env = new com.esri.core.geometry.Envelope(23, 23, 23, 23); com.esri.core.geometry.Point pt = new com.esri.core.geometry.Point(30, 30); double dist = com.esri.core.geometry.GeometryEngine.distance(env, pt, null); // expect just under 10. NUnit.Framework.Assert.IsTrue(System.Math.abs(dist - 9.8994949) < 0.0001); }
public virtual void TestTriangleLength() { com.esri.core.geometry.Point pt_0 = new com.esri.core.geometry.Point(10, 10); com.esri.core.geometry.Point pt_1 = new com.esri.core.geometry.Point(20, 20); com.esri.core.geometry.Point pt_2 = new com.esri.core.geometry.Point(20, 10); 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 - 3744719.4094597572) < 1e-13 * 3744719.4094597572); }
public static void testCR254240() { com.esri.core.geometry.OperatorProximity2D proximityOp = com.esri.core.geometry.OperatorProximity2D .local(); com.esri.core.geometry.Point inputPoint = new com.esri.core.geometry.Point(-12, 12 ); com.esri.core.geometry.Polyline line = new com.esri.core.geometry.Polyline(); line.startPath(-10, 0); line.lineTo(0, 0); com.esri.core.geometry.Proximity2DResult result = proximityOp.getNearestCoordinate (line, inputPoint, false, true); NUnit.Framework.Assert.IsTrue(result.isRightSide() == false); }
public 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 static com.esri.core.geometry.Point[] pointsFromMultiPath(com.esri.core.geometry.MultiPath geom) { int numberOfPoints = geom.getPointCount(); com.esri.core.geometry.Point[] points = new com.esri.core.geometry.Point[numberOfPoints ]; for (int i = 0; i < geom.getPointCount(); i++) { points[i] = geom.getPoint(i); } return(points); }
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 testTouchesBetweenPointAndLine() { com.esri.core.geometry.SpatialReference sr = com.esri.core.geometry.SpatialReference .create(4326); com.esri.core.geometry.Point p = new com.esri.core.geometry.Point(2, 4); com.esri.core.geometry.Polyline compPl = new com.esri.core.geometry.Polyline(); compPl.startPath(2, 4); compPl.lineTo(9, 4); compPl.lineTo(9, 9); compPl.lineTo(2, 9); compPl.lineTo(2, 4); bool isTouched = com.esri.core.geometry.GeometryEngine.touches(p, compPl, sr); NUnit.Framework.Assert.IsTrue(!isTouched); }
public virtual void testTriangleLength() { com.esri.core.geometry.Point pt_0 = new com.esri.core.geometry.Point(10, 10); com.esri.core.geometry.Point pt_1 = new com.esri.core.geometry.Point(20, 20); com.esri.core.geometry.Point pt_2 = new com.esri.core.geometry.Point(20, 10); 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 - 3744719.4094597572) < 1e-13 * 3744719.4094597572); }
public virtual void testBufferPoint() { com.esri.core.geometry.SpatialReference sr = com.esri.core.geometry.SpatialReference .create(4326); com.esri.core.geometry.Point inputGeom = new com.esri.core.geometry.Point(12, 120 ); 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); com.esri.core.geometry.Geometry result = buffer.execute(inputGeom, sr, 40.0, null ); NUnit.Framework.Assert.IsTrue(result.getType().value() == com.esri.core.geometry.Geometry.GeometryType .Polygon); com.esri.core.geometry.Polygon poly = (com.esri.core.geometry.Polygon)result; int pathCount = poly.getPathCount(); NUnit.Framework.Assert.IsTrue(pathCount == 1); int pointCount = poly.getPointCount(); NUnit.Framework.Assert.IsTrue(System.Math.abs(pointCount - 100.0) < 10); com.esri.core.geometry.Envelope2D env2D = new com.esri.core.geometry.Envelope2D(); result.queryEnvelope2D(env2D); NUnit.Framework.Assert.IsTrue(System.Math.abs(env2D.getWidth() - 80) < 0.01 && System.Math .abs(env2D.getHeight() - 80) < 0.01); NUnit.Framework.Assert.IsTrue(System.Math.abs(env2D.getCenterX() - 12) < 0.001 && System.Math.abs(env2D.getCenterY() - 120) < 0.001); com.esri.core.geometry.NonSimpleResult nsr = new com.esri.core.geometry.NonSimpleResult (); bool is_simple = simplify.isSimpleAsFeature(result, sr, true, nsr, null); NUnit.Framework.Assert.IsTrue(is_simple); { result = buffer.execute(inputGeom, sr, 0, null); NUnit.Framework.Assert.IsTrue(result.getType().value() == com.esri.core.geometry.Geometry.GeometryType .Polygon); NUnit.Framework.Assert.IsTrue(result.isEmpty()); } { result = buffer.execute(inputGeom, sr, -1, null); NUnit.Framework.Assert.IsTrue(result.getType().value() == com.esri.core.geometry.Geometry.GeometryType .Polygon); NUnit.Framework.Assert.IsTrue(result.isEmpty()); } }
public virtual void TestEqualsOnEnvelopes() { com.esri.core.geometry.SpatialReference sr = com.esri.core.geometry.SpatialReference.Create(4326); com.esri.core.geometry.Point p = new com.esri.core.geometry.Point(-130, 10); com.esri.core.geometry.Envelope env = new com.esri.core.geometry.Envelope(p, 12, 12); com.esri.core.geometry.Envelope env2 = new com.esri.core.geometry.Envelope(-136, 4, -124, 16); bool isEqual; try { isEqual = com.esri.core.geometry.GeometryEngine.Equals(env, env2, sr); } catch (System.ArgumentException) { isEqual = false; } NUnit.Framework.Assert.IsTrue(isEqual); }
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 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 testSerializePoint() { try { java.io.ByteArrayOutputStream streamOut = new java.io.ByteArrayOutputStream(); java.io.ObjectOutputStream oo = new java.io.ObjectOutputStream(streamOut); com.esri.core.geometry.Point pt = new com.esri.core.geometry.Point(10, 40); oo.writeObject(pt); java.io.ByteArrayInputStream streamIn = new java.io.ByteArrayInputStream(streamOut .toByteArray()); java.io.ObjectInputStream ii = new java.io.ObjectInputStream(streamIn); com.esri.core.geometry.Point ptRes = (com.esri.core.geometry.Point)ii.readObject( ); NUnit.Framework.Assert.IsTrue(ptRes.Equals(pt)); } catch (System.Exception) { fail("Point serialization failure"); } // try // { // FileOutputStream streamOut = new FileOutputStream(m_thisDirectory + // "savedPoint.txt"); // ObjectOutputStream oo = new ObjectOutputStream(streamOut); // Point pt = new Point(10, 40); // oo.writeObject(pt); // } // catch(Exception ex) // { // fail("Point serialization failure"); // } try { java.io.InputStream s = Sharpen.Runtime.getClassForType(typeof(com.esri.core.geometry.TestSerialization )).getResourceAsStream("savedPoint.txt"); java.io.ObjectInputStream ii = new java.io.ObjectInputStream(s); com.esri.core.geometry.Point ptRes = (com.esri.core.geometry.Point)ii.readObject( ); NUnit.Framework.Assert.IsTrue(ptRes.getX() == 10 && ptRes.getY() == 40); } catch (System.Exception) { fail("Point serialization failure"); } }
public static void testDistanceBetweenVariousGeometries() { com.esri.core.geometry.Polygon polygon = makePolygon(); com.esri.core.geometry.Polyline polyline = makePolyline(); com.esri.core.geometry.MultiPoint multipoint = makeMultiPoint(); com.esri.core.geometry.Point point = makePoint(); // SpatialReference spatialRef = // SpatialReference.create(3857);//PCS_WGS_1984_WEB_MERCATOR_AUXSPHERE double distance; distance = com.esri.core.geometry.GeometryEngine.distance(polygon, polyline, null ); NUnit.Framework.Assert.IsTrue(System.Math.abs(distance - 5.0) < 0.00001); distance = com.esri.core.geometry.GeometryEngine.distance(polygon, multipoint, null ); NUnit.Framework.Assert.IsTrue(System.Math.abs(distance - 5.0) < 0.00001); distance = com.esri.core.geometry.GeometryEngine.distance(polygon, point, null); NUnit.Framework.Assert.IsTrue(System.Math.abs(distance - 5.0) < 0.00001); }
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); }
public virtual void TestIntersection() { 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.Polygon polygon = new com.esri.core.geometry.Polygon(); // outer ring1 polygon.startPath(0, 0); polygon.lineTo(10, 10); polygon.lineTo(20, 0); com.esri.core.geometry.Point point1 = new com.esri.core.geometry.Point(15, 10); com.esri.core.geometry.Point point2 = new com.esri.core.geometry.Point(2, 10); com.esri.core.geometry.Point point3 = new com.esri.core.geometry.Point(5, 5); bool res = op.execute(polygon, point1, null, null); NUnit.Framework.Assert.IsTrue(!res); res = op.execute(polygon, point2, null, null); NUnit.Framework.Assert.IsTrue(!res); res = op.execute(polygon, point3, null, null); NUnit.Framework.Assert.IsTrue(res); }
public virtual void testTouchesOnPointAndEnvelope() { com.esri.core.geometry.SpatialReference sr = com.esri.core.geometry.SpatialReference .create(4326); com.esri.core.geometry.Point p = new com.esri.core.geometry.Point(-130, 10); // Envelope env = new Envelope(p, 12, 12);//not touched com.esri.core.geometry.Envelope env = new com.esri.core.geometry.Envelope(-130, 10 , -110, 20); // touched bool isTouched; try { isTouched = com.esri.core.geometry.GeometryEngine.touches(p, env, sr); } catch (System.ArgumentException) { isTouched = false; } NUnit.Framework.Assert.AreEqual(isTouched, true); }
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 TestTouchOnPointAndPolygon() { com.esri.core.geometry.Geometry baseGeom = new com.esri.core.geometry.Point(-130, 10); 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.SpatialReference sr = com.esri.core.geometry.SpatialReference.Create(4326); bool isTouched; bool isTouched2; try { isTouched = com.esri.core.geometry.GeometryEngine.Touches(baseGeom, pg, sr); isTouched2 = com.esri.core.geometry.GeometryEngine.Touches(pg, baseGeom, sr); } catch (System.ArgumentException) { isTouched = false; isTouched2 = false; } NUnit.Framework.Assert.AreEqual(isTouched && isTouched2, true); }
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 static void TestCR254240() { com.esri.core.geometry.OperatorProximity2D proximityOp = com.esri.core.geometry.OperatorProximity2D.Local(); com.esri.core.geometry.Point inputPoint = new com.esri.core.geometry.Point(-12, 12); com.esri.core.geometry.Polyline line = new com.esri.core.geometry.Polyline(); line.StartPath(-10, 0); line.LineTo(0, 0); com.esri.core.geometry.Proximity2DResult result = proximityOp.GetNearestCoordinate(line, inputPoint, false, true); NUnit.Framework.Assert.IsTrue(result.IsRightSide() == false); }
public 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 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); }
public virtual void TestProximity2D_2() { com.esri.core.geometry.Point point1 = new com.esri.core.geometry.Point(3, 2); com.esri.core.geometry.Point point2 = new com.esri.core.geometry.Point(2, 4); com.esri.core.geometry.Envelope envelope = new com.esri.core.geometry.Envelope(); envelope.SetCoords(4, 3, 7, 6); com.esri.core.geometry.Polygon polygonToTest = new com.esri.core.geometry.Polygon(); polygonToTest.AddEnvelope(envelope, false); com.esri.core.geometry.Proximity2DResult prxResult1 = com.esri.core.geometry.GeometryEngine.GetNearestVertex(envelope, point1); com.esri.core.geometry.Proximity2DResult prxResult2 = com.esri.core.geometry.GeometryEngine.GetNearestVertex(polygonToTest, point1); com.esri.core.geometry.Proximity2DResult prxResult3 = com.esri.core.geometry.GeometryEngine.GetNearestCoordinate(envelope, point2, false); com.esri.core.geometry.Proximity2DResult prxResult4 = com.esri.core.geometry.GeometryEngine.GetNearestCoordinate(polygonToTest, point2, false); com.esri.core.geometry.Point result1 = prxResult1.GetCoordinate(); com.esri.core.geometry.Point result2 = prxResult2.GetCoordinate(); NUnit.Framework.Assert.IsTrue(result1.GetX() == result2.GetX()); com.esri.core.geometry.Point result3 = prxResult3.GetCoordinate(); com.esri.core.geometry.Point result4 = prxResult4.GetCoordinate(); NUnit.Framework.Assert.IsTrue(result3.GetX() == result4.GetX()); }
public virtual void TestTouchPointLineCR183227() { // Tests CR 183227 com.esri.core.geometry.Geometry baseGeom = new com.esri.core.geometry.Point(-130, 10); com.esri.core.geometry.Polyline pl = new com.esri.core.geometry.Polyline(); // pl.startPath(new Point(-130, 10)); pl.StartPath(-130, 10); pl.LineTo(-131, 15); pl.LineTo(-140, 20); com.esri.core.geometry.SpatialReference sr = com.esri.core.geometry.SpatialReference.Create(4326); bool isTouched; bool isTouched2; isTouched = com.esri.core.geometry.GeometryEngine.Touches(baseGeom, pl, sr); isTouched2 = com.esri.core.geometry.GeometryEngine.Touches(pl, baseGeom, sr); NUnit.Framework.Assert.IsTrue(isTouched && isTouched2); { com.esri.core.geometry.Geometry baseGeom2 = (com.esri.core.geometry.Geometry)new com.esri.core.geometry.Point(-131, 15); bool bIsTouched; bool bIsTouched2; bIsTouched = com.esri.core.geometry.GeometryEngine.Touches(baseGeom2, pl, sr); bIsTouched2 = com.esri.core.geometry.GeometryEngine.Touches(pl, baseGeom2, sr); NUnit.Framework.Assert.IsTrue(!bIsTouched && !bIsTouched2); } }
public 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 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 TestPointAndMultiPoint2() { com.esri.core.geometry.Point basePl = new com.esri.core.geometry.Point(-115, 20); com.esri.core.geometry.MultiPoint compPl = new com.esri.core.geometry.MultiPoint(); compPl.Add(new com.esri.core.geometry.Point(-116, 20)); compPl.Add(new com.esri.core.geometry.Point(-117, 21)); compPl.Add(new com.esri.core.geometry.Point(-118, 20)); compPl.Add(new com.esri.core.geometry.Point(-119, 21)); int noException = 1; // no exception com.esri.core.geometry.Geometry intersectGeom = null; try { intersectGeom = com.esri.core.geometry.GeometryEngine.Intersect(basePl, compPl, com.esri.core.geometry.SpatialReference.Create(4326)); } catch (System.Exception) { noException = 0; } NUnit.Framework.Assert.AreEqual(noException, 1); NUnit.Framework.Assert.IsTrue(intersectGeom.IsEmpty()); }
public static void TestCopy() { 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, -1.0); com.esri.core.geometry.Point pt1 = new com.esri.core.geometry.Point(0.0, 0.0, 1.0); com.esri.core.geometry.Point pt2 = new com.esri.core.geometry.Point(0.0, 1.0, 1.0); mpoint.Add(pt0); mpoint.Add(pt1); mpoint.Add(pt2); mpoint.RemovePoint(1); com.esri.core.geometry.MultiPoint mpCopy = (com.esri.core.geometry.MultiPoint)mpoint.Copy(); NUnit.Framework.Assert.IsTrue(mpCopy.Equals(mpoint)); com.esri.core.geometry.Point pt; pt = mpCopy.GetPoint(0); NUnit.Framework.Assert.IsTrue(pt.GetX() == pt0.GetX() && pt.GetY() == pt0.GetY()); pt = mpCopy.GetPoint(1); NUnit.Framework.Assert.IsTrue(pt.GetX() == pt2.GetX() && pt.GetY() == pt2.GetY()); NUnit.Framework.Assert.IsTrue(mpCopy.GetPointCount() == 2); }
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 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 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 virtual void TestTouchesOnPointAndEnvelope() { com.esri.core.geometry.SpatialReference sr = com.esri.core.geometry.SpatialReference.Create(4326); com.esri.core.geometry.Point p = new com.esri.core.geometry.Point(-130, 10); // Envelope env = new Envelope(p, 12, 12);//not touched com.esri.core.geometry.Envelope env = new com.esri.core.geometry.Envelope(-130, 10, -110, 20); // touched bool isTouched; try { isTouched = com.esri.core.geometry.GeometryEngine.Touches(p, env, sr); } catch (System.ArgumentException) { isTouched = false; } NUnit.Framework.Assert.AreEqual(isTouched, true); }
public static void TestDifferenceAndSymmetricDifference() { com.esri.core.geometry.OperatorFactoryLocal engine = com.esri.core.geometry.OperatorFactoryLocal.GetInstance(); com.esri.core.geometry.OperatorDifference differenceOp = (com.esri.core.geometry.OperatorDifference)engine.GetOperator(com.esri.core.geometry.Operator.Type.Difference); com.esri.core.geometry.SpatialReference spatialRef = com.esri.core.geometry.SpatialReference.Create(102113); com.esri.core.geometry.Polygon polygon1 = MakePolygon1(); com.esri.core.geometry.Polygon polygon2 = MakePolygon2(); com.esri.core.geometry.Polyline polyline1 = MakePolyline1(); com.esri.core.geometry.MultiPoint multipoint1 = MakeMultiPoint1(); com.esri.core.geometry.MultiPoint multipoint2 = MakeMultiPoint2(); com.esri.core.geometry.MultiPoint multipoint3 = MakeMultiPoint3(); com.esri.core.geometry.Point point1 = MakePoint1(); com.esri.core.geometry.Point point2 = MakePoint2(); com.esri.core.geometry.Envelope envelope1 = MakeEnvelope1(); com.esri.core.geometry.Envelope envelope2 = MakeEnvelope2(); com.esri.core.geometry.Envelope envelope3 = MakeEnvelope3(); com.esri.core.geometry.Polygon outputPolygon = (com.esri.core.geometry.Polygon)differenceOp.Execute(polygon1, polygon2, spatialRef, null); double area = outputPolygon.CalculateArea2D(); NUnit.Framework.Assert.IsTrue(System.Math.Abs(area - 75) <= 0.001); { com.esri.core.geometry.Point point_1 = new com.esri.core.geometry.Point(-130, 10); com.esri.core.geometry.Point point_2 = new com.esri.core.geometry.Point(-130, 10); com.esri.core.geometry.Geometry baseGeom = new com.esri.core.geometry.Point(point_1.GetX(), point_1.GetY()); com.esri.core.geometry.Geometry comparisonGeom = new com.esri.core.geometry.Point(point_2.GetX(), point2.GetY()); com.esri.core.geometry.SpatialReference sr = com.esri.core.geometry.SpatialReference.Create(4326); com.esri.core.geometry.Geometry geom = differenceOp.Execute(baseGeom, comparisonGeom, sr, null); } com.esri.core.geometry.OperatorSymmetricDifference symDifferenceOp = (com.esri.core.geometry.OperatorSymmetricDifference)engine.GetOperator(com.esri.core.geometry.Operator.Type.SymmetricDifference); outputPolygon = (com.esri.core.geometry.Polygon)symDifferenceOp.Execute(polygon1, polygon2, spatialRef, null); area = outputPolygon.CalculateArea2D(); NUnit.Framework.Assert.IsTrue(System.Math.Abs(area - 150) <= 0.001); com.esri.core.geometry.Polyline outputPolyline = (com.esri.core.geometry.Polyline)differenceOp.Execute(polyline1, polygon1, spatialRef, null); double length = outputPolyline.CalculateLength2D(); NUnit.Framework.Assert.IsTrue(System.Math.Abs(length * length - 50) < 0.001); com.esri.core.geometry.MultiPoint outputMultiPoint = (com.esri.core.geometry.MultiPoint)differenceOp.Execute(multipoint1, polygon1, spatialRef, null); int pointCount = outputMultiPoint.GetPointCount(); NUnit.Framework.Assert.IsTrue(pointCount == 1); outputMultiPoint = (com.esri.core.geometry.MultiPoint)(symDifferenceOp.Execute(multipoint1, point1, spatialRef, null)); pointCount = outputMultiPoint.GetPointCount(); NUnit.Framework.Assert.IsTrue(pointCount == 2); outputMultiPoint = (com.esri.core.geometry.MultiPoint)(symDifferenceOp.Execute(multipoint1, point2, spatialRef, null)); pointCount = outputMultiPoint.GetPointCount(); NUnit.Framework.Assert.IsTrue(pointCount == 4); outputMultiPoint = (com.esri.core.geometry.MultiPoint)(differenceOp.Execute(multipoint1, point1, spatialRef, null)); pointCount = outputMultiPoint.GetPointCount(); NUnit.Framework.Assert.IsTrue(pointCount == 2); outputMultiPoint = (com.esri.core.geometry.MultiPoint)(differenceOp.Execute(multipoint1, point2, spatialRef, null)); pointCount = outputMultiPoint.GetPointCount(); NUnit.Framework.Assert.IsTrue(pointCount == 3); outputPolygon = (com.esri.core.geometry.Polygon)(differenceOp.Execute(polygon1, envelope1, spatialRef, null)); area = outputPolygon.CalculateArea2D(); NUnit.Framework.Assert.IsTrue(System.Math.Abs(area - 75) <= 0.001); outputPolygon = (com.esri.core.geometry.Polygon)(differenceOp.Execute(polygon2, envelope2, spatialRef, null)); area = outputPolygon.CalculateArea2D(); NUnit.Framework.Assert.IsTrue(System.Math.Abs(area - 75) <= 0.001); outputPolyline = (com.esri.core.geometry.Polyline)(differenceOp.Execute(polyline1, envelope2, spatialRef, null)); length = outputPolyline.CalculateLength2D(); NUnit.Framework.Assert.IsTrue(System.Math.Abs(length * length - 50) <= 0.001); outputMultiPoint = (com.esri.core.geometry.MultiPoint)(differenceOp.Execute(multipoint1, envelope2, spatialRef, null)); pointCount = outputMultiPoint.GetPointCount(); NUnit.Framework.Assert.IsTrue(pointCount == 1); outputMultiPoint = (com.esri.core.geometry.MultiPoint)(differenceOp.Execute(multipoint2, envelope2, spatialRef, null)); pointCount = outputMultiPoint.GetPointCount(); NUnit.Framework.Assert.IsTrue(pointCount == 6); outputMultiPoint = (com.esri.core.geometry.MultiPoint)(differenceOp.Execute(multipoint3, envelope2, spatialRef, null)); pointCount = outputMultiPoint.GetPointCount(); NUnit.Framework.Assert.IsTrue(pointCount == 0); com.esri.core.geometry.Point outputPoint = (com.esri.core.geometry.Point)(differenceOp.Execute(point1, envelope2, spatialRef, null)); NUnit.Framework.Assert.IsTrue(!outputPoint.IsEmpty()); outputPoint = (com.esri.core.geometry.Point)(differenceOp.Execute(point2, envelope2, spatialRef, null)); NUnit.Framework.Assert.IsTrue(outputPoint.IsEmpty()); outputPolygon = (com.esri.core.geometry.Polygon)(differenceOp.Execute(envelope3, envelope2, spatialRef, null)); NUnit.Framework.Assert.IsTrue(outputPolygon != null && outputPolygon.IsEmpty()); outputPolygon = (com.esri.core.geometry.Polygon)(symDifferenceOp.Execute(envelope3, envelope3, spatialRef, null)); NUnit.Framework.Assert.IsTrue(outputPolygon != null && outputPolygon.IsEmpty()); outputPoint = (com.esri.core.geometry.Point)(differenceOp.Execute(point1, polygon1, spatialRef, null)); NUnit.Framework.Assert.IsTrue(outputPoint != null); }
public virtual void TestTouchesBetweenPointAndLine() { com.esri.core.geometry.SpatialReference sr = com.esri.core.geometry.SpatialReference.Create(4326); com.esri.core.geometry.Point p = new com.esri.core.geometry.Point(2, 4); com.esri.core.geometry.Polyline compPl = new com.esri.core.geometry.Polyline(); compPl.StartPath(2, 4); compPl.LineTo(9, 4); compPl.LineTo(9, 9); compPl.LineTo(2, 9); compPl.LineTo(2, 4); bool isTouched = com.esri.core.geometry.GeometryEngine.Touches(p, compPl, sr); NUnit.Framework.Assert.IsTrue(!isTouched); }
public virtual void 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); }
internal virtual com.esri.core.geometry.Point MakePoint() { com.esri.core.geometry.Point point = new com.esri.core.geometry.Point(3, 2.5); return point; }