Example #1
0
 public virtual void TestMultiPoint()
 {
     com.epl.geometry.MultiPoint multiPoint1 = new com.epl.geometry.MultiPoint();
     multiPoint1.Add(-97.06138, 32.837);
     multiPoint1.Add(-97.06133, 32.836);
     multiPoint1.Add(-97.06124, 32.834);
     multiPoint1.Add(-97.06127, 32.832);
     {
         com.fasterxml.jackson.core.JsonParser mPointWgs84Parser = factory.CreateJsonParser(com.epl.geometry.GeometryEngine.GeometryToJson(spatialReferenceWGS84, multiPoint1));
         com.epl.geometry.MapGeometry          mPointWgs84MP     = com.epl.geometry.GeometryEngine.JsonToGeometry(mPointWgs84Parser);
         NUnit.Framework.Assert.IsTrue(multiPoint1.GetPointCount() == ((com.epl.geometry.MultiPoint)mPointWgs84MP.GetGeometry()).GetPointCount());
         NUnit.Framework.Assert.IsTrue(multiPoint1.GetPoint(0).GetX() == ((com.epl.geometry.MultiPoint)mPointWgs84MP.GetGeometry()).GetPoint(0).GetX());
         NUnit.Framework.Assert.IsTrue(multiPoint1.GetPoint(0).GetY() == ((com.epl.geometry.MultiPoint)mPointWgs84MP.GetGeometry()).GetPoint(0).GetY());
         int lastIndex = multiPoint1.GetPointCount() - 1;
         NUnit.Framework.Assert.IsTrue(multiPoint1.GetPoint(lastIndex).GetX() == ((com.epl.geometry.MultiPoint)mPointWgs84MP.GetGeometry()).GetPoint(lastIndex).GetX());
         NUnit.Framework.Assert.IsTrue(multiPoint1.GetPoint(lastIndex).GetY() == ((com.epl.geometry.MultiPoint)mPointWgs84MP.GetGeometry()).GetPoint(lastIndex).GetY());
         NUnit.Framework.Assert.IsTrue(spatialReferenceWGS84.GetID() == mPointWgs84MP.GetSpatialReference().GetID());
         com.epl.geometry.MultiPoint mPointEmpty = new com.epl.geometry.MultiPoint();
         string mPointEmptyString = com.epl.geometry.GeometryEngine.GeometryToJson(spatialReferenceWGS84, mPointEmpty);
         mPointWgs84Parser = factory.CreateJsonParser(mPointEmptyString);
         mPointWgs84MP     = com.epl.geometry.GeometryEngine.JsonToGeometry(mPointWgs84Parser);
         NUnit.Framework.Assert.IsTrue(mPointWgs84MP.GetGeometry().IsEmpty());
         NUnit.Framework.Assert.IsTrue(spatialReferenceWGS84.GetID() == mPointWgs84MP.GetSpatialReference().GetID());
     }
 }
        /// <exception cref="com.fasterxml.jackson.core.JsonParseException"/>
        /// <exception cref="System.IO.IOException"/>
        internal virtual bool TestMultiPoint()
        {
            bool bAnswer = true;

            com.epl.geometry.MultiPoint multiPoint1 = new com.epl.geometry.MultiPoint();
            multiPoint1.Add(-97.06138, 32.837);
            multiPoint1.Add(-97.06133, 32.836);
            multiPoint1.Add(-97.06124, 32.834);
            multiPoint1.Add(-97.06127, 32.832);
            {
                string s = com.epl.geometry.GeometryEngine.GeometryToJson(spatialReferenceWGS84, multiPoint1);
                com.fasterxml.jackson.core.JsonParser mPointWgs84Parser = factory.CreateParser(s);
                com.epl.geometry.MapGeometry          mPointWgs84MP     = com.epl.geometry.GeometryEngine.JsonToGeometry(mPointWgs84Parser);
                NUnit.Framework.Assert.IsTrue(multiPoint1.GetPointCount() == ((com.epl.geometry.MultiPoint)mPointWgs84MP.GetGeometry()).GetPointCount());
                NUnit.Framework.Assert.IsTrue(multiPoint1.GetPoint(0).GetX() == ((com.epl.geometry.MultiPoint)mPointWgs84MP.GetGeometry()).GetPoint(0).GetX());
                NUnit.Framework.Assert.IsTrue(multiPoint1.GetPoint(0).GetY() == ((com.epl.geometry.MultiPoint)mPointWgs84MP.GetGeometry()).GetPoint(0).GetY());
                int lastIndex = multiPoint1.GetPointCount() - 1;
                NUnit.Framework.Assert.IsTrue(multiPoint1.GetPoint(lastIndex).GetX() == ((com.epl.geometry.MultiPoint)mPointWgs84MP.GetGeometry()).GetPoint(lastIndex).GetX());
                NUnit.Framework.Assert.IsTrue(multiPoint1.GetPoint(lastIndex).GetY() == ((com.epl.geometry.MultiPoint)mPointWgs84MP.GetGeometry()).GetPoint(lastIndex).GetY());
                NUnit.Framework.Assert.IsTrue(spatialReferenceWGS84.GetID() == mPointWgs84MP.GetSpatialReference().GetID());
                if (!CheckResultSpatialRef(mPointWgs84MP, 4326, 0))
                {
                    bAnswer = false;
                }
            }
            {
                com.epl.geometry.MultiPoint p = new com.epl.geometry.MultiPoint();
                p.AddAttribute(com.epl.geometry.VertexDescription.Semantics.Z);
                p.AddAttribute(com.epl.geometry.VertexDescription.Semantics.M);
                string s = com.epl.geometry.GeometryEngine.GeometryToJson(spatialReferenceWebMerc1, p);
                NUnit.Framework.Assert.IsTrue(s.Equals("{\"hasZ\":true,\"hasM\":true,\"points\":[],\"spatialReference\":{\"wkid\":102100,\"latestWkid\":3857}}"));
                p.Add(10.0, 20.0, 30.0);
                p.Add(20.0, 40.0, 60.0);
                s = com.epl.geometry.GeometryEngine.GeometryToJson(spatialReferenceWebMerc1, p);
                NUnit.Framework.Assert.IsTrue(s.Equals("{\"hasZ\":true,\"hasM\":true,\"points\":[[10,20,30,null],[20,40,60,null]],\"spatialReference\":{\"wkid\":102100,\"latestWkid\":3857}}"));
            }
            {
                string points = "{\"hasM\" : false, \"hasZ\" : true, \"uncle remus\" : null, \"points\" : [ [0,0,1], [0.0,10.0,1], [10.0,10.0,1], [10.0,0.0,1, 6666] ],\"spatialReference\" : {\"wkid\" : 4326}}";
                com.epl.geometry.MapGeometry mp         = com.epl.geometry.GeometryEngine.JsonToGeometry(factory.CreateParser(points));
                com.epl.geometry.MultiPoint  multipoint = (com.epl.geometry.MultiPoint)mp.GetGeometry();
                NUnit.Framework.Assert.IsTrue(multipoint.GetPointCount() == 4);
                com.epl.geometry.Point2D point2d;
                point2d = multipoint.GetXY(0);
                NUnit.Framework.Assert.IsTrue(point2d.x == 0.0 && point2d.y == 0.0);
                point2d = multipoint.GetXY(1);
                NUnit.Framework.Assert.IsTrue(point2d.x == 0.0 && point2d.y == 10.0);
                point2d = multipoint.GetXY(2);
                NUnit.Framework.Assert.IsTrue(point2d.x == 10.0 && point2d.y == 10.0);
                point2d = multipoint.GetXY(3);
                NUnit.Framework.Assert.IsTrue(point2d.x == 10.0 && point2d.y == 0.0);
                NUnit.Framework.Assert.IsTrue(multipoint.HasAttribute(com.epl.geometry.VertexDescription.Semantics.Z));
                NUnit.Framework.Assert.IsTrue(!multipoint.HasAttribute(com.epl.geometry.VertexDescription.Semantics.M));
                double z = multipoint.GetAttributeAsDbl(com.epl.geometry.VertexDescription.Semantics.Z, 0, 0);
                NUnit.Framework.Assert.IsTrue(z == 1);
                com.epl.geometry.SpatialReference spatial_reference = mp.GetSpatialReference();
                NUnit.Framework.Assert.IsTrue(spatial_reference.GetID() == 4326);
            }
            return(bAnswer);
        }
        private static int QuickTest2DMultiPointEnvelope(com.epl.geometry.MultiPoint geomA, com.epl.geometry.Envelope2D geomBEnv, double tolerance, int testType)
        {
            // Add early bailout for disjoint test.
            com.epl.geometry.Envelope2D envBMinus = geomBEnv;
            envBMinus.Inflate(-tolerance, -tolerance);
            com.epl.geometry.Envelope2D envBPlus = geomBEnv;
            envBPlus.Inflate(tolerance, tolerance);
            int dres = 0;

            for (int i = 0, n = geomA.GetPointCount(); i < n; i++)
            {
                com.epl.geometry.Point2D ptA;
                ptA = geomA.GetXY(i);
                int res = ReverseResult(QuickTest2DEnvelopePoint(envBPlus, envBMinus, ptA, tolerance));
                if (res != (int)com.epl.geometry.OperatorInternalRelationUtils.Relation.Disjoint)
                {
                    dres |= res;
                    if (testType == (int)com.epl.geometry.OperatorInternalRelationUtils.Relation.Disjoint)
                    {
                        return((int)com.epl.geometry.OperatorInternalRelationUtils.Relation.Intersects);
                    }
                }
            }
            if (dres == 0)
            {
                return((int)com.epl.geometry.OperatorInternalRelationUtils.Relation.Disjoint);
            }
            if (dres == (int)com.epl.geometry.OperatorInternalRelationUtils.Relation.Within)
            {
                return(dres);
            }
            return((int)com.epl.geometry.OperatorInternalRelationUtils.Relation.Overlaps);
        }
        public static void CompareGeometryContent(com.epl.geometry.MultiPoint geom1, com.epl.geometry.MultiPoint geom2)
        {
            // Geometry types
            NUnit.Framework.Assert.IsTrue(geom1.GetType().Value() == geom2.GetType().Value());
            // Envelopes
            com.epl.geometry.Envelope env1 = new com.epl.geometry.Envelope();
            geom1.QueryEnvelope(env1);
            com.epl.geometry.Envelope env2 = new com.epl.geometry.Envelope();
            geom2.QueryEnvelope(env2);
            NUnit.Framework.Assert.IsTrue(env1.GetXMin() == env2.GetXMin() && env1.GetXMax() == env2.GetXMax() && env1.GetYMin() == env2.GetYMin() && env1.GetYMax() == env2.GetYMax());
            // Point count
            int pointCount1 = geom1.GetPointCount();
            int pointCount2 = geom2.GetPointCount();

            NUnit.Framework.Assert.IsTrue(pointCount1 == pointCount2);
            com.epl.geometry.Point point1;
            com.epl.geometry.Point point2;
            for (int i = 0; i < pointCount1; i++)
            {
                point1 = geom1.GetPoint(i);
                point2 = geom2.GetPoint(i);
                double x1 = point1.GetX();
                double x2 = point2.GetX();
                NUnit.Framework.Assert.IsTrue(x1 == x2);
                double y1 = point1.GetY();
                double y2 = point2.GetY();
                NUnit.Framework.Assert.IsTrue(y1 == y2);
            }
        }
        internal static com.epl.geometry.Geometry MultiPointSymDiffPoint_(com.epl.geometry.MultiPoint multi_point, com.epl.geometry.Point point, double tolerance, com.epl.geometry.ProgressTracker progress_tracker)
        {
            com.epl.geometry.MultiPointImpl       multipointImpl = (com.epl.geometry.MultiPointImpl)(multi_point._getImpl());
            com.epl.geometry.AttributeStreamOfDbl position       = (com.epl.geometry.AttributeStreamOfDbl)(multipointImpl.GetAttributeStreamRef(com.epl.geometry.VertexDescription.Semantics.POSITION));
            int point_count = multi_point.GetPointCount();

            com.epl.geometry.Point2D    point2D        = point.GetXY();
            com.epl.geometry.MultiPoint new_multipoint = (com.epl.geometry.MultiPoint)(multi_point.CreateInstance());
            double tolerance_cluster = tolerance * System.Math.Sqrt(2.0) * 1.00001;

            com.epl.geometry.Envelope2D env = new com.epl.geometry.Envelope2D();
            multi_point.QueryEnvelope2D(env);
            env.Inflate(tolerance_cluster, tolerance_cluster);
            if (env.Contains(point2D))
            {
                double tolerance_cluster_sq = tolerance_cluster * tolerance_cluster;
                bool   b_found_covered      = false;
                bool[] covered = new bool[point_count];
                for (int i = 0; i < point_count; i++)
                {
                    covered[i] = false;
                }
                for (int i_1 = 0; i_1 < point_count; i_1++)
                {
                    double x  = position.Read(2 * i_1);
                    double y  = position.Read(2 * i_1 + 1);
                    double dx = x - point2D.x;
                    double dy = y - point2D.y;
                    if (dx * dx + dy * dy <= tolerance_cluster_sq)
                    {
                        b_found_covered = true;
                        covered[i_1]    = true;
                    }
                }
                if (!b_found_covered)
                {
                    new_multipoint.Add(multi_point, 0, point_count);
                    new_multipoint.Add(point);
                }
                else
                {
                    for (int i_2 = 0; i_2 < point_count; i_2++)
                    {
                        if (!covered[i_2])
                        {
                            new_multipoint.Add(multi_point, i_2, i_2 + 1);
                        }
                    }
                }
            }
            else
            {
                new_multipoint.Add(multi_point, 0, point_count);
                new_multipoint.Add(point);
            }
            return(new_multipoint);
        }
        private static int QuickTest2DMultiPointMultiPoint(com.epl.geometry.MultiPoint geomA, com.epl.geometry.MultiPoint geomB, double tolerance, int testType)
        {
            int counter = 0;

            for (int ib = 0, nb = geomB.GetPointCount(); ib < nb; ib++)
            {
                com.epl.geometry.Point2D ptB;
                ptB = geomB.GetXY(ib);
                int res = QuickTest2DMultiPointPoint(geomA, ptB, tolerance);
                if (res != (int)com.epl.geometry.OperatorInternalRelationUtils.Relation.Disjoint)
                {
                    counter++;
                    if (testType == (int)com.epl.geometry.OperatorInternalRelationUtils.Relation.Disjoint)
                    {
                        return((int)com.epl.geometry.OperatorInternalRelationUtils.Relation.Intersects);
                    }
                }
            }
            if (counter > 0)
            {
                if (counter == geomB.GetPointCount())
                {
                    // every point from B is within
                    // A. Means the A contains B
                    if (testType == (int)com.epl.geometry.OperatorInternalRelationUtils.Relation.Equals)
                    {
                        // This is slow.
                        // Refactor.
                        int res = QuickTest2DMultiPointMultiPoint(geomB, geomA, tolerance, (int)com.epl.geometry.OperatorInternalRelationUtils.Relation.Contains);
                        return(res == (int)com.epl.geometry.OperatorInternalRelationUtils.Relation.Contains ? (int)com.epl.geometry.OperatorInternalRelationUtils.Relation.Equals : (int)com.epl.geometry.OperatorInternalRelationUtils.Relation.Unknown);
                    }
                    return((int)com.epl.geometry.OperatorInternalRelationUtils.Relation.Contains);
                }
                else
                {
                    return((int)com.epl.geometry.OperatorInternalRelationUtils.Relation.Overlaps);
                }
            }
            return(0);
        }
        internal static com.epl.geometry.Geometry MultiPointMinusPolygon_(com.epl.geometry.MultiPoint multi_point, com.epl.geometry.Polygon polygon, double tolerance, com.epl.geometry.ProgressTracker progress_tracker)
        {
            com.epl.geometry.Envelope2D env = new com.epl.geometry.Envelope2D();
            polygon.QueryEnvelope2D(env);
            env.Inflate(tolerance, tolerance);
            int  point_count     = multi_point.GetPointCount();
            bool b_found_covered = false;

            bool[] covered = new bool[point_count];
            for (int i = 0; i < point_count; i++)
            {
                covered[i] = false;
            }
            com.epl.geometry.Point2D pt = new com.epl.geometry.Point2D();
            for (int i_1 = 0; i_1 < point_count; i_1++)
            {
                multi_point.GetXY(i_1, pt);
                if (!env.Contains(pt))
                {
                    continue;
                }
                com.epl.geometry.PolygonUtils.PiPResult result = com.epl.geometry.PolygonUtils.IsPointInPolygon2D(polygon, pt, tolerance);
                if (result == com.epl.geometry.PolygonUtils.PiPResult.PiPOutside)
                {
                    continue;
                }
                b_found_covered = true;
                covered[i_1]    = true;
            }
            if (!b_found_covered)
            {
                return(multi_point);
            }
            com.epl.geometry.MultiPoint new_multipoint = (com.epl.geometry.MultiPoint)multi_point.CreateInstance();
            for (int i_2 = 0; i_2 < point_count; i_2++)
            {
                if (!covered[i_2])
                {
                    new_multipoint.Add(multi_point, i_2, i_2 + 1);
                }
            }
            return(new_multipoint);
        }
 public static void TestCopy()
 {
     com.epl.geometry.MultiPoint mpoint = new com.epl.geometry.MultiPoint();
     com.epl.geometry.Point      pt0    = new com.epl.geometry.Point(0.0, 0.0, -1.0);
     com.epl.geometry.Point      pt1    = new com.epl.geometry.Point(0.0, 0.0, 1.0);
     com.epl.geometry.Point      pt2    = new com.epl.geometry.Point(0.0, 1.0, 1.0);
     mpoint.Add(pt0);
     mpoint.Add(pt1);
     mpoint.Add(pt2);
     mpoint.RemovePoint(1);
     com.epl.geometry.MultiPoint mpCopy = (com.epl.geometry.MultiPoint)mpoint.Copy();
     NUnit.Framework.Assert.IsTrue(mpCopy.Equals(mpoint));
     com.epl.geometry.Point pt;
     pt = mpCopy.GetPoint(0);
     NUnit.Framework.Assert.IsTrue(pt.GetX() == pt0.GetX() && pt.GetY() == pt0.GetY());
     pt = mpCopy.GetPoint(1);
     NUnit.Framework.Assert.IsTrue(pt.GetX() == pt2.GetX() && pt.GetY() == pt2.GetY());
     NUnit.Framework.Assert.IsTrue(mpCopy.GetPointCount() == 2);
 }
        internal static com.epl.geometry.Geometry MultiPointMinusPoint_(com.epl.geometry.MultiPoint multi_point, com.epl.geometry.Point point, double tolerance, com.epl.geometry.ProgressTracker progress_tracker)
        {
            com.epl.geometry.MultiPointImpl       multipointImpl = (com.epl.geometry.MultiPointImpl)(multi_point._getImpl());
            com.epl.geometry.AttributeStreamOfDbl position       = (com.epl.geometry.AttributeStreamOfDbl)(multipointImpl.GetAttributeStreamRef(com.epl.geometry.VertexDescription.Semantics.POSITION));
            int point_count = multi_point.GetPointCount();

            com.epl.geometry.Point2D point2D = point.GetXY();
            com.epl.geometry.Point2D pt      = new com.epl.geometry.Point2D();
            bool b_found_covered             = false;

            bool[] covered = new bool[point_count];
            for (int i = 0; i < point_count; i++)
            {
                covered[i] = false;
            }
            double tolerance_cluster    = tolerance * System.Math.Sqrt(2.0) * 1.00001;
            double tolerance_cluster_sq = tolerance_cluster * tolerance_cluster;

            for (int i_1 = 0; i_1 < point_count; i_1++)
            {
                position.Read(2 * i_1, pt);
                double sqr_dist = com.epl.geometry.Point2D.SqrDistance(pt, point2D);
                if (sqr_dist <= tolerance_cluster_sq)
                {
                    b_found_covered = true;
                    covered[i_1]    = true;
                }
            }
            if (!b_found_covered)
            {
                return(multi_point);
            }
            com.epl.geometry.MultiPoint new_multipoint = (com.epl.geometry.MultiPoint)(multi_point.CreateInstance());
            for (int i_2 = 0; i_2 < point_count; i_2++)
            {
                if (!covered[i_2])
                {
                    new_multipoint.Add(multi_point, i_2, i_2 + 1);
                }
            }
            return(new_multipoint);
        }
 private static int QuickTest2DMultiPointPoint(com.epl.geometry.MultiPoint geomA, com.epl.geometry.Point2D ptB, double tolerance)
 {
     // TODO: Add Geometry accelerator. (RasterizedGeometry + kd-tree or
     // alike)
     for (int i = 0, n = geomA.GetPointCount(); i < n; i++)
     {
         com.epl.geometry.Point2D ptA;
         ptA = geomA.GetXY(i);
         int res = QuickTest2DPointPoint(ptA, ptB, tolerance);
         if (res != (int)com.epl.geometry.OperatorInternalRelationUtils.Relation.Disjoint)
         {
             if ((res & (int)com.epl.geometry.OperatorInternalRelationUtils.Relation.Within) != 0 && n != 1)
             {
                 // _ASSERT(res & (int)Relation.Contains);
                 return((int)com.epl.geometry.OperatorInternalRelationUtils.Relation.Contains);
             }
             return(res);
         }
     }
     return((int)com.epl.geometry.OperatorInternalRelationUtils.Relation.Disjoint);
 }
        internal static com.epl.geometry.Geometry PointMinusMultiPoint_(com.epl.geometry.Point point, com.epl.geometry.MultiPoint multi_point, double tolerance, com.epl.geometry.ProgressTracker progress_tracker)
        {
            com.epl.geometry.MultiPointImpl       multipointImpl = (com.epl.geometry.MultiPointImpl)(multi_point._getImpl());
            com.epl.geometry.AttributeStreamOfDbl position       = (com.epl.geometry.AttributeStreamOfDbl)multipointImpl.GetAttributeStreamRef(com.epl.geometry.VertexDescription.Semantics.POSITION);
            int point_count = multi_point.GetPointCount();

            com.epl.geometry.Point2D point2D = point.GetXY();
            com.epl.geometry.Point2D pt      = new com.epl.geometry.Point2D();
            double tolerance_cluster         = tolerance * System.Math.Sqrt(2.0) * 1.00001;
            double tolerance_cluster_sq      = tolerance_cluster * tolerance_cluster;

            for (int i = 0; i < point_count; i++)
            {
                position.Read(2 * i, pt);
                double sqr_dist = com.epl.geometry.Point2D.SqrDistance(pt, point2D);
                if (sqr_dist <= tolerance_cluster_sq)
                {
                    return(point.CreateInstance());
                }
            }
            // return an empty point.
            return(point);
        }
 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);
     }
 }
 internal static bool IsConvex_(com.epl.geometry.Geometry geom, com.epl.geometry.ProgressTracker progress_tracker)
 {
     if (geom.IsEmpty())
     {
         return(true);
     }
     // vacuously true
     com.epl.geometry.Geometry.Type type = geom.GetType();
     if (type == com.epl.geometry.Geometry.Type.Point)
     {
         return(true);
     }
     // vacuously true
     if (type == com.epl.geometry.Geometry.Type.Envelope)
     {
         com.epl.geometry.Envelope envelope = (com.epl.geometry.Envelope)geom;
         if (envelope.GetXMin() == envelope.GetXMax() || envelope.GetYMin() == envelope.GetYMax())
         {
             return(false);
         }
         return(true);
     }
     if (com.epl.geometry.MultiPath.IsSegment(type.Value()))
     {
         com.epl.geometry.Segment segment = (com.epl.geometry.Segment)geom;
         if (segment.GetStartXY().Equals(segment.GetEndXY()))
         {
             return(false);
         }
         return(true);
     }
     // true, but we will upgrade to a Polyline for the ConvexHull operation
     if (type == com.epl.geometry.Geometry.Type.MultiPoint)
     {
         com.epl.geometry.MultiPoint multi_point = (com.epl.geometry.MultiPoint)geom;
         if (multi_point.GetPointCount() == 1)
         {
             return(true);
         }
         // vacuously true, but we will downgrade to a Point for the ConvexHull operation
         return(false);
     }
     if (type == com.epl.geometry.Geometry.Type.Polyline)
     {
         com.epl.geometry.Polyline polyline = (com.epl.geometry.Polyline)geom;
         if (polyline.GetPathCount() == 1 && polyline.GetPointCount() == 2)
         {
             if (!polyline.GetXY(0).Equals(polyline.GetXY(1)))
             {
                 return(true);
             }
         }
         // vacuously true
         return(false);
     }
     // create convex hull
     com.epl.geometry.Polygon polygon = (com.epl.geometry.Polygon)geom;
     if (polygon.GetPathCount() != 1 || polygon.GetPointCount() < 3)
     {
         return(false);
     }
     return(com.epl.geometry.ConvexHull.IsPathConvex(polygon, 0, progress_tracker));
 }
        public static void TestCreation()
        {
            {
                // simple create
                com.epl.geometry.MultiPoint mpoint = new com.epl.geometry.MultiPoint();
                NUnit.Framework.Assert.IsTrue(mpoint.GetType() == Geometry.Type.MultiPoint);
                // assertFalse(mpoint.getClass() == Polyline.class);
                NUnit.Framework.Assert.IsTrue(mpoint != null);
                NUnit.Framework.Assert.IsTrue(mpoint.GetType() == com.epl.geometry.Geometry.Type.MultiPoint);
                NUnit.Framework.Assert.IsTrue(mpoint.IsEmpty());
                NUnit.Framework.Assert.IsTrue(mpoint.GetPointCount() == 0);
                mpoint = null;
                NUnit.Framework.Assert.IsFalse(mpoint != null);
            }
            {
                // play with default attributes
                com.epl.geometry.MultiPoint mpoint = new com.epl.geometry.MultiPoint();
                SimpleTest(mpoint);
            }
            {
                // simple create 2D
                com.epl.geometry.MultiPoint mpoint = new com.epl.geometry.MultiPoint();
                NUnit.Framework.Assert.IsTrue(mpoint != null);
                com.epl.geometry.MultiPoint mpoint1 = new com.epl.geometry.MultiPoint();
                NUnit.Framework.Assert.IsTrue(mpoint1 != null);
                mpoint.SetEmpty();
                com.epl.geometry.Point pt = new com.epl.geometry.Point(0, 0);
                mpoint.Add(pt);
                com.epl.geometry.Point pt3 = mpoint.GetPoint(0);
                NUnit.Framework.Assert.IsTrue(pt3.GetX() == 0 && pt3.GetY() == 0);
                // assertFalse(mpoint->HasAttribute(VertexDescription::Semantics::Z));
                // pt3.setZ(115.0);
                mpoint.SetPoint(0, pt3);
                pt3 = mpoint.GetPoint(0);
                NUnit.Framework.Assert.IsTrue(pt3.GetX() == 0 && pt3.GetY() == 0);
            }
            {
                /* && pt3.getZ() == 115 */
                // assertTrue(mpoint->HasAttribute(VertexDescription::Semantics::Z));
                // CompareGeometryContent(mpoint, &pt, 1);
                // move 3d
                com.epl.geometry.MultiPoint mpoint = new com.epl.geometry.MultiPoint();
                NUnit.Framework.Assert.IsTrue(mpoint != null);
                com.epl.geometry.Point pt = new com.epl.geometry.Point(0, 0);
                mpoint.Add(pt);
                com.epl.geometry.Point pt3 = mpoint.GetPoint(0);
                NUnit.Framework.Assert.IsTrue(pt3.GetX() == 0 && pt3.GetY() == 0);
            }
            {
                /* && pt3.getZ() == 0 */
                // test QueryInterval
                com.epl.geometry.MultiPoint mpoint = new com.epl.geometry.MultiPoint();
                com.epl.geometry.Point      pt1    = new com.epl.geometry.Point(0.0, 0.0);
                // pt1.setZ(-1.0);
                com.epl.geometry.Point pt2 = new com.epl.geometry.Point(0.0, 0.0);
                // pt2.setZ(1.0);
                mpoint.Add(pt1);
                mpoint.Add(pt2);
                // Envelope1D e =
                // mpoint->QueryInterval(enum_value2(VertexDescription, Semantics,
                // Z), 0);
                com.epl.geometry.Envelope e = new com.epl.geometry.Envelope();
                mpoint.QueryEnvelope(e);
            }
            {
                // assertTrue(e.get == -1.0 && e.vmax == 1.0);
                com.epl.geometry.MultiPoint geom = new com.epl.geometry.MultiPoint();
            }
            {
                // int sz = sizeof(openString) / sizeof(openString[0]);
                // for (int i = 0; i < sz; i++)
                // geom.add(openString[i]);
                // CompareGeometryContent(geom, openString, sz);
                com.epl.geometry.MultiPoint geom = new com.epl.geometry.MultiPoint();
            }
            {
                // int sz = sizeof(openString) / sizeof(openString[0]);
                // Point point = GCNEW Point;
                // for (int i = 0; i < sz; i++)
                // {
                // point.setXY(openString[i]);
                // geom.add(point);
                // }
                // CompareGeometryContent(geom, openString, sz);
                // Test AddPoints
                com.epl.geometry.MultiPoint geom = new com.epl.geometry.MultiPoint();
            }
            {
                // int sz = sizeof(openString) / sizeof(openString[0]);
                // geom.addPoints(openString, sz, 0, -1);
                // CompareGeometryContent((MultiVertexGeometry)geom, openString,
                // sz);
                // Test InsertPoint(Point2D)
                com.epl.geometry.MultiPoint mpoint = new com.epl.geometry.MultiPoint();
                com.epl.geometry.Point      pt0    = new com.epl.geometry.Point(0.0, 0.0);
                // pt0.setZ(-1.0);
                // pt0.setID(7);
                com.epl.geometry.Point pt1 = new com.epl.geometry.Point(0.0, 0.0);
                // pt1.setZ(1.0);
                // pt1.setID(11);
                com.epl.geometry.Point pt2 = new com.epl.geometry.Point(0.0, 1.0);
                // pt2.setZ(1.0);
                // pt2.setID(13);
                mpoint.Add(pt0);
                mpoint.Add(pt1);
                mpoint.Add(pt2);
                com.epl.geometry.Point pt3 = new com.epl.geometry.Point(-11.0, -13.0);
                mpoint.Add(pt3);
                mpoint.InsertPoint(1, pt3);
                NUnit.Framework.Assert.IsTrue(mpoint.GetPointCount() == 5);
                com.epl.geometry.Point pt;
                pt = mpoint.GetPoint(0);
                NUnit.Framework.Assert.IsTrue(pt.GetX() == pt0.GetX() && pt.GetY() == pt0.GetY());

                /*
                 * &&
                 * pt.
                 * getZ
                 * () ==
                 * pt0
                 * .getZ
                 * ()
                 */
                pt = mpoint.GetPoint(1);
                NUnit.Framework.Assert.IsTrue(pt.GetX() == pt3.GetX() && pt.GetY() == pt3.GetY());
                pt = mpoint.GetPoint(2);
                NUnit.Framework.Assert.IsTrue(pt.GetX() == pt1.GetX() && pt.GetY() == pt1.GetY());

                /*
                 * &&
                 * pt.
                 * getZ
                 * () ==
                 * pt1
                 * .getZ
                 * ()
                 */
                pt = mpoint.GetPoint(3);
                NUnit.Framework.Assert.IsTrue(pt.GetX() == pt2.GetX() && pt.GetY() == pt2.GetY());

                /*
                 * &&
                 * pt.
                 * getZ
                 * () ==
                 * pt2
                 * .getZ
                 * ()
                 */
                com.epl.geometry.Point point = new com.epl.geometry.Point();
                point.SetXY(17.0, 19.0);
                // point.setID(12);
                // point.setM(5);
                mpoint.InsertPoint(2, point);
                mpoint.Add(point);
                NUnit.Framework.Assert.IsTrue(mpoint.GetPointCount() == 7);
            }
            // double m;
            // int id;
            // pt = mpoint.getXYZ(2);
            // assertTrue(pt.x == 17.0 && pt.y == 19.0 && pt.z == defaultZ);
            // m = mpoint.getAttributeAsDbl(enum_value2(VertexDescription,
            // Semantics, M), 2, 0);
            // assertTrue(m == 5);
            // id = mpoint.getAttributeAsInt(enum_value2(VertexDescription,
            // Semantics, ID), 2, 0);
            // assertTrue(id == 23);
            //
            // pt = mpoint.getXYZ(3);
            // assertTrue(pt.x == pt1.x && pt.y == pt1.y && pt.z == pt1.z);
            // m = mpoint.getAttributeAsDbl(enum_value2(VertexDescription,
            // Semantics, M), 3, 0);
            // assertTrue(NumberUtils::IsNaN(m));
            // id = mpoint.getAttributeAsInt(enum_value2(VertexDescription,
            // Semantics, ID), 3, 0);
            // assertTrue(id == 11);
            com.epl.geometry.MultiPoint mpoint_1 = new com.epl.geometry.MultiPoint();
            com.epl.geometry.Point      pt0_1    = new com.epl.geometry.Point(0.0, 0.0, -1.0);
            com.epl.geometry.Point      pt1_1    = new com.epl.geometry.Point(0.0, 0.0, 1.0);
            com.epl.geometry.Point      pt2_1    = new com.epl.geometry.Point(0.0, 1.0, 1.0);
            mpoint_1.Add(pt0_1);
            mpoint_1.Add(pt1_1);
            mpoint_1.Add(pt2_1);
            mpoint_1.RemovePoint(1);
            com.epl.geometry.Point pt_1;
            pt_1 = mpoint_1.GetPoint(0);
            NUnit.Framework.Assert.IsTrue(pt_1.GetX() == pt0_1.GetX() && pt_1.GetY() == pt0_1.GetY());
            pt_1 = mpoint_1.GetPoint(1);
            NUnit.Framework.Assert.IsTrue(pt_1.GetX() == pt2_1.GetX() && pt_1.GetY() == pt2_1.GetY());
            NUnit.Framework.Assert.IsTrue(mpoint_1.GetPointCount() == 2);
        }
