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); }
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); }
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); }
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); }
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); }
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); }