Example #1
0
 public virtual void testEnvelope2D_corners()
 {
     com.esri.core.geometry.Envelope2D env = new com.esri.core.geometry.Envelope2D(0,
                                                                                   1, 2, 3);
     NUnit.Framework.Assert.IsFalse(env.Equals(null));
     NUnit.Framework.Assert.IsTrue(env.Equals((object)new com.esri.core.geometry.Envelope2D
                                                  (0, 1, 2, 3)));
     com.esri.core.geometry.Point2D pt2D = env.getLowerLeft();
     NUnit.Framework.Assert.IsTrue(pt2D.equals(com.esri.core.geometry.Point2D.construct
                                                   (0, 1)));
     pt2D = env.getUpperLeft();
     NUnit.Framework.Assert.IsTrue(pt2D.equals(com.esri.core.geometry.Point2D.construct
                                                   (0, 3)));
     pt2D = env.getUpperRight();
     NUnit.Framework.Assert.IsTrue(pt2D.equals(com.esri.core.geometry.Point2D.construct
                                                   (2, 3)));
     pt2D = env.getLowerRight();
     NUnit.Framework.Assert.IsTrue(pt2D.equals(com.esri.core.geometry.Point2D.construct
                                                   (2, 1)));
     {
         com.esri.core.geometry.Point2D[] corners = new com.esri.core.geometry.Point2D[4];
         env.queryCorners(corners);
         NUnit.Framework.Assert.IsTrue(corners[0].equals(com.esri.core.geometry.Point2D.construct
                                                             (0, 1)));
         NUnit.Framework.Assert.IsTrue(corners[1].equals(com.esri.core.geometry.Point2D.construct
                                                             (0, 3)));
         NUnit.Framework.Assert.IsTrue(corners[2].equals(com.esri.core.geometry.Point2D.construct
                                                             (2, 3)));
         NUnit.Framework.Assert.IsTrue(corners[3].equals(com.esri.core.geometry.Point2D.construct
                                                             (2, 1)));
         env.queryCorners(corners);
         NUnit.Framework.Assert.IsTrue(corners[0].equals(env.queryCorner(0)));
         NUnit.Framework.Assert.IsTrue(corners[1].equals(env.queryCorner(1)));
         NUnit.Framework.Assert.IsTrue(corners[2].equals(env.queryCorner(2)));
         NUnit.Framework.Assert.IsTrue(corners[3].equals(env.queryCorner(3)));
     }
     {
         com.esri.core.geometry.Point2D[] corners = new com.esri.core.geometry.Point2D[4];
         env.queryCornersReversed(corners);
         NUnit.Framework.Assert.IsTrue(corners[0].equals(com.esri.core.geometry.Point2D.construct
                                                             (0, 1)));
         NUnit.Framework.Assert.IsTrue(corners[1].equals(com.esri.core.geometry.Point2D.construct
                                                             (2, 1)));
         NUnit.Framework.Assert.IsTrue(corners[2].equals(com.esri.core.geometry.Point2D.construct
                                                             (2, 3)));
         NUnit.Framework.Assert.IsTrue(corners[3].equals(com.esri.core.geometry.Point2D.construct
                                                             (0, 3)));
         env.queryCornersReversed(corners);
         NUnit.Framework.Assert.IsTrue(corners[0].equals(env.queryCorner(0)));
         NUnit.Framework.Assert.IsTrue(corners[1].equals(env.queryCorner(3)));
         NUnit.Framework.Assert.IsTrue(corners[2].equals(env.queryCorner(2)));
         NUnit.Framework.Assert.IsTrue(corners[3].equals(env.queryCorner(1)));
     }
     NUnit.Framework.Assert.IsTrue(env.getCenter().equals(com.esri.core.geometry.Point2D
                                                          .construct(1, 2)));
     NUnit.Framework.Assert.IsFalse(env.containsExclusive(env.getUpperLeft()));
     NUnit.Framework.Assert.IsTrue(env.contains(env.getUpperLeft()));
     NUnit.Framework.Assert.IsTrue(env.containsExclusive(env.getCenter()));
 }