Example #15
0
        public static void TestClipGeometries()
        {
            // RandomTest();
            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                     = MakePolygon();
            com.epl.geometry.SimpleGeometryCursor polygonCurs    = new com.epl.geometry.SimpleGeometryCursor(polygon);
            com.epl.geometry.Polyline             polyline       = MakePolyline();
            com.epl.geometry.SimpleGeometryCursor polylineCurs   = new com.epl.geometry.SimpleGeometryCursor(polyline);
            com.epl.geometry.MultiPoint           multipoint     = MakeMultiPoint();
            com.epl.geometry.SimpleGeometryCursor multipointCurs = new com.epl.geometry.SimpleGeometryCursor(multipoint);
            com.epl.geometry.Point point = MakePoint();
            com.epl.geometry.SimpleGeometryCursor pointCurs  = new com.epl.geometry.SimpleGeometryCursor(point);
            com.epl.geometry.SpatialReference     spatialRef = com.epl.geometry.SpatialReference.Create(3857);
            com.epl.geometry.Envelope2D           envelope   = new com.epl.geometry.Envelope2D();
            envelope.xmin = 0;
            envelope.xmax = 20;
            envelope.ymin = 5;
            envelope.ymax = 15;
            // Cursor implementation
            com.epl.geometry.GeometryCursor clipPolygonCurs = clipOp.Execute(polygonCurs, envelope, spatialRef, null);
            com.epl.geometry.Polygon        clippedPolygon  = (com.epl.geometry.Polygon)clipPolygonCurs.Next();
            double area = clippedPolygon.CalculateArea2D();

            NUnit.Framework.Assert.IsTrue(System.Math.Abs(area - 25) < 0.00001);
            // Single Geometry implementation
            clippedPolygon = (com.epl.geometry.Polygon)clipOp.Execute(polygon, envelope, spatialRef, null);
            area           = clippedPolygon.CalculateArea2D();
            NUnit.Framework.Assert.IsTrue(System.Math.Abs(area - 25) < 0.00001);
            // Cursor implementation
            com.epl.geometry.GeometryCursor clipPolylineCurs = clipOp.Execute(polylineCurs, envelope, spatialRef, null);
            com.epl.geometry.Polyline       clippedPolyline  = (com.epl.geometry.Polyline)clipPolylineCurs.Next();
            double length = clippedPolyline.CalculateLength2D();

            NUnit.Framework.Assert.IsTrue(System.Math.Abs(length - 10 * System.Math.Sqrt(2.0)) < 1e-10);
            // Single Geometry implementation
            clippedPolyline = (com.epl.geometry.Polyline)clipOp.Execute(polyline, envelope, spatialRef, null);
            length          = clippedPolyline.CalculateLength2D();
            NUnit.Framework.Assert.IsTrue(System.Math.Abs(length - 10 * System.Math.Sqrt(2.0)) < 1e-10);
            // Cursor implementation
            com.epl.geometry.GeometryCursor clipMulti_pointCurs = clipOp.Execute(multipointCurs, envelope, spatialRef, null);
            com.epl.geometry.MultiPoint     clipped_multi_point = (com.epl.geometry.MultiPoint)clipMulti_pointCurs.Next();
            int pointCount = clipped_multi_point.GetPointCount();

            NUnit.Framework.Assert.IsTrue(pointCount == 2);
            // Cursor implementation
            com.epl.geometry.GeometryCursor clipPointCurs = clipOp.Execute(pointCurs, envelope, spatialRef, null);
            com.epl.geometry.Point          clippedPoint  = (com.epl.geometry.Point)clipPointCurs.Next();
            NUnit.Framework.Assert.IsTrue(clippedPoint != null);
            // RandomTest();
            com.epl.geometry.Polyline _poly = new com.epl.geometry.Polyline();
            _poly.StartPath(2, 2);
            _poly.LineTo(0, 0);
            com.epl.geometry.Envelope2D _env = new com.epl.geometry.Envelope2D();
            _env.SetCoords(2, 1, 5, 3);
            com.epl.geometry.Polyline _clippedPolyline = (com.epl.geometry.Polyline)clipOp.Execute(_poly, _env, spatialRef, null);
            NUnit.Framework.Assert.IsTrue(_clippedPolyline.IsEmpty());
            {
                com.epl.geometry.Polygon poly = new com.epl.geometry.Polygon();
                poly.AddEnvelope(new com.epl.geometry.Envelope2D(0, 0, 100, 100), false);
                poly.AddEnvelope(new com.epl.geometry.Envelope2D(5, 5, 95, 95), true);
                com.epl.geometry.Polygon clippedPoly = (com.epl.geometry.Polygon)clipOp.Execute(poly, new com.epl.geometry.Envelope2D(-10, -10, 110, 50), spatialRef, null);
                NUnit.Framework.Assert.IsTrue(clippedPoly.GetPathCount() == 1);
                NUnit.Framework.Assert.IsTrue(clippedPoly.GetPointCount() == 8);
            }
        }
