예제 #1
0
        public virtual void TestEqualsOnPolylines()
        {
            com.epl.geometry.SpatialReference sr     = com.epl.geometry.SpatialReference.Create(4326);
            com.epl.geometry.Polyline         baseMp = new com.epl.geometry.Polyline();
            com.epl.geometry.Polyline         compMp = new com.epl.geometry.Polyline();
            baseMp.StartPath(-116, 40);
            baseMp.LineTo(-120, 39);
            baseMp.LineTo(-121, 10);
            baseMp.LineTo(-130, 12);
            baseMp.LineTo(-108, 25);
            compMp.StartPath(-116, 40);
            compMp.LineTo(-120, 39);
            compMp.LineTo(-121, 10);
            compMp.LineTo(-130, 12);
            compMp.LineTo(-108, 25);
            bool isEqual;

            try
            {
                isEqual = com.epl.geometry.GeometryEngine.Equals(baseMp, compMp, sr);
            }
            catch (System.ArgumentException)
            {
                isEqual = false;
            }
            NUnit.Framework.Assert.IsTrue(isEqual);
        }
        public virtual void TestIntersectBetweenPolylineAndPolygon()
        {
            com.epl.geometry.Polyline basePl = new com.epl.geometry.Polyline();
            basePl.StartPath(new com.epl.geometry.Point(-117, 20));
            basePl.LineTo(new com.epl.geometry.Point(-117, 10));
            basePl.LineTo(new com.epl.geometry.Point(-130, 10));
            basePl.LineTo(new com.epl.geometry.Point(-130, 20));
            basePl.LineTo(new com.epl.geometry.Point(-117, 20));
            com.epl.geometry.Polygon compPl = new com.epl.geometry.Polygon();
            compPl.StartPath(-116, 20);
            compPl.LineTo(-131, 10);
            compPl.LineTo(-121, 50);
            com.epl.geometry.Geometry intersectGeom = null;
            int noException = 1;

            // no exception
            try
            {
                intersectGeom = com.epl.geometry.GeometryEngine.Intersect(basePl, compPl, com.epl.geometry.SpatialReference.Create(4326));
            }
            catch (System.Exception)
            {
                noException = 0;
            }
            NUnit.Framework.Assert.IsNotNull(intersectGeom);
        }
