protected void SetUp()
		{
			
			factory = com.esri.core.geometry.OperatorFactoryLocal.GetInstance();
			simplifyOp = (com.esri.core.geometry.OperatorSimplify)factory.GetOperator(com.esri.core.geometry.Operator.Type.Simplify);
			simplifyOpOGC = (com.esri.core.geometry.OperatorSimplifyOGC)factory.GetOperator(com.esri.core.geometry.Operator.Type.SimplifyOGC);
			sr102100 = com.esri.core.geometry.SpatialReference.Create(102100);
			sr3857 = com.esri.core.geometry.SpatialReference.Create(3857);
			// PE_PCS_WGS_1984_WEB_MERCATOR_AUXSPHERE);
			sr4326 = com.esri.core.geometry.SpatialReference.Create(4326);
		}
Esempio n. 2
0
        public virtual void testBufferPoint()
        {
            com.esri.core.geometry.SpatialReference sr = com.esri.core.geometry.SpatialReference
                                                         .create(4326);
            com.esri.core.geometry.Point inputGeom = new com.esri.core.geometry.Point(12, 120
                                                                                      );
            com.esri.core.geometry.OperatorBuffer buffer = (com.esri.core.geometry.OperatorBuffer
                                                            )com.esri.core.geometry.OperatorFactoryLocal.getInstance().getOperator(com.esri.core.geometry.Operator.Type
                                                                                                                                   .Buffer);
            com.esri.core.geometry.OperatorSimplify simplify = (com.esri.core.geometry.OperatorSimplify
                                                                )com.esri.core.geometry.OperatorFactoryLocal.getInstance().getOperator(com.esri.core.geometry.Operator.Type
                                                                                                                                       .Simplify);
            com.esri.core.geometry.Geometry result = buffer.execute(inputGeom, sr, 40.0, null
                                                                    );
            NUnit.Framework.Assert.IsTrue(result.getType().value() == com.esri.core.geometry.Geometry.GeometryType
                                          .Polygon);
            com.esri.core.geometry.Polygon poly = (com.esri.core.geometry.Polygon)result;
            int pathCount = poly.getPathCount();

            NUnit.Framework.Assert.IsTrue(pathCount == 1);
            int pointCount = poly.getPointCount();

            NUnit.Framework.Assert.IsTrue(System.Math.abs(pointCount - 100.0) < 10);
            com.esri.core.geometry.Envelope2D env2D = new com.esri.core.geometry.Envelope2D();
            result.queryEnvelope2D(env2D);
            NUnit.Framework.Assert.IsTrue(System.Math.abs(env2D.getWidth() - 80) < 0.01 && System.Math
                                          .abs(env2D.getHeight() - 80) < 0.01);
            NUnit.Framework.Assert.IsTrue(System.Math.abs(env2D.getCenterX() - 12) < 0.001 &&
                                          System.Math.abs(env2D.getCenterY() - 120) < 0.001);
            com.esri.core.geometry.NonSimpleResult nsr = new com.esri.core.geometry.NonSimpleResult
                                                             ();
            bool is_simple = simplify.isSimpleAsFeature(result, sr, true, nsr, null);

            NUnit.Framework.Assert.IsTrue(is_simple);
            {
                result = buffer.execute(inputGeom, sr, 0, null);
                NUnit.Framework.Assert.IsTrue(result.getType().value() == com.esri.core.geometry.Geometry.GeometryType
                                              .Polygon);
                NUnit.Framework.Assert.IsTrue(result.isEmpty());
            }
            {
                result = buffer.execute(inputGeom, sr, -1, null);
                NUnit.Framework.Assert.IsTrue(result.getType().value() == com.esri.core.geometry.Geometry.GeometryType
                                              .Polygon);
                NUnit.Framework.Assert.IsTrue(result.isEmpty());
            }
        }
