예제 #1
0
 //This is a writeReplace class for Envelope
 /// <exception cref="java.io.ObjectStreamException"/>
 public virtual object ReadResolve()
 {
     com.epl.geometry.Envelope env = null;
     if (descriptionBitMask == -1)
     {
         return(null);
     }
     try
     {
         com.epl.geometry.VertexDescription vd = com.epl.geometry.VertexDescriptionDesignerImpl.GetVertexDescription(descriptionBitMask);
         env = new com.epl.geometry.Envelope(vd);
         if (attribs != null)
         {
             env.SetCoords(attribs[0], attribs[1], attribs[2], attribs[3]);
             int index = 4;
             for (int i = 1, n = vd.GetAttributeCount(); i < n; i++)
             {
                 int semantics = vd.GetSemantics(i);
                 int comps     = com.epl.geometry.VertexDescription.GetComponentCount(semantics);
                 for (int ord = 0; ord < comps; ord++)
                 {
                     env.SetInterval(semantics, ord, attribs[index++], attribs[index++]);
                 }
             }
         }
     }
     catch (System.Exception)
     {
         throw new System.IO.InvalidDataException("Cannot read geometry from stream");
     }
     return(env);
 }
예제 #2
0
        public virtual void TestEnvelopeGeometryEngine()
        {
            com.epl.geometry.Envelope e = new com.epl.geometry.Envelope();
            e.SetCoords(-180.0, -90.0, 180.0, 90.0);
            string result = com.epl.geometry.GeometryEngine.GeometryToGeoJson(e);

            NUnit.Framework.Assert.AreEqual("{\"type\":\"Polygon\",\"coordinates\":[[[-180,-90],[180,-90],[180,90],[-180,90],[-180,-90]]]}", result);
        }
예제 #3
0
        public virtual void TestEnvelope()
        {
            com.epl.geometry.Envelope e = new com.epl.geometry.Envelope();
            e.SetCoords(-180.0, -90.0, 180.0, 90.0);
            string result = com.epl.geometry.OperatorExportToGeoJson.Local().Execute(e);

            NUnit.Framework.Assert.AreEqual("{\"type\":\"Polygon\",\"coordinates\":[[[-180,-90],[180,-90],[180,90],[-180,90],[-180,-90]]]}", result);
        }
예제 #4
0
 public virtual void TestEnvelope()
 {
     com.epl.geometry.Envelope env = new com.epl.geometry.Envelope();
     env.SetCoords(100, 200, 250, 300);
     NUnit.Framework.Assert.IsFalse(env.HasAttribute(com.epl.geometry.VertexDescription.Semantics.M));
     env.AddAttribute(com.epl.geometry.VertexDescription.Semantics.M);
     NUnit.Framework.Assert.IsTrue(env.HasAttribute(com.epl.geometry.VertexDescription.Semantics.M));
     NUnit.Framework.Assert.IsTrue(env.QueryInterval(com.epl.geometry.VertexDescription.Semantics.M, 0).IsEmpty());
     env.SetInterval(com.epl.geometry.VertexDescription.Semantics.M, 0, 1, 2);
     NUnit.Framework.Assert.IsTrue(env.QueryInterval(com.epl.geometry.VertexDescription.Semantics.M, 0).vmin == 1);
     NUnit.Framework.Assert.IsTrue(env.QueryInterval(com.epl.geometry.VertexDescription.Semantics.M, 0).vmax == 2);
     NUnit.Framework.Assert.IsFalse(env.HasAttribute(com.epl.geometry.VertexDescription.Semantics.Z));
     env.AddAttribute(com.epl.geometry.VertexDescription.Semantics.Z);
     NUnit.Framework.Assert.IsTrue(env.HasAttribute(com.epl.geometry.VertexDescription.Semantics.Z));
     NUnit.Framework.Assert.IsTrue(env.QueryInterval(com.epl.geometry.VertexDescription.Semantics.Z, 0).vmin == 0);
     NUnit.Framework.Assert.IsTrue(env.QueryInterval(com.epl.geometry.VertexDescription.Semantics.Z, 0).vmax == 0);
     env.SetInterval(com.epl.geometry.VertexDescription.Semantics.Z, 0, 3, 4);
     NUnit.Framework.Assert.IsTrue(env.QueryInterval(com.epl.geometry.VertexDescription.Semantics.Z, 0).vmin == 3);
     NUnit.Framework.Assert.IsTrue(env.QueryInterval(com.epl.geometry.VertexDescription.Semantics.Z, 0).vmax == 4);
     NUnit.Framework.Assert.IsFalse(env.HasAttribute(com.epl.geometry.VertexDescription.Semantics.ID));
     env.AddAttribute(com.epl.geometry.VertexDescription.Semantics.ID);
     NUnit.Framework.Assert.IsTrue(env.HasAttribute(com.epl.geometry.VertexDescription.Semantics.ID));
     NUnit.Framework.Assert.IsTrue(env.QueryInterval(com.epl.geometry.VertexDescription.Semantics.ID, 0).vmin == 0);
     NUnit.Framework.Assert.IsTrue(env.QueryInterval(com.epl.geometry.VertexDescription.Semantics.ID, 0).vmax == 0);
     env.SetInterval(com.epl.geometry.VertexDescription.Semantics.ID, 0, 5, 6);
     NUnit.Framework.Assert.IsTrue(env.QueryInterval(com.epl.geometry.VertexDescription.Semantics.ID, 0).vmin == 5);
     NUnit.Framework.Assert.IsTrue(env.QueryInterval(com.epl.geometry.VertexDescription.Semantics.ID, 0).vmax == 6);
     NUnit.Framework.Assert.IsTrue(env.QueryInterval(com.epl.geometry.VertexDescription.Semantics.Z, 0).vmin == 3);
     NUnit.Framework.Assert.IsTrue(env.QueryInterval(com.epl.geometry.VertexDescription.Semantics.Z, 0).vmax == 4);
     NUnit.Framework.Assert.IsTrue(env.QueryInterval(com.epl.geometry.VertexDescription.Semantics.M, 0).vmin == 1);
     NUnit.Framework.Assert.IsTrue(env.QueryInterval(com.epl.geometry.VertexDescription.Semantics.M, 0).vmax == 2);
     env.DropAttribute(com.epl.geometry.VertexDescription.Semantics.M);
     NUnit.Framework.Assert.IsFalse(env.HasAttribute(com.epl.geometry.VertexDescription.Semantics.M));
     NUnit.Framework.Assert.IsTrue(env.QueryInterval(com.epl.geometry.VertexDescription.Semantics.ID, 0).vmin == 5);
     NUnit.Framework.Assert.IsTrue(env.QueryInterval(com.epl.geometry.VertexDescription.Semantics.ID, 0).vmax == 6);
     NUnit.Framework.Assert.IsTrue(env.QueryInterval(com.epl.geometry.VertexDescription.Semantics.Z, 0).vmin == 3);
     NUnit.Framework.Assert.IsTrue(env.QueryInterval(com.epl.geometry.VertexDescription.Semantics.Z, 0).vmax == 4);
     com.epl.geometry.Envelope env1 = new com.epl.geometry.Envelope();
     env.CopyTo(env1);
     NUnit.Framework.Assert.IsFalse(env1.HasAttribute(com.epl.geometry.VertexDescription.Semantics.M));
     NUnit.Framework.Assert.IsTrue(env1.QueryInterval(com.epl.geometry.VertexDescription.Semantics.ID, 0).vmin == 5);
     NUnit.Framework.Assert.IsTrue(env1.QueryInterval(com.epl.geometry.VertexDescription.Semantics.ID, 0).vmax == 6);
     NUnit.Framework.Assert.IsTrue(env1.QueryInterval(com.epl.geometry.VertexDescription.Semantics.Z, 0).vmin == 3);
     NUnit.Framework.Assert.IsTrue(env1.QueryInterval(com.epl.geometry.VertexDescription.Semantics.Z, 0).vmax == 4);
 }
 public virtual void TestProximity2D_2()
 {
     com.epl.geometry.Point    point1   = new com.epl.geometry.Point(3, 2);
     com.epl.geometry.Point    point2   = new com.epl.geometry.Point(2, 4);
     com.epl.geometry.Envelope envelope = new com.epl.geometry.Envelope();
     envelope.SetCoords(4, 3, 7, 6);
     com.epl.geometry.Polygon polygonToTest = new com.epl.geometry.Polygon();
     polygonToTest.AddEnvelope(envelope, false);
     com.epl.geometry.Proximity2DResult prxResult1 = com.epl.geometry.GeometryEngine.GetNearestVertex(envelope, point1);
     com.epl.geometry.Proximity2DResult prxResult2 = com.epl.geometry.GeometryEngine.GetNearestVertex(polygonToTest, point1);
     com.epl.geometry.Proximity2DResult prxResult3 = com.epl.geometry.GeometryEngine.GetNearestCoordinate(envelope, point2, false);
     com.epl.geometry.Proximity2DResult prxResult4 = com.epl.geometry.GeometryEngine.GetNearestCoordinate(polygonToTest, point2, false);
     com.epl.geometry.Point             result1    = prxResult1.GetCoordinate();
     com.epl.geometry.Point             result2    = prxResult2.GetCoordinate();
     NUnit.Framework.Assert.IsTrue(result1.GetX() == result2.GetX());
     com.epl.geometry.Point result3 = prxResult3.GetCoordinate();
     com.epl.geometry.Point result4 = prxResult4.GetCoordinate();
     NUnit.Framework.Assert.IsTrue(result3.GetX() == result4.GetX());
 }