예제 #3
0
        public virtual void TestTouchesOnPolylineAndPolygon()
        {
            com.epl.geometry.SpatialReference sr     = com.epl.geometry.SpatialReference.Create(4326);
            com.epl.geometry.Polygon          basePl = new com.epl.geometry.Polygon();
            basePl.StartPath(new com.epl.geometry.Point(-117, 20));
            basePl.LineTo(new com.epl.geometry.Point(-100, 20));
            basePl.LineTo(new com.epl.geometry.Point(-100, 10));
            basePl.LineTo(new com.epl.geometry.Point(-117, 10));
            com.epl.geometry.Polyline compPl = new com.epl.geometry.Polyline();
            compPl.StartPath(new com.epl.geometry.Point(-117, 20));
            compPl.LineTo(new com.epl.geometry.Point(-108, 25));
            compPl.LineTo(new com.epl.geometry.Point(-100, 20));
            compPl.LineTo(new com.epl.geometry.Point(-100, 30));
            bool isTouched;

            try
            {
                isTouched = com.epl.geometry.GeometryEngine.Touches(basePl, compPl, sr);
            }
            catch (System.ArgumentException)
            {
                isTouched = false;
            }
            NUnit.Framework.Assert.AreEqual(isTouched, true);
        }
 public static void Test4()
 {
     com.epl.geometry.Polyline poly = new com.epl.geometry.Polyline();
     poly.StartPath(0, System.Math.Sqrt(0.0));
     poly.LineTo(0, System.Math.Sqrt(1.0));
     poly.StartPath(0, System.Math.Sqrt(1.0));
     poly.LineTo(0, System.Math.Sqrt(2.0));
     poly.StartPath(0, System.Math.Sqrt(2.0));
     poly.LineTo(0, System.Math.Sqrt(3.0));
     poly.StartPath(0, System.Math.Sqrt(3.0));
     poly.LineTo(0, System.Math.Sqrt(4.0));
     poly.StartPath(0, System.Math.Sqrt(4.0));
     poly.LineTo(0, System.Math.Sqrt(5.0));
     poly.SetAttribute(com.epl.geometry.VertexDescription.Semantics.M, 1, 0, System.Math.Sqrt(1.0));
     poly.SetAttribute(com.epl.geometry.VertexDescription.Semantics.M, 8, 0, System.Math.Sqrt(4.0));
     poly.InterpolateAttributes(com.epl.geometry.VertexDescription.Semantics.M, 0, 1, 4, 0);
     NUnit.Framework.Assert.IsTrue(com.epl.geometry.NumberUtils.IsNaN(poly.GetAttributeAsDbl(com.epl.geometry.VertexDescription.Semantics.M, 0, 0)));
     NUnit.Framework.Assert.IsTrue(poly.GetAttributeAsDbl(com.epl.geometry.VertexDescription.Semantics.M, 1, 0) == System.Math.Sqrt(1.0));
     NUnit.Framework.Assert.IsTrue(poly.GetAttributeAsDbl(com.epl.geometry.VertexDescription.Semantics.M, 2, 0) == System.Math.Sqrt(1.0));
     NUnit.Framework.Assert.IsTrue(poly.GetAttributeAsDbl(com.epl.geometry.VertexDescription.Semantics.M, 3, 0) == System.Math.Sqrt(2.0));
     NUnit.Framework.Assert.IsTrue(poly.GetAttributeAsDbl(com.epl.geometry.VertexDescription.Semantics.M, 4, 0) == System.Math.Sqrt(2.0));
     NUnit.Framework.Assert.IsTrue(poly.GetAttributeAsDbl(com.epl.geometry.VertexDescription.Semantics.M, 5, 0) == System.Math.Sqrt(3.0));
     NUnit.Framework.Assert.IsTrue(poly.GetAttributeAsDbl(com.epl.geometry.VertexDescription.Semantics.M, 6, 0) == System.Math.Sqrt(3.0));
     NUnit.Framework.Assert.IsTrue(poly.GetAttributeAsDbl(com.epl.geometry.VertexDescription.Semantics.M, 7, 0) == System.Math.Sqrt(4.0));
     NUnit.Framework.Assert.IsTrue(poly.GetAttributeAsDbl(com.epl.geometry.VertexDescription.Semantics.M, 8, 0) == System.Math.Sqrt(4.0));
     NUnit.Framework.Assert.IsTrue(com.epl.geometry.NumberUtils.IsNaN(poly.GetAttributeAsDbl(com.epl.geometry.VertexDescription.Semantics.M, 9, 0)));
 }
