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);
            }
        }
Пример #2
0
 public OGCMultiPoint(com.epl.geometry.ogc.OGCPoint startPoint, com.epl.geometry.ogc.OGCPoint endPoint)
 {
     multiPoint = new com.epl.geometry.MultiPoint();
     multiPoint.Add((com.epl.geometry.Point)startPoint.GetEsriGeometry());
     multiPoint.Add((com.epl.geometry.Point)endPoint.GetEsriGeometry());
     esriSR = startPoint.esriSR;
 }
        private com.epl.geometry.Geometry Get_result_geometry(int dim)
        {
            System.Diagnostics.Debug.Assert((m_dim_geom_counts[dim] > 0));
            System.Collections.Generic.SortedDictionary <int, com.epl.geometry.OperatorUnionCursor.Bin_type> map = m_union_bins[dim];
            System.Collections.Generic.KeyValuePair <int, com.epl.geometry.OperatorUnionCursor.Bin_type>     e   = map.First();
            com.epl.geometry.OperatorUnionCursor.Bin_type bin = e.Value;
            com.epl.geometry.Geometry resG;
            resG = bin.Back_pair().geom;
            bool unioned = bin.Back_pair().unioned;

            map.Remove(e.Key);
            if (unioned)
            {
                resG = com.epl.geometry.OperatorSimplify.Local().Execute(resG, m_spatial_reference, false, m_progress_tracker);
                if (dim == 0 && resG.GetType() == com.epl.geometry.Geometry.Type.Point)
                {
                    // must
                    // return
                    // multipoint
                    // for
                    // points
                    com.epl.geometry.MultiPoint mp = new com.epl.geometry.MultiPoint(resG.GetDescription());
                    if (!resG.IsEmpty())
                    {
                        mp.Add((com.epl.geometry.Point)resG);
                    }
                    resG = mp;
                }
            }
            return(resG);
        }
Пример #4
0
 public virtual void TestOffsetPoint()
 {
     try
     {
         com.epl.geometry.Point point = new com.epl.geometry.Point();
         point.SetXY(0, 0);
         com.epl.geometry.OperatorOffset offset     = (com.epl.geometry.OperatorOffset)com.epl.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.epl.geometry.Operator.Type.Offset);
         com.epl.geometry.Geometry       outputGeom = offset.Execute(point, null, 2, com.epl.geometry.OperatorOffset.JoinType.Round, 2, 0, null);
         NUnit.Framework.Assert.IsNull(outputGeom);
     }
     catch (System.Exception)
     {
     }
     try
     {
         com.epl.geometry.MultiPoint mp = new com.epl.geometry.MultiPoint();
         mp.Add(0, 0);
         mp.Add(10, 10);
         com.epl.geometry.OperatorOffset offset     = (com.epl.geometry.OperatorOffset)com.epl.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.epl.geometry.Operator.Type.Offset);
         com.epl.geometry.Geometry       outputGeom = offset.Execute(mp, null, 2, com.epl.geometry.OperatorOffset.JoinType.Round, 2, 0, null);
         NUnit.Framework.Assert.IsNull(outputGeom);
     }
     catch (System.Exception)
     {
     }
 }
Пример #5
0
        public virtual void TestEqualsOnMultiPoints()
        {
            com.epl.geometry.SpatialReference sr     = com.epl.geometry.SpatialReference.Create(4326);
            com.epl.geometry.MultiPoint       baseMp = new com.epl.geometry.MultiPoint();
            com.epl.geometry.MultiPoint       compMp = new com.epl.geometry.MultiPoint();
            baseMp.Add(new com.epl.geometry.Point(-116, 40));
            baseMp.Add(new com.epl.geometry.Point(-120, 39));
            baseMp.Add(new com.epl.geometry.Point(-121, 10));
            baseMp.Add(new com.epl.geometry.Point(-130, 12));
            baseMp.Add(new com.epl.geometry.Point(-108, 25));
            compMp.Add(new com.epl.geometry.Point(-116, 40));
            compMp.Add(new com.epl.geometry.Point(-120, 39));
            compMp.Add(new com.epl.geometry.Point(-121, 10));
            compMp.Add(new com.epl.geometry.Point(-130, 12));
            compMp.Add(new com.epl.geometry.Point(-108, 25));
            bool isEqual;

            try
            {
                isEqual = com.epl.geometry.GeometryEngine.Equals(baseMp, compMp, sr);
            }
            catch (System.ArgumentException)
            {
                isEqual = false;
            }
            NUnit.Framework.Assert.IsTrue(isEqual);
        }
