Exemplo n.º 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);
 }
        internal virtual bool checkResultSpatialRef(com.esri.core.geometry.MapGeometry mapGeometry
                                                    , int expectWki1, int expectWki2)
        {
            com.esri.core.geometry.SpatialReference sr = mapGeometry.getSpatialReference();
            string Wkt  = sr.getText();
            int    wki1 = sr.getLatestID();

            if (!(wki1 == expectWki1 || wki1 == expectWki2))
            {
                return(false);
            }
            if (!(Wkt != null && Wkt.Length > 0))
            {
                return(false);
            }
            com.esri.core.geometry.SpatialReference sr2 = com.esri.core.geometry.SpatialReference
                                                          .create(Wkt);
            int wki2 = sr2.getID();

            if (expectWki2 > 0)
            {
                if (!(wki2 == expectWki1 || wki2 == expectWki2))
                {
                    return(false);
                }
            }
            else
            {
                if (!(wki2 == expectWki1))
                {
                    return(false);
                }
            }
            return(true);
        }
        protected void SetUp()
		{
			
			projEnv = com.esri.core.geometry.OperatorFactoryLocal.GetInstance();
			inputSR = com.esri.core.geometry.SpatialReference.Create(codeIn);
			outputSR = com.esri.core.geometry.SpatialReference.Create(codeOut);
		}
Exemplo n.º 4
0
        public static void testEngine(com.esri.core.geometry.SpatialReference spatialReference
                                      )
        {
            com.esri.core.geometry.Polygon    polygon8 = makePolygon8();
            com.esri.core.geometry.Polyline   cutter8  = makePolygonCutter8();
            com.esri.core.geometry.Geometry[] cuts     = com.esri.core.geometry.GeometryEngine.cut
                                                             (polygon8, cutter8, spatialReference);
            com.esri.core.geometry.Polygon cut;
            int    pathCount;
            int    pointCount;
            double area;

            cut        = (com.esri.core.geometry.Polygon)cuts[0];
            pathCount  = cut.getPathCount();
            pointCount = cut.getPointCount();
            area       = cut.calculateArea2D();
            NUnit.Framework.Assert.IsTrue(pathCount == 1);
            NUnit.Framework.Assert.IsTrue(pointCount == 4);
            NUnit.Framework.Assert.IsTrue(area == 100);
            cut        = (com.esri.core.geometry.Polygon)cuts[1];
            pathCount  = cut.getPathCount();
            pointCount = cut.getPointCount();
            area       = cut.calculateArea2D();
            NUnit.Framework.Assert.IsTrue(pathCount == 2);
            NUnit.Framework.Assert.IsTrue(pointCount == 8);
            NUnit.Framework.Assert.IsTrue(area == 800);
        }
Exemplo n.º 5
0
        public virtual void testTouchesOnPolylineAndPolygon()
        {
            com.esri.core.geometry.SpatialReference sr = com.esri.core.geometry.SpatialReference
                                                         .create(4326);
            com.esri.core.geometry.Polygon basePl = new com.esri.core.geometry.Polygon();
            basePl.startPath(new com.esri.core.geometry.Point(-117, 20));
            basePl.lineTo(new com.esri.core.geometry.Point(-100, 20));
            basePl.lineTo(new com.esri.core.geometry.Point(-100, 10));
            basePl.lineTo(new com.esri.core.geometry.Point(-117, 10));
            com.esri.core.geometry.Polyline compPl = new com.esri.core.geometry.Polyline();
            compPl.startPath(new com.esri.core.geometry.Point(-117, 20));
            compPl.lineTo(new com.esri.core.geometry.Point(-108, 25));
            compPl.lineTo(new com.esri.core.geometry.Point(-100, 20));
            compPl.lineTo(new com.esri.core.geometry.Point(-100, 30));
            bool isTouched;

            try
            {
                isTouched = com.esri.core.geometry.GeometryEngine.touches(basePl, compPl, sr);
            }
            catch (System.ArgumentException)
            {
                isTouched = false;
            }
            NUnit.Framework.Assert.AreEqual(isTouched, true);
        }