예제 #5
0
 public virtual void TestPolyline()
 {
     com.epl.geometry.Polyline polyline = new com.epl.geometry.Polyline();
     polyline.StartPath(-97.06138, 32.837);
     polyline.LineTo(-97.06133, 32.836);
     polyline.LineTo(-97.06124, 32.834);
     polyline.LineTo(-97.06127, 32.832);
     polyline.StartPath(-97.06326, 32.759);
     polyline.LineTo(-97.06298, 32.755);
     {
         com.fasterxml.jackson.core.JsonParser polylinePathsWgs84Parser = factory.CreateJsonParser(com.epl.geometry.GeometryEngine.GeometryToJson(spatialReferenceWGS84, polyline));
         com.epl.geometry.MapGeometry          mPolylineWGS84MP         = com.epl.geometry.GeometryEngine.JsonToGeometry(polylinePathsWgs84Parser);
         NUnit.Framework.Assert.IsTrue(polyline.GetPointCount() == ((com.epl.geometry.Polyline)mPolylineWGS84MP.GetGeometry()).GetPointCount());
         NUnit.Framework.Assert.IsTrue(polyline.GetPoint(0).GetX() == ((com.epl.geometry.Polyline)mPolylineWGS84MP.GetGeometry()).GetPoint(0).GetX());
         NUnit.Framework.Assert.IsTrue(polyline.GetPoint(0).GetY() == ((com.epl.geometry.Polyline)mPolylineWGS84MP.GetGeometry()).GetPoint(0).GetY());
         NUnit.Framework.Assert.IsTrue(polyline.GetPathCount() == ((com.epl.geometry.Polyline)mPolylineWGS84MP.GetGeometry()).GetPathCount());
         NUnit.Framework.Assert.IsTrue(polyline.GetSegmentCount() == ((com.epl.geometry.Polyline)mPolylineWGS84MP.GetGeometry()).GetSegmentCount());
         NUnit.Framework.Assert.IsTrue(polyline.GetSegmentCount(0) == ((com.epl.geometry.Polyline)mPolylineWGS84MP.GetGeometry()).GetSegmentCount(0));
         NUnit.Framework.Assert.IsTrue(polyline.GetSegmentCount(1) == ((com.epl.geometry.Polyline)mPolylineWGS84MP.GetGeometry()).GetSegmentCount(1));
         int lastIndex = polyline.GetPointCount() - 1;
         NUnit.Framework.Assert.IsTrue(polyline.GetPoint(lastIndex).GetX() == ((com.epl.geometry.Polyline)mPolylineWGS84MP.GetGeometry()).GetPoint(lastIndex).GetX());
         NUnit.Framework.Assert.IsTrue(polyline.GetPoint(lastIndex).GetY() == ((com.epl.geometry.Polyline)mPolylineWGS84MP.GetGeometry()).GetPoint(lastIndex).GetY());
         NUnit.Framework.Assert.IsTrue(spatialReferenceWGS84.GetID() == mPolylineWGS84MP.GetSpatialReference().GetID());
         com.epl.geometry.Polyline emptyPolyline = new com.epl.geometry.Polyline();
         string emptyString = com.epl.geometry.GeometryEngine.GeometryToJson(spatialReferenceWGS84, emptyPolyline);
         mPolylineWGS84MP = com.epl.geometry.GeometryEngine.JsonToGeometry(factory.CreateJsonParser(emptyString));
         NUnit.Framework.Assert.IsTrue(mPolylineWGS84MP.GetGeometry().IsEmpty());
         NUnit.Framework.Assert.IsTrue(spatialReferenceWGS84.GetID() == mPolylineWGS84MP.GetSpatialReference().GetID());
     }
 }
예제 #6
0
        public virtual void TestTouchPointLineCR183227()
        {
            // Tests CR 183227
            com.epl.geometry.Geometry baseGeom = new com.epl.geometry.Point(-130, 10);
            com.epl.geometry.Polyline pl       = new com.epl.geometry.Polyline();
            // pl.startPath(new Point(-130, 10));
            pl.StartPath(-130, 10);
            pl.LineTo(-131, 15);
            pl.LineTo(-140, 20);
            com.epl.geometry.SpatialReference sr = com.epl.geometry.SpatialReference.Create(4326);
            bool isTouched;
            bool isTouched2;

            isTouched  = com.epl.geometry.GeometryEngine.Touches(baseGeom, pl, sr);
            isTouched2 = com.epl.geometry.GeometryEngine.Touches(pl, baseGeom, sr);
            NUnit.Framework.Assert.IsTrue(isTouched && isTouched2);
            {
                com.epl.geometry.Geometry baseGeom2 = (com.epl.geometry.Geometry) new com.epl.geometry.Point(-131, 15);
                bool bIsTouched;
                bool bIsTouched2;
                bIsTouched  = com.epl.geometry.GeometryEngine.Touches(baseGeom2, pl, sr);
                bIsTouched2 = com.epl.geometry.GeometryEngine.Touches(pl, baseGeom2, sr);
                NUnit.Framework.Assert.IsTrue(!bIsTouched && !bIsTouched2);
            }
        }
        public virtual void TestPointAndPolyline1()
        {
            com.epl.geometry.Point    basePl = new com.epl.geometry.Point(-116, 20);
            com.epl.geometry.Polyline compPl = new com.epl.geometry.Polyline();
            compPl.StartPath(new com.epl.geometry.Point(-116, 20));
            compPl.LineTo(new com.epl.geometry.Point(-131, 10));
            compPl.LineTo(new com.epl.geometry.Point(-121, 50));
            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.Point);
            com.epl.geometry.Point ip = (com.epl.geometry.Point)intersectGeom;
            NUnit.Framework.Assert.AreEqual(ip.GetX(), -116, 0.1E7);
            NUnit.Framework.Assert.AreEqual(ip.GetY(), 20, 0.1E7);
        }
