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);
        }
示例#2
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);
        }
        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);
            }
        }
 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);
 }
 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");
     }
 }
        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);
        }