Example #16
0
 private static void ShowProjectedGeometryInfo(com.epl.geometry.MapGeometry mapGeom)
 {
     System.Console.Out.WriteLine("\n");
     com.epl.geometry.MapGeometry geom = mapGeom;
     // while ((geom = geomCursor.next()) != null) {
     if (geom.GetGeometry() is com.epl.geometry.Point)
     {
         com.epl.geometry.Point pnt = (com.epl.geometry.Point)geom.GetGeometry();
         System.Console.Out.WriteLine("Point(" + pnt.GetX() + " , " + pnt.GetY() + ")");
         if (geom.GetSpatialReference() == null)
         {
             System.Console.Out.WriteLine("No spatial reference");
         }
         else
         {
             System.Console.Out.WriteLine("wkid: " + geom.GetSpatialReference().GetID());
         }
     }
     else
     {
         if (geom.GetGeometry() is com.epl.geometry.MultiPoint)
         {
             com.epl.geometry.MultiPoint mp = (com.epl.geometry.MultiPoint)geom.GetGeometry();
             System.Console.Out.WriteLine("Multipoint has " + mp.GetPointCount() + " points.");
             System.Console.Out.WriteLine("wkid: " + geom.GetSpatialReference().GetID());
         }
         else
         {
             if (geom.GetGeometry() is com.epl.geometry.Polygon)
             {
                 com.epl.geometry.Polygon mp = (com.epl.geometry.Polygon)geom.GetGeometry();
                 System.Console.Out.WriteLine("Polygon has " + mp.GetPointCount() + " points and " + mp.GetPathCount() + " parts.");
                 if (mp.GetPathCount() > 1)
                 {
                     System.Console.Out.WriteLine("Part start of 2nd segment : " + mp.GetPathStart(1));
                     System.Console.Out.WriteLine("Part end of 2nd segment   : " + mp.GetPathEnd(1));
                     System.Console.Out.WriteLine("Part size of 2nd segment  : " + mp.GetPathSize(1));
                     int start = mp.GetPathStart(1);
                     int end   = mp.GetPathEnd(1);
                     for (int i = start; i < end; i++)
                     {
                         com.epl.geometry.Point pp = mp.GetPoint(i);
                         System.Console.Out.WriteLine("Point(" + i + ") = (" + pp.GetX() + ", " + pp.GetY() + ")");
                     }
                 }
                 System.Console.Out.WriteLine("wkid: " + geom.GetSpatialReference().GetID());
             }
             else
             {
                 if (geom.GetGeometry() is com.epl.geometry.Polyline)
                 {
                     com.epl.geometry.Polyline mp = (com.epl.geometry.Polyline)geom.GetGeometry();
                     System.Console.Out.WriteLine("Polyline has " + mp.GetPointCount() + " points and " + mp.GetPathCount() + " parts.");
                     System.Console.Out.WriteLine("Part start of 2nd segment : " + mp.GetPathStart(1));
                     System.Console.Out.WriteLine("Part end of 2nd segment   : " + mp.GetPathEnd(1));
                     System.Console.Out.WriteLine("Part size of 2nd segment  : " + mp.GetPathSize(1));
                     int start = mp.GetPathStart(1);
                     int end   = mp.GetPathEnd(1);
                     for (int i = start; i < end; i++)
                     {
                         com.epl.geometry.Point pp = mp.GetPoint(i);
                         System.Console.Out.WriteLine("Point(" + i + ") = (" + pp.GetX() + ", " + pp.GetY() + ")");
                     }
                     System.Console.Out.WriteLine("wkid: " + geom.GetSpatialReference().GetID());
                 }
             }
         }
     }
 }
        public static void TestDifferenceAndSymmetricDifference()
        {
            com.epl.geometry.OperatorFactoryLocal engine       = com.epl.geometry.OperatorFactoryLocal.GetInstance();
            com.epl.geometry.OperatorDifference   differenceOp = (com.epl.geometry.OperatorDifference)engine.GetOperator(com.epl.geometry.Operator.Type.Difference);
            com.epl.geometry.SpatialReference     spatialRef   = com.epl.geometry.SpatialReference.Create(102113);
            com.epl.geometry.Polygon    polygon1      = MakePolygon1();
            com.epl.geometry.Polygon    polygon2      = MakePolygon2();
            com.epl.geometry.Polyline   polyline1     = MakePolyline1();
            com.epl.geometry.MultiPoint multipoint1   = MakeMultiPoint1();
            com.epl.geometry.MultiPoint multipoint2   = MakeMultiPoint2();
            com.epl.geometry.MultiPoint multipoint3   = MakeMultiPoint3();
            com.epl.geometry.Point      point1        = MakePoint1();
            com.epl.geometry.Point      point2        = MakePoint2();
            com.epl.geometry.Envelope   envelope1     = MakeEnvelope1();
            com.epl.geometry.Envelope   envelope2     = MakeEnvelope2();
            com.epl.geometry.Envelope   envelope3     = MakeEnvelope3();
            com.epl.geometry.Polygon    outputPolygon = (com.epl.geometry.Polygon)differenceOp.Execute(polygon1, polygon2, spatialRef, null);
            double area = outputPolygon.CalculateArea2D();

            NUnit.Framework.Assert.IsTrue(System.Math.Abs(area - 75) <= 0.001);
            {
                com.epl.geometry.Point            point_1        = new com.epl.geometry.Point(-130, 10);
                com.epl.geometry.Point            point_2        = new com.epl.geometry.Point(-130, 10);
                com.epl.geometry.Geometry         baseGeom       = new com.epl.geometry.Point(point_1.GetX(), point_1.GetY());
                com.epl.geometry.Geometry         comparisonGeom = new com.epl.geometry.Point(point_2.GetX(), point2.GetY());
                com.epl.geometry.SpatialReference sr             = com.epl.geometry.SpatialReference.Create(4326);
                com.epl.geometry.Geometry         geom           = differenceOp.Execute(baseGeom, comparisonGeom, sr, null);
            }
            com.epl.geometry.OperatorSymmetricDifference symDifferenceOp = (com.epl.geometry.OperatorSymmetricDifference)engine.GetOperator(com.epl.geometry.Operator.Type.SymmetricDifference);
            outputPolygon = (com.epl.geometry.Polygon)symDifferenceOp.Execute(polygon1, polygon2, spatialRef, null);
            area          = outputPolygon.CalculateArea2D();
            NUnit.Framework.Assert.IsTrue(System.Math.Abs(area - 150) <= 0.001);
            com.epl.geometry.Polyline outputPolyline = (com.epl.geometry.Polyline)differenceOp.Execute(polyline1, polygon1, spatialRef, null);
            double length = outputPolyline.CalculateLength2D();

            NUnit.Framework.Assert.IsTrue(System.Math.Abs(length * length - 50) < 0.001);
            com.epl.geometry.MultiPoint outputMultiPoint = (com.epl.geometry.MultiPoint)differenceOp.Execute(multipoint1, polygon1, spatialRef, null);
            int pointCount = outputMultiPoint.GetPointCount();

            NUnit.Framework.Assert.IsTrue(pointCount == 1);
            outputMultiPoint = (com.epl.geometry.MultiPoint)(symDifferenceOp.Execute(multipoint1, point1, spatialRef, null));
            pointCount       = outputMultiPoint.GetPointCount();
            NUnit.Framework.Assert.IsTrue(pointCount == 2);
            outputMultiPoint = (com.epl.geometry.MultiPoint)(symDifferenceOp.Execute(multipoint1, point2, spatialRef, null));
            pointCount       = outputMultiPoint.GetPointCount();
            NUnit.Framework.Assert.IsTrue(pointCount == 4);
            outputMultiPoint = (com.epl.geometry.MultiPoint)(differenceOp.Execute(multipoint1, point1, spatialRef, null));
            pointCount       = outputMultiPoint.GetPointCount();
            NUnit.Framework.Assert.IsTrue(pointCount == 2);
            outputMultiPoint = (com.epl.geometry.MultiPoint)(differenceOp.Execute(multipoint1, point2, spatialRef, null));
            pointCount       = outputMultiPoint.GetPointCount();
            NUnit.Framework.Assert.IsTrue(pointCount == 3);
            outputPolygon = (com.epl.geometry.Polygon)(differenceOp.Execute(polygon1, envelope1, spatialRef, null));
            area          = outputPolygon.CalculateArea2D();
            NUnit.Framework.Assert.IsTrue(System.Math.Abs(area - 75) <= 0.001);
            outputPolygon = (com.epl.geometry.Polygon)(differenceOp.Execute(polygon2, envelope2, spatialRef, null));
            area          = outputPolygon.CalculateArea2D();
            NUnit.Framework.Assert.IsTrue(System.Math.Abs(area - 75) <= 0.001);
            outputPolyline = (com.epl.geometry.Polyline)(differenceOp.Execute(polyline1, envelope2, spatialRef, null));
            length         = outputPolyline.CalculateLength2D();
            NUnit.Framework.Assert.IsTrue(System.Math.Abs(length * length - 50) <= 0.001);
            outputMultiPoint = (com.epl.geometry.MultiPoint)(differenceOp.Execute(multipoint1, envelope2, spatialRef, null));
            pointCount       = outputMultiPoint.GetPointCount();
            NUnit.Framework.Assert.IsTrue(pointCount == 1);
            outputMultiPoint = (com.epl.geometry.MultiPoint)(differenceOp.Execute(multipoint2, envelope2, spatialRef, null));
            pointCount       = outputMultiPoint.GetPointCount();
            NUnit.Framework.Assert.IsTrue(pointCount == 6);
            outputMultiPoint = (com.epl.geometry.MultiPoint)(differenceOp.Execute(multipoint3, envelope2, spatialRef, null));
            pointCount       = outputMultiPoint.GetPointCount();
            NUnit.Framework.Assert.IsTrue(pointCount == 0);
            com.epl.geometry.Point outputPoint = (com.epl.geometry.Point)(differenceOp.Execute(point1, envelope2, spatialRef, null));
            NUnit.Framework.Assert.IsTrue(!outputPoint.IsEmpty());
            outputPoint = (com.epl.geometry.Point)(differenceOp.Execute(point2, envelope2, spatialRef, null));
            NUnit.Framework.Assert.IsTrue(outputPoint.IsEmpty());
            outputPolygon = (com.epl.geometry.Polygon)(differenceOp.Execute(envelope3, envelope2, spatialRef, null));
            NUnit.Framework.Assert.IsTrue(outputPolygon != null && outputPolygon.IsEmpty());
            outputPolygon = (com.epl.geometry.Polygon)(symDifferenceOp.Execute(envelope3, envelope3, spatialRef, null));
            NUnit.Framework.Assert.IsTrue(outputPolygon != null && outputPolygon.IsEmpty());
            outputPoint = (com.epl.geometry.Point)(differenceOp.Execute(point1, polygon1, spatialRef, null));
            NUnit.Framework.Assert.IsTrue(outputPoint != null);
        }
        private static void ExportMultiPointToJson(com.epl.geometry.MultiPoint mpt, com.epl.geometry.SpatialReference spatialReference, com.epl.geometry.JsonWriter jsonWriter, System.Collections.Generic.IDictionary <string, object> exportProperties)
        {
            bool bExportZs    = mpt.HasAttribute(com.epl.geometry.VertexDescription.Semantics.Z);
            bool bExportMs    = mpt.HasAttribute(com.epl.geometry.VertexDescription.Semantics.M);
            bool bPositionAsF = false;
            int  decimals     = 17;

            if (exportProperties != null)
            {
                object numberOfDecimalsXY = exportProperties["numberOfDecimalsXY"];
                if (numberOfDecimalsXY != null && numberOfDecimalsXY is java.lang.Number)
                {
                    bPositionAsF = true;
                    decimals     = ((java.lang.Number)numberOfDecimalsXY);
                }
            }
            jsonWriter.StartObject();
            if (bExportZs)
            {
                jsonWriter.AddPairBoolean("hasZ", true);
            }
            if (bExportMs)
            {
                jsonWriter.AddPairBoolean("hasM", true);
            }
            jsonWriter.AddPairArray("points");
            if (!mpt.IsEmpty())
            {
                com.epl.geometry.MultiPointImpl mpImpl = (com.epl.geometry.MultiPointImpl)mpt._getImpl();
                // get impl
                // for
                // faster
                // access
                com.epl.geometry.AttributeStreamOfDbl zs = null;
                com.epl.geometry.AttributeStreamOfDbl ms = null;
                if (bExportZs)
                {
                    zs = (com.epl.geometry.AttributeStreamOfDbl)mpImpl.GetAttributeStreamRef(com.epl.geometry.VertexDescription.Semantics.Z);
                }
                if (bExportMs)
                {
                    ms = (com.epl.geometry.AttributeStreamOfDbl)mpImpl.GetAttributeStreamRef(com.epl.geometry.VertexDescription.Semantics.M);
                }
                com.epl.geometry.Point2D pt = new com.epl.geometry.Point2D();
                int n = mpt.GetPointCount();
                for (int i = 0; i < n; i++)
                {
                    mpt.GetXY(i, pt);
                    jsonWriter.AddValueArray();
                    if (bPositionAsF)
                    {
                        jsonWriter.AddValueDouble(pt.x, decimals, true);
                        jsonWriter.AddValueDouble(pt.y, decimals, true);
                    }
                    else
                    {
                        jsonWriter.AddValueDouble(pt.x);
                        jsonWriter.AddValueDouble(pt.y);
                    }
                    if (bExportZs)
                    {
                        double z = zs.Get(i);
                        jsonWriter.AddValueDouble(z);
                    }
                    if (bExportMs)
                    {
                        double m = ms.Get(i);
                        jsonWriter.AddValueDouble(m);
                    }
                    jsonWriter.EndArray();
                }
            }
            jsonWriter.EndArray();
            if (spatialReference != null)
            {
                WriteSR(spatialReference, jsonWriter);
            }
            jsonWriter.EndObject();
        }