Exemplo n.º 6
0
        public virtual void testTouchOnPointAndPolyline()
        {
            com.esri.core.geometry.Geometry baseGeom = new com.esri.core.geometry.Point(-130,
                                                                                        10);
            com.esri.core.geometry.Polyline pl = new com.esri.core.geometry.Polyline();
            pl.startPath(new com.esri.core.geometry.Point(-130, 10));
            pl.lineTo(-131, 15);
            pl.lineTo(-140, 20);
            com.esri.core.geometry.SpatialReference sr = com.esri.core.geometry.SpatialReference
                                                         .create(4326);
            bool isTouched;
            bool isTouched2;

            try
            {
                isTouched  = com.esri.core.geometry.GeometryEngine.touches(baseGeom, pl, sr);
                isTouched2 = com.esri.core.geometry.GeometryEngine.touches(pl, baseGeom, sr);
            }
            catch (System.ArgumentException)
            {
                isTouched  = false;
                isTouched2 = false;
            }
            NUnit.Framework.Assert.AreEqual(isTouched && isTouched2, true);
        }
Exemplo n.º 7
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);
        }
Exemplo n.º 8
0
        public virtual void testEqualsOnPoints()
        {
            com.esri.core.geometry.SpatialReference sr = com.esri.core.geometry.SpatialReference
                                                         .create(4326);
            com.esri.core.geometry.Point p1  = new com.esri.core.geometry.Point(-116, 40);
            com.esri.core.geometry.Point p2  = new com.esri.core.geometry.Point(-120, 39);
            com.esri.core.geometry.Point p3  = new com.esri.core.geometry.Point(-121, 10);
            com.esri.core.geometry.Point p4  = new com.esri.core.geometry.Point(-130, 12);
            com.esri.core.geometry.Point p5  = new com.esri.core.geometry.Point(-108, 25);
            com.esri.core.geometry.Point p12 = new com.esri.core.geometry.Point(-116, 40);
            com.esri.core.geometry.Point p22 = new com.esri.core.geometry.Point(-120, 39);
            com.esri.core.geometry.Point p32 = new com.esri.core.geometry.Point(-121, 10);
            com.esri.core.geometry.Point p42 = new com.esri.core.geometry.Point(-130, 12);
            com.esri.core.geometry.Point p52 = new com.esri.core.geometry.Point(-108, 25);
            bool isEqual1 = false;
            bool isEqual2 = false;
            bool isEqual3 = false;
            bool isEqual4 = false;
            bool isEqual5 = false;

            try
            {
                isEqual1 = com.esri.core.geometry.GeometryEngine.equals(p1, p12, sr);
                isEqual2 = com.esri.core.geometry.GeometryEngine.equals(p1, p12, sr);
                isEqual3 = com.esri.core.geometry.GeometryEngine.equals(p1, p12, sr);
                isEqual4 = com.esri.core.geometry.GeometryEngine.equals(p1, p12, sr);
                isEqual5 = com.esri.core.geometry.GeometryEngine.equals(p1, p12, sr);
            }
            catch (System.ArgumentException)
            {
            }
            NUnit.Framework.Assert.IsTrue(isEqual1 && isEqual2 && isEqual3 && isEqual4 && isEqual5
                                          );
        }
Exemplo n.º 9
0
        public virtual void testEqualsOnPolygons()
        {
            com.esri.core.geometry.SpatialReference sr = com.esri.core.geometry.SpatialReference
                                                         .create(4326);
            com.esri.core.geometry.Polygon baseMp = new com.esri.core.geometry.Polygon();
            com.esri.core.geometry.Polygon compMp = new com.esri.core.geometry.Polygon();
            baseMp.startPath(-116, 40);
            baseMp.lineTo(-120, 39);
            baseMp.lineTo(-121, 10);
            baseMp.lineTo(-130, 12);
            baseMp.lineTo(-108, 25);
            compMp.startPath(-116, 40);
            compMp.lineTo(-120, 39);
            compMp.lineTo(-121, 10);
            compMp.lineTo(-130, 12);
            compMp.lineTo(-108, 25);
            bool isEqual;

            try
            {
                isEqual = com.esri.core.geometry.GeometryEngine.equals(baseMp, compMp, sr);
            }
            catch (System.ArgumentException)
            {
                isEqual = false;
            }
            NUnit.Framework.Assert.IsTrue(isEqual);
        }