Esempio n. 3
0
        public virtual void testWKB2()
        {
            // JSON -> GEOM -> WKB
            // String strPolygon1 =
            // "{\"xmin\":-1.16605115291E7,\"ymin\":4925189.941699997,\"xmax\":-1.16567772126E7,\"ymax\":4928658.771399997,\"spatialReference\":{\"wkid\":102100}}";
            string strPolygon1 = "{\"rings\" : [ [ [-1.16605115291E7,4925189.941699997], [-1.16567772126E7,4925189.941699997], [-1.16567772126E7,4928658.771399997], [-1.16605115291E7,4928658.771399997], [-1.16605115291E7,4925189.941699997] ] ], \"spatialReference\" : {\"wkid\" : 102100}}";

            org.codehaus.jackson.JsonFactory factory = new org.codehaus.jackson.JsonFactory();
            org.codehaus.jackson.JsonParser  parser  = factory.createJsonParser(strPolygon1);
            parser.nextToken();
            com.esri.core.geometry.MapGeometry mapGeom = com.esri.core.geometry.GeometryEngine
                                                         .jsonToGeometry(parser);
            com.esri.core.geometry.Geometry geom = mapGeom.getGeometry();
            // simplifying geom
            com.esri.core.geometry.OperatorSimplify operatorSimplify = (com.esri.core.geometry.OperatorSimplify
                                                                        )com.esri.core.geometry.OperatorFactoryLocal.getInstance().getOperator(com.esri.core.geometry.Operator.Type
                                                                                                                                               .Simplify);
            com.esri.core.geometry.SpatialReference sr = com.esri.core.geometry.SpatialReference
                                                         .create(102100);
            geom = operatorSimplify.execute(geom, sr, true, null);
            com.esri.core.geometry.OperatorExportToWkb operatorExport = (com.esri.core.geometry.OperatorExportToWkb
                                                                         )com.esri.core.geometry.OperatorFactoryLocal.getInstance().getOperator(com.esri.core.geometry.Operator.Type
                                                                                                                                                .ExportToWkb);
            java.nio.ByteBuffer byteBuffer = operatorExport.execute(0, geom, null);
            byte[] wkb = ((byte[])byteBuffer.array());
            // // checking WKB correctness
            // WKBReader jtsReader = new WKBReader();
            // com.vividsolutions.jts.geom.Geometry jtsGeom = jtsReader.read(wkb);
            // System.out.println("jtsGeom = " + jtsGeom);
            // WKB -> GEOM -> JSON
            com.esri.core.geometry.OperatorImportFromWkb operatorImport = (com.esri.core.geometry.OperatorImportFromWkb
                                                                           )com.esri.core.geometry.OperatorFactoryLocal.getInstance().getOperator(com.esri.core.geometry.Operator.Type
                                                                                                                                                  .ImportFromWkb);
            geom = operatorImport.execute(0, com.esri.core.geometry.Geometry.Type.Polygon, java.nio.ByteBuffer
                                          .wrap(wkb), null);
            NUnit.Framework.Assert.IsTrue(!geom.isEmpty());
        }