Пример #6
0
        public virtual void TestBufferMultiPoint()
        {
            com.epl.geometry.SpatialReference sr        = com.epl.geometry.SpatialReference.Create(4326);
            com.epl.geometry.OperatorBuffer   buffer    = (com.epl.geometry.OperatorBuffer)com.epl.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.epl.geometry.Operator.Type.Buffer);
            com.epl.geometry.OperatorSimplify simplify  = (com.epl.geometry.OperatorSimplify)com.epl.geometry.OperatorFactoryLocal.GetInstance().GetOperator(com.epl.geometry.Operator.Type.Simplify);
            com.epl.geometry.MultiPoint       inputGeom = new com.epl.geometry.MultiPoint();
            inputGeom.Add(12, 120);
            inputGeom.Add(20, 120);
            com.epl.geometry.Geometry result = buffer.Execute(inputGeom, sr, 40.0, null);
            NUnit.Framework.Assert.IsTrue(result.GetType().Value() == com.epl.geometry.Geometry.GeometryType.Polygon);
            com.epl.geometry.Polygon    poly  = (com.epl.geometry.Polygon)(result);
            com.epl.geometry.Envelope2D env2D = new com.epl.geometry.Envelope2D();
            result.QueryEnvelope2D(env2D);
            NUnit.Framework.Assert.IsTrue(System.Math.Abs(env2D.GetWidth() - 80 - 8) < 0.001 && System.Math.Abs(env2D.GetHeight() - 80) < 0.001);
            NUnit.Framework.Assert.IsTrue(System.Math.Abs(env2D.GetCenterX() - 16) < 0.001 && System.Math.Abs(env2D.GetCenterY() - 120) < 0.001);
            int pathCount = poly.GetPathCount();

            NUnit.Framework.Assert.IsTrue(pathCount == 1);
            int pointCount = poly.GetPointCount();

            NUnit.Framework.Assert.IsTrue(System.Math.Abs(pointCount - 108.0) < 10);
            NUnit.Framework.Assert.IsTrue(simplify.IsSimpleAsFeature(result, sr, null));
            {
                result = buffer.Execute(inputGeom, sr, 0, null);
                NUnit.Framework.Assert.IsTrue(result.GetType().Value() == com.epl.geometry.Geometry.GeometryType.Polygon);
                NUnit.Framework.Assert.IsTrue(result.IsEmpty());
            }
            {
                result = buffer.Execute(inputGeom, sr, -1, null);
                NUnit.Framework.Assert.IsTrue(result.GetType().Value() == com.epl.geometry.Geometry.GeometryType.Polygon);
                NUnit.Framework.Assert.IsTrue(result.IsEmpty());
            }
        }
        public virtual void TestMultiPointAndMultiPoint2()
        {
            com.epl.geometry.MultiPoint basePl = new com.epl.geometry.MultiPoint();
            basePl.Add(new com.epl.geometry.Point(-116, 20));
            basePl.Add(new com.epl.geometry.Point(-118, 21));
            com.epl.geometry.MultiPoint compPl = new com.epl.geometry.MultiPoint();
            compPl.Add(new com.epl.geometry.Point(-116, 20));
            compPl.Add(new com.epl.geometry.Point(-118, 21));
            int noException = 1;

            // no exception
            com.epl.geometry.Geometry intersectGeom = null;
            try
            {
                intersectGeom = com.epl.geometry.GeometryEngine.Intersect(basePl, compPl, com.epl.geometry.SpatialReference.Create(4326));
            }
            catch (System.Exception)
            {
                noException = 0;
            }
            NUnit.Framework.Assert.AreEqual(noException, 1);
            NUnit.Framework.Assert.IsNotNull(intersectGeom);
            NUnit.Framework.Assert.IsTrue(intersectGeom.GetType() == com.epl.geometry.Geometry.Type.MultiPoint);
            com.epl.geometry.MultiPoint ip = (com.epl.geometry.MultiPoint)intersectGeom;
            NUnit.Framework.Assert.AreEqual(ip.GetPoint(0).GetX(), -116, 0.1E7);
            NUnit.Framework.Assert.AreEqual(ip.GetPoint(0).GetY(), 20, 0.1E7);
            NUnit.Framework.Assert.AreEqual(ip.GetPoint(0).GetX(), -118, 0.1E7);
            NUnit.Framework.Assert.AreEqual(ip.GetPoint(0).GetY(), 21, 0.1E7);
        }
        public virtual void TestMultiPointAndMultiPoint3()
        {
            com.epl.geometry.MultiPoint basePl = new com.epl.geometry.MultiPoint();
            basePl.Add(new com.epl.geometry.Point(-116, 21));
            basePl.Add(new com.epl.geometry.Point(-117, 20));
            com.epl.geometry.MultiPoint compPl = new com.epl.geometry.MultiPoint();
            compPl.Add(new com.epl.geometry.Point(-116, 20));
            compPl.Add(new com.epl.geometry.Point(-117, 21));
            compPl.Add(new com.epl.geometry.Point(-118, 20));
            compPl.Add(new com.epl.geometry.Point(-119, 21));
            int noException = 1;

            // no exception
            com.epl.geometry.Geometry intersectGeom = null;
            try
            {
                intersectGeom = com.epl.geometry.GeometryEngine.Intersect(basePl, compPl, com.epl.geometry.SpatialReference.Create(4326));
            }
            catch (System.Exception)
            {
                noException = 0;
            }
            NUnit.Framework.Assert.AreEqual(noException, 1);
            NUnit.Framework.Assert.IsTrue(intersectGeom.IsEmpty());
        }