Exemplo n.º 10
0
        public virtual void testTouchesOnPolygonAndEnvelope()
        {
            com.esri.core.geometry.SpatialReference sr = com.esri.core.geometry.SpatialReference
                                                         .create(4326);
            com.esri.core.geometry.Polygon basePl = new com.esri.core.geometry.Polygon();
            basePl.startPath(new com.esri.core.geometry.Point(-117, 20));
            basePl.lineTo(new com.esri.core.geometry.Point(-100, 20));
            basePl.lineTo(new com.esri.core.geometry.Point(-100, 10));
            basePl.lineTo(new com.esri.core.geometry.Point(-117, 10));
            // Envelope env = new Envelope(new Point(-117,20), 12, 12);//not touched
            com.esri.core.geometry.Envelope env = new com.esri.core.geometry.Envelope(-100, 20
                                                                                      , -80, 30);
            // touched
            bool isTouched;

            try
            {
                isTouched = com.esri.core.geometry.GeometryEngine.touches(basePl, env, sr);
            }
            catch (System.ArgumentException)
            {
                isTouched = false;
            }
            NUnit.Framework.Assert.AreEqual(isTouched, true);
        }
Exemplo n.º 11
0
        public virtual void testEqualsOnMultiPoints()
        {
            com.esri.core.geometry.SpatialReference sr = com.esri.core.geometry.SpatialReference
                                                         .create(4326);
            com.esri.core.geometry.MultiPoint baseMp = new com.esri.core.geometry.MultiPoint(
                );
            com.esri.core.geometry.MultiPoint compMp = new com.esri.core.geometry.MultiPoint(
                );
            baseMp.add(new com.esri.core.geometry.Point(-116, 40));
            baseMp.add(new com.esri.core.geometry.Point(-120, 39));
            baseMp.add(new com.esri.core.geometry.Point(-121, 10));
            baseMp.add(new com.esri.core.geometry.Point(-130, 12));
            baseMp.add(new com.esri.core.geometry.Point(-108, 25));
            compMp.add(new com.esri.core.geometry.Point(-116, 40));
            compMp.add(new com.esri.core.geometry.Point(-120, 39));
            compMp.add(new com.esri.core.geometry.Point(-121, 10));
            compMp.add(new com.esri.core.geometry.Point(-130, 12));
            compMp.add(new com.esri.core.geometry.Point(-108, 25));
            bool isEqual;

            try
            {
                isEqual = com.esri.core.geometry.GeometryEngine.equals(baseMp, compMp, sr);
            }
            catch (System.ArgumentException)
            {
                isEqual = false;
            }
            NUnit.Framework.Assert.IsTrue(isEqual);
        }
Exemplo n.º 12
0
        public virtual void testGeometryOperationSupport()
        {
            com.esri.core.geometry.Geometry baseGeom = new com.esri.core.geometry.Point(-130,
                                                                                        10);
            com.esri.core.geometry.Geometry comparisonGeom = new com.esri.core.geometry.Point
                                                                 (-130, 10);
            com.esri.core.geometry.SpatialReference sr = com.esri.core.geometry.SpatialReference
                                                         .create(4326);
            com.esri.core.geometry.Geometry diffGeom = null;
            int noException = 1;

            // no exception
            try
            {
                diffGeom = com.esri.core.geometry.GeometryEngine.difference(baseGeom, comparisonGeom
                                                                            , sr);
            }
            catch (System.ArgumentException)
            {
                noException = 0;
            }
            catch (com.esri.core.geometry.GeometryException)
            {
                noException = 0;
            }
            NUnit.Framework.Assert.AreEqual(noException, 1);
        }
Exemplo n.º 13
0
        public virtual void testTouchOnPolygons()
        {
            com.esri.core.geometry.Polygon pg = new com.esri.core.geometry.Polygon();
            pg.startPath(new com.esri.core.geometry.Point(-130, 10));
            pg.lineTo(-131, 15);
            pg.lineTo(-140, 20);
            com.esri.core.geometry.Polygon pg2 = new com.esri.core.geometry.Polygon();
            pg2.startPath(new com.esri.core.geometry.Point(-130, 10));
            pg2.lineTo(-131, 15);
            pg2.lineTo(-120, 20);
            com.esri.core.geometry.SpatialReference sr = com.esri.core.geometry.SpatialReference
                                                         .create(4326);
            bool isTouched;
            bool isTouched2;

            try
            {
                isTouched  = com.esri.core.geometry.GeometryEngine.touches(pg, pg2, sr);
                isTouched2 = com.esri.core.geometry.GeometryEngine.touches(pg2, pg, sr);
            }
            catch (System.ArgumentException)
            {
                isTouched  = false;
                isTouched2 = false;
            }
            NUnit.Framework.Assert.AreEqual(isTouched && isTouched2, true);
        }