예제 #8
0
 internal static com.epl.geometry.Polyline MakePolyline()
 {
     com.epl.geometry.Polyline poly = new com.epl.geometry.Polyline();
     poly.StartPath(0, 0);
     poly.LineTo(10, 10);
     poly.LineTo(20, 0);
     return(poly);
 }
 public virtual void TestSerializePolyline()
 {
     try
     {
         java.io.ByteArrayOutputStream streamOut = new java.io.ByteArrayOutputStream();
         java.io.ObjectOutputStream    oo        = new java.io.ObjectOutputStream(streamOut);
         com.epl.geometry.Polyline     pt        = new com.epl.geometry.Polyline();
         pt.StartPath(10, 10);
         pt.LineTo(100, 100);
         pt.LineTo(200, 100);
         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.Polyline ptRes    = (com.epl.geometry.Polyline)ii.ReadObject();
         NUnit.Framework.Assert.IsTrue(ptRes.Equals(pt));
     }
     catch (System.Exception)
     {
         Fail("Polyline serialization failure");
     }
     //try
     //{
     //FileOutputStream streamOut = new FileOutputStream("c:/temp/savedPolyline1.txt");
     //ObjectOutputStream oo = new ObjectOutputStream(streamOut);
     //Polyline pt = new Polyline();
     //pt.startPath(10, 10);
     //pt.lineTo(100, 100);
     //pt.lineTo(200, 100);
     //oo.writeObject(pt);
     //}
     //catch(Exception ex)
     //{
     //fail("Polyline serialization failure");
     //}
     try
     {
         java.io.InputStream       s     = typeof(com.epl.geometry.TestSerialization).GetResourceAsStream("savedPolyline.txt");
         java.io.ObjectInputStream ii    = new java.io.ObjectInputStream(s);
         com.epl.geometry.Polyline ptRes = (com.epl.geometry.Polyline)ii.ReadObject();
         NUnit.Framework.Assert.IsTrue(ptRes != null);
     }
     catch (System.Exception)
     {
         Fail("Polyline serialization failure");
     }
     try
     {
         java.io.InputStream       s     = typeof(com.epl.geometry.TestSerialization).GetResourceAsStream("savedPolyline1.txt");
         java.io.ObjectInputStream ii    = new java.io.ObjectInputStream(s);
         com.epl.geometry.Polyline ptRes = (com.epl.geometry.Polyline)ii.ReadObject();
         NUnit.Framework.Assert.IsTrue(ptRes != null);
     }
     catch (System.Exception)
     {
         Fail("Polyline serialization failure");
     }
 }
예제 #10
0
 public static com.epl.geometry.Polyline MakePolygonCutter5()
 {
     com.epl.geometry.Polyline poly = new com.epl.geometry.Polyline();
     poly.StartPath(15, 0);
     poly.LineTo(0, 15);
     poly.LineTo(15, 30);
     poly.LineTo(30, 15);
     poly.LineTo(15, 0);
     return(poly);
 }
예제 #11
0
 public static com.epl.geometry.Polyline MakePolygonCutter8()
 {
     com.epl.geometry.Polyline poly = new com.epl.geometry.Polyline();
     poly.StartPath(10, 10);
     poly.LineTo(10, 20);
     poly.LineTo(20, 20);
     poly.LineTo(20, 10);
     poly.LineTo(10, 10);
     return(poly);
 }
예제 #12
0
        public virtual void TestPolylineWithTwoPaths()
        {
            com.epl.geometry.Polyline p = new com.epl.geometry.Polyline();
            p.StartPath(100.0, 0.0);
            p.LineTo(100.0, 1.0);
            p.StartPath(100.2, 0.2);
            p.LineTo(100.8, 0.2);
            string result = com.epl.geometry.GeometryEngine.GeometryToGeoJson(p);

            NUnit.Framework.Assert.AreEqual("{\"type\":\"MultiLineString\",\"coordinates\":[[[100,0],[100,1]],[[100.2,0.2],[100.8,0.2]]]}", result);
        }
