Exemplo n.º 1
0
        public void SetZValueCausesPropertyChangedForXYZCrossSection()
        {
            IChannel channel = new Channel {
                Geometry = new LineString(new[] { new Coordinate(0, 0), new Coordinate(20, 0) })
            };
            var crossSection = new CrossSection {
                Branch = channel
            };

            NetworkHelper.AddBranchFeatureToBranch(channel, crossSection, 10.0);

            var yzCoordinates = new List <ICoordinate>
            {
                new Coordinate(0.0, 0.0),
                new Coordinate(100.0, 0.0),
            };

            crossSection.Geometry = CrossSectionHelper.CreateCrossSectionGeometryForXyzCrossSectionFromYZ(channel.Geometry,
                                                                                                          crossSection.Offset,
                                                                                                          yzCoordinates);

            int callCount = 0;

            ((INotifyPropertyChanged)(crossSection)).PropertyChanged += (s, e) =>
            {
                callCount++;
                Assert.AreEqual("Geometry",
                                e.PropertyName);
            };

            crossSection.SetZValue(0, 100);
            Assert.AreEqual(1, callCount);
        }
Exemplo n.º 2
0
        public void AreaOfEmptyProfiles()
        {
            var upper = new ICoordinate[] {};
            var lower = new ICoordinate[] { };

            Assert.AreEqual(0.0, CrossSectionHelper.CalculateStorageArea(lower, upper));
        }
Exemplo n.º 3
0
        public void SetDefaultGeometryWithBrancheGeometry()
        {
            const double defaultLength = 2;
            var          hydroNetwork  = new HydroNetwork();

            var channel = new Channel {
                Geometry = new LineString(new[] { new Coordinate(0, 0), new Coordinate(20, 0) })
            };

            var crossSection = new CrossSection
            {
                CrossSectionType = CrossSectionType.GeometryBased,
                Geometry         = new LineString(new[] { new Coordinate(10, 0), new Coordinate(10, 0) }),
                ThalWay          = defaultLength / 2
            };

            hydroNetwork.Branches.Add(channel);
            NetworkHelper.AddBranchFeatureToBranch(channel, crossSection, crossSection.Offset);
            crossSection.Offset = 12;

            CrossSectionHelper.SetDefaultGeometry(crossSection, defaultLength);

            Assert.AreEqual(defaultLength, crossSection.Geometry.Length);
            Assert.AreEqual(2, crossSection.Geometry.Coordinates.Length);

            Assert.AreEqual(12, crossSection.Geometry.Coordinates[0].X);
            Assert.AreEqual(12, crossSection.Geometry.Coordinates[1].X);
            Assert.AreEqual(-defaultLength / 2, crossSection.Geometry.Coordinates[0].Y);
            Assert.AreEqual(defaultLength / 2, crossSection.Geometry.Coordinates[1].Y);
        }
Exemplo n.º 4
0
        public void AreaOfLine()
        {
            var upper = new ICoordinate[] { new Coordinate(0, 0) };
            var lower = new ICoordinate[] { new Coordinate(0, 3) };

            Assert.AreEqual(0.0, CrossSectionHelper.CalculateStorageArea(lower, upper));
        }
Exemplo n.º 5
0
        public void AreaOfStraightProfiles()
        {
            var upper = new ICoordinate[] { new Coordinate(0, 0), new Coordinate(1, 0), new Coordinate(2, 0), new Coordinate(3, 0) };
            var lower = new ICoordinate[] { new Coordinate(0, 3), new Coordinate(1, 3), new Coordinate(2, 3), new Coordinate(3, 3) };

            Assert.AreEqual(9.0, CrossSectionHelper.CalculateStorageArea(lower, upper));
        }
Exemplo n.º 6
0
        public void YZTableToXyzGeometryAtInvertedHorizontalBranchTest()
        {
            var branchGeometry = new LineString(new[] { new Coordinate(111, 0), new Coordinate(11, 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)
            };
            IGeometry geometry = CrossSectionHelper.CreateCrossSectionGeometryForXyzCrossSectionFromYZ(branchGeometry, 30, yzCoordinates);

            Assert.AreEqual(20.0, geometry.Length, 1.0e-6);
            Assert.AreEqual(81.0, geometry.Coordinates[0].X, 1.0e-6);
            Assert.AreEqual(81.0, geometry.Coordinates[1].X, 1.0e-6);
            Assert.AreEqual(81.0, geometry.Coordinates[2].X, 1.0e-6);
            Assert.AreEqual(81.0, geometry.Coordinates[3].X, 1.0e-6);
            //
            //                             cs[0] (10)
            //                                  |
            // branch end(11) <-----------------81------ start (111)
            //                                  |
            //                          cs[count-1] (-10)
            //
            Assert.AreEqual(10.0, geometry.Coordinates[0].Y, 1.0e-6);
            Assert.AreEqual(-10.0, geometry.Coordinates[3].Y, 1.0e-6);
        }
Exemplo n.º 7
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);
        }