Exemplo n.º 14
0
        public virtual void testTouchPointLineCR183227()
        {
            // Tests CR 183227
            com.esri.core.geometry.Geometry baseGeom = new com.esri.core.geometry.Point(-130,
                                                                                        10);
            com.esri.core.geometry.Polyline pl = new com.esri.core.geometry.Polyline();
            // pl.startPath(new Point(-130, 10));
            pl.startPath(-130, 10);
            pl.lineTo(-131, 15);
            pl.lineTo(-140, 20);
            com.esri.core.geometry.SpatialReference sr = com.esri.core.geometry.SpatialReference
                                                         .create(4326);
            bool isTouched;
            bool isTouched2;

            isTouched  = com.esri.core.geometry.GeometryEngine.touches(baseGeom, pl, sr);
            isTouched2 = com.esri.core.geometry.GeometryEngine.touches(pl, baseGeom, sr);
            NUnit.Framework.Assert.IsTrue(isTouched && isTouched2);
            {
                com.esri.core.geometry.Geometry baseGeom2 = (com.esri.core.geometry.Geometry) new
                                                            com.esri.core.geometry.Point(-131, 15);
                bool bIsTouched;
                bool bIsTouched2;
                bIsTouched  = com.esri.core.geometry.GeometryEngine.touches(baseGeom2, pl, sr);
                bIsTouched2 = com.esri.core.geometry.GeometryEngine.touches(pl, baseGeom2, sr);
                NUnit.Framework.Assert.IsTrue(!bIsTouched && !bIsTouched2);
            }
        }
Exemplo n.º 15
0
 public virtual void test_80()
 {
     com.esri.core.geometry.SpatialReference sr = com.esri.core.geometry.SpatialReference
                                                  .create(3857);
     NUnit.Framework.Assert.IsTrue(sr.getID() == 3857);
     NUnit.Framework.Assert.IsTrue(sr.getLatestID() == 3857);
     NUnit.Framework.Assert.IsTrue(sr.getOldID() == 102100);
     NUnit.Framework.Assert.IsTrue(sr.getTolerance() == 0.001);
 }
Exemplo n.º 16
0
        internal static string getJSonStringFromGeometry(com.esri.core.geometry.Geometry
                                                         geomIn, com.esri.core.geometry.SpatialReference sr)
        {
            string jsonStr4Geom = com.esri.core.geometry.GeometryEngine.geometryToJson(sr, geomIn
                                                                                       );
            string jsonStrNew = "{\"geometryType\":\"" + getGeometryType(geomIn) + "\",\"geometries\":["
                                + jsonStr4Geom + "]}";

            return(jsonStrNew);
        }
        public virtual void testGetSpatialReferenceFor4326()
        {
            string completeStr = "GEOGCS[\"GCS_Sphere\",DATUM[\"D_Sphere\"," + "SPHEROID[\"Sphere\",6371000.0,0.0]],PRIMEM[\"Greenwich\",0.0],"
                                 + "UNIT[\"Degree\",0.0174532925199433]]";

            // 4326 GCS_WGS_1984
            com.esri.core.geometry.SpatialReference sr = com.esri.core.geometry.SpatialReference
                                                         .create(completeStr);
            NUnit.Framework.Assert.IsNotNull(sr);
        }
        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);
		}