예제 #13
0
        public virtual void TestPolyline()
        {
            com.epl.geometry.Polyline p = new com.epl.geometry.Polyline();
            p.StartPath(100.0, 0.0);
            p.LineTo(101.0, 0.0);
            p.LineTo(101.0, 1.0);
            p.LineTo(100.0, 1.0);
            com.epl.geometry.OperatorExportToGeoJson exporter = (com.epl.geometry.OperatorExportToGeoJson)factory.GetOperator(com.epl.geometry.Operator.Type.ExportToGeoJson);
            string result = exporter.Execute(p);

            NUnit.Framework.Assert.AreEqual("{\"type\":\"LineString\",\"coordinates\":[[100,0],[101,0],[101,1],[100,1]]}", result);
        }
예제 #14
0
        public virtual void TestOGCLineString()
        {
            com.epl.geometry.Polyline p = new com.epl.geometry.Polyline();
            p.StartPath(100.0, 0.0);
            p.LineTo(101.0, 0.0);
            p.LineTo(101.0, 1.0);
            p.LineTo(100.0, 1.0);
            com.epl.geometry.ogc.OGCLineString ogcLineString = new com.epl.geometry.ogc.OGCLineString(p, 0, null);
            string result = ogcLineString.AsGeoJson();

            NUnit.Framework.Assert.AreEqual("{\"type\":\"LineString\",\"coordinates\":[[100,0],[101,0],[101,1],[100,1]],\"crs\":null}", result);
        }
예제 #15
0
 public virtual void OffsetPolyline_(double distance, com.epl.geometry.OperatorOffset.JoinType joins)
 {
     com.epl.geometry.Polyline polyline = new com.epl.geometry.Polyline();
     polyline.StartPath(0, 0);
     polyline.LineTo(6, 0);
     polyline.LineTo(6, 1);
     polyline.LineTo(4, 1);
     polyline.LineTo(4, 2);
     polyline.LineTo(10, 2);
     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(polyline, null, distance, joins, 2, 0, null);
     NUnit.Framework.Assert.IsNotNull(outputGeom);
 }
 public static void Test3()
 {
     com.epl.geometry.Polyline poly = new com.epl.geometry.Polyline();
     poly.StartPath(0, System.Math.Sqrt(0.0));
     poly.LineTo(0, System.Math.Sqrt(5.0));
     poly.StartPath(0, System.Math.Sqrt(8.0));
     poly.LineTo(0, System.Math.Sqrt(10.0));
     poly.SetAttribute(com.epl.geometry.VertexDescription.Semantics.M, 0, 0, System.Math.Sqrt(3.0));
     poly.SetAttribute(com.epl.geometry.VertexDescription.Semantics.M, 2, 0, System.Math.Sqrt(5.0));
     poly.InterpolateAttributes(com.epl.geometry.VertexDescription.Semantics.M, 0, 0, 1, 0);
     NUnit.Framework.Assert.IsTrue(poly.GetAttributeAsDbl(com.epl.geometry.VertexDescription.Semantics.M, 0, 0) == System.Math.Sqrt(3.0));
     NUnit.Framework.Assert.IsTrue(poly.GetAttributeAsDbl(com.epl.geometry.VertexDescription.Semantics.M, 1, 0) == System.Math.Sqrt(5.0));
     NUnit.Framework.Assert.IsTrue(poly.GetAttributeAsDbl(com.epl.geometry.VertexDescription.Semantics.M, 2, 0) == System.Math.Sqrt(5.0));
 }
예제 #17
0
        public virtual void TestTouchesBetweenPointAndLine()
        {
            com.epl.geometry.SpatialReference sr     = com.epl.geometry.SpatialReference.Create(4326);
            com.epl.geometry.Point            p      = new com.epl.geometry.Point(2, 4);
            com.epl.geometry.Polyline         compPl = new com.epl.geometry.Polyline();
            compPl.StartPath(2, 4);
            compPl.LineTo(9, 4);
            compPl.LineTo(9, 9);
            compPl.LineTo(2, 9);
            compPl.LineTo(2, 4);
            bool isTouched = com.epl.geometry.GeometryEngine.Touches(p, compPl, sr);

            NUnit.Framework.Assert.IsTrue(!isTouched);
        }
