Example #1
0
        public static void TestClipOfCoinciding()
        {
            com.epl.geometry.OperatorFactoryLocal engine = com.epl.geometry.OperatorFactoryLocal.GetInstance();
            com.epl.geometry.OperatorClip         clipOp = (com.epl.geometry.OperatorClip)engine.GetOperator(com.epl.geometry.Operator.Type.Clip);
            com.epl.geometry.Polygon    polygon          = new com.epl.geometry.Polygon();
            com.epl.geometry.Envelope2D envelopeCR       = new com.epl.geometry.Envelope2D();
            envelopeCR.xmin = -180;
            envelopeCR.xmax = 180;
            envelopeCR.ymin = -90;
            envelopeCR.ymax = 90;
            polygon.AddEnvelope(envelopeCR, false);
            com.epl.geometry.SpatialReference gcsWGS84 = com.epl.geometry.SpatialReference.Create(4326);
            // CR
            com.epl.geometry.Polygon clippedPolygon = (com.epl.geometry.Polygon)clipOp.Execute(polygon, envelopeCR, gcsWGS84, null);
            NUnit.Framework.Assert.IsTrue(clippedPolygon.GetPathCount() == 1);
            NUnit.Framework.Assert.IsTrue(clippedPolygon.GetPointCount() == 4);
            com.epl.geometry.OperatorDensifyByLength densifyOp = (com.epl.geometry.OperatorDensifyByLength)engine.GetOperator(com.epl.geometry.Operator.Type.DensifyByLength);
            polygon.SetEmpty();
            polygon.AddEnvelope(envelopeCR, false);
            polygon = (com.epl.geometry.Polygon)densifyOp.Execute(polygon, 1, null);
            int pc    = polygon.GetPointCount();
            int pathc = polygon.GetPathCount();

            NUnit.Framework.Assert.IsTrue(pc == 1080);
            NUnit.Framework.Assert.IsTrue(pathc == 1);
            clippedPolygon = (com.epl.geometry.Polygon)clipOp.Execute(polygon, envelopeCR, gcsWGS84, null);
            int _pathc = clippedPolygon.GetPathCount();
            int _pc    = clippedPolygon.GetPointCount();

            NUnit.Framework.Assert.IsTrue(_pathc == 1);
            NUnit.Framework.Assert.IsTrue(_pc == pc);
        }
Example #2
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);
            }
        }
 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);
     }
 }