예제 #6
0
 public virtual void TestEnvelope()
 {
     com.epl.geometry.Envelope envelope = new com.epl.geometry.Envelope();
     envelope.SetCoords(-109.55, 25.76, -86.39, 49.94);
     {
         com.fasterxml.jackson.core.JsonParser envelopeWGS84Parser = factory.CreateJsonParser(com.epl.geometry.GeometryEngine.GeometryToJson(spatialReferenceWGS84, envelope));
         com.epl.geometry.MapGeometry          envelopeWGS84MP     = com.epl.geometry.GeometryEngine.JsonToGeometry(envelopeWGS84Parser);
         NUnit.Framework.Assert.IsTrue(envelope.IsEmpty() == envelopeWGS84MP.GetGeometry().IsEmpty());
         NUnit.Framework.Assert.IsTrue(envelope.GetXMax() == ((com.epl.geometry.Envelope)envelopeWGS84MP.GetGeometry()).GetXMax());
         NUnit.Framework.Assert.IsTrue(envelope.GetYMax() == ((com.epl.geometry.Envelope)envelopeWGS84MP.GetGeometry()).GetYMax());
         NUnit.Framework.Assert.IsTrue(envelope.GetXMin() == ((com.epl.geometry.Envelope)envelopeWGS84MP.GetGeometry()).GetXMin());
         NUnit.Framework.Assert.IsTrue(envelope.GetYMin() == ((com.epl.geometry.Envelope)envelopeWGS84MP.GetGeometry()).GetYMin());
         NUnit.Framework.Assert.IsTrue(spatialReferenceWGS84.GetID() == envelopeWGS84MP.GetSpatialReference().GetID());
         com.epl.geometry.Envelope emptyEnvelope = new com.epl.geometry.Envelope();
         string emptyEnvString = com.epl.geometry.GeometryEngine.GeometryToJson(spatialReferenceWGS84, emptyEnvelope);
         envelopeWGS84Parser = factory.CreateJsonParser(emptyEnvString);
         envelopeWGS84MP     = com.epl.geometry.GeometryEngine.JsonToGeometry(envelopeWGS84Parser);
         NUnit.Framework.Assert.IsTrue(envelopeWGS84MP.GetGeometry().IsEmpty());
         NUnit.Framework.Assert.IsTrue(spatialReferenceWGS84.GetID() == envelopeWGS84MP.GetSpatialReference().GetID());
     }
 }