예제 #18
0
 public static com.epl.geometry.Polyline MakePolyline()
 {
     com.epl.geometry.Polyline poly = new com.epl.geometry.Polyline();
     // 0
     poly.StartPath(0, 40);
     poly.LineTo(30, 0);
     // 1
     poly.StartPath(20, 70);
     poly.LineTo(45, 100);
     // 2
     poly.StartPath(50, 100);
     poly.LineTo(50, 60);
     // 3
     poly.StartPath(35, 25);
     poly.LineTo(65, 45);
     // 4
     poly.StartPath(60, 10);
     poly.LineTo(65, 35);
     // 5
     poly.StartPath(60, 60);
     poly.LineTo(100, 60);
     // 6
     poly.StartPath(80, 10);
     poly.LineTo(80, 99);
     // 7
     poly.StartPath(60, 60);
     poly.LineTo(65, 35);
     return(poly);
 }
예제 #19
0
 public static com.epl.geometry.Polyline MakePolyline1()
 {
     com.epl.geometry.Polyline poly = new com.epl.geometry.Polyline();
     poly.StartPath(0, 0);
     poly.LineTo(2, 0);
     poly.LineTo(4, 0);
     poly.LineTo(6, 0);
     poly.LineTo(8, 0);
     poly.LineTo(10, 0);
     poly.LineTo(12, 0);
     poly.LineTo(14, 0);
     poly.LineTo(16, 0);
     poly.LineTo(18, 0);
     poly.LineTo(20, 0);
     return(poly);
 }
예제 #20
0
 public static com.epl.geometry.Polyline MakePolyline1()
 {
     com.epl.geometry.Polyline poly = new com.epl.geometry.Polyline();
     poly.StartPath(0, 0);
     poly.LineTo(15, 15);
     return(poly);
 }
예제 #21
0
        public virtual void TestTouchesBetweenPolylines()
        {
            com.epl.geometry.SpatialReference sr = com.epl.geometry.SpatialReference.Create(4326);
            com.epl.geometry.Polyline         pl = new com.epl.geometry.Polyline();
            pl.StartPath(2, 4);
            pl.LineTo(9, 9);
            com.epl.geometry.Polyline compPl = new com.epl.geometry.Polyline();
            compPl.StartPath(2, 4);
            compPl.LineTo(9, 4);
            compPl.LineTo(9, 9);
            compPl.LineTo(2, 9);
            compPl.LineTo(2, 4);
            bool isTouched = com.epl.geometry.GeometryEngine.Touches(pl, compPl, sr);

            NUnit.Framework.Assert.AreEqual(isTouched, true);
        }
예제 #22
0
 public static com.epl.geometry.Polyline MakePolygonCutter9()
 {
     com.epl.geometry.Polyline poly = new com.epl.geometry.Polyline();
     poly.StartPath(5, -1);
     poly.LineTo(5, 51);
     return(poly);
 }
예제 #23
0
 public static void Test2()
 {
     com.epl.geometry.OperatorFactoryLocal engine   = com.epl.geometry.OperatorFactoryLocal.GetInstance();
     com.epl.geometry.OperatorGeneralize   op       = (com.epl.geometry.OperatorGeneralize)engine.GetOperator(com.epl.geometry.Operator.Type.Generalize);
     com.epl.geometry.Polyline             polyline = new com.epl.geometry.Polyline();
     polyline.StartPath(0, 0);
     polyline.LineTo(1, 1);
     polyline.LineTo(2, 0);
     polyline.LineTo(3, 2);
     polyline.LineTo(4, 1);
     polyline.LineTo(5, 0);
     polyline.LineTo(5, 10);
     polyline.LineTo(0, 10);
     com.epl.geometry.Geometry  geom   = op.Execute(polyline, 2, true, null);
     com.epl.geometry.Polyline  p      = (com.epl.geometry.Polyline)geom;
     com.epl.geometry.Point2D[] points = p.GetCoordinates2D();
     NUnit.Framework.Assert.IsTrue(points.Length == 4);
     NUnit.Framework.Assert.IsTrue(points[0].x == 0 && points[0].y == 0);
     NUnit.Framework.Assert.IsTrue(points[1].x == 5 && points[1].y == 0);
     NUnit.Framework.Assert.IsTrue(points[2].x == 5 && points[2].y == 10);
     NUnit.Framework.Assert.IsTrue(points[3].x == 0 && points[3].y == 10);
     com.epl.geometry.Geometry geom1 = op.Execute(geom, 5, false, null);
     p      = (com.epl.geometry.Polyline)geom1;
     points = p.GetCoordinates2D();
     NUnit.Framework.Assert.IsTrue(points.Length == 2);
     NUnit.Framework.Assert.IsTrue(points[0].x == 0 && points[0].y == 0);
     NUnit.Framework.Assert.IsTrue(points[1].x == 0 && points[1].y == 10);
     geom1  = op.Execute(geom, 5, true, null);
     p      = (com.epl.geometry.Polyline)geom1;
     points = p.GetCoordinates2D();
     NUnit.Framework.Assert.IsTrue(points.Length == 2);
     NUnit.Framework.Assert.IsTrue(points[0].x == 0 && points[0].y == 0);
     NUnit.Framework.Assert.IsTrue(points[1].x == 0 && points[1].y == 10);
 }