Example #4
0
 public static void TestEditShape__()
 {
     {
         // Single part polygon
         com.epl.geometry.Polygon poly = new com.epl.geometry.Polygon();
         poly.StartPath(10, 10);
         poly.LineTo(10, 12);
         poly.LineTo(14, 15);
         poly.LineTo(10, 11);
         com.epl.geometry.EditShape editShape = new com.epl.geometry.EditShape();
         int geom = editShape.AddGeometry(poly);
         com.epl.geometry.Polygon poly2 = (com.epl.geometry.Polygon)editShape.GetGeometry(geom);
         NUnit.Framework.Assert.IsTrue(poly.Equals(poly2));
     }
     {
         // Two part poly
         com.epl.geometry.Polygon poly = new com.epl.geometry.Polygon();
         poly.StartPath(10, 10);
         poly.LineTo(10, 12);
         poly.LineTo(14, 15);
         poly.LineTo(10, 11);
         poly.StartPath(100, 10);
         poly.LineTo(100, 12);
         poly.LineTo(14, 150);
         poly.LineTo(10, 101);
         poly.LineTo(100, 11);
         com.epl.geometry.EditShape editShape = new com.epl.geometry.EditShape();
         int geom = editShape.AddGeometry(poly);
         com.epl.geometry.Polygon poly2 = (com.epl.geometry.Polygon)editShape.GetGeometry(geom);
         NUnit.Framework.Assert.IsTrue(poly.Equals(poly2));
     }
     {
         // Single part polyline
         com.epl.geometry.Polyline poly = new com.epl.geometry.Polyline();
         poly.StartPath(10, 10);
         poly.LineTo(10, 12);
         poly.LineTo(14, 15);
         poly.LineTo(10, 11);
         com.epl.geometry.EditShape editShape = new com.epl.geometry.EditShape();
         int geom = editShape.AddGeometry(poly);
         com.epl.geometry.Polyline poly2 = (com.epl.geometry.Polyline)editShape.GetGeometry(geom);
         NUnit.Framework.Assert.IsTrue(poly.Equals(poly2));
     }
     {
         // Two part poly
         com.epl.geometry.Polyline poly = new com.epl.geometry.Polyline();
         poly.StartPath(10, 10);
         poly.LineTo(10, 12);
         poly.LineTo(14, 15);
         poly.LineTo(10, 11);
         poly.StartPath(100, 10);
         poly.LineTo(100, 12);
         poly.LineTo(14, 150);
         poly.LineTo(10, 101);
         poly.LineTo(100, 11);
         com.epl.geometry.EditShape editShape = new com.epl.geometry.EditShape();
         int geom = editShape.AddGeometry(poly);
         com.epl.geometry.Polyline poly2 = (com.epl.geometry.Polyline)editShape.GetGeometry(geom);
         NUnit.Framework.Assert.IsTrue(poly.Equals(poly2));
     }
     {
         // Five part poly. Close one of parts to test if it works.
         com.epl.geometry.Polyline poly = new com.epl.geometry.Polyline();
         poly.StartPath(10, 10);
         poly.LineTo(10, 12);
         poly.LineTo(14, 15);
         poly.LineTo(10, 11);
         poly.StartPath(100, 10);
         poly.LineTo(100, 12);
         poly.LineTo(14, 150);
         poly.LineTo(10, 101);
         poly.LineTo(100, 11);
         poly.StartPath(1100, 101);
         poly.LineTo(1300, 132);
         poly.LineTo(144, 150);
         poly.LineTo(106, 1051);
         poly.LineTo(1600, 161);
         poly.StartPath(100, 190);
         poly.LineTo(1800, 192);
         poly.LineTo(184, 8150);
         poly.LineTo(1080, 181);
         poly.StartPath(1030, 10);
         poly.LineTo(1300, 132);
         poly.LineTo(314, 3150);
         poly.LineTo(310, 1301);
         poly.LineTo(3100, 311);
         com.epl.geometry.EditShape editShape = new com.epl.geometry.EditShape();
         int geom = editShape.AddGeometry(poly);
         editShape.SetClosedPath(editShape.GetNextPath(editShape.GetFirstPath(geom)), true);
         ((com.epl.geometry.MultiPathImpl)poly._getImpl()).ClosePathWithLine(1);
         com.epl.geometry.Polyline poly2 = (com.epl.geometry.Polyline)editShape.GetGeometry(geom);
         NUnit.Framework.Assert.IsTrue(poly.Equals(poly2));
     }
     {
         // Test erase
         com.epl.geometry.Polyline poly = new com.epl.geometry.Polyline();
         poly.StartPath(10, 10);
         poly.LineTo(10, 12);
         poly.LineTo(314, 3150);
         poly.LineTo(310, 1301);
         poly.LineTo(3100, 311);
         com.epl.geometry.EditShape editShape = new com.epl.geometry.EditShape();
         int geom   = editShape.AddGeometry(poly);
         int vertex = editShape.GetFirstVertex(editShape.GetFirstPath(geom));
         vertex = editShape.RemoveVertex(vertex, true);
         vertex = editShape.GetNextVertex(vertex);
         editShape.RemoveVertex(vertex, true);
         com.epl.geometry.Polyline poly2 = (com.epl.geometry.Polyline)editShape.GetGeometry(geom);
         poly.SetEmpty();
         poly.StartPath(10, 12);
         poly.LineTo(310, 1301);
         poly.LineTo(3100, 311);
         NUnit.Framework.Assert.IsTrue(poly.Equals(poly2));
     }
     {
         // Test erase
         com.epl.geometry.Polygon poly = new com.epl.geometry.Polygon();
         poly.StartPath(10, 10);
         poly.LineTo(10, 12);
         poly.LineTo(314, 3150);
         poly.LineTo(310, 1301);
         poly.LineTo(3100, 311);
         com.epl.geometry.EditShape editShape = new com.epl.geometry.EditShape();
         int geom   = editShape.AddGeometry(poly);
         int vertex = editShape.GetFirstVertex(editShape.GetFirstPath(geom));
         vertex = editShape.RemoveVertex(vertex, true);
         vertex = editShape.GetNextVertex(vertex);
         editShape.RemoveVertex(vertex, true);
         com.epl.geometry.Polygon poly2 = (com.epl.geometry.Polygon)editShape.GetGeometry(geom);
         poly.SetEmpty();
         poly.StartPath(10, 12);
         poly.LineTo(310, 1301);
         poly.LineTo(3100, 311);
         NUnit.Framework.Assert.IsTrue(poly.Equals(poly2));
     }
     {
         // Test Filter Close Points
         com.epl.geometry.Polygon poly = new com.epl.geometry.Polygon();
         poly.StartPath(10, 10);
         poly.LineTo(10, 10.001);
         poly.LineTo(10.001, 10);
         com.epl.geometry.EditShape editShape = new com.epl.geometry.EditShape();
         int geom = editShape.AddGeometry(poly);
         editShape.FilterClosePoints(0.002, true, false);
         com.epl.geometry.Polygon poly2 = (com.epl.geometry.Polygon)editShape.GetGeometry(geom);
         NUnit.Framework.Assert.IsTrue(poly2.IsEmpty());
     }
     {
         // Test Filter Close Points
         com.epl.geometry.Polygon poly = new com.epl.geometry.Polygon();
         poly.StartPath(10, 10);
         poly.LineTo(10, 10.0025);
         poly.LineTo(11.0, 10);
         com.epl.geometry.EditShape editShape = new com.epl.geometry.EditShape();
         int geom = editShape.AddGeometry(poly);
         editShape.FilterClosePoints(0.002, true, false);
         com.epl.geometry.Polygon poly2 = (com.epl.geometry.Polygon)editShape.GetGeometry(geom);
         NUnit.Framework.Assert.IsTrue(!poly2.IsEmpty());
     }
     {
         // Test Filter Close Points
         com.epl.geometry.Polygon poly = new com.epl.geometry.Polygon();
         poly.StartPath(10, 10);
         poly.LineTo(10, 10.001);
         poly.LineTo(11.0, 10);
         com.epl.geometry.EditShape editShape = new com.epl.geometry.EditShape();
         int geom = editShape.AddGeometry(poly);
         editShape.FilterClosePoints(0.002, true, false);
         com.epl.geometry.Polygon poly2 = (com.epl.geometry.Polygon)editShape.GetGeometry(geom);
         NUnit.Framework.Assert.IsTrue(poly2.IsEmpty());
     }
     {
         // Test attribute splitting 1
         com.epl.geometry.Polyline polyline = new com.epl.geometry.Polyline();
         polyline.StartPath(0, 0);
         polyline.LineTo(1, 1);
         polyline.LineTo(2, 2);
         polyline.LineTo(3, 3);
         polyline.LineTo(4, 4);
         polyline.StartPath(5, 5);
         polyline.LineTo(6, 6);
         polyline.LineTo(7, 7);
         polyline.LineTo(8, 8);
         polyline.LineTo(9, 9);
         polyline.AddAttribute(com.epl.geometry.VertexDescription.Semantics.Z);
         polyline.SetAttribute(com.epl.geometry.VertexDescription.Semantics.Z, 0, 0, 4);
         polyline.SetAttribute(com.epl.geometry.VertexDescription.Semantics.Z, 1, 0, 8);
         polyline.SetAttribute(com.epl.geometry.VertexDescription.Semantics.Z, 2, 0, 12);
         polyline.SetAttribute(com.epl.geometry.VertexDescription.Semantics.Z, 3, 0, 16);
         polyline.SetAttribute(com.epl.geometry.VertexDescription.Semantics.Z, 4, 0, 20);
         polyline.SetAttribute(com.epl.geometry.VertexDescription.Semantics.Z, 5, 0, 22);
         polyline.SetAttribute(com.epl.geometry.VertexDescription.Semantics.Z, 6, 0, 26);
         polyline.SetAttribute(com.epl.geometry.VertexDescription.Semantics.Z, 7, 0, 30);
         polyline.SetAttribute(com.epl.geometry.VertexDescription.Semantics.Z, 8, 0, 34);
         polyline.SetAttribute(com.epl.geometry.VertexDescription.Semantics.Z, 9, 0, 38);
         com.epl.geometry.EditShape shape = new com.epl.geometry.EditShape();
         int geometry = shape.AddGeometry(polyline);
         com.epl.geometry.AttributeStreamOfInt32 vertex_handles = new com.epl.geometry.AttributeStreamOfInt32(0);
         for (int path = shape.GetFirstPath(geometry); path != -1; path = shape.GetNextPath(path))
         {
             for (int vertex = shape.GetFirstVertex(path); vertex != -1; vertex = shape.GetNextVertex(vertex))
             {
                 if (vertex != shape.GetLastVertex(path))
                 {
                     vertex_handles.Add(vertex);
                 }
             }
         }
         double[] t = new double[1];
         for (int i = 0; i < vertex_handles.Size(); i++)
         {
             int vertex = vertex_handles.Read(i);
             t[0] = 0.5;
             shape.SplitSegment(vertex, t, 1);
         }
         com.epl.geometry.Polyline chopped_polyline = (com.epl.geometry.Polyline)shape.GetGeometry(geometry);
         NUnit.Framework.Assert.IsTrue(chopped_polyline.GetPointCount() == 18);
         double att_ = 4;
         for (int i_1 = 0; i_1 < 18; i_1++)
         {
             double att = chopped_polyline.GetAttributeAsDbl(com.epl.geometry.VertexDescription.Semantics.Z, i_1, 0);
             NUnit.Framework.Assert.IsTrue(att == att_);
             att_ += 2;
         }
     }
     {
         // Test attribute splitting 2
         com.epl.geometry.Polyline line1 = new com.epl.geometry.Polyline();
         com.epl.geometry.Polyline line2 = new com.epl.geometry.Polyline();
         line1.AddAttribute(com.epl.geometry.VertexDescription.Semantics.M);
         line2.AddAttribute(com.epl.geometry.VertexDescription.Semantics.M);
         line1.StartPath(0, 0);
         line1.LineTo(10, 10);
         line2.StartPath(10, 0);
         line2.LineTo(0, 10);
         line1.SetAttribute(com.epl.geometry.VertexDescription.Semantics.M, 0, 0, 7);
         line1.SetAttribute(com.epl.geometry.VertexDescription.Semantics.M, 1, 0, 17);
         line2.SetAttribute(com.epl.geometry.VertexDescription.Semantics.M, 0, 0, 5);
         line2.SetAttribute(com.epl.geometry.VertexDescription.Semantics.M, 1, 0, 15);
         com.epl.geometry.EditShape shape = new com.epl.geometry.EditShape();
         int g1 = shape.AddGeometry(line1);
         int g2 = shape.AddGeometry(line2);
         com.epl.geometry.CrackAndCluster.Execute(shape, 0.001, null, true);
         com.epl.geometry.Polyline chopped_line1 = (com.epl.geometry.Polyline)shape.GetGeometry(g1);
         com.epl.geometry.Polyline chopped_line2 = (com.epl.geometry.Polyline)shape.GetGeometry(g2);
         double att1 = chopped_line1.GetAttributeAsDbl(com.epl.geometry.VertexDescription.Semantics.M, 1, 0);
         double att2 = chopped_line2.GetAttributeAsDbl(com.epl.geometry.VertexDescription.Semantics.M, 1, 0);
         NUnit.Framework.Assert.IsTrue(att1 == 12);
         NUnit.Framework.Assert.IsTrue(att2 == 10);
     }
     {
         // Test attribute splitting 3
         com.epl.geometry.Polygon polygon = new com.epl.geometry.Polygon();
         polygon.AddAttribute(com.epl.geometry.VertexDescription.Semantics.M);
         polygon.StartPath(0, 0);
         polygon.LineTo(0, 10);
         polygon.LineTo(10, 10);
         polygon.LineTo(10, 0);
         polygon.SetAttribute(com.epl.geometry.VertexDescription.Semantics.M, 0, 0, 7);
         polygon.SetAttribute(com.epl.geometry.VertexDescription.Semantics.M, 1, 0, 17);
         polygon.SetAttribute(com.epl.geometry.VertexDescription.Semantics.M, 2, 0, 23);
         polygon.SetAttribute(com.epl.geometry.VertexDescription.Semantics.M, 3, 0, 43);
         com.epl.geometry.EditShape shape = new com.epl.geometry.EditShape();
         int geometry = shape.AddGeometry(polygon);
         com.epl.geometry.AttributeStreamOfInt32 vertex_handles = new com.epl.geometry.AttributeStreamOfInt32(0);
         int start_v = shape.GetFirstVertex(shape.GetFirstPath(geometry));
         int v       = start_v;
         do
         {
             vertex_handles.Add(v);
             v = shape.GetNextVertex(v);
         }while (v != start_v);
         double[] t = new double[1];
         for (int i = 0; i < vertex_handles.Size(); i++)
         {
             int v1 = vertex_handles.Read(i);
             t[0] = 0.5;
             shape.SplitSegment(v1, t, 1);
         }
         com.epl.geometry.Polygon cut_polygon = (com.epl.geometry.Polygon)shape.GetGeometry(geometry);
         NUnit.Framework.Assert.IsTrue(cut_polygon.GetPointCount() == 8);
         com.epl.geometry.Point2D pt0 = cut_polygon.GetXY(0);
         double a0 = cut_polygon.GetAttributeAsDbl(com.epl.geometry.VertexDescription.Semantics.M, 0, 0);
         NUnit.Framework.Assert.IsTrue(a0 == 25);
         com.epl.geometry.Point2D pt1 = cut_polygon.GetXY(1);
         double a1 = cut_polygon.GetAttributeAsDbl(com.epl.geometry.VertexDescription.Semantics.M, 1, 0);
         NUnit.Framework.Assert.IsTrue(a1 == 7);
         com.epl.geometry.Point2D pt2 = cut_polygon.GetXY(2);
         double a2 = cut_polygon.GetAttributeAsDbl(com.epl.geometry.VertexDescription.Semantics.M, 2, 0);
         NUnit.Framework.Assert.IsTrue(a2 == 12);
         com.epl.geometry.Point2D pt3 = cut_polygon.GetXY(3);
         double a3 = cut_polygon.GetAttributeAsDbl(com.epl.geometry.VertexDescription.Semantics.M, 3, 0);
         NUnit.Framework.Assert.IsTrue(a3 == 17);
         com.epl.geometry.Point2D pt4 = cut_polygon.GetXY(4);
         double a4 = cut_polygon.GetAttributeAsDbl(com.epl.geometry.VertexDescription.Semantics.M, 4, 0);
         NUnit.Framework.Assert.IsTrue(a4 == 20);
         com.epl.geometry.Point2D pt5 = cut_polygon.GetXY(5);
         double a5 = cut_polygon.GetAttributeAsDbl(com.epl.geometry.VertexDescription.Semantics.M, 5, 0);
         NUnit.Framework.Assert.IsTrue(a5 == 23);
         com.epl.geometry.Point2D pt6 = cut_polygon.GetXY(6);
         double a6 = cut_polygon.GetAttributeAsDbl(com.epl.geometry.VertexDescription.Semantics.M, 6, 0);
         NUnit.Framework.Assert.IsTrue(a6 == 33);
         com.epl.geometry.Point2D pt7 = cut_polygon.GetXY(7);
         double a7 = cut_polygon.GetAttributeAsDbl(com.epl.geometry.VertexDescription.Semantics.M, 7, 0);
         NUnit.Framework.Assert.IsTrue(a7 == 43);
     }
 }