Exemplo n.º 8
0
        private static CrossSection CreateDefaultCrossSection()
        {
            IChannel channel = new Channel {
                Geometry = new LineString(new[] { new Coordinate(0, 0), new Coordinate(20, 0) })
            };
            var crossSection = new CrossSection {
                Branch = channel, CrossSectionType = CrossSectionType.YZTable
            };

            CrossSectionHelper.CreateDefaultYZTableAndGeometryForYZCrossSection(crossSection, 100.0);
            return(crossSection);
        }
Exemplo n.º 9
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));
        }
Exemplo n.º 10
0
        public void YZProfileFromHeightFlowStorageExceptionNonAscendingYZProfile()
        {
            //       [---------------] width 15
            //
            //
            //
            // [---------------------------] width 20
            IList <HeightFlowStorageWidth> tabulatedData = new List <HeightFlowStorageWidth>
            {
                new HeightFlowStorageWidth(0.0, 25, 15),
                new HeightFlowStorageWidth(-10.0, 30, 20)
            };
            IList <ICoordinate> yZValues = new List <ICoordinate>();

            CrossSectionHelper.CalculateYZProfileFromTabulatedCrossSection(yZValues, tabulatedData, "kees", true);
        }
Exemplo n.º 11
0
        public void TabulatedToSimpleGeometryTest()
        {
            var branchGeometry = new LineString(new[] { new Coordinate(0, 0), new Coordinate(100, 0) });
            IList <HeightFlowStorageWidth> tabulatedCrossSectionData = new List <HeightFlowStorageWidth>
            {
                // height, totalwidth, flowingwidth
                new HeightFlowStorageWidth(0.0, 20.0, 10.0),
                new HeightFlowStorageWidth(10.0, 30.0, 12.0),
                new HeightFlowStorageWidth(20.0, 20.0, 10.0)
            };
            IGeometry geometry = CrossSectionHelper.CreateCrossSectionGeometryFromTabulated(branchGeometry, 30, tabulatedCrossSectionData);

            // The expected length of the geometry is the maximum of the flowwidth
            Assert.AreEqual(12.0, geometry.Length, 1.0e-6);
            Assert.IsInstanceOfType(typeof(LineString), geometry);
            Assert.AreEqual(2, geometry.Coordinates.Length);
        }
Exemplo n.º 12
0
        public void YZProfileFromTabulatedCrossSections()
        {
            var branchGeometry = new LineString(new[] { new Coordinate(111, 0), new Coordinate(11, 0) });
            var channel        = new Channel {
                Geometry = branchGeometry
            };
            var crossSection = new CrossSection {
                CrossSectionType = CrossSectionType.HeightFlowStorageWidth, Offset = 10
            };

            NetworkHelper.AddBranchFeatureToBranch(channel, crossSection, crossSection.Offset);
            crossSection.HeightFlowStorageWidthData.Add(new HeightFlowStorageWidth(-10.0, 15, 25));
            crossSection.HeightFlowStorageWidthData.Add(new HeightFlowStorageWidth(0.0, 20, 30));

            CrossSectionHelper.ConvertCrossSectionType(crossSection, CrossSectionType.YZTable);
            Assert.AreEqual(CrossSectionType.YZTable, crossSection.CrossSectionType);
            Assert.AreEqual(4, crossSection.YZValues.Count);
        }
Exemplo n.º 13
0
        public void YZTableToSimpleGeometryTest()
        {
            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)
            };
            IGeometry geometry = CrossSectionHelper.CreateCrossSectionGeometryFromYz(branchGeometry, 30, yzCoordinates);

            Assert.AreEqual(20.0, geometry.Length, 1.0e-6);
            Assert.IsInstanceOfType(typeof(LineString), geometry);
            Assert.AreEqual(2, geometry.Coordinates.Length);
        }
Exemplo n.º 14
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);
        }
Exemplo n.º 15
0
        public void YZTableToXyzGeometryAtVerticalBranchTest()
        {
            var branchGeometry = new LineString(new[] { new Coordinate(0, 11), new Coordinate(0, 111) });
            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)
            };
            IGeometry geometry = CrossSectionHelper.CreateCrossSectionGeometryForXyzCrossSectionFromYZ(branchGeometry, 30, yzCoordinates);

            Assert.AreEqual(20.0, geometry.Length, 1.0e-6);
            Assert.AreEqual(41.0, geometry.Coordinates[0].Y, 1.0e-6);
            Assert.AreEqual(41.0, geometry.Coordinates[1].Y, 1.0e-6);
            Assert.AreEqual(41.0, geometry.Coordinates[2].Y, 1.0e-6);
            Assert.AreEqual(41.0, geometry.Coordinates[3].Y, 1.0e-6);
        }