예제 #24
0
        public virtual void TestRelationTouch()
        {
            com.epl.geometry.SpatialReference sr     = com.epl.geometry.SpatialReference.Create(4326);
            com.epl.geometry.Polyline         basePl = new com.epl.geometry.Polyline();
            basePl.StartPath(2, 2);
            basePl.LineTo(2, 10);
            com.epl.geometry.Polyline compPl = new com.epl.geometry.Polyline();
            compPl.StartPath(2, 4);
            compPl.LineTo(9, 4);
            compPl.LineTo(9, 9);
            compPl.LineTo(2, 9);
            compPl.LineTo(2, 4);
            bool isTouched = false;

            // GeometryEngine.relation(basePl, compPl, sr,
            // "G1 TOUCH G2");
            NUnit.Framework.Assert.AreEqual(isTouched, false);
        }
 public static void TestCR254240()
 {
     com.epl.geometry.OperatorProximity2D proximityOp = com.epl.geometry.OperatorProximity2D.Local();
     com.epl.geometry.Point    inputPoint             = new com.epl.geometry.Point(-12, 12);
     com.epl.geometry.Polyline line = new com.epl.geometry.Polyline();
     line.StartPath(-10, 0);
     line.LineTo(0, 0);
     com.epl.geometry.Proximity2DResult result = proximityOp.GetNearestCoordinate(line, inputPoint, false, true);
     NUnit.Framework.Assert.IsTrue(result.IsRightSide() == false);
 }
        public virtual void TestLocalExport()
        {
            string s = com.epl.geometry.OperatorExportToJson.Local().Execute(null, new com.epl.geometry.Point(1000000.2, 2000000.3));

            //assertTrue(s.contains("."));
            //assertFalse(s.contains(","));
            com.epl.geometry.Polyline line = new com.epl.geometry.Polyline();
            line.StartPath(1.1, 2.2);
            line.LineTo(2.3, 4.5);
            string s1 = com.epl.geometry.OperatorExportToJson.Local().Execute(null, line);

            NUnit.Framework.Assert.IsTrue(s.Contains("."));
        }
예제 #27
0
        public virtual void TestPointAndPolyline2()
        {
            com.epl.geometry.Point    basePl = new com.epl.geometry.Point(-115, 20);
            com.epl.geometry.Polyline compPl = new com.epl.geometry.Polyline();
            compPl.StartPath(new com.epl.geometry.Point(-116, 20));
            compPl.LineTo(new com.epl.geometry.Point(-131, 10));
            compPl.LineTo(new com.epl.geometry.Point(-121, 50));
            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());
        }
