/// <exception cref="org.codehaus.jackson.JsonParseException"/>
        /// <exception cref="System.IO.IOException"/>
        internal virtual bool testEnvelope()
        {
            bool bAnswer = true;

            com.esri.core.geometry.Envelope envelope = new com.esri.core.geometry.Envelope();
            envelope.setCoords(-109.55, 25.76, -86.39, 49.94);
            {
                org.codehaus.jackson.JsonParser envelopeWGS84Parser = factory.createJsonParser(com.esri.core.geometry.GeometryEngine
                                                                                               .geometryToJson(spatialReferenceWGS84, envelope));
                com.esri.core.geometry.MapGeometry envelopeWGS84MP = com.esri.core.geometry.GeometryEngine
                                                                     .jsonToGeometry(envelopeWGS84Parser);
                NUnit.Framework.Assert.IsTrue(envelope.isEmpty() == envelopeWGS84MP.getGeometry()
                                              .isEmpty());
                NUnit.Framework.Assert.IsTrue(envelope.getXMax() == ((com.esri.core.geometry.Envelope
                                                                      )envelopeWGS84MP.getGeometry()).getXMax());
                NUnit.Framework.Assert.IsTrue(envelope.getYMax() == ((com.esri.core.geometry.Envelope
                                                                      )envelopeWGS84MP.getGeometry()).getYMax());
                NUnit.Framework.Assert.IsTrue(envelope.getXMin() == ((com.esri.core.geometry.Envelope
                                                                      )envelopeWGS84MP.getGeometry()).getXMin());
                NUnit.Framework.Assert.IsTrue(envelope.getYMin() == ((com.esri.core.geometry.Envelope
                                                                      )envelopeWGS84MP.getGeometry()).getYMin());
                NUnit.Framework.Assert.IsTrue(spatialReferenceWGS84.getID() == envelopeWGS84MP.getSpatialReference
                                                  ().getID());
                if (!checkResultSpatialRef(envelopeWGS84MP, 4326, 0))
                {
                    bAnswer = false;
                }
            }
            {
                // export
                com.esri.core.geometry.Envelope e = new com.esri.core.geometry.Envelope();
                e.addAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z);
                e.addAttribute(com.esri.core.geometry.VertexDescription.Semantics.M);
                string s = com.esri.core.geometry.GeometryEngine.geometryToJson(spatialReferenceWebMerc1
                                                                                , e);
                NUnit.Framework.Assert.IsTrue(s.Equals("{\"xmin\":null,\"ymin\":null,\"xmax\":null,\"ymax\":null,\"zmin\":null,\"zmax\":null,\"mmin\":null,\"mmax\":null,\"spatialReference\":{\"wkid\":102100,\"latestWkid\":3857}}"
                                                       ));
                e.setCoords(0, 1, 2, 3);
                com.esri.core.geometry.Envelope1D z = new com.esri.core.geometry.Envelope1D();
                com.esri.core.geometry.Envelope1D m = new com.esri.core.geometry.Envelope1D();
                z.setCoords(5, 7);
                m.setCoords(11, 13);
                e.setInterval(com.esri.core.geometry.VertexDescription.Semantics.Z, 0, z);
                e.setInterval(com.esri.core.geometry.VertexDescription.Semantics.M, 0, m);
                s = com.esri.core.geometry.GeometryEngine.geometryToJson(spatialReferenceWebMerc1
                                                                         , e);
                NUnit.Framework.Assert.IsTrue(s.Equals("{\"xmin\":0,\"ymin\":1,\"xmax\":2,\"ymax\":3,\"zmin\":5,\"zmax\":7,\"mmin\":11,\"mmax\":13,\"spatialReference\":{\"wkid\":102100,\"latestWkid\":3857}}"
                                                       ));
            }
            {
                // import
                string s = "{\"xmin\":0.0,\"ymin\":1.0,\"xmax\":2.0,\"ymax\":3.0,\"zmin\":5.0,\"zmax\":7.0,\"mmin\":11.0,\"mmax\":13.0,\"spatialReference\":{\"wkid\":102100,\"latestWkid\":3857}}";
                org.codehaus.jackson.JsonParser    parser  = factory.createJsonParser(s);
                com.esri.core.geometry.MapGeometry map_env = com.esri.core.geometry.GeometryEngine
                                                             .jsonToGeometry(parser);
                com.esri.core.geometry.Envelope env = (com.esri.core.geometry.Envelope)map_env.getGeometry
                                                          ();
                com.esri.core.geometry.Envelope1D z = env.queryInterval(com.esri.core.geometry.VertexDescription.Semantics
                                                                        .Z, 0);
                com.esri.core.geometry.Envelope1D m = env.queryInterval(com.esri.core.geometry.VertexDescription.Semantics
                                                                        .M, 0);
                NUnit.Framework.Assert.IsTrue(z.vmin == 5.0);
                NUnit.Framework.Assert.IsTrue(z.vmax == 7.0);
                NUnit.Framework.Assert.IsTrue(m.vmin == 11.0);
                NUnit.Framework.Assert.IsTrue(m.vmax == 13.0);
            }
            {
                string s = "{ \"zmin\" : 33, \"xmin\" : -109.55, \"zmax\" : 53, \"ymin\" : 25.76, \"xmax\" : -86.39, \"ymax\" : 49.94, \"mmax\" : 13}";
                org.codehaus.jackson.JsonParser    parser  = factory.createJsonParser(s);
                com.esri.core.geometry.MapGeometry map_env = com.esri.core.geometry.GeometryEngine
                                                             .jsonToGeometry(parser);
                com.esri.core.geometry.Envelope env = (com.esri.core.geometry.Envelope)map_env.getGeometry
                                                          ();
                com.esri.core.geometry.Envelope2D e = new com.esri.core.geometry.Envelope2D();
                env.queryEnvelope2D(e);
                NUnit.Framework.Assert.IsTrue(e.xmin == -109.55 && e.ymin == 25.76 && e.xmax == -
                                              86.39 && e.ymax == 49.94);
                com.esri.core.geometry.Envelope1D e1D;
                NUnit.Framework.Assert.IsTrue(env.hasAttribute(com.esri.core.geometry.VertexDescription.Semantics
                                                               .Z));
                e1D = env.queryInterval(com.esri.core.geometry.VertexDescription.Semantics.Z, 0);
                NUnit.Framework.Assert.IsTrue(e1D.vmin == 33 && e1D.vmax == 53);
                NUnit.Framework.Assert.IsTrue(!env.hasAttribute(com.esri.core.geometry.VertexDescription.Semantics
                                                                .M));
            }
            return(bAnswer);
        }
		public static com.esri.core.geometry.Envelope MakeEnvelope()
		{
			com.esri.core.geometry.Envelope envelope;
			com.esri.core.geometry.Envelope env = new com.esri.core.geometry.Envelope(0.0, 0.0, 5.0, 5.0);
			envelope = env;
			com.esri.core.geometry.Envelope1D interval = new com.esri.core.geometry.Envelope1D();
			interval.vmin = -3.0;
			interval.vmax = -7.0;
			envelope.SetInterval(com.esri.core.geometry.VertexDescription.Semantics.Z, 0, interval);
			interval.vmin = 16.0;
			interval.vmax = 32.0;
			envelope.SetInterval(com.esri.core.geometry.VertexDescription.Semantics.M, 0, interval);
			interval.vmin = 5.0;
			interval.vmax = 11.0;
			envelope.SetInterval(com.esri.core.geometry.VertexDescription.Semantics.ID, 0, interval);
			return envelope;
		}
        public static void testIntervalTree()
        {
            System.Collections.Generic.List <com.esri.core.geometry.Envelope1D> intervals = new
                                                                                            System.Collections.Generic.List <com.esri.core.geometry.Envelope1D>(0);
            com.esri.core.geometry.Envelope1D env0 = new com.esri.core.geometry.Envelope1D(2,
                                                                                           3);
            com.esri.core.geometry.Envelope1D env1 = new com.esri.core.geometry.Envelope1D(5,
                                                                                           13);
            com.esri.core.geometry.Envelope1D env2 = new com.esri.core.geometry.Envelope1D(6,
                                                                                           9);
            com.esri.core.geometry.Envelope1D env3 = new com.esri.core.geometry.Envelope1D(8,
                                                                                           10);
            com.esri.core.geometry.Envelope1D env4 = new com.esri.core.geometry.Envelope1D(11
                                                                                           , 12);
            com.esri.core.geometry.Envelope1D env5 = new com.esri.core.geometry.Envelope1D(1,
                                                                                           3);
            com.esri.core.geometry.Envelope1D env6 = new com.esri.core.geometry.Envelope1D(0,
                                                                                           2);
            com.esri.core.geometry.Envelope1D env7 = new com.esri.core.geometry.Envelope1D(4,
                                                                                           7);
            com.esri.core.geometry.Envelope1D env8;
            intervals.add(env0);
            intervals.add(env1);
            intervals.add(env2);
            intervals.add(env3);
            intervals.add(env4);
            intervals.add(env5);
            intervals.add(env6);
            intervals.add(env7);
            int counter;

            com.esri.core.geometry.IntervalTreeImpl intervalTree = new com.esri.core.geometry.IntervalTreeImpl
                                                                       (false);
            construct(intervalTree, intervals);
            com.esri.core.geometry.IntervalTreeImpl.IntervalTreeIteratorImpl iterator = intervalTree
                                                                                        .getIterator(new com.esri.core.geometry.Envelope1D(-1, 14), 0.0);
            counter = 0;
            while (iterator.next() != -1)
            {
                counter++;
            }
            NUnit.Framework.Assert.IsTrue(counter == 8);
            iterator.resetIterator(new com.esri.core.geometry.Envelope1D(2.5, 10.5), 0.0);
            counter = 0;
            while (iterator.next() != -1)
            {
                counter++;
            }
            NUnit.Framework.Assert.IsTrue(counter == 6);
            iterator.resetIterator(5.0, 0.0);
            counter = 0;
            while (iterator.next() != -1)
            {
                counter++;
            }
            NUnit.Framework.Assert.IsTrue(counter == 2);
            iterator.resetIterator(7, 0.0);
            counter = 0;
            while (iterator.next() != -1)
            {
                counter++;
            }
            NUnit.Framework.Assert.IsTrue(counter == 3);
            iterator.resetIterator(new com.esri.core.geometry.Envelope1D(2.0, 10.5), 0.0);
            counter = 0;
            while (iterator.next() != -1)
            {
                counter++;
            }
            NUnit.Framework.Assert.IsTrue(counter == 7);
            iterator.resetIterator(new com.esri.core.geometry.Envelope1D(2.5, 11), 0.0);
            counter = 0;
            while (iterator.next() != -1)
            {
                counter++;
            }
            NUnit.Framework.Assert.IsTrue(counter == 7);
            iterator.resetIterator(new com.esri.core.geometry.Envelope1D(2.1, 2.5), 0.0);
            counter = 0;
            while (iterator.next() != -1)
            {
                counter++;
            }
            NUnit.Framework.Assert.IsTrue(counter == 2);
            iterator.resetIterator(new com.esri.core.geometry.Envelope1D(2.1, 5), 0.0);
            counter = 0;
            while (iterator.next() != -1)
            {
                counter++;
            }
            NUnit.Framework.Assert.IsTrue(counter == 4);
            iterator.resetIterator(new com.esri.core.geometry.Envelope1D(2.0, 5), 0.0);
            counter = 0;
            while (iterator.next() != -1)
            {
                counter++;
            }
            NUnit.Framework.Assert.IsTrue(counter == 5);
            iterator.resetIterator(new com.esri.core.geometry.Envelope1D(5.0, 11), 0.0);
            counter = 0;
            while (iterator.next() != -1)
            {
                counter++;
            }
            NUnit.Framework.Assert.IsTrue(counter == 5);
            iterator.resetIterator(new com.esri.core.geometry.Envelope1D(8, 10.5), 0.0);
            counter = 0;
            while (iterator.next() != -1)
            {
                counter++;
            }
            NUnit.Framework.Assert.IsTrue(counter == 3);
            iterator.resetIterator(new com.esri.core.geometry.Envelope1D(10, 11), 0.0);
            counter = 0;
            while (iterator.next() != -1)
            {
                counter++;
            }
            NUnit.Framework.Assert.IsTrue(counter == 3);
            iterator.resetIterator(new com.esri.core.geometry.Envelope1D(10, 10.9), 0.0);
            counter = 0;
            while (iterator.next() != -1)
            {
                counter++;
            }
            NUnit.Framework.Assert.IsTrue(counter == 2);
            iterator.resetIterator(new com.esri.core.geometry.Envelope1D(11.5, 12), 0.0);
            counter = 0;
            while (iterator.next() != -1)
            {
                counter++;
            }
            NUnit.Framework.Assert.IsTrue(counter == 2);
            env0 = new com.esri.core.geometry.Envelope1D(0, 4);
            env1 = new com.esri.core.geometry.Envelope1D(6, 7);
            env2 = new com.esri.core.geometry.Envelope1D(9, 10);
            env3 = new com.esri.core.geometry.Envelope1D(9, 11);
            env4 = new com.esri.core.geometry.Envelope1D(7, 12);
            env5 = new com.esri.core.geometry.Envelope1D(13, 15);
            env6 = new com.esri.core.geometry.Envelope1D(1, 6);
            env7 = new com.esri.core.geometry.Envelope1D(3, 3);
            env8 = new com.esri.core.geometry.Envelope1D(8, 8);
            intervals.clear();
            intervals.add(env0);
            intervals.add(env1);
            intervals.add(env2);
            intervals.add(env3);
            intervals.add(env4);
            intervals.add(env5);
            intervals.add(env6);
            intervals.add(env7);
            intervals.add(env8);
            com.esri.core.geometry.IntervalTreeImpl intervalTree2 = new com.esri.core.geometry.IntervalTreeImpl
                                                                        (true);
            construct(intervalTree2, intervals);
            intervalTree2.insert(0);
            intervalTree2.insert(1);
            intervalTree2.insert(2);
            intervalTree2.insert(3);
            intervalTree2.insert(4);
            intervalTree2.insert(5);
            intervalTree2.insert(6);
            intervalTree2.insert(7);
            intervalTree2.insert(8);
            iterator = intervalTree2.getIterator(new com.esri.core.geometry.Envelope1D(8, 8),
                                                 0.0);
            counter = 0;
            while (iterator.next() != -1)
            {
                counter++;
            }
            NUnit.Framework.Assert.IsTrue(counter == 2);
            iterator.resetIterator(new com.esri.core.geometry.Envelope1D(3, 7), 0.0);
            counter = 0;
            while (iterator.next() != -1)
            {
                counter++;
            }
            NUnit.Framework.Assert.IsTrue(counter == 5);
            iterator.resetIterator(new com.esri.core.geometry.Envelope1D(1, 3), 0.0);
            counter = 0;
            while (iterator.next() != -1)
            {
                counter++;
            }
            NUnit.Framework.Assert.IsTrue(counter == 3);
            iterator.resetIterator(new com.esri.core.geometry.Envelope1D(6, 9), 0.0);
            counter = 0;
            while (iterator.next() != -1)
            {
                counter++;
            }
            NUnit.Framework.Assert.IsTrue(counter == 6);
            iterator.resetIterator(new com.esri.core.geometry.Envelope1D(10, 14), 0.0);
            counter = 0;
            while (iterator.next() != -1)
            {
                counter++;
            }
            NUnit.Framework.Assert.IsTrue(counter == 4);
            env0 = new com.esri.core.geometry.Envelope1D(11, 14);
            env1 = new com.esri.core.geometry.Envelope1D(21, 36);
            env2 = new com.esri.core.geometry.Envelope1D(15, 19);
            env3 = new com.esri.core.geometry.Envelope1D(3, 8);
            env4 = new com.esri.core.geometry.Envelope1D(34, 38);
            env5 = new com.esri.core.geometry.Envelope1D(23, 27);
            env6 = new com.esri.core.geometry.Envelope1D(6, 36);
            intervals.clear();
            intervals.add(env0);
            intervals.add(env1);
            intervals.add(env2);
            intervals.add(env3);
            intervals.add(env4);
            intervals.add(env5);
            intervals.add(env6);
            com.esri.core.geometry.IntervalTreeImpl intervalTree3 = new com.esri.core.geometry.IntervalTreeImpl
                                                                        (false);
            construct(intervalTree3, intervals);
            iterator = intervalTree3.getIterator(new com.esri.core.geometry.Envelope1D(50, 50
                                                                                       ), 0.0);
            System.Diagnostics.Debug.Assert((iterator.next() == -1));
        }
		public static void TestIntervalTree_1()
		{
			System.Collections.Generic.List<com.esri.core.geometry.Envelope1D> intervals = new System.Collections.Generic.List<com.esri.core.geometry.Envelope1D>(0);
			com.esri.core.geometry.Envelope1D env0 = new com.esri.core.geometry.Envelope1D(2, 3);
			com.esri.core.geometry.Envelope1D env1 = new com.esri.core.geometry.Envelope1D(5, 13);
			com.esri.core.geometry.Envelope1D env2 = new com.esri.core.geometry.Envelope1D(6, 9);
			com.esri.core.geometry.Envelope1D env3 = new com.esri.core.geometry.Envelope1D(8, 10);
			com.esri.core.geometry.Envelope1D env4 = new com.esri.core.geometry.Envelope1D(11, 12);
			com.esri.core.geometry.Envelope1D env5 = new com.esri.core.geometry.Envelope1D(1, 3);
			com.esri.core.geometry.Envelope1D env6 = new com.esri.core.geometry.Envelope1D(0, 2);
			com.esri.core.geometry.Envelope1D env7 = new com.esri.core.geometry.Envelope1D(4, 7);
			com.esri.core.geometry.Envelope1D env8;
			intervals.Add(env0);
			intervals.Add(env1);
			intervals.Add(env2);
			intervals.Add(env3);
			intervals.Add(env4);
			intervals.Add(env5);
			intervals.Add(env6);
			intervals.Add(env7);
			int counter;
			com.esri.core.geometry.IntervalTreeImpl intervalTree = new com.esri.core.geometry.IntervalTreeImpl(false);
			Construct(intervalTree, intervals);
			com.esri.core.geometry.IntervalTreeImpl.IntervalTreeIteratorImpl iterator = intervalTree.GetIterator(new com.esri.core.geometry.Envelope1D(-1, 14), 0.0);
			counter = 0;
			while (iterator.Next() != -1)
			{
				counter++;
			}
			NUnit.Framework.Assert.IsTrue(counter == 8);
			iterator.ResetIterator(new com.esri.core.geometry.Envelope1D(2.5, 10.5), 0.0);
			counter = 0;
			while (iterator.Next() != -1)
			{
				counter++;
			}
			NUnit.Framework.Assert.IsTrue(counter == 6);
			iterator.ResetIterator(5.0, 0.0);
			counter = 0;
			while (iterator.Next() != -1)
			{
				counter++;
			}
			NUnit.Framework.Assert.IsTrue(counter == 2);
			iterator.ResetIterator(7, 0.0);
			counter = 0;
			while (iterator.Next() != -1)
			{
				counter++;
			}
			NUnit.Framework.Assert.IsTrue(counter == 3);
			iterator.ResetIterator(new com.esri.core.geometry.Envelope1D(2.0, 10.5), 0.0);
			counter = 0;
			while (iterator.Next() != -1)
			{
				counter++;
			}
			NUnit.Framework.Assert.IsTrue(counter == 7);
			iterator.ResetIterator(new com.esri.core.geometry.Envelope1D(2.5, 11), 0.0);
			counter = 0;
			while (iterator.Next() != -1)
			{
				counter++;
			}
			NUnit.Framework.Assert.IsTrue(counter == 7);
			iterator.ResetIterator(new com.esri.core.geometry.Envelope1D(2.1, 2.5), 0.0);
			counter = 0;
			while (iterator.Next() != -1)
			{
				counter++;
			}
			NUnit.Framework.Assert.IsTrue(counter == 2);
			iterator.ResetIterator(new com.esri.core.geometry.Envelope1D(2.1, 5), 0.0);
			counter = 0;
			while (iterator.Next() != -1)
			{
				counter++;
			}
			NUnit.Framework.Assert.IsTrue(counter == 4);
			iterator.ResetIterator(new com.esri.core.geometry.Envelope1D(2.0, 5), 0.0);
			counter = 0;
			while (iterator.Next() != -1)
			{
				counter++;
			}
			NUnit.Framework.Assert.IsTrue(counter == 5);
			iterator.ResetIterator(new com.esri.core.geometry.Envelope1D(5.0, 11), 0.0);
			counter = 0;
			while (iterator.Next() != -1)
			{
				counter++;
			}
			NUnit.Framework.Assert.IsTrue(counter == 5);
			iterator.ResetIterator(new com.esri.core.geometry.Envelope1D(8, 10.5), 0.0);
			counter = 0;
			while (iterator.Next() != -1)
			{
				counter++;
			}
			NUnit.Framework.Assert.IsTrue(counter == 3);
			iterator.ResetIterator(new com.esri.core.geometry.Envelope1D(10, 11), 0.0);
			counter = 0;
			while (iterator.Next() != -1)
			{
				counter++;
			}
			NUnit.Framework.Assert.IsTrue(counter == 3);
			iterator.ResetIterator(new com.esri.core.geometry.Envelope1D(10, 10.9), 0.0);
			counter = 0;
			while (iterator.Next() != -1)
			{
				counter++;
			}
			NUnit.Framework.Assert.IsTrue(counter == 2);
			iterator.ResetIterator(new com.esri.core.geometry.Envelope1D(11.5, 12), 0.0);
			counter = 0;
			while (iterator.Next() != -1)
			{
				counter++;
			}
			NUnit.Framework.Assert.IsTrue(counter == 2);
			env0 = new com.esri.core.geometry.Envelope1D(0, 4);
			env1 = new com.esri.core.geometry.Envelope1D(6, 7);
			env2 = new com.esri.core.geometry.Envelope1D(9, 10);
			env3 = new com.esri.core.geometry.Envelope1D(9, 11);
			env4 = new com.esri.core.geometry.Envelope1D(7, 12);
			env5 = new com.esri.core.geometry.Envelope1D(13, 15);
			env6 = new com.esri.core.geometry.Envelope1D(1, 6);
			env7 = new com.esri.core.geometry.Envelope1D(3, 3);
			env8 = new com.esri.core.geometry.Envelope1D(8, 8);
			intervals.Clear();
			intervals.Add(env0);
			intervals.Add(env1);
			intervals.Add(env2);
			intervals.Add(env3);
			intervals.Add(env4);
			intervals.Add(env5);
			intervals.Add(env6);
			intervals.Add(env7);
			intervals.Add(env8);
			com.esri.core.geometry.IntervalTreeImpl intervalTree2 = new com.esri.core.geometry.IntervalTreeImpl(true);
			Construct(intervalTree2, intervals);
			intervalTree2.Insert(0);
			intervalTree2.Insert(1);
			intervalTree2.Insert(2);
			intervalTree2.Insert(3);
			intervalTree2.Insert(4);
			intervalTree2.Insert(5);
			intervalTree2.Insert(6);
			intervalTree2.Insert(7);
			intervalTree2.Insert(8);
			iterator = intervalTree2.GetIterator(new com.esri.core.geometry.Envelope1D(8, 8), 0.0);
			counter = 0;
			while (iterator.Next() != -1)
			{
				counter++;
			}
			NUnit.Framework.Assert.IsTrue(counter == 2);
			iterator.ResetIterator(new com.esri.core.geometry.Envelope1D(3, 7), 0.0);
			counter = 0;
			while (iterator.Next() != -1)
			{
				counter++;
			}
			NUnit.Framework.Assert.IsTrue(counter == 5);
			iterator.ResetIterator(new com.esri.core.geometry.Envelope1D(1, 3), 0.0);
			counter = 0;
			while (iterator.Next() != -1)
			{
				counter++;
			}
			NUnit.Framework.Assert.IsTrue(counter == 3);
			iterator.ResetIterator(new com.esri.core.geometry.Envelope1D(6, 9), 0.0);
			counter = 0;
			while (iterator.Next() != -1)
			{
				counter++;
			}
			NUnit.Framework.Assert.IsTrue(counter == 6);
			iterator.ResetIterator(new com.esri.core.geometry.Envelope1D(10, 14), 0.0);
			counter = 0;
			while (iterator.Next() != -1)
			{
				counter++;
			}
			NUnit.Framework.Assert.IsTrue(counter == 4);
			env0 = new com.esri.core.geometry.Envelope1D(11, 14);
			env1 = new com.esri.core.geometry.Envelope1D(21, 36);
			env2 = new com.esri.core.geometry.Envelope1D(15, 19);
			env3 = new com.esri.core.geometry.Envelope1D(3, 8);
			env4 = new com.esri.core.geometry.Envelope1D(34, 38);
			env5 = new com.esri.core.geometry.Envelope1D(23, 27);
			env6 = new com.esri.core.geometry.Envelope1D(6, 36);
			intervals.Clear();
			intervals.Add(env0);
			intervals.Add(env1);
			intervals.Add(env2);
			intervals.Add(env3);
			intervals.Add(env4);
			intervals.Add(env5);
			intervals.Add(env6);
			com.esri.core.geometry.IntervalTreeImpl intervalTree3 = new com.esri.core.geometry.IntervalTreeImpl(false);
			Construct(intervalTree3, intervals);
			iterator = intervalTree3.GetIterator(new com.esri.core.geometry.Envelope1D(50, 50), 0.0);
			System.Diagnostics.Debug.Assert((iterator.Next() == -1));
		}
        public static void testIntervalTreeRandomConstruction()
        {
            int pointcount = 0;
            int passcount  = 1000;
            int figureSize = 50;

            com.esri.core.geometry.Envelope env = new com.esri.core.geometry.Envelope();
            env.setCoords(-10000, -10000, 10000, 10000);
            com.esri.core.geometry.RandomCoordinateGenerator generator = new com.esri.core.geometry.RandomCoordinateGenerator
                                                                             (System.Math.max(figureSize, 10000), env, 0.001);
            java.util.Random random = new java.util.Random(2013);
            int rand_max            = 98765;

            System.Collections.Generic.List <com.esri.core.geometry.Envelope1D> intervals = new
                                                                                            System.Collections.Generic.List <com.esri.core.geometry.Envelope1D>();
            com.esri.core.geometry.AttributeStreamOfInt8 intervalsFound = new com.esri.core.geometry.AttributeStreamOfInt8
                                                                              (0);
            for (int i = 0; i < passcount; i++)
            {
                int r = figureSize;
                if (r < 3)
                {
                    continue;
                }
                com.esri.core.geometry.Polygon poly = new com.esri.core.geometry.Polygon();
                com.esri.core.geometry.Point   pt;
                for (int j = 0; j < r; j++)
                {
                    int  rand       = random.nextInt(rand_max);
                    bool bRandomNew = (r > 10) && ((1.0 * rand) / rand_max > 0.95);
                    pt = generator.GetRandomCoord();
                    if (j == 0 || bRandomNew)
                    {
                        poly.startPath(pt);
                    }
                    else
                    {
                        poly.lineTo(pt);
                    }
                }
                {
                    intervals.clear();
                    com.esri.core.geometry.SegmentIterator seg_iter = poly.querySegmentIterator();
                    com.esri.core.geometry.Envelope1D      interval;
                    com.esri.core.geometry.Envelope1D      range = poly.queryInterval(com.esri.core.geometry.VertexDescription.Semantics
                                                                                      .POSITION, 0);
                    range.vmin -= 0.01;
                    range.vmax += 0.01;
                    while (seg_iter.nextPath())
                    {
                        while (seg_iter.hasNextSegment())
                        {
                            com.esri.core.geometry.Segment segment = seg_iter.nextSegment();
                            interval = segment.queryInterval(com.esri.core.geometry.VertexDescription.Semantics
                                                             .POSITION, 0);
                            intervals.add(interval);
                        }
                    }
                    intervalsFound.resize(intervals.Count, 0);
                    // Just test construction for assertions
                    com.esri.core.geometry.IntervalTreeImpl intervalTree = new com.esri.core.geometry.IntervalTreeImpl
                                                                               (true);
                    construct(intervalTree, intervals);
                    for (int j_1 = 0; j_1 < intervals.Count; j_1++)
                    {
                        intervalTree.insert(j_1);
                    }
                    com.esri.core.geometry.IntervalTreeImpl.IntervalTreeIteratorImpl iterator = intervalTree
                                                                                                .getIterator(range, 0.0);
                    int count = 0;
                    int handle;
                    while ((handle = iterator.next()) != -1)
                    {
                        count++;
                        intervalsFound.write(handle, unchecked ((byte)1));
                    }
                    NUnit.Framework.Assert.IsTrue(count == intervals.Count);
                    for (int j_2 = 0; j_2 < intervalsFound.size(); j_2++)
                    {
                        interval = intervals[j_2];
                        NUnit.Framework.Assert.IsTrue(intervalsFound.read(j_2) == 1);
                    }
                    for (int j_3 = 0; j_3 < intervals.Count >> 1; j_3++)
                    {
                        intervalTree.remove(j_3);
                    }
                    iterator.resetIterator(range, 0.0);
                    count = 0;
                    while ((handle = iterator.next()) != -1)
                    {
                        count++;
                        intervalsFound.write(handle, unchecked ((byte)1));
                    }
                    NUnit.Framework.Assert.IsTrue(count == intervals.Count - (intervals.Count >> 1));
                    for (int j_4 = (intervals.Count >> 1); j_4 < intervals.Count; j_4++)
                    {
                        intervalTree.remove(j_4);
                    }
                }
            }
        }