Example #1
0
        /// <summary>
        /// Adds a cross section to this branch and gives it the right position
        /// </summary>
        /// <param name="cs"></param>
        public void AddCrossection(CrossSection cs)
        {
            CrossSections.Add(cs);

            M11Point p_upstream;
            M11Point p_downstream;

            //Find upstream POINTS.

            //The cross section is at the end of the branch. Cast to int to avoid rounding problems
            if (Math.Round(_points.Last().Chainage) == Math.Round(cs.Chainage))
            {
                p_upstream = _points.Last();
            }
            else
            {
                p_upstream = _points.FirstOrDefault(var => var.Chainage > cs.Chainage);
            }

            //Downstream point is the previous point
            p_downstream = _points[_points.IndexOf(p_upstream) - 1];

            //Set the POINTS on the cross section
            cs.SetPoints(p_downstream, p_upstream);
        }
Example #2
0
        public override bool Equals(object obj)
        {
            CrossSection othercs = obj as CrossSection;

            if (othercs == null)
            {
                return(false);
            }
            return(BranchName == othercs.BranchName & TopoID == othercs.TopoID & Chainage == othercs.Chainage);
        }
Example #3
0
 /// <summary>
 /// Adds the cross section to the correct branch
 /// </summary>
 /// <param name="MyCs"></param>
 private void CombineNetworkAndCrossSections(CrossSection MyCs)
 {
     if (network != null)
     {
         //Finds the branch with the correct name, topoid, and chainage interval
         M11Branch mb = network.Branches.FirstOrDefault(var => var.Name.ToUpper() == MyCs.BranchName.ToUpper() & var.TopoID.ToUpper() == MyCs.TopoID.ToUpper() & var.ChainageStart <= MyCs.Chainage & var.ChainageEnd >= MyCs.Chainage);
         if (mb != null)
         {
             mb.AddCrossection(MyCs);
         }
     }
 }
Example #4
0
        /// <summary>
        /// Reads the cross sections from an .xns-file
        /// </summary>
        /// <param name="xnsFile"></param>
        public void ReadCrossSections(string xnsFile)
        {
            CrossSectionDataFactory cd = new CrossSectionDataFactory();

            xsecs = cd.Open(xnsFile, null);


            //Now loop the cross sections
            foreach (var cs in xsecs)
            {
                XSOpen Opencs = cs.BaseCrossSection as XSOpen;
                if (Opencs != null)
                {
                    //Create a HydroNumerics.MikeSheTools.Mike11.CrossSection from the M11-CrossSection
                    CrossSection MyCs = new CrossSection(cs);

                    CombineNetworkAndCrossSections(MyCs);
                }
            }
        }
Example #5
0
 /// <summary>
 /// Adds the cross section to the correct branch
 /// </summary>
 /// <param name="MyCs"></param>
 private void CombineNetworkAndCrossSections(CrossSection MyCs)
 {
   if (network != null)
   {
     //Finds the branch with the correct name, topoid, and chainage interval
     M11Branch mb = network.Branches.FirstOrDefault(var => var.Name.ToUpper() == MyCs.BranchName.ToUpper() & var.TopoID.ToUpper() == MyCs.TopoID.ToUpper() & var.ChainageStart <= MyCs.Chainage & var.ChainageEnd >= MyCs.Chainage);
     if (mb != null)
       mb.AddCrossection(MyCs);
   } 
 }
Example #6
0
    /// <summary>
    /// Reads the cross sections from an .xns-file
    /// </summary>
    /// <param name="xnsFile"></param>
    public void ReadCrossSections(string xnsFile)
    {
      CrossSectionDataFactory cd = new CrossSectionDataFactory();
      xsecs = cd.Open(xnsFile, null);
      
     
      //Now loop the cross sections
      foreach (var cs in xsecs)
      {
        XSOpen Opencs = cs.BaseCrossSection as XSOpen;
        if (Opencs != null)
        {
          //Create a HydroNumerics.MikeSheTools.Mike11.CrossSection from the M11-CrossSection
          CrossSection MyCs = new CrossSection(cs);

          CombineNetworkAndCrossSections(MyCs);
        }
      }
    }
 public void SetPointsTest1()
 {
   CrossSection target = new CrossSection();
   IXYPoint p1 = new HydroNumerics.Geometry.XYPoint(0, 0);
   IXYPoint p2 = new HydroNumerics.Geometry.XYPoint(10, 2);
   target.SetPoints(p1, p2, 0, 10, 5);
   Assert.AreEqual(5, target.MidStreamLocation.X);
   Assert.AreEqual(1, target.MidStreamLocation.Y);
 }
Example #8
0
    /// <summary>
    /// Adds a cross section to this branch and gives it the right position
    /// </summary>
    /// <param name="cs"></param>
    public void AddCrossection(CrossSection cs)
    {
      CrossSections.Add(cs);
     
      M11Point p_upstream;
      M11Point p_downstream;

      //Find upstream POINTS.

      //The cross section is at the end of the branch. Cast to int to avoid rounding problems
      if (Math.Round(_points.Last().Chainage) == Math.Round(cs.Chainage))
        p_upstream = _points.Last();
      else
        p_upstream = _points.FirstOrDefault(var => var.Chainage > cs.Chainage);

      //Downstream point is the previous point
      p_downstream = _points[_points.IndexOf(p_upstream) - 1];

      //Set the POINTS on the cross section
      cs.SetPoints(p_downstream, p_upstream);
    }