Exemplo n.º 19
0
 public static void testCut4326()
 {
     com.esri.core.geometry.SpatialReference sr = com.esri.core.geometry.SpatialReference
                                                  .create(4326);
     testConsiderTouch1(sr);
     testConsiderTouch2(sr);
     testPolygon5(sr);
     testPolygon7(sr);
     testPolygon8(sr);
     testPolygon9(sr);
     testEngine(sr);
 }
        public virtual void testOnlyWKI()
        {
            string jsonStringSR = "{\"wkid\" : 4326}";

            org.codehaus.jackson.JsonParser jsonParserSR = factory.createJsonParser(jsonStringSR
                                                                                    );
            jsonParserSR.nextToken();
            com.esri.core.geometry.MapGeometry mapGeom = com.esri.core.geometry.GeometryEngine
                                                         .jsonToGeometry(jsonParserSR);
            com.esri.core.geometry.Utils.showProjectedGeometryInfo(mapGeom);
            com.esri.core.geometry.SpatialReference sr = mapGeom.getSpatialReference();
            NUnit.Framework.Assert.IsTrue(sr == null);
        }
Exemplo n.º 21
0
        public virtual void test()
        {
            com.esri.core.geometry.SpatialReference sr = com.esri.core.geometry.SpatialReference
                                                         .create(102100);
            NUnit.Framework.Assert.IsTrue(sr.getID() == 102100);
            NUnit.Framework.Assert.IsTrue(sr.getLatestID() == 3857);
            NUnit.Framework.Assert.IsTrue(sr.getOldID() == 102100);
            NUnit.Framework.Assert.IsTrue(sr.getTolerance() == 0.001);
            com.esri.core.geometry.SpatialReference sr84 = com.esri.core.geometry.SpatialReference
                                                           .create(4326);
            double tol84 = sr84.getTolerance();

            NUnit.Framework.Assert.IsTrue(System.Math.abs(tol84 - 1e-8) < 1e-8 * 1e-8);
        }