예제 #28
0
        public static void TestDifferenceOnPolyline()
        {
            // # * * #
            // # * @
            // # @ *
            // # *
            //
            // ///////////////////////////////
            //
            // The polyline drawn in *s represents basePl
            // The polyline drawn in #s represents compPl
            // The @ represents their intersection points, so that
            // the difference polyline will be basePl with two new vertices @ added.
            com.epl.geometry.Polyline basePl = new com.epl.geometry.Polyline();
            basePl.StartPath(new com.epl.geometry.Point(-117, 20));
            basePl.LineTo(new com.epl.geometry.Point(-130, 10));
            basePl.LineTo(new com.epl.geometry.Point(-120, 50));
            com.epl.geometry.Polyline compPl = new com.epl.geometry.Polyline();
            compPl.StartPath(new com.epl.geometry.Point(-116, 20));
            compPl.LineTo(new com.epl.geometry.Point(-131, 10));
            compPl.LineTo(new com.epl.geometry.Point(-121, 50));
            com.epl.geometry.Geometry diffGeom = com.epl.geometry.GeometryEngine.Difference(basePl, compPl, com.epl.geometry.SpatialReference.Create(4326));
            NUnit.Framework.Assert.IsTrue(diffGeom is com.epl.geometry.Polyline);
            com.epl.geometry.Polyline diffPolyline = (com.epl.geometry.Polyline)diffGeom;
            int pointCountDiffPolyline             = diffPolyline.GetPointCount();

            // first line in comp_pl is 3y = 2x + 292
            NUnit.Framework.Assert.AreEqual(3 * 20, 2 * (-116) + 292);
            NUnit.Framework.Assert.AreEqual(3 * 10, 2 * (-131) + 292);
            // new points should also lie on this line
            NUnit.Framework.Assert.IsTrue(3.0 * diffPolyline.GetCoordinates2D()[1].y - 2.0 * diffPolyline.GetCoordinates2D()[1].x - 292.0 == 0.0);
            NUnit.Framework.Assert.IsTrue(3.0 * diffPolyline.GetCoordinates2D()[3].y - 2.0 * diffPolyline.GetCoordinates2D()[3].x - 292.0 == 0.0);
            for (int i = 0; i < 3; i++)
            {
                NUnit.Framework.Assert.IsTrue(basePl.GetCoordinates2D()[i].x == diffPolyline.GetCoordinates2D()[2 * i].x);
                NUnit.Framework.Assert.IsTrue(basePl.GetCoordinates2D()[i].y == diffPolyline.GetCoordinates2D()[2 * i].y);
            }
            NUnit.Framework.Assert.AreEqual(5, pointCountDiffPolyline);
        }
예제 #29
0
        public virtual void TestTouchesBetweenMultipartPolylines()
        {
            com.epl.geometry.SpatialReference sr = com.epl.geometry.SpatialReference.Create(4326);
            com.epl.geometry.Polyline         pl = new com.epl.geometry.Polyline();
            pl.StartPath(2, 4);
            pl.LineTo(1, 10);
            pl.LineTo(6, 12);
            pl.StartPath(6, 12);
            pl.LineTo(12, 12);
            pl.LineTo(9, 9);
            com.epl.geometry.Polyline compPl = new com.epl.geometry.Polyline();
            compPl.StartPath(2, 4);
            compPl.LineTo(2, 9);
            compPl.LineTo(9, 9);
            compPl.LineTo(9, 4);
            compPl.StartPath(2, 9);
            compPl.LineTo(6, 12);
            compPl.LineTo(9, 10);
            bool isTouched = com.epl.geometry.GeometryEngine.Touches(pl, compPl, sr);

            NUnit.Framework.Assert.IsTrue(!isTouched);
        }
예제 #30
0
        public virtual void TestTouchOnPointAndPolyline()
        {
            com.epl.geometry.Geometry baseGeom = new com.epl.geometry.Point(-130, 10);
            com.epl.geometry.Polyline pl       = new com.epl.geometry.Polyline();
            pl.StartPath(new com.epl.geometry.Point(-130, 10));
            pl.LineTo(-131, 15);
            pl.LineTo(-140, 20);
            com.epl.geometry.SpatialReference sr = com.epl.geometry.SpatialReference.Create(4326);
            bool isTouched;
            bool isTouched2;

            try
            {
                isTouched  = com.epl.geometry.GeometryEngine.Touches(baseGeom, pl, sr);
                isTouched2 = com.epl.geometry.GeometryEngine.Touches(pl, baseGeom, sr);
            }
            catch (System.ArgumentException)
            {
                isTouched  = false;
                isTouched2 = false;
            }
            NUnit.Framework.Assert.AreEqual(isTouched && isTouched2, true);
        }