Exemplo n.º 16
0
        public void AddDefaultZToGeometry()
        {
            var crossSection = new CrossSectionDefinitionXYZ();
            // just a horizontal line from 10 to 40. Now just set z to 0 to make it work.
            // could be something more fancy.
            var coordinates = new List <ICoordinate>
            {
                new Coordinate(0, 0),
                new Coordinate(10, 0),
                new Coordinate(20, 0),
                new Coordinate(30, 0),
                new Coordinate(40, 0)
            };

            crossSection.Geometry = new LineString(coordinates.ToArray());
            CrossSectionHelper.AddDefaultZToGeometry(crossSection);
            Assert.AreEqual(10.0, crossSection.Geometry.Coordinates[0].Z);
            Assert.AreEqual(5.0, crossSection.Geometry.Coordinates[1].Z);
            Assert.AreEqual(0.0, crossSection.Geometry.Coordinates[2].Z);
            Assert.AreEqual(5.0, crossSection.Geometry.Coordinates[3].Z);
            Assert.AreEqual(10.0, crossSection.Geometry.Coordinates[4].Z);
        }
Exemplo n.º 17
0
        public void YZTableToXyzGeometryAt90DegreeBranchTest()
        {
            var branchGeometry = new LineString(new[] { new Coordinate(11, 22), new Coordinate(111, 122) });
            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)
            };
            IGeometry geometry = CrossSectionHelper.CreateCrossSectionGeometryForXyzCrossSectionFromYZ(branchGeometry, 30, yzCoordinates);

            Assert.AreEqual(20.0, geometry.Length, 1.0e-6);

            //
            //
            //                 111, 122
            //                   ^
            //                  /
            //                 /
            //                /
            //               /
            //  cs[count-1] /
            //           \ /
            //            +
            //           / \cs[0]
            //          /
            //      11, 22
            //
            Assert.Greater(geometry.Coordinates[0].X, geometry.Coordinates[1].X);
            Assert.Greater(geometry.Coordinates[1].X, geometry.Coordinates[2].X);
            Assert.Greater(geometry.Coordinates[2].X, geometry.Coordinates[3].X);

            Assert.Less(geometry.Coordinates[0].Y, geometry.Coordinates[1].Y);
            Assert.Less(geometry.Coordinates[1].Y, geometry.Coordinates[2].Y);
            Assert.Less(geometry.Coordinates[2].Y, geometry.Coordinates[3].Y);
        }
Exemplo n.º 18
0
        public void YZProfileFromHeightFlowStorageWidthWithVerticalSide()
        {
            // [---------------------------] width 15
            //
            //
            //
            // [---------------------------] width 15
            IList <HeightFlowStorageWidth> tabulatedData = new List <HeightFlowStorageWidth>
            {
                new HeightFlowStorageWidth(-10.0, 25, 15),
                new HeightFlowStorageWidth(0.0, 25, 15)
            };
            IList <ICoordinate> yZValues = new List <ICoordinate>();

            CrossSectionHelper.CalculateYZProfileFromTabulatedCrossSection(yZValues, tabulatedData, "", true);
            Assert.AreEqual(4, yZValues.Count);
            // left part:
            // 0 (-7.5001, 0)
            //  \
            //   \
            //    1
            // (-7.5, -10)
            Assert.AreEqual(-7.501, yZValues[0].X, 1.0e-6);
            Assert.AreEqual(0.0, yZValues[0].Y, 1.0e-6);
            Assert.AreEqual(-7.5, yZValues[1].X, 1.0e-6);
            Assert.AreEqual(-10.0, yZValues[1].Y, 1.0e-6);

            // left part:
            //               3 (7.5001, 0)
            //              /
            //             /
            //   ---------2
            //       (7.5, -10)
            Assert.AreEqual(7.5, yZValues[2].X, 1.0e-6);
            Assert.AreEqual(-10.0, yZValues[2].Y, 1.0e-6);
            Assert.AreEqual(7.501, yZValues[3].X, 1.0e-6);
            Assert.AreEqual(0.0, yZValues[3].Y, 1.0e-6);
        }