예제 #7
0
        public static void TestIntervalTree_RandomConstruction()
        {
            int pointcount = 0;
            int passcount  = 1000;
            int figureSize = 50;

            com.epl.geometry.Envelope env = new com.epl.geometry.Envelope();
            env.SetCoords(-10000, -10000, 10000, 10000);
            com.epl.geometry.RandomCoordinateGenerator generator = new com.epl.geometry.RandomCoordinateGenerator(System.Math.Max(figureSize, 10000), env, 0.001);
            System.Random random   = new System.Random(2013);
            int           rand_max = 98765;

            System.Collections.Generic.List <com.epl.geometry.Envelope1D> intervals = new System.Collections.Generic.List <com.epl.geometry.Envelope1D>();
            com.epl.geometry.AttributeStreamOfInt8 intervalsFound = new com.epl.geometry.AttributeStreamOfInt8(0);
            for (int i = 0; i < passcount; i++)
            {
                int r = figureSize;
                if (r < 3)
                {
                    continue;
                }
                com.epl.geometry.Polygon poly = new com.epl.geometry.Polygon();
                com.epl.geometry.Point   pt;
                for (int j = 0; j < r; j++)
                {
                    int  rand       = random.Next(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.epl.geometry.SegmentIterator seg_iter = poly.QuerySegmentIterator();
                    com.epl.geometry.Envelope1D      interval;
                    com.epl.geometry.Envelope1D      range = poly.QueryInterval(com.epl.geometry.VertexDescription.Semantics.POSITION, 0);
                    range.vmin -= 0.01;
                    range.vmax += 0.01;
                    while (seg_iter.NextPath())
                    {
                        while (seg_iter.HasNextSegment())
                        {
                            com.epl.geometry.Segment segment = seg_iter.NextSegment();
                            interval = segment.QueryInterval(com.epl.geometry.VertexDescription.Semantics.POSITION, 0);
                            intervals.Add(interval);
                        }
                    }
                    intervalsFound.Resize(intervals.Count, 0);
                    // Just test construction for assertions
                    com.epl.geometry.IntervalTreeImpl intervalTree = new com.epl.geometry.IntervalTreeImpl(true);
                    Construct(intervalTree, intervals);
                    for (int j_1 = 0; j_1 < intervals.Count; j_1++)
                    {
                        intervalTree.Insert(j_1);
                    }
                    com.epl.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);
                    }
                }
            }
        }
        public static void TestRandom()
        {
            int passcount   = 10;
            int figureSize  = 100;
            int figureSize2 = 100;

            com.epl.geometry.Envelope extent1 = new com.epl.geometry.Envelope();
            com.epl.geometry.Envelope extent2 = new com.epl.geometry.Envelope();
            com.epl.geometry.Envelope extent3 = new com.epl.geometry.Envelope();
            com.epl.geometry.Envelope extent4 = new com.epl.geometry.Envelope();
            extent1.SetCoords(-10000, 5000, 10000, 25000);
            // red
            extent2.SetCoords(-10000, 2000, 10000, 8000);
            // blue
            extent3.SetCoords(-10000, -8000, 10000, -2000);
            // blue
            extent4.SetCoords(-10000, -25000, 10000, -5000);
            // red
            com.epl.geometry.RandomCoordinateGenerator generator1 = new com.epl.geometry.RandomCoordinateGenerator(System.Math.Max(figureSize, 10000), extent1, 0.001);
            com.epl.geometry.RandomCoordinateGenerator generator2 = new com.epl.geometry.RandomCoordinateGenerator(System.Math.Max(figureSize, 10000), extent2, 0.001);
            com.epl.geometry.RandomCoordinateGenerator generator3 = new com.epl.geometry.RandomCoordinateGenerator(System.Math.Max(figureSize, 10000), extent3, 0.001);
            com.epl.geometry.RandomCoordinateGenerator generator4 = new com.epl.geometry.RandomCoordinateGenerator(System.Math.Max(figureSize, 10000), extent4, 0.001);
            System.Random random   = new System.Random(1982);
            int           rand_max = 511;
            int           qCount   = 0;
            int           eCount   = 0;
            int           bCount   = 0;

            for (int c = 0; c < passcount; c++)
            {
                com.epl.geometry.Polygon polyRed  = new com.epl.geometry.Polygon();
                com.epl.geometry.Polygon polyBlue = new com.epl.geometry.Polygon();
                int r = figureSize;
                if (r < 3)
                {
                    continue;
                }
                com.epl.geometry.Point pt;
                for (int j = 0; j < r; j++)
                {
                    int  rand       = random.Next(rand_max);
                    bool bRandomNew = (r > 10) && ((1.0 * rand) / rand_max > 0.95);
                    pt = generator1.GetRandomCoord();
                    if (j == 0 || bRandomNew)
                    {
                        polyRed.StartPath(pt);
                    }
                    else
                    {
                        polyRed.LineTo(pt);
                    }
                }
                for (int j_1 = 0; j_1 < r; j_1++)
                {
                    int  rand       = random.Next(rand_max);
                    bool bRandomNew = (r > 10) && ((1.0 * rand) / rand_max > 0.95);
                    pt = generator4.GetRandomCoord();
                    if (j_1 == 0 || bRandomNew)
                    {
                        polyRed.StartPath(pt);
                    }
                    else
                    {
                        polyRed.LineTo(pt);
                    }
                }
                r = figureSize2;
                if (r < 3)
                {
                    continue;
                }
                for (int j_2 = 0; j_2 < r; j_2++)
                {
                    int  rand       = random.Next(rand_max);
                    bool bRandomNew = (r > 10) && ((1.0 * rand) / rand_max > 0.95);
                    pt = generator2.GetRandomCoord();
                    if (j_2 == 0 || bRandomNew)
                    {
                        polyBlue.StartPath(pt);
                    }
                    else
                    {
                        polyBlue.LineTo(pt);
                    }
                }
                for (int j_3 = 0; j_3 < r; j_3++)
                {
                    int  rand       = random.Next(rand_max);
                    bool bRandomNew = (r > 10) && ((1.0 * rand) / rand_max > 0.95);
                    pt = generator3.GetRandomCoord();
                    if (j_3 == 0 || bRandomNew)
                    {
                        polyBlue.StartPath(pt);
                    }
                    else
                    {
                        polyBlue.LineTo(pt);
                    }
                }
                com.epl.geometry.Envelope2D env = new com.epl.geometry.Envelope2D();
                // Quad_tree
                com.epl.geometry.QuadTree quadTree = BuildQuadTree(polyBlue);
                com.epl.geometry.QuadTree.QuadTreeIterator iterator    = quadTree.GetIterator();
                com.epl.geometry.SegmentIteratorImpl       _segIterRed = ((com.epl.geometry.MultiPathImpl)polyRed._getImpl()).QuerySegmentIterator();
                while (_segIterRed.NextPath())
                {
                    while (_segIterRed.HasNextSegment())
                    {
                        com.epl.geometry.Segment segmentRed = _segIterRed.NextSegment();
                        segmentRed.QueryEnvelope2D(env);
                        iterator.ResetIterator(env, 0.001);
                        while (iterator.Next() != -1)
                        {
                            qCount++;
                        }
                    }
                }
                // Envelope_2D_intersector
                System.Collections.Generic.List <com.epl.geometry.Envelope2D> envelopes_red  = new System.Collections.Generic.List <com.epl.geometry.Envelope2D>();
                System.Collections.Generic.List <com.epl.geometry.Envelope2D> envelopes_blue = new System.Collections.Generic.List <com.epl.geometry.Envelope2D>();
                com.epl.geometry.SegmentIterator segIterRed = polyRed.QuerySegmentIterator();
                while (segIterRed.NextPath())
                {
                    while (segIterRed.HasNextSegment())
                    {
                        com.epl.geometry.Segment segment = segIterRed.NextSegment();
                        env = new com.epl.geometry.Envelope2D();
                        segment.QueryEnvelope2D(env);
                        envelopes_red.Add(env);
                    }
                }
                com.epl.geometry.SegmentIterator segIterBlue = polyBlue.QuerySegmentIterator();
                while (segIterBlue.NextPath())
                {
                    while (segIterBlue.HasNextSegment())
                    {
                        com.epl.geometry.Segment segment = segIterBlue.NextSegment();
                        env = new com.epl.geometry.Envelope2D();
                        segment.QueryEnvelope2D(env);
                        envelopes_blue.Add(env);
                    }
                }
                com.epl.geometry.Envelope2DIntersectorImpl intersector = new com.epl.geometry.Envelope2DIntersectorImpl();
                intersector.SetTolerance(0.001);
                intersector.StartRedConstruction();
                for (int i = 0; i < envelopes_red.Count; i++)
                {
                    intersector.AddRedEnvelope(i, envelopes_red[i]);
                }
                intersector.EndRedConstruction();
                intersector.StartBlueConstruction();
                for (int i_1 = 0; i_1 < envelopes_blue.Count; i_1++)
                {
                    intersector.AddBlueEnvelope(i_1, envelopes_blue[i_1]);
                }
                intersector.EndBlueConstruction();
                while (intersector.Next())
                {
                    eCount++;
                }
                NUnit.Framework.Assert.IsTrue(qCount == eCount);
            }
        }
