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 static void testWkbImportOnPostgresST() { try { java.sql.Connection con = java.sql.DriverManager.getConnection("jdbc:postgresql://tb.esri.com:5432/new_gdb" , "tb", "tb"); com.esri.core.geometry.OperatorFactoryLocal factory = com.esri.core.geometry.OperatorFactoryLocal .getInstance(); com.esri.core.geometry.OperatorImportFromWkb operatorImport = (com.esri.core.geometry.OperatorImportFromWkb )factory.getOperator(com.esri.core.geometry.Operator.Type.ImportFromWkb); string stmt = "SELECT objectid,sde.st_asbinary(shape) FROM new_gdb.tb.interstates a WHERE objectid IN (2) AND (a.shape IS NULL OR sde.st_geometrytype(shape)::text IN ('ST_MULTILINESTRING','ST_LINESTRING')) LIMIT 1000"; java.sql.PreparedStatement ps = con.prepareStatement(stmt); java.sql.ResultSet rs = ps.executeQuery(); while (rs.next()) { byte[] rsWkbGeom = rs.getBytes(2); com.esri.core.geometry.Geometry geomBorg = null; if (rsWkbGeom != null) { geomBorg = operatorImport.execute(0, com.esri.core.geometry.Geometry.Type.Unknown , java.nio.ByteBuffer.wrap(rsWkbGeom), null); } } ps.close(); con.close(); } catch (System.Exception) { } }
public static void test1() { com.esri.core.geometry.OperatorFactoryLocal engine = com.esri.core.geometry.OperatorFactoryLocal .getInstance(); com.esri.core.geometry.OperatorGeneralize op = (com.esri.core.geometry.OperatorGeneralize )engine.getOperator(com.esri.core.geometry.Operator.Type.Generalize); com.esri.core.geometry.Polygon poly = new com.esri.core.geometry.Polygon(); poly.startPath(0, 0); poly.lineTo(1, 1); poly.lineTo(2, 0); poly.lineTo(3, 2); poly.lineTo(4, 1); poly.lineTo(5, 0); poly.lineTo(5, 10); poly.lineTo(0, 10); com.esri.core.geometry.Geometry geom = op.execute(poly, 2, true, null); com.esri.core.geometry.Polygon p = (com.esri.core.geometry.Polygon)geom; com.esri.core.geometry.Point2D[] points = p.getCoordinates2D(); NUnit.Framework.Assert.IsTrue(points.Length == 4); NUnit.Framework.Assert.IsTrue(points[0].x == 0 && points[0].y == 0); NUnit.Framework.Assert.IsTrue(points[1].x == 5 && points[1].y == 0); NUnit.Framework.Assert.IsTrue(points[2].x == 5 && points[2].y == 10); NUnit.Framework.Assert.IsTrue(points[3].x == 0 && points[3].y == 10); com.esri.core.geometry.Geometry geom1 = op.execute(geom, 5, false, null); p = (com.esri.core.geometry.Polygon)geom1; points = p.getCoordinates2D(); NUnit.Framework.Assert.IsTrue(points.Length == 3); NUnit.Framework.Assert.IsTrue(points[0].x == 0 && points[0].y == 0); NUnit.Framework.Assert.IsTrue(points[1].x == 5 && points[1].y == 10); NUnit.Framework.Assert.IsTrue(points[2].x == 5 && points[2].y == 10); geom1 = op.execute(geom, 5, true, null); p = (com.esri.core.geometry.Polygon)geom1; points = p.getCoordinates2D(); NUnit.Framework.Assert.IsTrue(points.Length == 0); }
public static void testClipOfCoinciding() { 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.Polygon polygon = new com.esri.core.geometry.Polygon(); com.esri.core.geometry.Envelope2D envelopeCR = new com.esri.core.geometry.Envelope2D (); envelopeCR.xmin = -180; envelopeCR.xmax = 180; envelopeCR.ymin = -90; envelopeCR.ymax = 90; polygon.addEnvelope(envelopeCR, false); com.esri.core.geometry.SpatialReference gcsWGS84 = com.esri.core.geometry.SpatialReference .create(4326); // CR com.esri.core.geometry.Polygon clippedPolygon = (com.esri.core.geometry.Polygon)clipOp .execute(polygon, envelopeCR, gcsWGS84, null); NUnit.Framework.Assert.IsTrue(clippedPolygon.getPathCount() == 1); NUnit.Framework.Assert.IsTrue(clippedPolygon.getPointCount() == 4); com.esri.core.geometry.OperatorDensifyByLength densifyOp = (com.esri.core.geometry.OperatorDensifyByLength )engine.getOperator(com.esri.core.geometry.Operator.Type.DensifyByLength); polygon.setEmpty(); polygon.addEnvelope(envelopeCR, false); polygon = (com.esri.core.geometry.Polygon)densifyOp.execute(polygon, 1, null); int pc = polygon.getPointCount(); int pathc = polygon.getPathCount(); NUnit.Framework.Assert.IsTrue(pc == 1080); NUnit.Framework.Assert.IsTrue(pathc == 1); clippedPolygon = (com.esri.core.geometry.Polygon)clipOp.execute(polygon, envelopeCR , gcsWGS84, null); int _pathc = clippedPolygon.getPathCount(); int _pc = clippedPolygon.getPointCount(); NUnit.Framework.Assert.IsTrue(_pathc == 1); NUnit.Framework.Assert.IsTrue(_pc == pc); }
public static void testArcObjectsFailureCR196492() { 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.Polygon polygon = new com.esri.core.geometry.Polygon(); polygon.addEnvelope(new com.esri.core.geometry.Envelope2D(0, 0, 600, 600), false); polygon.startPath(30, 300); polygon.lineTo(20, 310); polygon.lineTo(10, 300); 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 (10, 10, 500, 500); com.esri.core.geometry.Polygon clippedPolygon = (com.esri.core.geometry.Polygon)clipOp .execute(polygon, envelopeCR, gcsWGS84, null); NUnit.Framework.Assert.IsTrue(clippedPolygon.getPointCount() == 7); }
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 static void testClipAttributes() { 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.Polygon polygon = new com.esri.core.geometry.Polygon(); polygon.addAttribute(com.esri.core.geometry.VertexDescription.Semantics.M); polygon.startPath(0, 0); polygon.lineTo(30, 30); polygon.lineTo(60, 0); polygon.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.M, 0, 0, 0); polygon.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.M, 1, 0, 60); polygon.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.M, 2, 0, 120); com.esri.core.geometry.Envelope2D clipper = new com.esri.core.geometry.Envelope2D (); clipper.setCoords(10, 0, 50, 20); com.esri.core.geometry.Polygon clippedPolygon = (com.esri.core.geometry.Polygon)clipOp .execute(polygon, clipper, com.esri.core.geometry.SpatialReference.create(4326), null); NUnit.Framework.Assert.IsTrue(clippedPolygon.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .M, 0, 0) == 100); NUnit.Framework.Assert.IsTrue(clippedPolygon.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .M, 1, 0) == 19.999999999999996); // 20.0 NUnit.Framework.Assert.IsTrue(clippedPolygon.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .M, 2, 0) == 20); NUnit.Framework.Assert.IsTrue(clippedPolygon.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .M, 3, 0) == 40); NUnit.Framework.Assert.IsTrue(clippedPolygon.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .M, 4, 0) == 80); NUnit.Framework.Assert.IsTrue(clippedPolygon.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .M, 5, 0) == 100); } { com.esri.core.geometry.Polygon polygon = new com.esri.core.geometry.Polygon(); polygon.addAttribute(com.esri.core.geometry.VertexDescription.Semantics.M); polygon.startPath(0, 0); polygon.lineTo(0, 40); polygon.lineTo(20, 40); polygon.lineTo(20, 0); polygon.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.M, 0, 0, 0); polygon.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.M, 1, 0, 60); polygon.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.M, 2, 0, 120); polygon.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.M, 3, 0, 180); com.esri.core.geometry.Envelope2D clipper = new com.esri.core.geometry.Envelope2D (); clipper.setCoords(0, 10, 20, 20); com.esri.core.geometry.Polygon clippedPolygon = (com.esri.core.geometry.Polygon)clipOp .execute(polygon, clipper, com.esri.core.geometry.SpatialReference.create(4326), null); NUnit.Framework.Assert.IsTrue(clippedPolygon.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .M, 0, 0) == 15); NUnit.Framework.Assert.IsTrue(clippedPolygon.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .M, 1, 0) == 30); NUnit.Framework.Assert.IsTrue(clippedPolygon.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .M, 2, 0) == 150); NUnit.Framework.Assert.IsTrue(clippedPolygon.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .M, 3, 0) == 165); } }
public static void testClipGeometries() { // RandomTest(); 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.Polygon polygon = makePolygon(); com.esri.core.geometry.SimpleGeometryCursor polygonCurs = new com.esri.core.geometry.SimpleGeometryCursor (polygon); com.esri.core.geometry.Polyline polyline = makePolyline(); com.esri.core.geometry.SimpleGeometryCursor polylineCurs = new com.esri.core.geometry.SimpleGeometryCursor (polyline); com.esri.core.geometry.MultiPoint multipoint = makeMultiPoint(); com.esri.core.geometry.SimpleGeometryCursor multipointCurs = new com.esri.core.geometry.SimpleGeometryCursor (multipoint); com.esri.core.geometry.Point point = makePoint(); com.esri.core.geometry.SimpleGeometryCursor pointCurs = new com.esri.core.geometry.SimpleGeometryCursor (point); com.esri.core.geometry.SpatialReference spatialRef = com.esri.core.geometry.SpatialReference .create(3857); com.esri.core.geometry.Envelope2D envelope = new com.esri.core.geometry.Envelope2D (); envelope.xmin = 0; envelope.xmax = 20; envelope.ymin = 5; envelope.ymax = 15; // Cursor implementation com.esri.core.geometry.GeometryCursor clipPolygonCurs = clipOp.execute(polygonCurs , envelope, spatialRef, null); com.esri.core.geometry.Polygon clippedPolygon = (com.esri.core.geometry.Polygon)clipPolygonCurs .next(); double area = clippedPolygon.calculateArea2D(); NUnit.Framework.Assert.IsTrue(System.Math.abs(area - 25) < 0.00001); // Single Geometry implementation clippedPolygon = (com.esri.core.geometry.Polygon)clipOp.execute(polygon, envelope , spatialRef, null); area = clippedPolygon.calculateArea2D(); NUnit.Framework.Assert.IsTrue(System.Math.abs(area - 25) < 0.00001); // Cursor implementation com.esri.core.geometry.GeometryCursor clipPolylineCurs = clipOp.execute(polylineCurs , envelope, spatialRef, null); com.esri.core.geometry.Polyline clippedPolyline = (com.esri.core.geometry.Polyline )clipPolylineCurs.next(); double length = clippedPolyline.calculateLength2D(); NUnit.Framework.Assert.IsTrue(System.Math.abs(length - 10 * System.Math.sqrt(2.0) ) < 1e-10); // Single Geometry implementation clippedPolyline = (com.esri.core.geometry.Polyline)clipOp.execute(polyline, envelope , spatialRef, null); length = clippedPolyline.calculateLength2D(); NUnit.Framework.Assert.IsTrue(System.Math.abs(length - 10 * System.Math.sqrt(2.0) ) < 1e-10); // Cursor implementation com.esri.core.geometry.GeometryCursor clipMulti_pointCurs = clipOp.execute(multipointCurs , envelope, spatialRef, null); com.esri.core.geometry.MultiPoint clipped_multi_point = (com.esri.core.geometry.MultiPoint )clipMulti_pointCurs.next(); int pointCount = clipped_multi_point.getPointCount(); NUnit.Framework.Assert.IsTrue(pointCount == 2); // Cursor implementation com.esri.core.geometry.GeometryCursor clipPointCurs = clipOp.execute(pointCurs, envelope , spatialRef, null); com.esri.core.geometry.Point clippedPoint = (com.esri.core.geometry.Point)clipPointCurs .next(); NUnit.Framework.Assert.IsTrue(clippedPoint != null); // RandomTest(); com.esri.core.geometry.Polyline _poly = new com.esri.core.geometry.Polyline(); _poly.startPath(2, 2); _poly.lineTo(0, 0); com.esri.core.geometry.Envelope2D _env = new com.esri.core.geometry.Envelope2D(); _env.setCoords(2, 1, 5, 3); com.esri.core.geometry.Polyline _clippedPolyline = (com.esri.core.geometry.Polyline )clipOp.execute(_poly, _env, spatialRef, null); NUnit.Framework.Assert.IsTrue(_clippedPolyline.isEmpty()); { com.esri.core.geometry.Polygon poly = new com.esri.core.geometry.Polygon(); poly.addEnvelope(new com.esri.core.geometry.Envelope2D(0, 0, 100, 100), false); poly.addEnvelope(new com.esri.core.geometry.Envelope2D(5, 5, 95, 95), true); com.esri.core.geometry.Polygon clippedPoly = (com.esri.core.geometry.Polygon)clipOp .execute(poly, new com.esri.core.geometry.Envelope2D(-10, -10, 110, 50), spatialRef , null); NUnit.Framework.Assert.IsTrue(clippedPoly.getPathCount() == 1); NUnit.Framework.Assert.IsTrue(clippedPoly.getPointCount() == 8); } }
public static void testConsiderTouch2(com.esri.core.geometry.SpatialReference spatialReference ) { com.esri.core.geometry.OperatorFactoryLocal engine = com.esri.core.geometry.OperatorFactoryLocal .getInstance(); com.esri.core.geometry.OperatorCut opCut = (com.esri.core.geometry.OperatorCut)engine .getOperator(com.esri.core.geometry.Operator.Type.Cut); com.esri.core.geometry.Polyline polyline2 = makePolyline2(); com.esri.core.geometry.Polyline cutter2 = makePolylineCutter2(); com.esri.core.geometry.GeometryCursor cursor = opCut.execute(true, polyline2, cutter2 , spatialReference, null); com.esri.core.geometry.Polyline cut; int pathCount; int segmentCount; double length; cut = (com.esri.core.geometry.Polyline)cursor.next(); pathCount = cut.getPathCount(); segmentCount = cut.getSegmentCount(); length = cut.calculateLength2D(); NUnit.Framework.Assert.IsTrue(pathCount == 4); NUnit.Framework.Assert.IsTrue(segmentCount == 4); NUnit.Framework.Assert.IsTrue(System.Math.abs(length - 5.74264068) <= 0.001); cut = (com.esri.core.geometry.Polyline)cursor.next(); pathCount = cut.getPathCount(); segmentCount = cut.getSegmentCount(); length = cut.calculateLength2D(); NUnit.Framework.Assert.IsTrue(pathCount == 6); NUnit.Framework.Assert.IsTrue(segmentCount == 8); NUnit.Framework.Assert.IsTrue(length == 6.75); cut = (com.esri.core.geometry.Polyline)cursor.next(); pathCount = cut.getPathCount(); segmentCount = cut.getSegmentCount(); length = cut.calculateLength2D(); NUnit.Framework.Assert.IsTrue(pathCount == 1); NUnit.Framework.Assert.IsTrue(segmentCount == 1); NUnit.Framework.Assert.IsTrue(System.Math.abs(length - 0.5) <= 0.001); cut = (com.esri.core.geometry.Polyline)cursor.next(); pathCount = cut.getPathCount(); segmentCount = cut.getSegmentCount(); length = cut.calculateLength2D(); NUnit.Framework.Assert.IsTrue(pathCount == 1); NUnit.Framework.Assert.IsTrue(segmentCount == 1); NUnit.Framework.Assert.IsTrue(System.Math.abs(length - 0.25) <= 0.001); cut = (com.esri.core.geometry.Polyline)cursor.next(); pathCount = cut.getPathCount(); segmentCount = cut.getSegmentCount(); length = cut.calculateLength2D(); NUnit.Framework.Assert.IsTrue(pathCount == 1); NUnit.Framework.Assert.IsTrue(segmentCount == 1); NUnit.Framework.Assert.IsTrue(System.Math.abs(length - 1) <= 0.001); cut = (com.esri.core.geometry.Polyline)cursor.next(); pathCount = cut.getPathCount(); segmentCount = cut.getSegmentCount(); length = cut.calculateLength2D(); NUnit.Framework.Assert.IsTrue(pathCount == 1); NUnit.Framework.Assert.IsTrue(segmentCount == 1); NUnit.Framework.Assert.IsTrue(System.Math.abs(length - 1.41421356) <= 0.001); cut = (com.esri.core.geometry.Polyline)cursor.next(); NUnit.Framework.Assert.IsTrue(cut == null); }
public static void testConsiderTouch1(com.esri.core.geometry.SpatialReference spatialReference ) { com.esri.core.geometry.OperatorFactoryLocal engine = com.esri.core.geometry.OperatorFactoryLocal .getInstance(); com.esri.core.geometry.OperatorCut opCut = (com.esri.core.geometry.OperatorCut)engine .getOperator(com.esri.core.geometry.Operator.Type.Cut); com.esri.core.geometry.Polyline polyline1 = makePolyline1(); com.esri.core.geometry.Polyline cutter1 = makePolylineCutter1(); com.esri.core.geometry.GeometryCursor cursor = opCut.execute(true, polyline1, cutter1 , spatialReference, null); com.esri.core.geometry.Polyline cut; int pathCount; int segmentCount; double length; cut = (com.esri.core.geometry.Polyline)cursor.next(); pathCount = cut.getPathCount(); segmentCount = cut.getSegmentCount(); length = cut.calculateLength2D(); NUnit.Framework.Assert.IsTrue(pathCount == 4); NUnit.Framework.Assert.IsTrue(segmentCount == 4); NUnit.Framework.Assert.IsTrue(length == 6); cut = (com.esri.core.geometry.Polyline)cursor.next(); pathCount = cut.getPathCount(); segmentCount = cut.getSegmentCount(); length = cut.calculateLength2D(); NUnit.Framework.Assert.IsTrue(pathCount == 6); NUnit.Framework.Assert.IsTrue(segmentCount == 8); NUnit.Framework.Assert.IsTrue(length == 12); cut = (com.esri.core.geometry.Polyline)cursor.next(); pathCount = cut.getPathCount(); segmentCount = cut.getSegmentCount(); length = cut.calculateLength2D(); NUnit.Framework.Assert.IsTrue(pathCount == 1); NUnit.Framework.Assert.IsTrue(segmentCount == 1); NUnit.Framework.Assert.IsTrue(length == 1); cut = (com.esri.core.geometry.Polyline)cursor.next(); pathCount = cut.getPathCount(); segmentCount = cut.getSegmentCount(); length = cut.calculateLength2D(); NUnit.Framework.Assert.IsTrue(pathCount == 1); NUnit.Framework.Assert.IsTrue(segmentCount == 1); NUnit.Framework.Assert.IsTrue(length == 1); cut = (com.esri.core.geometry.Polyline)cursor.next(); NUnit.Framework.Assert.IsTrue(cut == null); }
public static void testPolygon9(com.esri.core.geometry.SpatialReference spatialReference ) { com.esri.core.geometry.OperatorFactoryLocal engine = com.esri.core.geometry.OperatorFactoryLocal .getInstance(); com.esri.core.geometry.OperatorCut opCut = (com.esri.core.geometry.OperatorCut)engine .getOperator(com.esri.core.geometry.Operator.Type.Cut); com.esri.core.geometry.Polygon cut; int path_count; int point_count; double area; com.esri.core.geometry.Polygon polygon9 = makePolygon9(); com.esri.core.geometry.Polyline cutter9 = makePolygonCutter9(); com.esri.core.geometry.GeometryCursor cursor = opCut.execute(false, polygon9, cutter9 , spatialReference, null); cut = (com.esri.core.geometry.Polygon)cursor.next(); path_count = cut.getPathCount(); point_count = cut.getPointCount(); area = cut.calculateArea2D(); NUnit.Framework.Assert.IsTrue(path_count == 3); NUnit.Framework.Assert.IsTrue(point_count == 12); NUnit.Framework.Assert.IsTrue(area == 150); cut = (com.esri.core.geometry.Polygon)cursor.next(); path_count = cut.getPathCount(); point_count = cut.getPointCount(); area = cut.calculateArea2D(); NUnit.Framework.Assert.IsTrue(path_count == 3); NUnit.Framework.Assert.IsTrue(point_count == 12); NUnit.Framework.Assert.IsTrue(area == 150); cut = (com.esri.core.geometry.Polygon)cursor.next(); NUnit.Framework.Assert.IsTrue(cut == null); }
public virtual void testPoint() { com.esri.core.geometry.Point p = new com.esri.core.geometry.Point(10.0, 20.0); 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\":[10.0,20.0]}" , result); }
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 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 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); } }