Пример #9
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());
     }
 }
        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);
        }
Пример #11
0
        public static void Test2()
        {
            com.epl.geometry.MultiPoint multipoint = new com.epl.geometry.MultiPoint();
            for (int i = 0; i < 100; i++)
            {
                for (int j = 0; j < 100; j++)
                {
                    multipoint.Add(i, j);
                }
            }
            com.epl.geometry.Envelope2D extent = new com.epl.geometry.Envelope2D();
            multipoint.QueryEnvelope2D(extent);
            com.epl.geometry.MultiPointImpl            multipointImpl = (com.epl.geometry.MultiPointImpl)multipoint._getImpl();
            com.epl.geometry.QuadTree                  quadtree       = BuildQuadTree_(multipointImpl);
            com.epl.geometry.QuadTree.QuadTreeIterator qtIter         = quadtree.GetIterator();
            NUnit.Framework.Assert.IsTrue(qtIter.Next() == -1);
            int count = 0;

            qtIter.ResetIterator(extent, 0.0);
            while (qtIter.Next() != -1)
            {
                count++;
            }
            NUnit.Framework.Assert.IsTrue(count == 10000);
        }
        /// <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);
        }
Пример #13
0
        public virtual void TestEmptyMultiPoint()
        {
            com.epl.geometry.MultiPoint mp = new com.epl.geometry.MultiPoint();
            com.epl.geometry.OperatorExportToGeoJson exporter = (com.epl.geometry.OperatorExportToGeoJson)factory.GetOperator(com.epl.geometry.Operator.Type.ExportToGeoJson);
            string result = exporter.Execute(mp);

            NUnit.Framework.Assert.AreEqual("{\"type\":\"MultiPoint\",\"coordinates\":[]}", result);
        }
