public void LRSLineStringTest()
        {
            var lrsLine = new LRSLine(4326);
            var wkt     = lrsLine.ToString();

            Assert.AreEqual(wkt, "LINESTRING EMPTY");
            lrsLine.AddPoint(new LRSPoint(1, 1, 0, 1, 4326));
            lrsLine.AddPoint(new LRSPoint(2, 2, null, null, 4326));
            lrsLine.LocatePoint(3);
            lrsLine.AddPoint(new LRSPoint(3, 3, 0, 3, 4326), new LRSPoint(4, 4, 0, 4, 4326));

            var enumerator = lrsLine.GetEnumerator();

            enumerator.MoveNext();
            enumerator.MoveNext();
            enumerator.MoveNext();
            enumerator.MoveNext();
            var currentPoint = enumerator.Current;

            Assert.AreEqual(currentPoint, new LRSPoint(4, 4, 0, 4, 4326));
            try
            {
                enumerator.MoveNext();
                // ReSharper disable once RedundantAssignment
                currentPoint = enumerator.Current;
            }
            catch (InvalidOperationException)
            {
                enumerator.Reset();
            }
        }
        public void LRSMultiLineToSqlTest()
        {
            // empty LRS Point check
            var point1   = new LRSPoint("LINESTRING EMPTY".GetGeom());
            var hashCode = point1.GetHashCode();

            Assert.IsTrue(hashCode > 0);
            Assert.AreEqual(point1.ToString(), "POINT (0 0 )");

            // LRS Point Equality check
            point1 = new LRSPoint("POINT(1 1 0 1)".GetGeom());
            var point2 = new LRSPoint("POINT(1 1 0 1)".GetGeom());

            Assert.IsTrue(point1 == point2);

            // range check
            Assert.IsTrue(point1.IsXYWithinTolerance(point2, 0.5));

            point2 = new LRSPoint("POINT(2 2 0 2)".GetGeom());
            var point3    = new LRSPoint("POINT(3 3 0 3)".GetGeom());
            var point4    = new LRSPoint("POINT(4 4 0 4)".GetGeom());
            var lrsPoints = new List <LRSPoint> {
                point1, point2, point3
            };

            // next and previous point
            Assert.AreEqual(LRSPoint.GetNextPoint(ref lrsPoints, point2), point3);
            Assert.AreEqual(LRSPoint.GetNextPoint(ref lrsPoints, point4), null);
            Assert.AreEqual(LRSPoint.GetPreviousPoint(ref lrsPoints, point2), point1);
            Assert.AreEqual(LRSPoint.GetPreviousPoint(ref lrsPoints, point4), null);

            // Multiline
            var lrs = new LRSMultiLine(4326);
            SqlGeometryBuilder geomBuilder = null;

            lrs.ToSqlGeometry(ref geomBuilder);
            lrs.BuildSqlGeometry(ref geomBuilder);

            geomBuilder = new SqlGeometryBuilder();
            lrs.ToSqlGeometry(ref geomBuilder);
            lrs.BuildSqlGeometry(ref geomBuilder);

            var lrsLine = new LRSLine(4326);

            lrsLine.AddPoint(new LRSPoint(1, 1, 0, 1, 4326));
            lrs.AddLine(lrsLine);

            geomBuilder = new SqlGeometryBuilder();
            lrs.ToSqlGeometry(ref geomBuilder);

            var lrsLine1 = new LRSLine(4326);
            var wkt      = lrs.ToString();

            Assert.AreEqual("MULTILINESTRING EMPTY", wkt);
            Assert.AreEqual(lrs.GetPointAtM(10), null);

            var pt = new LRSPoint(1, 1, 0, 1, 4326);

            lrsLine1.AddPoint(pt);
            Assert.AreEqual(lrsLine1.ToString(), "POINT (1 1 1)");

            pt = new LRSPoint(2, 2, 0, 2, 4326);
            lrsLine1.AddPoint(pt);

            lrs = new LRSMultiLine(4326);
            lrs.AddLine(lrsLine1);

            wkt = lrs.ToString();
            Assert.AreEqual("LINESTRING (1 1 1, 2 2 2)", wkt);

            var lrsLine2 = new LRSLine(4326);

            pt = new LRSPoint(3, 3, 0, 3, 4326);
            Assert.AreEqual(pt.ToString(), "POINT (3 3 3)");
            lrsLine2.AddPoint(pt);
            pt = new LRSPoint(4, 4, 0, 4, 4326);
            lrsLine2.AddPoint(pt);

            lrs = new LRSMultiLine(4326);
            lrs.AddLine(lrsLine1);
            lrs.AddLine(lrsLine2);
            geomBuilder = null;
            lrs.BuildSqlGeometry(ref geomBuilder);

            Assert.AreEqual(lrs.GetPointAtM(10), null);
            Assert.AreEqual(lrs.GetPointAtM(2), new LRSPoint(2, 2, 0, 2, 4326));
            wkt = lrs.ToString();
            lrs.RemoveFirst();
            Assert.AreEqual(lrs.Count, 1);
            lrs.RemoveLast();
            Assert.AreEqual(lrs.Count, 0);
            lrs.RemoveFirst();
            lrs.RemoveLast();
            Assert.AreEqual("MULTILINESTRING ((1 1 1, 2 2 2), (3 3 3, 4 4 4))", wkt);
        }