Exemplo n.º 22
0
        public virtual void testTouchesBetweenPointAndLine()
        {
            com.esri.core.geometry.SpatialReference sr = com.esri.core.geometry.SpatialReference
                                                         .create(4326);
            com.esri.core.geometry.Point    p      = new com.esri.core.geometry.Point(2, 4);
            com.esri.core.geometry.Polyline compPl = new com.esri.core.geometry.Polyline();
            compPl.startPath(2, 4);
            compPl.lineTo(9, 4);
            compPl.lineTo(9, 9);
            compPl.lineTo(2, 9);
            compPl.lineTo(2, 4);
            bool isTouched = com.esri.core.geometry.GeometryEngine.touches(p, compPl, sr);

            NUnit.Framework.Assert.IsTrue(!isTouched);
        }
        public virtual void testPolygonWithEmptyWKT_NoWKI()
        {
            string jsonStringPg = "{ \"rings\" :[  [ [-97.06138,32.837], [-97.06133,32.836], "
                                  + "[-97.06124,32.834], [-97.06127,32.832], [-97.06138,32.837] ],  " + "[ [-97.06326,32.759], [-97.06298,32.755], [-97.06153,32.749], [-97.06326,32.759] ]], "
                                  + "\"spatialReference\" : {\"wkt\" : \"\"}}";

            org.codehaus.jackson.JsonParser jsonParserPg = factory.createJsonParser(jsonStringPg
                                                                                    );
            jsonParserPg.nextToken();
            com.esri.core.geometry.MapGeometry mapGeom = com.esri.core.geometry.GeometryEngine
                                                         .jsonToGeometry(jsonParserPg);
            com.esri.core.geometry.Utils.showProjectedGeometryInfo(mapGeom);
            com.esri.core.geometry.SpatialReference sr = mapGeom.getSpatialReference();
            NUnit.Framework.Assert.IsTrue(sr == null);
        }
		public virtual void TestIntersection1()
		{
			// OperatorFactoryLocal projEnv = OperatorFactoryLocal.getInstance();
			// int codeIn = 26910;//NAD_1983_UTM_Zone_10N : GCS 6269
			// int codeOut = 32610;//WGS_1984_UTM_Zone_10N; : GCS 4326
			// int codeIn = SpatialReference::PCS_WGS_1984_UTM_10N;
			// int codeOut = SpatialReference::PCS_WORLD_MOLLWEIDE;
			// int codeOut = 102100;
			inputSR = com.esri.core.geometry.SpatialReference.Create(codeIn);
			NUnit.Framework.Assert.IsTrue(inputSR.GetID() == codeIn);
			outputSR = com.esri.core.geometry.SpatialReference.Create(codeOut);
			NUnit.Framework.Assert.IsTrue(outputSR.GetID() == codeOut);
			com.esri.core.geometry.OperatorIntersection operatorIntersection = (com.esri.core.geometry.OperatorIntersection)projEnv.GetOperator(com.esri.core.geometry.Operator.Type.Intersection);
			com.esri.core.geometry.Polygon poly1 = new com.esri.core.geometry.Polygon();
			com.esri.core.geometry.Envelope env1 = new com.esri.core.geometry.Envelope(855277, 3892059, 855277 + 100, 3892059 + 100);
			// Envelope env1 = new Envelope(-1000000, -1000000, 1000000, 1000000);
			// env1.SetCoords(-8552770, -3892059, 855277 + 100, 3892059 + 100);
			poly1.AddEnvelope(env1, false);
			com.esri.core.geometry.Polygon poly2 = new com.esri.core.geometry.Polygon();
			com.esri.core.geometry.Envelope env2 = new com.esri.core.geometry.Envelope(855277 + 1, 3892059 + 1, 855277 + 30, 3892059 + 20);
			poly2.AddEnvelope(env2, false);
			com.esri.core.geometry.GeometryCursor cursor1 = new com.esri.core.geometry.SimpleGeometryCursor(poly1);
			com.esri.core.geometry.GeometryCursor cursor2 = new com.esri.core.geometry.SimpleGeometryCursor(poly2);
			com.esri.core.geometry.GeometryCursor outputGeoms = operatorIntersection.Execute(cursor1, cursor2, inputSR, null);
			com.esri.core.geometry.Geometry geomr = outputGeoms.Next();
			NUnit.Framework.Assert.IsNotNull(geomr);
			NUnit.Framework.Assert.IsTrue(geomr.GetType() == com.esri.core.geometry.Geometry.Type.Polygon);
			com.esri.core.geometry.Polygon geom = (com.esri.core.geometry.Polygon)geomr;
			NUnit.Framework.Assert.IsTrue(geom.GetPointCount() == 4);
//			com.esri.core.geometry.Point[] points = com.esri.core.geometry.TestCommonMethods.PointsFromMultiPath(geom);
//			// SPtrOfArrayOf(Point2D)
//			// pts =
//			// geom.get.getCoordinates2D();
//			NUnit.Framework.Assert.IsTrue(System.Math.Abs(points[0].GetX() - 855278.000000000) < 1e-7);
//			NUnit.Framework.Assert.IsTrue(System.Math.Abs(points[0].GetY() - 3892060.0000000000) < 1e-7);
//			NUnit.Framework.Assert.IsTrue(System.Math.Abs(points[2].GetX() - 855307.00000000093) < 1e-7);
//			NUnit.Framework.Assert.IsTrue(System.Math.Abs(points[2].GetY() - 3892079.0000000000) < 1e-7);
//			geomr = operatorIntersection.Execute(poly1, poly2, inputSR, null);
//			NUnit.Framework.Assert.IsNotNull(geomr);
//			NUnit.Framework.Assert.IsTrue(geomr.GetType() == com.esri.core.geometry.Geometry.Type.Polygon);
//			com.esri.core.geometry.Polygon outputGeom = (com.esri.core.geometry.Polygon)geomr;
//			NUnit.Framework.Assert.IsTrue(outputGeom.GetPointCount() == 4);
//			points = com.esri.core.geometry.TestCommonMethods.PointsFromMultiPath(outputGeom);
//			NUnit.Framework.Assert.IsTrue(System.Math.Abs(points[0].GetX() - 855278.000000000) < 1e-7);
//			NUnit.Framework.Assert.IsTrue(System.Math.Abs(points[0].GetY() - 3892060.0000000000) < 1e-7);
//			NUnit.Framework.Assert.IsTrue(System.Math.Abs(points[2].GetX() - 855307.00000000093) < 1e-7);
//			NUnit.Framework.Assert.IsTrue(System.Math.Abs(points[2].GetY() - 3892079.0000000000) < 1e-7);
		}
Exemplo n.º 25
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);
        }
Exemplo n.º 26
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());
            }
        }