Пример #14
0
 private static com.epl.geometry.MultiPoint MakeMultiPoint()
 {
     com.epl.geometry.MultiPoint mpoint = new com.epl.geometry.MultiPoint();
     mpoint.Add(0, 30);
     mpoint.Add(15, 15);
     mpoint.Add(0, 15);
     return(mpoint);
 }
Пример #15
0
        internal static com.epl.geometry.Geometry Calculate(com.epl.geometry.Geometry geom, com.epl.geometry.ProgressTracker progress_tracker)
        {
            int gt = geom.GetType().Value();

            if (gt == com.epl.geometry.Geometry.GeometryType.Polygon)
            {
                com.epl.geometry.Polyline dst = new com.epl.geometry.Polyline(geom.GetDescription());
                if (!geom.IsEmpty())
                {
                    ((com.epl.geometry.MultiPathImpl)geom._getImpl())._copyToUnsafe((com.epl.geometry.MultiPathImpl)dst._getImpl());
                }
                return(dst);
            }
            else
            {
                if (gt == com.epl.geometry.Geometry.GeometryType.Polyline)
                {
                    return(CalculatePolylineBoundary_(geom._getImpl(), progress_tracker, false, null));
                }
                else
                {
                    if (gt == com.epl.geometry.Geometry.GeometryType.Envelope)
                    {
                        com.epl.geometry.Polyline dst = new com.epl.geometry.Polyline(geom.GetDescription());
                        if (!geom.IsEmpty())
                        {
                            dst.AddEnvelope((com.epl.geometry.Envelope)geom, false);
                        }
                        return(dst);
                    }
                    else
                    {
                        if (com.epl.geometry.Geometry.IsSegment(gt))
                        {
                            com.epl.geometry.MultiPoint mp = new com.epl.geometry.MultiPoint(geom.GetDescription());
                            if (!geom.IsEmpty() && !((com.epl.geometry.Segment)geom).IsClosed())
                            {
                                com.epl.geometry.Point pt = new com.epl.geometry.Point();
                                ((com.epl.geometry.Segment)geom).QueryStart(pt);
                                mp.Add(pt);
                                ((com.epl.geometry.Segment)geom).QueryEnd(pt);
                                mp.Add(pt);
                            }
                            return(mp);
                        }
                        else
                        {
                            if (com.epl.geometry.Geometry.IsPoint(gt))
                            {
                                // returns empty point for points and multipoints.
                                return(null);
                            }
                        }
                    }
                }
            }
            throw new System.ArgumentException();
        }
        internal static com.epl.geometry.Geometry MultiPointTaggedText(int import_flags, com.epl.geometry.WktParser wkt_parser)
        {
            com.epl.geometry.MultiPoint           multi_point;
            com.epl.geometry.MultiPointImpl       multi_point_impl;
            com.epl.geometry.AttributeStreamOfDbl zs = null;
            com.epl.geometry.AttributeStreamOfDbl ms = null;
            com.epl.geometry.AttributeStreamOfDbl position;
            position         = (com.epl.geometry.AttributeStreamOfDbl)com.epl.geometry.AttributeStreamBase.CreateDoubleStream(0);
            multi_point      = new com.epl.geometry.MultiPoint();
            multi_point_impl = (com.epl.geometry.MultiPointImpl)multi_point._getImpl();
            int current_token = wkt_parser.NextToken();

            if (current_token == com.epl.geometry.WktParser.WktToken.attribute_z)
            {
                zs = (com.epl.geometry.AttributeStreamOfDbl)com.epl.geometry.AttributeStreamBase.CreateDoubleStream(0, com.epl.geometry.NumberUtils.TheNaN);
                multi_point_impl.AddAttribute(com.epl.geometry.VertexDescription.Semantics.Z);
                wkt_parser.NextToken();
            }
            else
            {
                if (current_token == com.epl.geometry.WktParser.WktToken.attribute_m)
                {
                    ms = (com.epl.geometry.AttributeStreamOfDbl)com.epl.geometry.AttributeStreamBase.CreateDoubleStream(0, com.epl.geometry.NumberUtils.TheNaN);
                    multi_point_impl.AddAttribute(com.epl.geometry.VertexDescription.Semantics.M);
                    wkt_parser.NextToken();
                }
                else
                {
                    if (current_token == com.epl.geometry.WktParser.WktToken.attribute_zm)
                    {
                        zs = (com.epl.geometry.AttributeStreamOfDbl)com.epl.geometry.AttributeStreamBase.CreateDoubleStream(0, com.epl.geometry.NumberUtils.TheNaN);
                        ms = (com.epl.geometry.AttributeStreamOfDbl)com.epl.geometry.AttributeStreamBase.CreateDoubleStream(0, com.epl.geometry.NumberUtils.TheNaN);
                        multi_point_impl.AddAttribute(com.epl.geometry.VertexDescription.Semantics.Z);
                        multi_point_impl.AddAttribute(com.epl.geometry.VertexDescription.Semantics.M);
                        wkt_parser.NextToken();
                    }
                }
            }
            int point_count = MultiPointText(zs, ms, position, wkt_parser);

            if (point_count != 0)
            {
                System.Diagnostics.Debug.Assert((2 * point_count == position.Size()));
                multi_point_impl.Resize(point_count);
                multi_point_impl.SetAttributeStreamRef(com.epl.geometry.VertexDescription.Semantics.POSITION, position);
                if (zs != null)
                {
                    multi_point_impl.SetAttributeStreamRef(com.epl.geometry.VertexDescription.Semantics.Z, zs);
                }
                if (ms != null)
                {
                    multi_point_impl.SetAttributeStreamRef(com.epl.geometry.VertexDescription.Semantics.M, ms);
                }
                multi_point_impl.NotifyModified(com.epl.geometry.MultiVertexGeometryImpl.DirtyFlags.DirtyAll);
            }
            return(multi_point);
        }
