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