Exemplo n.º 19
0
        public void YZTableToXyzGeometryAtHorizontalBranchTest()
        {
            var branchGeometry = new LineString(new[] { new Coordinate(11, 0), new Coordinate(111, 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)
            };
            IGeometry geometry = CrossSectionHelper.CreateCrossSectionGeometryForXyzCrossSectionFromYZ(branchGeometry, 30, yzCoordinates);

            Assert.AreEqual(20.0, geometry.Length, 1.0e-6);
            Assert.IsInstanceOfType(typeof(LineString), geometry);
            Assert.AreEqual(4, geometry.Coordinates.Length);
            // test if z values are set correctly to geometry
            Assert.AreEqual(0.0, geometry.Coordinates[0].Z, 1.0e-6);
            Assert.AreEqual(-20.0, geometry.Coordinates[1].Z, 1.0e-6);
            Assert.AreEqual(-20.0, geometry.Coordinates[2].Z, 1.0e-6);
            Assert.AreEqual(0.0, geometry.Coordinates[3].Z, 1.0e-6);
            // test is geometry is a vertical line
            Assert.AreEqual(41.0, geometry.Coordinates[0].X, 1.0e-6);
            Assert.AreEqual(41.0, geometry.Coordinates[1].X, 1.0e-6);
            Assert.AreEqual(41.0, geometry.Coordinates[2].X, 1.0e-6);
            Assert.AreEqual(41.0, geometry.Coordinates[3].X, 1.0e-6);
            //
            //                  cs[count-1] (10)
            //                        |
            // branch start(11) ------41---------------> end (111)
            //                        |
            //                   cs[0] (-10)
            //
            Assert.AreEqual(-10.0, geometry.Coordinates[0].Y, 1.0e-6);
            Assert.AreEqual(10.0, geometry.Coordinates[3].Y, 1.0e-6);
        }
Exemplo n.º 20
0
        public void GeometryToYzToGeometryOrThereAndBackAgain()
        {
            var branchGeometry = new LineString(new[] { new Coordinate(111, 0), new Coordinate(11, 0) });
            var channel        = new Channel {
                Geometry = branchGeometry
            };
            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)
            };
            IGeometry geometry = CrossSectionHelper.CreateCrossSectionGeometryForXyzCrossSectionFromYZ(branchGeometry,
                                                                                                       30, yzCoordinates);
            CrossSection crossSection = new CrossSection {
                Geometry = geometry, Offset = 10
            };

            NetworkHelper.AddBranchFeatureToBranch(channel, crossSection, crossSection.Offset);
            Assert.AreEqual(CrossSectionType.GeometryBased, crossSection.CrossSectionType);
            const int coordinateCount = 4;

            Assert.AreEqual(coordinateCount, crossSection.Geometry.Coordinates.Length);
            Assert.AreEqual(coordinateCount, crossSection.YZValues.Count);

            CrossSectionHelper.ConvertCrossSectionType(crossSection, CrossSectionType.YZTable);
            Assert.AreEqual(coordinateCount, crossSection.YZValues.Count);
            Assert.AreEqual(2, crossSection.Geometry.Coordinates.Length);
            Assert.AreEqual(4, crossSection.YZValues.Count);
            CrossSectionHelper.ConvertCrossSectionType(crossSection, CrossSectionType.GeometryBased);
            Assert.AreEqual(CrossSectionType.GeometryBased, crossSection.CrossSectionType);
            Assert.AreEqual(coordinateCount, crossSection.Geometry.Coordinates.Length);
        }
Exemplo n.º 21
0
        public void ChangeRoughnessTypeCausesPropertyChanged()
        {
            IChannel channel = new Channel {
                Geometry = new LineString(new[] { new Coordinate(0, 0), new Coordinate(20, 0) })
            };
            var crossSection = new CrossSection {
                Branch = channel, CrossSectionType = CrossSectionType.YZTable
            };

            CrossSectionHelper.CreateDefaultYZTableAndGeometryForYZCrossSection(crossSection, 100.0);
            crossSection.SetRoughness(10.0, 1.0, RoughnessType.Chezy, "");

            int callCount = 0;

            ((INotifyPropertyChanged)(crossSection)).PropertyChanged += (s, e) =>
            {
                callCount++;
                Assert.AreEqual("RoughnessType",
                                e.PropertyName);
            };

            crossSection.RoughnessSections[0].RoughnessType = RoughnessType.StricklerKn;
            Assert.AreEqual(1, callCount);
        }
Exemplo n.º 22
0
        public void SetDefaultGeometryNoBranche()
        {
            var crossSection = new CrossSection();

            CrossSectionHelper.SetDefaultGeometry(crossSection, 1);
        }
Exemplo n.º 23
0
        public void TestDefaultCrossSectionGeometry()
        {
            var crossSection = new CrossSection();

            CrossSectionHelper.CreateDefaultYZTableAndGeometryForYZCrossSection(crossSection, 100.0);
        }