Пример #17
0
        public virtual void TestMultiPointGeometryEngine()
        {
            com.epl.geometry.MultiPoint mp = new com.epl.geometry.MultiPoint();
            mp.Add(10.0, 20.0);
            mp.Add(20.0, 30.0);
            string result = com.epl.geometry.GeometryEngine.GeometryToGeoJson(mp);

            NUnit.Framework.Assert.AreEqual("{\"type\":\"MultiPoint\",\"coordinates\":[[10,20],[20,30]]}", result);
        }
        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);
        }
Пример #19
0
        public virtual void TestOGCMultiPoint()
        {
            com.epl.geometry.MultiPoint mp = new com.epl.geometry.MultiPoint();
            mp.Add(10.0, 20.0);
            mp.Add(20.0, 30.0);
            com.epl.geometry.ogc.OGCMultiPoint ogcMultiPoint = new com.epl.geometry.ogc.OGCMultiPoint(mp, null);
            string result = ogcMultiPoint.AsGeoJson();

            NUnit.Framework.Assert.AreEqual("{\"type\":\"MultiPoint\",\"coordinates\":[[10,20],[20,30]],\"crs\":null}", result);
        }
 public virtual void TestSerializeMultiPoint()
 {
     try
     {
         java.io.ByteArrayOutputStream streamOut = new java.io.ByteArrayOutputStream();
         java.io.ObjectOutputStream    oo        = new java.io.ObjectOutputStream(streamOut);
         com.epl.geometry.MultiPoint   pt        = new com.epl.geometry.MultiPoint();
         pt.Add(10, 30);
         pt.Add(120, 40);
         oo.WriteObject(pt);
         System.IO.BinaryWriter      streamIn = new System.IO.BinaryWriter(streamOut.ToByteArray());
         java.io.ObjectInputStream   ii       = new java.io.ObjectInputStream(streamIn);
         com.epl.geometry.MultiPoint ptRes    = (com.epl.geometry.MultiPoint)ii.ReadObject();
         NUnit.Framework.Assert.IsTrue(ptRes.Equals(pt));
     }
     catch (System.Exception)
     {
         Fail("MultiPoint serialization failure");
     }
     //try
     //{
     //FileOutputStream streamOut = new FileOutputStream("c:/temp/savedMultiPoint1.txt");
     //ObjectOutputStream oo = new ObjectOutputStream(streamOut);
     //MultiPoint pt = new MultiPoint();
     //pt.add(10, 30);
     //pt.add(120, 40);
     //oo.writeObject(pt);
     //}
     //catch(Exception ex)
     //{
     //fail("MultiPoint serialization failure");
     //}
     try
     {
         java.io.InputStream         s     = typeof(com.epl.geometry.TestSerialization).GetResourceAsStream("savedMultiPoint.txt");
         java.io.ObjectInputStream   ii    = new java.io.ObjectInputStream(s);
         com.epl.geometry.MultiPoint ptRes = (com.epl.geometry.MultiPoint)ii.ReadObject();
         NUnit.Framework.Assert.IsTrue(ptRes.GetPoint(1).GetY() == 40);
     }
     catch (System.Exception)
     {
         Fail("MultiPoint serialization failure");
     }
     try
     {
         java.io.InputStream         s     = typeof(com.epl.geometry.TestSerialization).GetResourceAsStream("savedMultiPoint1.txt");
         java.io.ObjectInputStream   ii    = new java.io.ObjectInputStream(s);
         com.epl.geometry.MultiPoint ptRes = (com.epl.geometry.MultiPoint)ii.ReadObject();
         NUnit.Framework.Assert.IsTrue(ptRes.GetPoint(1).GetY() == 40);
     }
     catch (System.Exception)
     {
         Fail("MultiPoint serialization failure");
     }
 }