Esempio n. 4
0
 public virtual void testBufferPolygon()
 {
     com.esri.core.geometry.SpatialReference sr = com.esri.core.geometry.SpatialReference
                                                  .create(4326);
     com.esri.core.geometry.Polygon        inputGeom = new com.esri.core.geometry.Polygon();
     com.esri.core.geometry.OperatorBuffer buffer    = (com.esri.core.geometry.OperatorBuffer
                                                        )com.esri.core.geometry.OperatorFactoryLocal.getInstance().getOperator(com.esri.core.geometry.Operator.Type
                                                                                                                               .Buffer);
     com.esri.core.geometry.OperatorSimplify simplify = (com.esri.core.geometry.OperatorSimplify
                                                         )com.esri.core.geometry.OperatorFactoryLocal.getInstance().getOperator(com.esri.core.geometry.Operator.Type
                                                                                                                                .Simplify);
     inputGeom.startPath(0, 0);
     inputGeom.lineTo(50, 50);
     inputGeom.lineTo(50, 0);
     {
         com.esri.core.geometry.Geometry result = buffer.execute(inputGeom, sr, 0, null);
         NUnit.Framework.Assert.IsTrue(result.getType().value() == com.esri.core.geometry.Geometry.GeometryType
                                       .Polygon);
         NUnit.Framework.Assert.IsTrue(result == inputGeom);
     }
     {
         com.esri.core.geometry.Geometry result = buffer.execute(inputGeom, sr, 10, null);
         NUnit.Framework.Assert.IsTrue(result.getType().value() == com.esri.core.geometry.Geometry.GeometryType
                                       .Polygon);
         com.esri.core.geometry.Polygon    poly  = (com.esri.core.geometry.Polygon)(result);
         com.esri.core.geometry.Envelope2D env2D = new com.esri.core.geometry.Envelope2D();
         result.queryEnvelope2D(env2D);
         NUnit.Framework.Assert.IsTrue(System.Math.abs(env2D.getWidth() - 20 - 50) < 0.1 &&
                                       System.Math.abs(env2D.getHeight() - 20 - 50) < 0.1);
         NUnit.Framework.Assert.IsTrue(System.Math.abs(env2D.getCenterX() - 25) < 0.1 && System.Math
                                       .abs(env2D.getCenterY() - 25) < 0.1);
         int pathCount = poly.getPathCount();
         NUnit.Framework.Assert.IsTrue(pathCount == 1);
         int pointCount = poly.getPointCount();
         NUnit.Framework.Assert.IsTrue(System.Math.abs(pointCount - 104.0) < 10);
         NUnit.Framework.Assert.IsTrue(simplify.isSimpleAsFeature(result, sr, null));
     }
     {
         sr        = com.esri.core.geometry.SpatialReference.create(4326);
         inputGeom = new com.esri.core.geometry.Polygon();
         inputGeom.startPath(0, 0);
         inputGeom.lineTo(50, 50);
         inputGeom.lineTo(50, 0);
         com.esri.core.geometry.Geometry result = buffer.execute(inputGeom, sr, -10, null);
         NUnit.Framework.Assert.IsTrue(result.getType().value() == com.esri.core.geometry.Geometry.GeometryType
                                       .Polygon);
         com.esri.core.geometry.Polygon    poly  = (com.esri.core.geometry.Polygon)(result);
         com.esri.core.geometry.Envelope2D env2D = new com.esri.core.geometry.Envelope2D();
         result.queryEnvelope2D(env2D);
         NUnit.Framework.Assert.IsTrue(System.Math.abs(env2D.getWidth() - 15.85) < 0.1 &&
                                       System.Math.abs(env2D.getHeight() - 15.85) < 0.1);
         NUnit.Framework.Assert.IsTrue(System.Math.abs(env2D.getCenterX() - 32.07) < 0.1 &&
                                       System.Math.abs(env2D.getCenterY() - 17.93) < 0.1);
         int pathCount = poly.getPathCount();
         NUnit.Framework.Assert.IsTrue(pathCount == 1);
         int pointCount = poly.getPointCount();
         NUnit.Framework.Assert.IsTrue(pointCount == 3);
         NUnit.Framework.Assert.IsTrue(simplify.isSimpleAsFeature(result, sr, null));
     }
     {
         sr        = com.esri.core.geometry.SpatialReference.create(4326);
         inputGeom = new com.esri.core.geometry.Polygon();
         inputGeom.startPath(0, 0);
         inputGeom.lineTo(0, 50);
         inputGeom.lineTo(50, 50);
         inputGeom.lineTo(50, 0);
         inputGeom.startPath(10, 10);
         inputGeom.lineTo(40, 10);
         inputGeom.lineTo(40, 40);
         inputGeom.lineTo(10, 40);
         com.esri.core.geometry.Geometry result = buffer.execute(inputGeom, sr, -2, null);
         NUnit.Framework.Assert.IsTrue(result.getType().value() == com.esri.core.geometry.Geometry.GeometryType
                                       .Polygon);
         com.esri.core.geometry.Polygon    poly  = (com.esri.core.geometry.Polygon)(result);
         com.esri.core.geometry.Envelope2D env2D = new com.esri.core.geometry.Envelope2D();
         result.queryEnvelope2D(env2D);
         NUnit.Framework.Assert.IsTrue(System.Math.abs(env2D.getWidth() + 4 - 50) < 0.1 &&
                                       System.Math.abs(env2D.getHeight() + 4 - 50) < 0.1);
         NUnit.Framework.Assert.IsTrue(System.Math.abs(env2D.getCenterX() - 25) < 0.1 && System.Math
                                       .abs(env2D.getCenterY() - 25) < 0.1);
         int pathCount = poly.getPathCount();
         NUnit.Framework.Assert.IsTrue(pathCount == 2);
         int pointCount = poly.getPointCount();
         NUnit.Framework.Assert.IsTrue(System.Math.abs(pointCount - 108) < 10);
         NUnit.Framework.Assert.IsTrue(simplify.isSimpleAsFeature(result, sr, null));
     }
 }