예제 #9
0
        public static void TestQuadTreeWithDuplicates()
        {
            int pass_count   = 10;
            int figure_size  = 400;
            int figure_size2 = 100;

            com.epl.geometry.Envelope extent1 = new com.epl.geometry.Envelope();
            extent1.SetCoords(-100000, -100000, 100000, 100000);
            com.epl.geometry.RandomCoordinateGenerator generator1 = new com.epl.geometry.RandomCoordinateGenerator(System.Math.Max(figure_size, 10000), extent1, 0.001);
            System.Random random   = new System.Random(2013);
            int           rand_max = 32;

            com.epl.geometry.Polygon poly_red  = new com.epl.geometry.Polygon();
            com.epl.geometry.Polygon poly_blue = new com.epl.geometry.Polygon();
            int r = figure_size;

            for (int c = 0; c < pass_count; c++)
            {
                com.epl.geometry.Point pt;
                for (int j = 0; j < r; j++)
                {
                    int  rand         = random.Next(rand_max);
                    bool b_random_new = r > 10 && ((1.0 * rand) / rand_max > 0.95);
                    pt = generator1.GetRandomCoord();
                    if (j == 0 || b_random_new)
                    {
                        poly_blue.StartPath(pt);
                    }
                    else
                    {
                        poly_blue.LineTo(pt);
                    }
                }
                com.epl.geometry.Envelope2D env                       = new com.epl.geometry.Envelope2D();
                com.epl.geometry.QuadTree   quad_tree_blue            = BuildQuadTree_((com.epl.geometry.MultiPathImpl)poly_blue._getImpl(), false);
                com.epl.geometry.QuadTree   quad_tree_blue_duplicates = BuildQuadTree_((com.epl.geometry.MultiPathImpl)poly_blue._getImpl(), true);
                com.epl.geometry.Envelope2D e1 = quad_tree_blue.GetDataExtent();
                com.epl.geometry.Envelope2D e2 = quad_tree_blue_duplicates.GetDataExtent();
                NUnit.Framework.Assert.IsTrue(e1.Equals(e2));
                NUnit.Framework.Assert.IsTrue(quad_tree_blue.GetElementCount() == poly_blue.GetSegmentCount());
                com.epl.geometry.SegmentIterator seg_iter_blue = poly_blue.QuerySegmentIterator();
                poly_red.SetEmpty();
                r = figure_size2;
                if (r < 3)
                {
                    continue;
                }
                for (int j_1 = 0; j_1 < r; j_1++)
                {
                    int  rand         = random.Next(rand_max);
                    bool b_random_new = r > 10 && ((1.0 * rand) / rand_max > 0.95);
                    pt = generator1.GetRandomCoord();
                    if (j_1 == 0 || b_random_new)
                    {
                        poly_red.StartPath(pt);
                    }
                    else
                    {
                        poly_red.LineTo(pt);
                    }
                }
                com.epl.geometry.QuadTree.QuadTreeIterator        iterator     = quad_tree_blue.GetIterator();
                com.epl.geometry.SegmentIteratorImpl              seg_iter_red = ((com.epl.geometry.MultiPathImpl)poly_red._getImpl()).QuerySegmentIterator();
                System.Collections.Generic.Dictionary <int, bool> map1         = new System.Collections.Generic.Dictionary <int, bool>(0);
                int count = 0;
                int intersections_per_query = 0;
                while (seg_iter_red.NextPath())
                {
                    while (seg_iter_red.HasNextSegment())
                    {
                        com.epl.geometry.Segment segment_red = seg_iter_red.NextSegment();
                        segment_red.QueryEnvelope2D(env);
                        iterator.ResetIterator(env, 0.0);
                        int count_upper = 0;
                        int element_handle;
                        while ((element_handle = iterator.Next()) != -1)
                        {
                            count_upper++;
                            int  index = quad_tree_blue.GetElement(element_handle);
                            bool iter  = map1.ContainsKey(index);
                            if (!iter)
                            {
                                count++;
                                map1[index] = true;
                            }
                            intersections_per_query++;
                        }
                        int intersection_count = quad_tree_blue.GetIntersectionCount(env, 0.0, -1);
                        NUnit.Framework.Assert.IsTrue(intersection_count == count_upper);
                    }
                }
                seg_iter_red.ResetToFirstPath();
                System.Collections.Generic.Dictionary <int, bool> map2 = new System.Collections.Generic.Dictionary <int, bool>(0);
                com.epl.geometry.QuadTree.QuadTreeIterator        iterator_duplicates = quad_tree_blue_duplicates.GetIterator();
                int count_duplicates = 0;
                int intersections_per_query_duplicates = 0;
                while (seg_iter_red.NextPath())
                {
                    while (seg_iter_red.HasNextSegment())
                    {
                        com.epl.geometry.Segment segment_red = seg_iter_red.NextSegment();
                        segment_red.QueryEnvelope2D(env);
                        iterator_duplicates.ResetIterator(env, 0.0);
                        int count_lower = 0;
                        System.Collections.Generic.Dictionary <int, bool> map_per_query = new System.Collections.Generic.Dictionary <int, bool>(0);
                        int count_upper = 0;
                        int element_handle;
                        while ((element_handle = iterator_duplicates.Next()) != -1)
                        {
                            count_upper++;
                            int  index = quad_tree_blue_duplicates.GetElement(element_handle);
                            bool iter  = map2.ContainsKey(index);
                            if (!iter)
                            {
                                count_duplicates++;
                                map2[index] = true;
                            }
                            bool iter_lower = map_per_query.ContainsKey(index);
                            if (!iter_lower)
                            {
                                count_lower++;
                                intersections_per_query_duplicates++;
                                map_per_query[index] = true;
                            }
                            int q = quad_tree_blue_duplicates.GetQuad(element_handle);
                            NUnit.Framework.Assert.IsTrue(quad_tree_blue_duplicates.GetSubTreeElementCount(q) >= quad_tree_blue_duplicates.GetContainedSubTreeElementCount(q));
                        }
                        int  intersection_count = quad_tree_blue_duplicates.GetIntersectionCount(env, 0.0, -1);
                        bool b_has_data         = quad_tree_blue_duplicates.HasData(env, 0.0);
                        NUnit.Framework.Assert.IsTrue(b_has_data || intersection_count == 0);
                        NUnit.Framework.Assert.IsTrue(count_lower <= intersection_count && intersection_count <= count_upper);
                        NUnit.Framework.Assert.IsTrue(count_upper <= 4 * count_lower);
                    }
                }
                NUnit.Framework.Assert.IsTrue(count == count_duplicates);
                NUnit.Framework.Assert.IsTrue(intersections_per_query == intersections_per_query_duplicates);
            }
        }