Пример #21
0
 public static com.epl.geometry.MultiPoint MakeMultiPoint3()
 {
     com.epl.geometry.MultiPoint mpoint = new com.epl.geometry.MultiPoint();
     com.epl.geometry.Point2D    pt1    = new com.epl.geometry.Point2D();
     pt1.x = 1.0;
     pt1.y = 1.0;
     com.epl.geometry.Point2D pt2 = new com.epl.geometry.Point2D();
     pt2.x = 5.0;
     pt2.y = 5.0;
     mpoint.Add(pt1.x, pt1.y);
     mpoint.Add(pt2.x, pt2.y);
     return(mpoint);
 }
Пример #22
0
 public static com.epl.geometry.MultiPoint MakeMultiPoint2()
 {
     com.epl.geometry.MultiPoint mpoint = new com.epl.geometry.MultiPoint();
     com.epl.geometry.Point2D    pt1    = new com.epl.geometry.Point2D();
     pt1.x = 1.0;
     pt1.y = 1.0;
     com.epl.geometry.Point2D pt2 = new com.epl.geometry.Point2D();
     pt2.x = 1.0;
     pt2.y = 1.0;
     com.epl.geometry.Point2D pt3 = new com.epl.geometry.Point2D();
     pt3.x = 15.0;
     pt3.y = 15.0;
     com.epl.geometry.Point2D pt4 = new com.epl.geometry.Point2D();
     pt4.x = 15.0;
     pt4.y = 15.0;
     com.epl.geometry.Point2D pt5 = new com.epl.geometry.Point2D();
     pt5.x = 1.0;
     pt5.y = 1.0;
     com.epl.geometry.Point2D pt6 = new com.epl.geometry.Point2D();
     pt6.x = 1.0;
     pt6.y = 1.0;
     com.epl.geometry.Point2D pt7 = new com.epl.geometry.Point2D();
     pt7.x = 15.0;
     pt7.y = 15.0;
     com.epl.geometry.Point2D pt8 = new com.epl.geometry.Point2D();
     pt8.x = 15.0;
     pt8.y = 15.0;
     com.epl.geometry.Point2D pt9 = new com.epl.geometry.Point2D();
     pt9.x = 15.0;
     pt9.y = 15.0;
     com.epl.geometry.Point2D pt10 = new com.epl.geometry.Point2D();
     pt10.x = 1.0;
     pt10.y = 1.0;
     com.epl.geometry.Point2D pt11 = new com.epl.geometry.Point2D();
     pt11.x = 15.0;
     pt11.y = 15.0;
     mpoint.Add(pt1.x, pt1.y);
     mpoint.Add(pt2.x, pt2.y);
     mpoint.Add(pt3.x, pt3.y);
     mpoint.Add(pt4.x, pt4.y);
     mpoint.Add(pt5.x, pt5.y);
     mpoint.Add(pt6.x, pt6.y);
     mpoint.Add(pt7.x, pt7.y);
     mpoint.Add(pt8.x, pt8.y);
     mpoint.Add(pt9.x, pt9.y);
     mpoint.Add(pt10.x, pt10.y);
     mpoint.Add(pt11.x, pt11.y);
     return(mpoint);
 }
        internal static com.epl.geometry.Geometry PointSymDiffPoint_(com.epl.geometry.Point point_a, com.epl.geometry.Point point_b, double tolerance, com.epl.geometry.ProgressTracker progress_tracker)
        {
            double tolerance_cluster    = tolerance * System.Math.Sqrt(2.0) * 1.00001;
            double tolerance_cluster_sq = tolerance_cluster * tolerance_cluster;

            com.epl.geometry.Point2D    pt_a        = point_a.GetXY();
            com.epl.geometry.Point2D    pt_b        = point_b.GetXY();
            com.epl.geometry.MultiPoint multi_point = new com.epl.geometry.MultiPoint(point_a.GetDescription());
            if (com.epl.geometry.Point2D.SqrDistance(pt_a, pt_b) > tolerance_cluster_sq)
            {
                multi_point.Add(point_a);
                multi_point.Add(point_b);
            }
            return(multi_point);
        }
