public static void test1()
        {
            com.esri.core.geometry.Polyline polyline;
            polyline = makePolyline();
            com.esri.core.geometry.MultiPathImpl polylineImpl = (com.esri.core.geometry.MultiPathImpl
                                                                 )polyline._getImpl();
            com.esri.core.geometry.QuadTree quadtree  = buildQuadTree_(polylineImpl);
            com.esri.core.geometry.Line     queryline = new com.esri.core.geometry.Line(34, 9, 66
                                                                                        , 46);
            com.esri.core.geometry.QuadTree.QuadTreeIterator qtIter = quadtree.getIterator();
            NUnit.Framework.Assert.IsTrue(qtIter.next() == -1);
            qtIter.resetIterator(queryline, 0.0);
            int element_handle = qtIter.next();

            while (element_handle > 0)
            {
                int index = quadtree.getElement(element_handle);
                NUnit.Framework.Assert.IsTrue(index == 6 || index == 8 || index == 14);
                element_handle = qtIter.next();
            }
            com.esri.core.geometry.Envelope2D envelope = new com.esri.core.geometry.Envelope2D
                                                             (34, 9, 66, 46);
            com.esri.core.geometry.Polygon queryPolygon = new com.esri.core.geometry.Polygon(
                );
            queryPolygon.addEnvelope(envelope, true);
            qtIter.resetIterator(queryline, 0.0);
            element_handle = qtIter.next();
            while (element_handle > 0)
            {
                int index = quadtree.getElement(element_handle);
                NUnit.Framework.Assert.IsTrue(index == 6 || index == 8 || index == 14);
                element_handle = qtIter.next();
            }
        }
Esempio n. 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);
        }
Esempio n. 3
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);
 }
Esempio n. 4
0
		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());
		}
Esempio n. 5
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);
            }
        }