Exemple #1
0
        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);
        }
Exemple #2
0
        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 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();
 }
Exemple #4
0
        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);
            }
        }
Exemple #5
0
        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);
        }