Пример #24
0
 internal static com.epl.geometry.MultiPoint MakeMultiPoint()
 {
     com.epl.geometry.MultiPoint mpoint = new com.epl.geometry.MultiPoint();
     com.epl.geometry.Point2D    pt1    = new com.epl.geometry.Point2D();
     pt1.x = 10;
     pt1.y = 10;
     com.epl.geometry.Point2D pt2 = new com.epl.geometry.Point2D();
     pt2.x = 15;
     pt2.y = 10;
     com.epl.geometry.Point2D pt3 = new com.epl.geometry.Point2D();
     pt3.x = 10;
     pt3.y = 20;
     mpoint.Add(pt1.x, pt1.y);
     mpoint.Add(pt2.x, pt2.y);
     mpoint.Add(pt3.x, pt3.y);
     return(mpoint);
 }
Пример #25
0
        public static void TestDistanceBetweenVariousGeometries()
        {
            com.epl.geometry.Polygon    polygon    = MakePolygon();
            com.epl.geometry.Polyline   polyline   = MakePolyline();
            com.epl.geometry.MultiPoint multipoint = MakeMultiPoint();
            com.epl.geometry.Point      point      = MakePoint();
            // SpatialReference spatialRef =
            // SpatialReference.create(3857);//PCS_WGS_1984_WEB_MERCATOR_AUXSPHERE
            double distance;

            distance = com.epl.geometry.GeometryEngine.Distance(polygon, polyline, null);
            NUnit.Framework.Assert.IsTrue(System.Math.Abs(distance - 5.0) < 0.00001);
            distance = com.epl.geometry.GeometryEngine.Distance(polygon, multipoint, null);
            NUnit.Framework.Assert.IsTrue(System.Math.Abs(distance - 5.0) < 0.00001);
            distance = com.epl.geometry.GeometryEngine.Distance(polygon, point, null);
            NUnit.Framework.Assert.IsTrue(System.Math.Abs(distance - 5.0) < 0.00001);
        }
