Esempio n. 1
0
        public void TabulatedToSimpleGeometryTest()
        {
            var branchGeometry = new LineString(new[] { new Coordinate(0, 0), new Coordinate(100, 0) });

            IGeometry geometry = CrossSectionHelper.CreatePerpendicularGeometry(branchGeometry, 30, 30);

            // The expected length of the geometry is the maximum of the totalwidth
            Assert.AreEqual(30.0, geometry.Length, 1.0e-6);
            Assert.IsInstanceOfType(typeof(LineString), geometry);
            Assert.AreEqual(2, geometry.Coordinates.Length);
        }
Esempio n. 2
0
        public void CreatePerpendicularGeometry()
        {
            var branchGeometry        = new LineString(new[] { new Coordinate(0, 0), new Coordinate(100, 0) });
            var minY                  = -40.0d;
            var maxY                  = 60.0d;
            var offsetAlongBranch     = 25.0d;
            var perpendicularGeometry = CrossSectionHelper.CreatePerpendicularGeometry(branchGeometry, offsetAlongBranch, minY, maxY, 0.0);

            //compare the calculated geometry with a small tolerance. Rounding errors occur due to Sin/Cos
            LineString expected = new LineString(new[] { new Coordinate(25, 40), new Coordinate(25, -60) });

            Assert.IsTrue(expected.EqualsExact(perpendicularGeometry, 0.00001));
        }
Esempio n. 3
0
        public void YZTableToPerpendicularGeometry()
        {
            var branchGeometry = new LineString(new[] { new Coordinate(0, 0), new Coordinate(100, 0) });
            IList <ICoordinate> yzCoordinates = new List <ICoordinate>
            {
                // note: x, y of coordinate are interpreted as the yz for
                // the cross section.
                new Coordinate(0.0, 0.0),
                new Coordinate(5.0, -20.0),
                new Coordinate(15.0, -20.0),
                new Coordinate(20.0, 0.0)
            };
            double    thalWegOffset    = (yzCoordinates[yzCoordinates.Count - 1].X - yzCoordinates[0].X) / 2;
            var       minY             = yzCoordinates.Min(c => c.X);
            var       maxY             = yzCoordinates.Max(c => c.X);
            IGeometry geometry         = CrossSectionHelper.CreatePerpendicularGeometry(branchGeometry, 30, minY, maxY, thalWegOffset);
            var       expectedGeometry = new LineString(new[] { new Coordinate(30, -10, 0), new Coordinate(30, -5, -20), new Coordinate(30, 5, -20), new Coordinate(30, 10, 0) });

            Assert.AreEqual(expectedGeometry, geometry);
        }