예제 #10
0
 public static void Test_perf_quad_tree()
 {
     com.epl.geometry.Envelope extent1 = new com.epl.geometry.Envelope();
     extent1.SetCoords(-1000, -1000, 1000, 1000);
     com.epl.geometry.RandomCoordinateGenerator generator1 = new com.epl.geometry.RandomCoordinateGenerator(1000, extent1, 0.001);
     //HiResTimer timer;
     for (int N = 16; N <= 1024; N *= 2)
     {
         //timer.StartMeasurement();
         com.epl.geometry.Envelope2D extent = new com.epl.geometry.Envelope2D();
         extent.SetCoords(-1000, -1000, 1000, 1000);
         System.Collections.Generic.Dictionary <int, com.epl.geometry.Envelope2D> data = new System.Collections.Generic.Dictionary <int, com.epl.geometry.Envelope2D>(0);
         com.epl.geometry.QuadTree qt = new com.epl.geometry.QuadTree(extent, 10);
         for (int i = 0; i < N; i++)
         {
             com.epl.geometry.Envelope2D env    = new com.epl.geometry.Envelope2D();
             com.epl.geometry.Point2D    center = generator1.GetRandomCoord().GetXY();
             double w = 10;
             env.SetCoords(center, w, w);
             env.Intersect(extent);
             if (env.IsEmpty())
             {
                 continue;
             }
             int h = qt.Insert(i, env);
             data[h] = env;
         }
         int ecount = 0;
         com.epl.geometry.AttributeStreamOfInt32    handles = new com.epl.geometry.AttributeStreamOfInt32(0);
         com.epl.geometry.QuadTree.QuadTreeIterator iter    = qt.GetIterator();
         System.Collections.Generic.IEnumerator <System.Collections.Generic.KeyValuePair <int, com.epl.geometry.Envelope2D> > pairs = data.GetEnumerator();
         while (pairs.MoveNext())
         {
             System.Collections.Generic.KeyValuePair <int, com.epl.geometry.Envelope2D> entry = pairs.Current;
             iter.ResetIterator((com.epl.geometry.Envelope2D)entry.Value, 0.001);
             bool remove_self = false;
             for (int h = iter.Next(); h != -1; h = iter.Next())
             {
                 if (h != entry.Key)
                 {
                     handles.Add(h);
                 }
                 else
                 {
                     remove_self = true;
                 }
                 ecount++;
             }
             for (int i_1 = 0; i_1 < handles.Size(); i_1++)
             {
                 qt.RemoveElement(handles.Get(i_1));
             }
             //remove elements that were selected.
             if (remove_self)
             {
                 qt.RemoveElement(entry.Key);
             }
             handles.Resize(0);
         }
     }
 }