Пример #26
0
 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 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);
        }
        internal static void ExportMultiPointToWkt(int export_flags, com.epl.geometry.MultiPoint multipoint, System.Text.StringBuilder @string)
        {
            com.epl.geometry.MultiPointImpl multipoint_impl = (com.epl.geometry.MultiPointImpl)multipoint._getImpl();
            int  point_count = multipoint_impl.GetPointCount();
            int  precision   = 17 - (7 & (export_flags >> 13));
            bool b_export_zs = multipoint_impl.HasAttribute(com.epl.geometry.VertexDescription.Semantics.Z) && (export_flags & com.epl.geometry.WktExportFlags.wktExportStripZs) == 0;
            bool b_export_ms = multipoint_impl.HasAttribute(com.epl.geometry.VertexDescription.Semantics.M) && (export_flags & com.epl.geometry.WktExportFlags.wktExportStripMs) == 0;

            com.epl.geometry.AttributeStreamOfDbl position = null;
            com.epl.geometry.AttributeStreamOfDbl zs       = null;
            com.epl.geometry.AttributeStreamOfDbl ms       = null;
            if (point_count > 0)
            {
                position = (com.epl.geometry.AttributeStreamOfDbl)(multipoint_impl.GetAttributeStreamRef(com.epl.geometry.VertexDescription.Semantics.POSITION));
                if (b_export_zs)
                {
                    if (multipoint_impl._attributeStreamIsAllocated(com.epl.geometry.VertexDescription.Semantics.Z))
                    {
                        zs = (com.epl.geometry.AttributeStreamOfDbl)(multipoint_impl.GetAttributeStreamRef(com.epl.geometry.VertexDescription.Semantics.Z));
                    }
                }
                if (b_export_ms)
                {
                    if (multipoint_impl._attributeStreamIsAllocated(com.epl.geometry.VertexDescription.Semantics.M))
                    {
                        ms = (com.epl.geometry.AttributeStreamOfDbl)(multipoint_impl.GetAttributeStreamRef(com.epl.geometry.VertexDescription.Semantics.M));
                    }
                }
            }
            if ((export_flags & com.epl.geometry.WktExportFlags.wktExportPoint) != 0)
            {
                if (point_count > 1)
                {
                    throw new System.ArgumentException("Cannot export a Point with specified export flags: " + export_flags);
                }
                PointTaggedTextFromMultiPoint_(precision, b_export_zs, b_export_ms, zs, ms, position, @string);
            }
            else
            {
                MultiPointTaggedText_(precision, b_export_zs, b_export_ms, zs, ms, position, point_count, @string);
            }
        }
Пример #29
0
            private double BruteForceMultiPointMultiPoint_(com.epl.geometry.MultiPoint geometryA, com.epl.geometry.MultiPoint geometryB, bool geometriesAreDisjoint)
            {
                /* const */
                /* const */
                double minSqrDistance = com.epl.geometry.NumberUtils.DoubleMax();

                com.epl.geometry.Point2D pointA = new com.epl.geometry.Point2D();
                com.epl.geometry.Point2D pointB = new com.epl.geometry.Point2D();
                double sqrDistance = minSqrDistance;

                /* const */
                com.epl.geometry.MultiPointImpl multiPointImplA = (com.epl.geometry.MultiPointImpl)geometryA._getImpl();
                /* const */
                /* const */
                com.epl.geometry.MultiPointImpl multiPointImplB = (com.epl.geometry.MultiPointImpl)geometryB._getImpl();
                /* const */
                int pointCountA = multiPointImplA.GetPointCount();
                int pointCountB = multiPointImplB.GetPointCount();

                for (int i = 0; i < pointCountA; i++)
                {
                    multiPointImplA.GetXY(i, pointA);
                    if (pointCountB > 1 && this.m_env2DgeometryB.SqrDistance(pointA) > minSqrDistance)
                    {
                        continue;
                    }
                    for (int j = 0; j < pointCountB; j++)
                    {
                        multiPointImplB.GetXY(j, pointB);
                        sqrDistance = com.epl.geometry.Point2D.SqrDistance(pointA, pointB);
                        if (sqrDistance < minSqrDistance)
                        {
                            if (sqrDistance == 0.0)
                            {
                                return(0.0);
                            }
                            minSqrDistance = sqrDistance;
                        }
                    }
                }
                return(System.Math.Sqrt(minSqrDistance));
            }
        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);
        }