Exemplo n.º 27
0
        public virtual void testTouchesBetweenPolylines()
        {
            com.esri.core.geometry.SpatialReference sr = com.esri.core.geometry.SpatialReference
                                                         .create(4326);
            com.esri.core.geometry.Polyline pl = new com.esri.core.geometry.Polyline();
            pl.startPath(2, 4);
            pl.lineTo(9, 9);
            com.esri.core.geometry.Polyline compPl = new com.esri.core.geometry.Polyline();
            compPl.startPath(2, 4);
            compPl.lineTo(9, 4);
            compPl.lineTo(9, 9);
            compPl.lineTo(2, 9);
            compPl.lineTo(2, 4);
            bool isTouched = com.esri.core.geometry.GeometryEngine.touches(pl, compPl, sr);

            NUnit.Framework.Assert.AreEqual(isTouched, true);
        }
Exemplo n.º 28
0
        public virtual void testRelationTouch()
        {
            com.esri.core.geometry.SpatialReference sr = com.esri.core.geometry.SpatialReference
                                                         .create(4326);
            com.esri.core.geometry.Polyline basePl = new com.esri.core.geometry.Polyline();
            basePl.startPath(2, 2);
            basePl.lineTo(2, 10);
            com.esri.core.geometry.Polyline compPl = new com.esri.core.geometry.Polyline();
            compPl.startPath(2, 4);
            compPl.lineTo(9, 4);
            compPl.lineTo(9, 9);
            compPl.lineTo(2, 9);
            compPl.lineTo(2, 4);
            bool isTouched = false;

            // GeometryEngine.relation(basePl, compPl, sr,
            // "G1 TOUCH G2");
            NUnit.Framework.Assert.AreEqual(isTouched, false);
        }
Exemplo n.º 29
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);
 }
Exemplo n.º 30
0
 public virtual void testSerializeSR()
 {
     try
     {
         java.io.ByteArrayOutputStream           streamOut = new java.io.ByteArrayOutputStream();
         java.io.ObjectOutputStream              oo        = new java.io.ObjectOutputStream(streamOut);
         com.esri.core.geometry.SpatialReference sr        = com.esri.core.geometry.SpatialReference
                                                             .create(102100);
         oo.writeObject(sr);
         java.io.ByteArrayInputStream streamIn = new java.io.ByteArrayInputStream(streamOut
                                                                                  .toByteArray());
         java.io.ObjectInputStream ii = new java.io.ObjectInputStream(streamIn);
         com.esri.core.geometry.SpatialReference ptRes = (com.esri.core.geometry.SpatialReference
                                                          )ii.readObject();
         NUnit.Framework.Assert.IsTrue(ptRes.Equals(sr));
     }
     catch (System.Exception)
     {
         fail("Spatial Reference serialization failure");
     }
 }
Exemplo n.º 31
0
        public virtual void testEqualsOnEnvelopes()
        {
            com.esri.core.geometry.SpatialReference sr = com.esri.core.geometry.SpatialReference
                                                         .create(4326);
            com.esri.core.geometry.Point    p   = new com.esri.core.geometry.Point(-130, 10);
            com.esri.core.geometry.Envelope env = new com.esri.core.geometry.Envelope(p, 12,
                                                                                      12);
            com.esri.core.geometry.Envelope env2 = new com.esri.core.geometry.Envelope(-136,
                                                                                       4, -124, 16);
            bool isEqual;

            try
            {
                isEqual = com.esri.core.geometry.GeometryEngine.equals(env, env2, sr);
            }
            catch (System.ArgumentException)
            {
                isEqual = false;
            }
            NUnit.Framework.Assert.IsTrue(isEqual);
        }
Exemplo n.º 32
0
        public virtual void testTouchesOnPointAndEnvelope()
        {
            com.esri.core.geometry.SpatialReference sr = com.esri.core.geometry.SpatialReference
                                                         .create(4326);
            com.esri.core.geometry.Point p = new com.esri.core.geometry.Point(-130, 10);
            // Envelope env = new Envelope(p, 12, 12);//not touched
            com.esri.core.geometry.Envelope env = new com.esri.core.geometry.Envelope(-130, 10
                                                                                      , -110, 20);
            // touched
            bool isTouched;

            try
            {
                isTouched = com.esri.core.geometry.GeometryEngine.touches(p, env, sr);
            }
            catch (System.ArgumentException)
            {
                isTouched = false;
            }
            NUnit.Framework.Assert.AreEqual(isTouched, true);
        }
Exemplo n.º 33
0
 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();
 }