예제 #11
0
 public static void TestPointTypes()
 {
     com.epl.geometry.OperatorFactoryLocal        engine         = com.epl.geometry.OperatorFactoryLocal.GetInstance();
     com.epl.geometry.OperatorDifference          difference     = (com.epl.geometry.OperatorDifference)engine.GetOperator(com.epl.geometry.Operator.Type.Difference);
     com.epl.geometry.OperatorSymmetricDifference sym_difference = (com.epl.geometry.OperatorSymmetricDifference)engine.GetOperator(com.epl.geometry.Operator.Type.SymmetricDifference);
     {
         // point/point
         com.epl.geometry.Point point_1 = new com.epl.geometry.Point();
         com.epl.geometry.Point point_2 = new com.epl.geometry.Point();
         point_1.SetXY(0, 0);
         point_2.SetXY(0.000000009, 0.000000009);
         com.epl.geometry.Point differenced = (com.epl.geometry.Point)(difference.Execute(point_1, point_2, com.epl.geometry.SpatialReference.Create(4326), null));
         NUnit.Framework.Assert.IsTrue(differenced.IsEmpty());
         com.epl.geometry.MultiPoint sym_differenced = (com.epl.geometry.MultiPoint)(sym_difference.Execute(point_1, point_2, com.epl.geometry.SpatialReference.Create(4326), null));
         NUnit.Framework.Assert.IsTrue(sym_differenced.IsEmpty());
     }
     {
         // point/point
         com.epl.geometry.Point point_1 = new com.epl.geometry.Point();
         com.epl.geometry.Point point_2 = new com.epl.geometry.Point();
         point_1.SetXY(0, 0);
         point_2.SetXY(0.000000009, 0.0);
         com.epl.geometry.Point differenced = (com.epl.geometry.Point)(difference.Execute(point_1, point_2, com.epl.geometry.SpatialReference.Create(4326), null));
         NUnit.Framework.Assert.IsTrue(differenced.IsEmpty());
         com.epl.geometry.MultiPoint sym_differenced = (com.epl.geometry.MultiPoint)(sym_difference.Execute(point_1, point_2, com.epl.geometry.SpatialReference.Create(4326), null));
         NUnit.Framework.Assert.IsTrue(sym_differenced.IsEmpty());
     }
     {
         // point/point
         com.epl.geometry.Point point_1 = new com.epl.geometry.Point();
         com.epl.geometry.Point point_2 = new com.epl.geometry.Point();
         point_1.SetXY(0, 0);
         point_2.SetXY(0.00000002, 0.00000002);
         com.epl.geometry.Point differenced_1 = (com.epl.geometry.Point)(difference.Execute(point_1, point_2, com.epl.geometry.SpatialReference.Create(4326), null));
         NUnit.Framework.Assert.IsTrue(!differenced_1.IsEmpty());
         com.epl.geometry.Point differenced_2 = (com.epl.geometry.Point)(difference.Execute(point_2, point_1, com.epl.geometry.SpatialReference.Create(4326), null));
         NUnit.Framework.Assert.IsTrue(!differenced_2.IsEmpty());
         com.epl.geometry.MultiPoint sym_differenced = (com.epl.geometry.MultiPoint)(sym_difference.Execute(point_1, point_2, com.epl.geometry.SpatialReference.Create(4326), null));
         NUnit.Framework.Assert.IsTrue(!sym_differenced.IsEmpty());
         NUnit.Framework.Assert.IsTrue(sym_differenced.GetXY(0).x == 0 && sym_differenced.GetXY(0).y == 0);
         NUnit.Framework.Assert.IsTrue(sym_differenced.GetXY(1).x == 0.00000002 && sym_differenced.GetXY(1).y == 0.00000002);
     }
     {
         // multi_point/point
         com.epl.geometry.MultiPoint multi_point_1 = new com.epl.geometry.MultiPoint();
         com.epl.geometry.Point      point_2       = new com.epl.geometry.Point();
         multi_point_1.Add(0, 0);
         multi_point_1.Add(1, 1);
         point_2.SetXY(0.000000009, 0.000000009);
         com.epl.geometry.MultiPoint differenced_1 = (com.epl.geometry.MultiPoint)(difference.Execute(multi_point_1, point_2, com.epl.geometry.SpatialReference.Create(4326), null));
         NUnit.Framework.Assert.IsTrue(!differenced_1.IsEmpty());
         NUnit.Framework.Assert.IsTrue(differenced_1.GetPointCount() == 1);
         NUnit.Framework.Assert.IsTrue(differenced_1.GetXY(0).x == 1 && differenced_1.GetXY(0).y == 1);
         com.epl.geometry.Point differenced_2 = (com.epl.geometry.Point)(difference.Execute(point_2, multi_point_1, com.epl.geometry.SpatialReference.Create(4326), null));
         NUnit.Framework.Assert.IsTrue(differenced_2.IsEmpty());
     }
     {
         // multi_point/point
         com.epl.geometry.MultiPoint multi_point_1 = new com.epl.geometry.MultiPoint();
         com.epl.geometry.Point      point_2       = new com.epl.geometry.Point();
         multi_point_1.Add(0, 0);
         multi_point_1.Add(1, 1);
         point_2.SetXY(0.000000009, 0.0);
         com.epl.geometry.MultiPoint differenced_1 = (com.epl.geometry.MultiPoint)(difference.Execute(multi_point_1, point_2, com.epl.geometry.SpatialReference.Create(4326), null));
         NUnit.Framework.Assert.IsTrue(!differenced_1.IsEmpty());
         NUnit.Framework.Assert.IsTrue(differenced_1.GetXY(0).x == 1.0 && differenced_1.GetXY(0).y == 1.0);
         com.epl.geometry.Point differenced_2 = (com.epl.geometry.Point)(difference.Execute(point_2, multi_point_1, com.epl.geometry.SpatialReference.Create(4326), null));
         NUnit.Framework.Assert.IsTrue(differenced_2.IsEmpty());
         com.epl.geometry.MultiPoint sym_differenced = (com.epl.geometry.MultiPoint)(sym_difference.Execute(multi_point_1, point_2, com.epl.geometry.SpatialReference.Create(4326), null));
         NUnit.Framework.Assert.IsTrue(!sym_differenced.IsEmpty());
         NUnit.Framework.Assert.IsTrue(sym_differenced.GetPointCount() == 1);
         NUnit.Framework.Assert.IsTrue(sym_differenced.GetXY(0).x == 1 && sym_differenced.GetXY(0).y == 1);
     }
     {
         // multi_point/point
         com.epl.geometry.MultiPoint multi_point_1 = new com.epl.geometry.MultiPoint();
         com.epl.geometry.Point      point_2       = new com.epl.geometry.Point();
         multi_point_1.Add(0, 0);
         multi_point_1.Add(0, 0);
         point_2.SetXY(0.000000009, 0.0);
         com.epl.geometry.MultiPoint differenced_1 = (com.epl.geometry.MultiPoint)(difference.Execute(multi_point_1, point_2, com.epl.geometry.SpatialReference.Create(4326), null));
         NUnit.Framework.Assert.IsTrue(differenced_1.IsEmpty());
         com.epl.geometry.MultiPoint sym_differenced = (com.epl.geometry.MultiPoint)(sym_difference.Execute(multi_point_1, point_2, com.epl.geometry.SpatialReference.Create(4326), null));
         NUnit.Framework.Assert.IsTrue(sym_differenced.IsEmpty());
     }
     {
         // multi_point/polygon
         com.epl.geometry.MultiPoint multi_point_1 = new com.epl.geometry.MultiPoint();
         com.epl.geometry.Polygon    polygon_2     = new com.epl.geometry.Polygon();
         multi_point_1.Add(0, 0);
         multi_point_1.Add(0, 0);
         multi_point_1.Add(2, 2);
         polygon_2.StartPath(-1, -1);
         polygon_2.LineTo(-1, 1);
         polygon_2.LineTo(1, 1);
         polygon_2.LineTo(1, -1);
         com.epl.geometry.MultiPoint differenced_1 = (com.epl.geometry.MultiPoint)(difference.Execute(multi_point_1, polygon_2, com.epl.geometry.SpatialReference.Create(4326), null));
         NUnit.Framework.Assert.IsTrue(!differenced_1.IsEmpty());
         NUnit.Framework.Assert.IsTrue(differenced_1.GetPointCount() == 1);
         NUnit.Framework.Assert.IsTrue(differenced_1.GetXY(0).x == 2 && differenced_1.GetXY(0).y == 2);
     }
     {
         // multi_point/polygon
         com.epl.geometry.MultiPoint multi_point_1 = new com.epl.geometry.MultiPoint();
         com.epl.geometry.Polygon    polygon_2     = new com.epl.geometry.Polygon();
         multi_point_1.Add(0, 0);
         multi_point_1.Add(0, 0);
         multi_point_1.Add(1, 1);
         polygon_2.StartPath(-1, -1);
         polygon_2.LineTo(-1, 1);
         polygon_2.LineTo(1, 1);
         polygon_2.LineTo(1, -1);
         com.epl.geometry.MultiPoint differenced_1 = (com.epl.geometry.MultiPoint)(difference.Execute(multi_point_1, polygon_2, com.epl.geometry.SpatialReference.Create(4326), null));
         NUnit.Framework.Assert.IsTrue(differenced_1.IsEmpty());
     }
     {
         // multi_point/envelope
         com.epl.geometry.MultiPoint multi_point_1 = new com.epl.geometry.MultiPoint();
         com.epl.geometry.Envelope   envelope_2    = new com.epl.geometry.Envelope();
         multi_point_1.Add(-2, 0);
         multi_point_1.Add(0, 2);
         multi_point_1.Add(2, 0);
         multi_point_1.Add(0, -2);
         envelope_2.SetCoords(-1, -1, 1, 1);
         com.epl.geometry.MultiPoint differenced_1 = (com.epl.geometry.MultiPoint)(difference.Execute(multi_point_1, envelope_2, com.epl.geometry.SpatialReference.Create(4326), null));
         NUnit.Framework.Assert.IsTrue(!differenced_1.IsEmpty() && differenced_1 == multi_point_1);
     }
     {
         // multi_point/polygon
         com.epl.geometry.MultiPoint multi_point_1 = new com.epl.geometry.MultiPoint();
         com.epl.geometry.Polygon    polygon_2     = new com.epl.geometry.Polygon();
         multi_point_1.Add(2, 2);
         multi_point_1.Add(2, 2);
         multi_point_1.Add(-2, -2);
         polygon_2.StartPath(-1, -1);
         polygon_2.LineTo(-1, 1);
         polygon_2.LineTo(1, 1);
         polygon_2.LineTo(1, -1);
         com.epl.geometry.MultiPoint differenced_1 = (com.epl.geometry.MultiPoint)(difference.Execute(multi_point_1, polygon_2, com.epl.geometry.SpatialReference.Create(4326), null));
         NUnit.Framework.Assert.IsTrue(!differenced_1.IsEmpty() && differenced_1 == multi_point_1);
     }
     {
         // point/polygon
         com.epl.geometry.Point   point_1   = new com.epl.geometry.Point();
         com.epl.geometry.Polygon polygon_2 = new com.epl.geometry.Polygon();
         point_1.SetXY(0, 0);
         polygon_2.StartPath(-1, -1);
         polygon_2.LineTo(-1, 1);
         polygon_2.LineTo(1, 1);
         polygon_2.LineTo(1, -1);
         com.epl.geometry.Point differenced_1 = (com.epl.geometry.Point)(difference.Execute(point_1, polygon_2, com.epl.geometry.SpatialReference.Create(4326), null));
         NUnit.Framework.Assert.IsTrue(differenced_1.IsEmpty());
         polygon_2.SetEmpty();
         polygon_2.StartPath(1, 1);
         polygon_2.LineTo(1, 2);
         polygon_2.LineTo(2, 2);
         polygon_2.LineTo(2, 1);
         differenced_1 = (com.epl.geometry.Point)(difference.Execute(point_1, polygon_2, com.epl.geometry.SpatialReference.Create(4326), null));
         NUnit.Framework.Assert.IsTrue(!differenced_1.IsEmpty());
         NUnit.Framework.Assert.IsTrue(differenced_1 == point_1);
     }
     {
         // point/polygon
         com.epl.geometry.Point   point_1   = new com.epl.geometry.Point();
         com.epl.geometry.Polygon polygon_2 = new com.epl.geometry.Polygon();
         point_1.SetXY(0, 0);
         polygon_2.StartPath(1, 0);
         polygon_2.LineTo(0, 1);
         polygon_2.LineTo(1, 1);
         com.epl.geometry.Point differenced_1 = (com.epl.geometry.Point)(difference.Execute(point_1, polygon_2, com.epl.geometry.SpatialReference.Create(4326), null));
         NUnit.Framework.Assert.IsTrue(!differenced_1.IsEmpty());
         NUnit.Framework.Assert.IsTrue(differenced_1 == point_1);
         point_1.SetEmpty();
         point_1.SetXY(0.5, 0.5);
         polygon_2.SetEmpty();
         polygon_2.StartPath(1, 0);
         polygon_2.LineTo(0, 1);
         polygon_2.LineTo(1, 1);
         differenced_1 = (com.epl.geometry.Point)(difference.Execute(point_1, polygon_2, com.epl.geometry.SpatialReference.Create(4326), null));
         NUnit.Framework.Assert.IsTrue(differenced_1.IsEmpty());
     }
     {
         // point/envelope
         com.epl.geometry.Point    point_1    = new com.epl.geometry.Point();
         com.epl.geometry.Envelope envelope_2 = new com.epl.geometry.Envelope();
         point_1.SetXY(0, 0);
         envelope_2.SetCoords(-1, -1, 1, 1);
         com.epl.geometry.Point differenced_1 = (com.epl.geometry.Point)(difference.Execute(point_1, envelope_2, com.epl.geometry.SpatialReference.Create(4326), null));
         NUnit.Framework.Assert.IsTrue(differenced_1.IsEmpty());
         envelope_2.SetEmpty();
         envelope_2.SetCoords(1, 1, 2, 2);
         differenced_1 = (com.epl.geometry.Point)(difference.Execute(point_1, envelope_2, com.epl.geometry.SpatialReference.Create(4326), null));
         NUnit.Framework.Assert.IsTrue(!differenced_1.IsEmpty());
         NUnit.Framework.Assert.IsTrue(differenced_1 == point_1);
     }
     {
         // point/polyline
         com.epl.geometry.Point    point_1    = new com.epl.geometry.Point();
         com.epl.geometry.Polyline polyline_2 = new com.epl.geometry.Polyline();
         point_1.SetXY(0, 0);
         polyline_2.StartPath(-1, 0);
         polyline_2.LineTo(1, 0);
         com.epl.geometry.Point differenced_1 = (com.epl.geometry.Point)(difference.Execute(point_1, polyline_2, com.epl.geometry.SpatialReference.Create(4326), null));
         NUnit.Framework.Assert.IsTrue(differenced_1.IsEmpty());
         polyline_2.SetEmpty();
         polyline_2.StartPath(1, 0);
         polyline_2.LineTo(2, 0);
         differenced_1 = (com.epl.geometry.Point)(difference.Execute(point_1, polyline_2, com.epl.geometry.SpatialReference.Create(4326), null));
         NUnit.Framework.Assert.IsTrue(!differenced_1.IsEmpty());
         NUnit.Framework.Assert.IsTrue(differenced_1 == point_1);
         polyline_2.SetEmpty();
         polyline_2.StartPath(-1, -1);
         polyline_2.LineTo(-1, 1);
         polyline_2.LineTo(1, 1);
         polyline_2.LineTo(1, -1);
         differenced_1 = (com.epl.geometry.Point)(difference.Execute(point_1, polyline_2, com.epl.geometry.SpatialReference.Create(4326), null));
         NUnit.Framework.Assert.IsTrue(!differenced_1.IsEmpty());
         NUnit.Framework.Assert.IsTrue(differenced_1 == point_1);
     }
 }
        /// <exception cref="com.fasterxml.jackson.core.JsonParseException"/>
        /// <exception cref="System.IO.IOException"/>
        internal virtual bool TestEnvelope()
        {
            bool bAnswer = true;

            com.epl.geometry.Envelope envelope = new com.epl.geometry.Envelope();
            envelope.SetCoords(-109.55, 25.76, -86.39, 49.94);
            {
                com.fasterxml.jackson.core.JsonParser envelopeWGS84Parser = factory.CreateParser(com.epl.geometry.GeometryEngine.GeometryToJson(spatialReferenceWGS84, envelope));
                com.epl.geometry.MapGeometry          envelopeWGS84MP     = com.epl.geometry.GeometryEngine.JsonToGeometry(envelopeWGS84Parser);
                NUnit.Framework.Assert.IsTrue(envelope.IsEmpty() == envelopeWGS84MP.GetGeometry().IsEmpty());
                NUnit.Framework.Assert.IsTrue(envelope.GetXMax() == ((com.epl.geometry.Envelope)envelopeWGS84MP.GetGeometry()).GetXMax());
                NUnit.Framework.Assert.IsTrue(envelope.GetYMax() == ((com.epl.geometry.Envelope)envelopeWGS84MP.GetGeometry()).GetYMax());
                NUnit.Framework.Assert.IsTrue(envelope.GetXMin() == ((com.epl.geometry.Envelope)envelopeWGS84MP.GetGeometry()).GetXMin());
                NUnit.Framework.Assert.IsTrue(envelope.GetYMin() == ((com.epl.geometry.Envelope)envelopeWGS84MP.GetGeometry()).GetYMin());
                NUnit.Framework.Assert.IsTrue(spatialReferenceWGS84.GetID() == envelopeWGS84MP.GetSpatialReference().GetID());
                if (!CheckResultSpatialRef(envelopeWGS84MP, 4326, 0))
                {
                    bAnswer = false;
                }
            }
            {
                // export
                com.epl.geometry.Envelope e = new com.epl.geometry.Envelope();
                e.AddAttribute(com.epl.geometry.VertexDescription.Semantics.Z);
                e.AddAttribute(com.epl.geometry.VertexDescription.Semantics.M);
                string s = com.epl.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.epl.geometry.Envelope1D z = new com.epl.geometry.Envelope1D();
                com.epl.geometry.Envelope1D m = new com.epl.geometry.Envelope1D();
                z.SetCoords(5, 7);
                m.SetCoords(11, 13);
                e.SetInterval(com.epl.geometry.VertexDescription.Semantics.Z, 0, z);
                e.SetInterval(com.epl.geometry.VertexDescription.Semantics.M, 0, m);
                s = com.epl.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}}";
                com.fasterxml.jackson.core.JsonParser parser  = factory.CreateParser(s);
                com.epl.geometry.MapGeometry          map_env = com.epl.geometry.GeometryEngine.JsonToGeometry(parser);
                com.epl.geometry.Envelope             env     = (com.epl.geometry.Envelope)map_env.GetGeometry();
                com.epl.geometry.Envelope1D           z       = env.QueryInterval(com.epl.geometry.VertexDescription.Semantics.Z, 0);
                com.epl.geometry.Envelope1D           m       = env.QueryInterval(com.epl.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}";
                com.fasterxml.jackson.core.JsonParser parser  = factory.CreateParser(s);
                com.epl.geometry.MapGeometry          map_env = com.epl.geometry.GeometryEngine.JsonToGeometry(parser);
                com.epl.geometry.Envelope             env     = (com.epl.geometry.Envelope)map_env.GetGeometry();
                com.epl.geometry.Envelope2D           e       = new com.epl.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.epl.geometry.Envelope1D e1D;
                NUnit.Framework.Assert.IsTrue(env.HasAttribute(com.epl.geometry.VertexDescription.Semantics.Z));
                e1D = env.QueryInterval(com.epl.geometry.VertexDescription.Semantics.Z, 0);
                NUnit.Framework.Assert.IsTrue(e1D.vmin == 33 && e1D.vmax == 53);
                NUnit.Framework.Assert.IsTrue(!env.HasAttribute(com.epl.geometry.VertexDescription.Semantics.M));
            }
            return(bAnswer);
        }