Example #2
0
 public virtual void testSerializeEnvelope2D()
 {
     try
     {
         java.io.ByteArrayOutputStream     streamOut = new java.io.ByteArrayOutputStream();
         java.io.ObjectOutputStream        oo        = new java.io.ObjectOutputStream(streamOut);
         com.esri.core.geometry.Envelope2D env       = new com.esri.core.geometry.Envelope2D(1.213948734
                                                                                             , 2.213948734, 11.213948734, 12.213948734);
         oo.writeObject(env);
         java.io.ByteArrayInputStream streamIn = new java.io.ByteArrayInputStream(streamOut
                                                                                  .toByteArray());
         java.io.ObjectInputStream         ii     = new java.io.ObjectInputStream(streamIn);
         com.esri.core.geometry.Envelope2D envRes = (com.esri.core.geometry.Envelope2D)ii.
                                                    readObject();
         NUnit.Framework.Assert.IsTrue(envRes.Equals(env));
     }
     catch (System.Exception)
     {
         fail("Envelope2D serialization failure");
     }
     //		try
     //		{
     //			 FileOutputStream streamOut = new FileOutputStream(
     //			 "c:/temp/savedEnvelope2D.txt");
     //			 ObjectOutputStream oo = new ObjectOutputStream(streamOut);
     //			 Envelope2D e = new Envelope2D(177.123, 188.234, 999.122, 888.999);
     //			 oo.writeObject(e);
     //		 }
     //		 catch(Exception ex)
     //		 {
     //		   fail("Envelope2D serialization failure");
     //		 }
     try
     {
         java.io.InputStream s = Sharpen.Runtime.getClassForType(typeof(com.esri.core.geometry.TestSerialization
                                                                        )).getResourceAsStream("savedEnvelope2D.txt");
         java.io.ObjectInputStream         ii = new java.io.ObjectInputStream(s);
         com.esri.core.geometry.Envelope2D e  = (com.esri.core.geometry.Envelope2D)ii.readObject
                                                    ();
         NUnit.Framework.Assert.IsTrue(e != null);
         NUnit.Framework.Assert.IsTrue(e.Equals(new com.esri.core.geometry.Envelope2D(177.123
                                                                                      , 188.234, 999.122, 888.999)));
     }
     catch (System.Exception)
     {
         fail("Envelope2D serialization failure");
     }
 }
		public virtual void TestEnvelope2D_corners()
		{
			com.esri.core.geometry.Envelope2D env = new com.esri.core.geometry.Envelope2D(0, 1, 2, 3);
			NUnit.Framework.Assert.IsFalse(env.Equals(null));
			NUnit.Framework.Assert.IsTrue(env.Equals((object)new com.esri.core.geometry.Envelope2D(0, 1, 2, 3)));
			com.esri.core.geometry.Point2D pt2D = env.GetLowerLeft();
			NUnit.Framework.Assert.IsTrue(pt2D.Equals(com.esri.core.geometry.Point2D.Construct(0, 1)));
			pt2D = env.GetUpperLeft();
			NUnit.Framework.Assert.IsTrue(pt2D.Equals(com.esri.core.geometry.Point2D.Construct(0, 3)));
			pt2D = env.GetUpperRight();
			NUnit.Framework.Assert.IsTrue(pt2D.Equals(com.esri.core.geometry.Point2D.Construct(2, 3)));
			pt2D = env.GetLowerRight();
			NUnit.Framework.Assert.IsTrue(pt2D.Equals(com.esri.core.geometry.Point2D.Construct(2, 1)));
			{
				com.esri.core.geometry.Point2D[] corners = new com.esri.core.geometry.Point2D[4];
				env.QueryCorners(corners);
				NUnit.Framework.Assert.IsTrue(corners[0].Equals(com.esri.core.geometry.Point2D.Construct(0, 1)));
				NUnit.Framework.Assert.IsTrue(corners[1].Equals(com.esri.core.geometry.Point2D.Construct(0, 3)));
				NUnit.Framework.Assert.IsTrue(corners[2].Equals(com.esri.core.geometry.Point2D.Construct(2, 3)));
				NUnit.Framework.Assert.IsTrue(corners[3].Equals(com.esri.core.geometry.Point2D.Construct(2, 1)));
				env.QueryCorners(corners);
				NUnit.Framework.Assert.IsTrue(corners[0].Equals(env.QueryCorner(0)));
				NUnit.Framework.Assert.IsTrue(corners[1].Equals(env.QueryCorner(1)));
				NUnit.Framework.Assert.IsTrue(corners[2].Equals(env.QueryCorner(2)));
				NUnit.Framework.Assert.IsTrue(corners[3].Equals(env.QueryCorner(3)));
			}
			{
				com.esri.core.geometry.Point2D[] corners = new com.esri.core.geometry.Point2D[4];
				env.QueryCornersReversed(corners);
				NUnit.Framework.Assert.IsTrue(corners[0].Equals(com.esri.core.geometry.Point2D.Construct(0, 1)));
				NUnit.Framework.Assert.IsTrue(corners[1].Equals(com.esri.core.geometry.Point2D.Construct(2, 1)));
				NUnit.Framework.Assert.IsTrue(corners[2].Equals(com.esri.core.geometry.Point2D.Construct(2, 3)));
				NUnit.Framework.Assert.IsTrue(corners[3].Equals(com.esri.core.geometry.Point2D.Construct(0, 3)));
				env.QueryCornersReversed(corners);
				NUnit.Framework.Assert.IsTrue(corners[0].Equals(env.QueryCorner(0)));
				NUnit.Framework.Assert.IsTrue(corners[1].Equals(env.QueryCorner(3)));
				NUnit.Framework.Assert.IsTrue(corners[2].Equals(env.QueryCorner(2)));
				NUnit.Framework.Assert.IsTrue(corners[3].Equals(env.QueryCorner(1)));
			}
			NUnit.Framework.Assert.IsTrue(env.GetCenter().Equals(com.esri.core.geometry.Point2D.Construct(1, 2)));
			NUnit.Framework.Assert.IsFalse(env.ContainsExclusive(env.GetUpperLeft()));
			NUnit.Framework.Assert.IsTrue(env.Contains(env.GetUpperLeft()));
			NUnit.Framework.Assert.IsTrue(env.ContainsExclusive(env.GetCenter()));
		}