Exemplo n.º 1
0
		[TestMethod] public void GetLine()
		{
			// -- Triangle -- 
			XYPolygon xypolygon = new XYPolygon();
			xypolygon.Points.Add(new XYPoint(1,2));
			xypolygon.Points.Add(new XYPoint(4,3));
			xypolygon.Points.Add(new XYPoint(2,5));

			Assert.AreEqual(new XYLine(1,2,4,3),xypolygon.GetLine(0));
			Assert.AreEqual(new XYLine(4,3,2,5),xypolygon.GetLine(1));
			Assert.AreEqual(new XYLine(2,5,1,2),xypolygon.GetLine(2));

			
			// -- concave polygon --
			XYPolygon xypolygon4 = new XYPolygon();
			xypolygon4.Points.Add(new XYPoint(1,1));
			xypolygon4.Points.Add(new XYPoint(9,1));
			xypolygon4.Points.Add(new XYPoint(5,5));
			xypolygon4.Points.Add(new XYPoint(5,3));
			xypolygon4.Points.Add(new XYPoint(3,3));
			xypolygon4.Points.Add(new XYPoint(3,8));
			xypolygon4.Points.Add(new XYPoint(9,8));
			xypolygon4.Points.Add(new XYPoint(9,11));
			xypolygon4.Points.Add(new XYPoint(1,11));

			Assert.AreEqual(new XYLine(1, 1, 9,  1),xypolygon4.GetLine(0));
			Assert.AreEqual(new XYLine(9, 1, 5,  5),xypolygon4.GetLine(1));
			Assert.AreEqual(new XYLine(5, 5, 5,  3),xypolygon4.GetLine(2));
			Assert.AreEqual(new XYLine(5, 3, 3,  3),xypolygon4.GetLine(3));
			Assert.AreEqual(new XYLine(3, 3, 3,  8),xypolygon4.GetLine(4));
			Assert.AreEqual(new XYLine(3, 8, 9,  8),xypolygon4.GetLine(5));
			Assert.AreEqual(new XYLine(9, 8, 9, 11),xypolygon4.GetLine(6));
			Assert.AreEqual(new XYLine(9,11, 1 ,11),xypolygon4.GetLine(7));
			Assert.AreEqual(new XYLine(1,11, 1 , 1),xypolygon4.GetLine(8));
		}
Exemplo n.º 2
0
    public static XYPolygon GetIntersection(XYPolygon pol1, XYPolygon pol2)
    {



      List<List<IntPoint>> subj = new List<List<IntPoint>>();
  subj.Add(new List<IntPoint>(pol1.Points.Count));
      foreach(var p in pol1.Points)
        subj[0].Add(new IntPoint(p.X, p.Y));


      List<List<IntPoint>> clip = new List<List<IntPoint>>();
      clip.Add(new List<IntPoint>(pol2.Points.Count));
  foreach (var p in pol2.Points)
    clip[0].Add(new IntPoint(p.X, p.Y));


  List<List<IntPoint>> solution = new List<List<IntPoint>>();

	Clipper c = new Clipper();
	c.AddPaths(subj, PolyType.ptSubject, true);
	c.AddPaths(clip, PolyType.ptClip, true);
	c.Execute(ClipType.ctIntersection, solution, 
	  PolyFillType.pftEvenOdd, PolyFillType.pftEvenOdd);

  XYPolygon ToReturn = new XYPolygon();
  if (solution.Count > 0) 
  foreach (var p in solution[0])
    ToReturn.Points.Add(new XYPoint(p.X,p.Y));

          return ToReturn;
    }
Exemplo n.º 3
0
    public void LoadPartial(string FileName, XYPolygon Area)
    {

      using (StreamReader sr = new StreamReader(FileName))
      {
        string line = sr.ReadLine();
        NumberOfColumns = int.Parse(line.Split(new Char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)[1]);
        line = sr.ReadLine();
        NumberOfRows = int.Parse(line.Split(new Char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)[1]);
        line = sr.ReadLine();
        XOrigin = double.Parse(line.Split(new Char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)[1]);
        line = sr.ReadLine();
        YOrigin = double.Parse(line.Split(new Char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)[1]);
        line = sr.ReadLine();
        GridSize = double.Parse(line.Split(new Char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)[1]);
        line = sr.ReadLine();
        DeleteValue = double.Parse(line.Split(new Char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)[1]);


        double MinX = Area.Points.Min(x => x.X);
        double MaxX = Area.Points.Max(x => x.X);
        double MaxY = Area.Points.Max(p => p.Y);
        double MinY = Area.Points.Min(p => p.Y);



      }

    }
Exemplo n.º 4
0
 /// <summary>
 /// Constructor. Copies the contents of the xyPolygon parameter.
 /// </summary>
 /// <param name="xyPolygon">Polygon to copy.</param>
 /// <returns>None</returns>
 public XYPolygon(XYPolygon xyPolygon) : this()
 {
     //	Points = new ArrayList();
     foreach (XYPoint xypoint in xyPolygon.Points)
     {
         Points.Add(new XYPoint(xypoint.X, xypoint.Y));
     }
 }
Exemplo n.º 5
0
    public static XYPolygon[,] GetPolygons(IGrid Grid)
    {
      XYPolygon[,] polygons = new XYPolygon[Grid.NumberOfColumns,Grid.NumberOfRows];

      for (int i = 0; i < Grid.NumberOfColumns; i++)
        for (int j = 0; j < Grid.NumberOfRows; j++)
          polygons[i, j] = GetSquare(Math.Pow(Grid.GridSize, 2), new XYPoint(Grid.XOrigin + i * Grid.GridSize, Grid.YOrigin + j * Grid.GridSize));
      return polygons;
    }
Exemplo n.º 6
0
    public SiteViewModel( GeoRefData Area, IWellCollection  Wells)
    {
      area = Area;
      site = area.Geometry as XYPolygon;
      this.Wells = Wells;

      DisplayName = Area.Data[0].ToString();
      Samples = new ObservableCollection<Sample>();
    }
Exemplo n.º 7
0
        /// <summary>
        /// Gets a rectangle from the four corners
        /// </summary>
        /// <param name="xmin"></param>
        /// <param name="xmax"></param>
        /// <param name="ymin"></param>
        /// <param name="ymax"></param>
        /// <returns></returns>
        public static XYPolygon Box(double xmin, double xmax, double ymin, double ymax)
        {
            XYPolygon boundingBox = new XYPolygon();

            boundingBox.Points.Add(new XYPoint(xmin, ymin));
            boundingBox.Points.Add(new XYPoint(xmin, ymax));
            boundingBox.Points.Add(new XYPoint(xmax, ymax));
            boundingBox.Points.Add(new XYPoint(xmax, ymin));
            boundingBox.Points.Add(new XYPoint(xmin, ymin));
            return(boundingBox);
        }
Exemplo n.º 8
0
    public static XYPolygon GetSquare(double area, IXYPoint LowerLeft)
    {
      double length = Math.Pow(area, 0.5);
      XYPolygon pol = new XYPolygon();
      pol.Points.Add(LowerLeft);
      pol.Points.Add(new XYPoint(LowerLeft.X + length, LowerLeft.Y));

      pol.Points.Add(new XYPoint(LowerLeft.X + length, LowerLeft.Y + length));
      pol.Points.Add(new XYPoint(LowerLeft.X, LowerLeft.Y + length));

      return pol;
    }
Exemplo n.º 9
0
        private bool OverLaps(XYPolygon Poly)
        {
            //Are any of the other polygon bounding box corners with in this polygon
            if (Poly.BoundingBox.Points.Any(p => this.BoundingBox.Contains(p)))
            {
                foreach (var P in Poly.Points)
                {
                    if (Contains(P))
                    {
                        return(true);
                    }
                }
            }

            // Are any of this bounding box corners in the other polygon
            if (this.BoundingBox.Points.Any(p => Poly.BoundingBox.Contains(p)))
            {
                foreach (var P in Points)
                {
                    if (Poly.Contains(P))
                    {
                        return(true);
                    }
                }
            }
            //Do any of the bounding box lines intersect/
            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    if (XYGeometryTools.DoLineSegmentsIntersect(Poly.BoundingBox.Points[i], Poly.BoundingBox.Points[i + 1], BoundingBox.Points[j], BoundingBox.Points[j + 1]))
                    {
                        foreach (var P in Points)
                        {
                            if (Poly.Contains(P))
                            {
                                return(true);
                            }
                        }
                        foreach (var P in Poly.Points)
                        {
                            if (Contains(P))
                            {
                                return(true);
                            }
                        }
                    }
                }
            }

            return(false);
        }
Exemplo n.º 10
0
        public static XYPolygon[,] GetPolygons(IGrid Grid)
        {
            XYPolygon[,] polygons = new XYPolygon[Grid.NumberOfColumns, Grid.NumberOfRows];

            for (int i = 0; i < Grid.NumberOfColumns; i++)
            {
                for (int j = 0; j < Grid.NumberOfRows; j++)
                {
                    polygons[i, j] = GetSquare(Math.Pow(Grid.GridSize, 2), new XYPoint(Grid.XOrigin + i * Grid.GridSize, Grid.YOrigin + j * Grid.GridSize));
                }
            }
            return(polygons);
        }
Exemplo n.º 11
0
        public static XYPolygon GetSquare(double area, IXYPoint LowerLeft)
        {
            double    length = Math.Pow(area, 0.5);
            XYPolygon pol    = new XYPolygon();

            pol.Points.Add(LowerLeft);
            pol.Points.Add(new XYPoint(LowerLeft.X + length, LowerLeft.Y));

            pol.Points.Add(new XYPoint(LowerLeft.X + length, LowerLeft.Y + length));
            pol.Points.Add(new XYPoint(LowerLeft.X, LowerLeft.Y + length));

            return(pol);
        }
Exemplo n.º 12
0
        /// <summary>
        /// The method decides if the triangle formed by  P(i-1), P(i) and
        /// P(i+1) from Polygon are intersected by any of the other points
        /// of the polygon.
        /// </summary>
        /// <param name="i">Middle index for the three points that forms the triangle</param>
        /// <returns>
        ///	<p>true: If the triangle P(i-1), P(i), P(i+1) is intersected by other parts of Polygon</p>
        ///	<p>false: otherwise</p>
        /// </returns>
        protected bool IsIntersected(int i)
        {
            double x = 0;
            double y = 0;
            int    n = Points.Count;

            int im1 = i - 1;
            int ip1 = i + 1;

            if (i == 0)
            {
                im1 = n - 1;
            }
            else if (i == n - 1)
            {
                ip1 = 0;
            }

            XYPoint   nodeim1      = new XYPoint((XYPoint)Points[im1]);
            XYPoint   nodei        = new XYPoint((XYPoint)Points[i]);
            XYPoint   nodeip1      = new XYPoint((XYPoint)Points[ip1]);
            XYPolygon localPolygon = new XYPolygon();

            localPolygon.Points.Add(nodeim1);
            localPolygon.Points.Add(nodei);
            localPolygon.Points.Add(nodeip1);

            int  j           = 0;
            bool intersected = false;

            while (((j < n - 1) && (!intersected)))
            {
                x = Points[j].X;
                y = Points[j].Y;

                if (((((j != im1) && (j != i)) && (j != ip1)) && XYGeometryTools.IsPointInPolygon(x, y, localPolygon)))
                {
                    return(true);
                }
                else
                {
                    j++;
                }
            }
            return(false);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Determines if a point in inside or outside a polygon.
        /// Works for both convex and concave polygons (Winding number test)
        /// </summary>
        /// <param name="x">x-coordinate for the point</param>
        /// <param name="y">y-coordiante for the point</param>
        /// <param name="polygon">Polygon</param>
        /// <returns>
        ///	<p>true:  If the point is inside the polygon</p>
        ///	<p>false: If the point is outside the polygon.</p>
        /// </returns>
        public static bool IsPointInPolygon(double x, double y, XYPolygon polygon)
        {
            double x1, x2, y1, y2;
            double xinters;
            bool   isInside = false;
            int    n        = polygon.Points.Count;

            for (int i = 0; i < n; i++)
            {
                if (i < n - 1)
                {
                    x1 = polygon.Points[i].X;
                    x2 = polygon.Points[i + 1].X;
                    y1 = polygon.Points[i].Y;
                    y2 = polygon.Points[i + 1].Y;
                }
                else
                {
                    x1 = polygon.Points[n - 1].X;
                    x2 = polygon.Points[0].X;
                    y1 = polygon.Points[n - 1].Y;
                    y2 = polygon.Points[0].Y;
                }

                if (y > Math.Min(y1, y2))
                {
                    if (y <= Math.Max(y1, y2))
                    {
                        if (x <= Math.Max(x1, x2))
                        {
                            if (y1 != y2)
                            {
                                xinters = (y - y1) * (x2 - x1) / (y2 - y1) + x1;

                                if (x1 == x2 || x <= xinters)
                                {
                                    isInside = !isInside;
                                }
                            }
                        }
                    }
                }
            }
            return(isInside);
        }
Exemplo n.º 14
0
        /// <summary>
        /// The methods calculates the shared area of two arbitrarily shaped
        /// polygons.
        /// </summary>
        /// <param name="polygonA">Polygon</param>
        /// <param name="polygonB">Polygon</param>
        /// <returns>
        ///	<p>The shared area.</p>
        /// </returns>
        public static double CalculateSharedArea(XYPolygon polygonA, XYPolygon polygonB)
        {
            var triangleListA = polygonA.GetTriangulation();
            var triangleListB = polygonB.GetTriangulation();

            double area = 0;

            for (int ia = 0; ia < triangleListA.Count; ia++)
            {
                XYPolygon triangleA = new XYPolygon(triangleListA[ia]);
                for (int ib = 0; ib < triangleListB.Count; ib++)
                {
                    XYPolygon triangleB = new XYPolygon(triangleListB[ib]);
                    area = area + TriangleIntersectionArea(triangleA, triangleB);
                }
            }
            return(area);
        }
Exemplo n.º 15
0
        public IEnumerable <XYPolygon> DivideIntoGrid(int Factor)
        {
            ASCIIGrid ag = new ASCIIGrid();

            ag.Data     = new MathNet.Numerics.LinearAlgebra.Double.DenseMatrix(Factor, Factor);
            ag.XOrigin  = this.Points.Min(p => p.X);
            ag.YOrigin  = this.Points.Min(p => p.Y);
            ag.GridSize = (Points.Max(p => p.X) - Points.Min(p => p.X)) / Factor;
            var area = XYPolygon.GetPolygons(ag);

            for (int i = 0; i < area.GetLength(0); i++)
            {
                for (int j = 0; j < area.GetLength(1); j++)
                {
                    yield return(area[i, j]);
                }
            }
        }
Exemplo n.º 16
0
        public static XYPolygon GetIntersection(XYPolygon pol1, XYPolygon pol2)
        {
            List <List <IntPoint> > subj = new List <List <IntPoint> >();

            subj.Add(new List <IntPoint>(pol1.Points.Count));
            foreach (var p in pol1.Points)
            {
                subj[0].Add(new IntPoint(p.X, p.Y));
            }


            List <List <IntPoint> > clip = new List <List <IntPoint> >();

            clip.Add(new List <IntPoint>(pol2.Points.Count));
            foreach (var p in pol2.Points)
            {
                clip[0].Add(new IntPoint(p.X, p.Y));
            }


            List <List <IntPoint> > solution = new List <List <IntPoint> >();

            Clipper c = new Clipper();

            c.AddPaths(subj, PolyType.ptSubject, true);
            c.AddPaths(clip, PolyType.ptClip, true);
            c.Execute(ClipType.ctIntersection, solution,
                      PolyFillType.pftEvenOdd, PolyFillType.pftEvenOdd);

            XYPolygon ToReturn = new XYPolygon();

            if (solution.Count > 0)
            {
                foreach (var p in solution[0])
                {
                    ToReturn.Points.Add(new XYPoint(p.X, p.Y));
                }
            }

            return(ToReturn);
        }
Exemplo n.º 17
0
        /// <summary>
        /// Determines if a point in inside or outside a polygon. Inside
        /// includes on the edge for this method.
        /// Works for both convex and concave polygons (Winding number test)
        /// </summary>
        /// <param name="x">x-coordinate for the point</param>
        /// <param name="y">y-coordiante for the point</param>
        /// <param name="polygon">Polygon</param>
        /// <returns>
        ///	<p>true:  If the point is inside the polygon</p>
        ///	<p>false: If the point is outside the polygon.</p>
        /// </returns>
        public static bool IsPointInPolygonOrOnEdge(double x, double y, XYPolygon polygon)
        {
            bool result = IsPointInPolygon(x, y, polygon);

            if (result)
            {
                return(result);
            }
            else
            {
                int iLine = 0;
                while ((!result) && (iLine < polygon.Points.Count))
                {
                    XYLine line;
                    line   = polygon.GetLine(iLine);
                    result = IsPointInLine(x, y, line);
                    iLine++;
                }
            }
            return(result);
        }
Exemplo n.º 18
0
		public void GetArea()
		{
			// -- Rectangle --
			XYPolygon xypolygon = new XYPolygon();
			xypolygon.Points.Add(new XYPoint(1,1));
			xypolygon.Points.Add(new XYPoint(9,1));
			xypolygon.Points.Add(new XYPoint(9,6));
			xypolygon.Points.Add(new XYPoint(1,6));
			Assert.AreEqual((double) 40, xypolygon.GetArea());

			// -- Triangle -- 
			XYPolygon xypolygon2 = new XYPolygon();
			xypolygon2.Points.Add(new XYPoint(1,1));
			xypolygon2.Points.Add(new XYPoint(9,1));
			xypolygon2.Points.Add(new XYPoint(9,6));
			Assert.AreEqual((double) 20, xypolygon2.GetArea());

			// -- concave --
			XYPolygon xypolygon3 = new XYPolygon();
			xypolygon3.Points.Add(new XYPoint(1,1));
			xypolygon3.Points.Add(new XYPoint(5,3));
			xypolygon3.Points.Add(new XYPoint(9,1));
			xypolygon3.Points.Add(new XYPoint(9,6));
			xypolygon3.Points.Add(new XYPoint(1,6));
			Assert.AreEqual((double) 32, xypolygon3.GetArea());

			// -- concave --
			XYPolygon xypolygon4 = new XYPolygon();
			xypolygon4.Points.Add(new XYPoint(1,1));
			xypolygon4.Points.Add(new XYPoint(9,1));
			xypolygon4.Points.Add(new XYPoint(5,5));
			xypolygon4.Points.Add(new XYPoint(5,3));
			xypolygon4.Points.Add(new XYPoint(3,3));
			xypolygon4.Points.Add(new XYPoint(3,8));
			xypolygon4.Points.Add(new XYPoint(9,8));
			xypolygon4.Points.Add(new XYPoint(9,11));
			xypolygon4.Points.Add(new XYPoint(1,11));
			Assert.AreEqual((double) 50, xypolygon4.GetArea());
		}
Exemplo n.º 19
0
        /// <summary>
        /// Returns an ArrayList of triangles of type XYPolygon describing the
        /// triangalation of the polygon.
        /// </summary>
        /// <param></param>
        /// <returns>
        /// A triangulation of the polygon.
        /// </returns>
        public List <XYPolygon> GetTriangulation()
        {
            if (TriangleList == null)
            {
                int i   = 0;
                int im1 = 0;
                int ip1 = 0;
                int n   = 0;

                XYPolygon LocalPolygon = new XYPolygon(this);
                TriangleList = new List <XYPolygon>();
                while (LocalPolygon.Points.Count > 3)
                {
                    i   = LocalPolygon.FindEar();
                    n   = LocalPolygon.Points.Count;
                    im1 = i - 1;
                    ip1 = i + 1;
                    if (i == 0)
                    {
                        im1 = n - 1;
                    }
                    else if (i == n - 1)
                    {
                        ip1 = 0;
                    }
                    XYPoint   Nodeim1  = new XYPoint((XYPoint)LocalPolygon.Points[im1]);
                    XYPoint   Nodei    = new XYPoint((XYPoint)LocalPolygon.Points[i]);
                    XYPoint   Nodeip1  = new XYPoint((XYPoint)LocalPolygon.Points[ip1]);
                    XYPolygon Triangle = new XYPolygon();
                    Triangle.Points.Add(Nodeim1);
                    Triangle.Points.Add(Nodei);
                    Triangle.Points.Add(Nodeip1);
                    TriangleList.Add(Triangle);
                    LocalPolygon.Points.RemoveAt(i);
                }
                TriangleList.Add(LocalPolygon);
            }
            return(TriangleList);
        }
Exemplo n.º 20
0
        public void LoadPartial(string FileName, XYPolygon Area)
        {
            using (StreamReader sr = new StreamReader(FileName))
            {
                string line = sr.ReadLine();
                NumberOfColumns = int.Parse(line.Split(new Char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)[1]);
                line            = sr.ReadLine();
                NumberOfRows    = int.Parse(line.Split(new Char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)[1]);
                line            = sr.ReadLine();
                XOrigin         = double.Parse(line.Split(new Char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)[1]);
                line            = sr.ReadLine();
                YOrigin         = double.Parse(line.Split(new Char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)[1]);
                line            = sr.ReadLine();
                GridSize        = double.Parse(line.Split(new Char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)[1]);
                line            = sr.ReadLine();
                DeleteValue     = double.Parse(line.Split(new Char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)[1]);


                double MinX = Area.Points.Min(x => x.X);
                double MaxX = Area.Points.Max(x => x.X);
                double MaxY = Area.Points.Max(p => p.Y);
                double MinY = Area.Points.Min(p => p.Y);
            }
        }
Exemplo n.º 21
0
 public GroundWaterBoundary(IWaterBody connection, double hydraulicConductivity, double distance, double groundwaterHead, XYPolygon ContactPolygon):this()
 {
   Connection = connection;
   HydraulicConductivity = hydraulicConductivity;
   Distance = distance;
   GroundwaterHead = groundwaterHead;
   ContactGeometry = ContactPolygon;
 }
Exemplo n.º 22
0
    /// <summary>
    /// The method decides if the triangle formed by  P(i-1), P(i) and 
    /// P(i+1) from Polygon are intersected by any of the other points 
    /// of the polygon.
    /// </summary>
    /// <param name="i">Middle index for the three points that forms the triangle</param>
    /// <returns>
    ///	<p>true: If the triangle P(i-1), P(i), P(i+1) is intersected by other parts of Polygon</p>
    ///	<p>false: otherwise</p>
    /// </returns>
    protected bool IsIntersected(int i)
    {
      double x = 0;
      double y = 0;
      int n = Points.Count;
      
      int im1 = i-1;
      int ip1 = i+1;
      if (i == 0)
      {
        im1 = n-1;
      }
      else if (i == n-1)
      {
        ip1 = 0;
      }
      
      XYPoint nodeim1 = new XYPoint((XYPoint) Points[im1]);
      XYPoint nodei   = new XYPoint((XYPoint) Points[i]);
      XYPoint nodeip1 = new XYPoint((XYPoint) Points[ip1]);
      XYPolygon localPolygon = new XYPolygon();
      localPolygon.Points.Add(nodeim1);
      localPolygon.Points.Add(nodei);
      localPolygon.Points.Add(nodeip1);

      int j = 0;
      bool intersected = false;
      while (((j < n-1) && (!intersected)))
      {
        x = Points[j].X;
        y = Points[j].Y;

        if (((((j!=im1) && (j!=i)) && (j!=ip1)) && XYGeometryTools.IsPointInPolygon(x,y,localPolygon)))
        {
          return true;
        }
        else
        {
          j++;
        }
      }
      return false;
    }
Exemplo n.º 23
0
    /// <summary>
    /// Constructor. Copies the contents of the xyPolygon parameter.
    /// </summary>
    /// <param name="xyPolygon">Polygon to copy.</param>
    /// <returns>None</returns>
    public XYPolygon(XYPolygon xyPolygon):this()
		{
		//	Points = new ArrayList();
			foreach (XYPoint xypoint in xyPolygon.Points)
			{
				Points.Add(new XYPoint(xypoint.X, xypoint.Y));
			}
		}
Exemplo n.º 24
0
 public Lake(string name, XYPolygon surface)
   : base(name)
 {
   SurfaceArea = surface;
   Depth = 1;
   Initialize();
 }
Exemplo n.º 25
0
    public XYPolygon Surround2(Func<double, bool> function)
    {
      XYPolygon toreturn = new XYPolygon();



      return toreturn;
    }
Exemplo n.º 26
0
        private Model CreateHydroNetModel()
        {
            
            DateTime startTime = new DateTime(2000, 1, 1);
          

            // -------------------- Polygons --------------------------------------
            HydroNumerics.Geometry.XYPolygon upperLakeGeometry = new HydroNumerics.Geometry.XYPolygon();
            upperLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(535.836, 2269.625));
            upperLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(675.768, 2187.713));
            upperLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(771.331, 2177.474));
            upperLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(887.372, 2184.300));
            upperLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(935.154, 2255.973));
            upperLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(945.392, 2385.666));
            upperLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(931.741, 2505.119));
            upperLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(877.133, 2546.075));
            upperLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(812.287, 2638.225));
            upperLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(696.246, 2675.768));
            upperLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(638.225, 2627.986));
            upperLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(573.379, 2587.031));

            HydroNumerics.Geometry.XYPolygon lowerLakeGeometry = new HydroNumerics.Geometry.XYPolygon();
            lowerLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1935.154, 1150.171));
            lowerLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1901.024, 1058.020));
            lowerLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1877.133, 965.870));
            lowerLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1894.198, 897.611));
            lowerLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1938.567, 808.874));
            lowerLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(2023.891, 761.092));
            lowerLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(2116.041, 740.614));
            lowerLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(2232.082, 747.440));
            lowerLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(2327.645, 808.874));
            lowerLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(2389.078, 969.283));
            lowerLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(2372.014, 1109.215));
            lowerLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(2262.799, 1218.430));
            lowerLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(2105.802, 1235.495));
            lowerLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1982.935, 1225.256));

            HydroNumerics.Geometry.XYPolygon upperStreamGeometry = new HydroNumerics.Geometry.XYPolygon();
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(863.481, 2177.474));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(914.676, 2129.693));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(965.870, 2071.672));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(976.109, 2027.304));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(976.109, 1989.761));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1006.826, 1959.044));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1051.195, 1918.089));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1095.563, 1877.133));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1126.280, 1808.874));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1187.713, 1781.570));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1228.669, 1730.375));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1262.799, 1665.529));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1283.276, 1597.270));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1317.406, 1535.836));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1341.297, 1484.642));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1389.078, 1457.338));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1423.208, 1440.273));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1477.816, 1402.730));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1511.945, 1358.362));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1539.249, 1327.645));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1566.553, 1354.949));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1535.836, 1406.143));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1508.532, 1457.338));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1440.273, 1522.184));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1368.601, 1580.205));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1327.645, 1631.399));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1307.167, 1696.246));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1269.625, 1767.918));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1221.843, 1819.113));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1191.126, 1843.003));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1136.519, 1894.198));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1088.737, 1935.154));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1061.433, 1976.109));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1030.717, 2040.956));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1013.652, 2105.802));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(972.696, 2177.474));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(918.089, 2228.669));

            HydroNumerics.Geometry.XYPolygon lowerStreamGeometry = new HydroNumerics.Geometry.XYPolygon();
            lowerStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1904.437, 1081.911));
            lowerStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1921.502, 1153.584));
            lowerStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1771.331, 1255.973));
            lowerStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1573.379, 1354.949));
            lowerStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1542.662, 1324.232));
            lowerStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1597.270, 1273.038));
            lowerStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1709.898, 1215.017));
            lowerStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1839.590, 1143.345));

            // --- precipitation --------------------------------------------------

            const int numberOfTimesteps = 2190;
            double[] precipitation = new double[numberOfTimesteps] { 0.0000, 0.0000, 2.3000, 0.2000, 0.0000, 0.1000, 0.1000, 0.0000, 0.3000, 0.4000, 0.1000, 0.1000, 1.0000, 0.0000, 0.5000, 5.3000, 1.9000, 0.1000, 0.0000, 0.4000, 1.1000, 1.2000, 2.6000, 0.0000, 1.5000, 3.4000, 6.0000, 0.7000, 4.0000, 0.1000, 0.6000, 2.0000, 0.4000, 0.1000, 0.0000, 0.0000, 0.0000, 4.1000, 0.2000, 4.0000, 0.3000, 0.6000, 3.1000, 14.1000, 3.9000, 0.1000, 3.7000, 2.4000, 4.3000, 0.0000, 0.0000, 0.0000, 0.0000, 2.7000, 1.0000, 0.1000, 0.3000, 0.2000, 0.0000, 0.2000, 8.7000, 2.0000, 1.8000, 0.9000, 0.1000, 0.2000, 0.1000, 0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1000, 0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.6000, 1.8000, 0.0000, 1.1000, 4.7000, 2.4000, 0.0000, 0.1000, 8.2000, 4.6000, 1.0000, 0.1000, 0.0000, 0.0000, 7.8000, 2.0000, 0.3000, 0.0000, 0.1000, 0.1000, 0.0000, 0.0000, 0.3000, 0.1000, 2.2000, 2.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1000, 6.7000, 0.0000, 0.0000, 0.0000, 5.4000, 2.2000, 1.0000, 10.8000, 3.6000, 3.1000, 10.1000, 0.0000, 0.3000, 2.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 1.3000, 0.0000, 0.0000, 7.6000, 3.6000, 0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1000, 4.5000, 0.0000, 12.8000, 0.0000, 4.4000, 0.0000, 0.0000, 0.0000, 0.0000, 4.9000, 0.0000, 0.8000, 0.0000, 2.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 7.1000, 0.2000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 4.4000, 1.5000, 4.6000, 1.4000, 0.8000, 0.0000, 0.0000, 0.0000, 0.0000, 5.5000, 4.6000, 1.3000, 0.1000, 2.8000, 2.6000, 0.0000, 0.1000, 3.5000, 1.0000, 8.7000, 0.5000, 0.0000, 0.4000, 0.0000, 0.0000, 0.0000, 0.0000, 3.8000, 4.9000, 4.6000, 2.5000, 7.9000, 0.1000, 4.7000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.6000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.2000, 14.4000, 2.0000, 6.2000, 0.5000, 0.3000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 3.2000, 8.1000, 1.3000, 20.2000, 13.5000, 1.1000, 1.3000, 0.0000, 0.0000, 2.1000, 13.7000, 3.9000, 0.5000, 0.1000, 0.0000, 0.0000, 0.1000, 0.0000, 0.0000, 0.2000, 4.8000, 7.2000, 0.4000, 0.0000, 4.6000, 0.2000, 0.0000, 0.0000, 0.5000, 4.8000, 9.8000, 0.6000, 0.0000, 0.0000, 0.0000, 0.0000, 3.2000, 0.0000, 0.0000, 0.0000, 0.0000, 0.4000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.5000, 8.5000, 0.5000, 1.9000, 1.2000, 0.0000, 3.2000, 1.7000, 12.3000, 1.9000, 0.0000, 4.3000, 3.6000, 1.1000, 6.7000, 5.4000, 0.0000, 0.0000, 0.9000, 10.0000, 7.8000, 0.1000, 1.3000, 0.5000, 0.1000, 0.2000, 0.5000, 0.0000, 7.2000, 0.0000, 0.0000, 10.2000, 9.7000, 0.2000, 0.1000, 0.9000, 3.5000, 1.2000, 4.9000, 4.6000, 3.5000, 1.1000, 5.8000, 0.4000, 0.0000, 0.0000, 0.6000, 0.1000, 1.2000, 0.8000, 9.4000, 1.5000, 0.1000, 0.1000, 0.2000, 0.9000, 4.8000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1000, 0.0000, 0.1000, 1.9000, 0.8000, 0.9000, 2.1000, 7.9000, 3.8000, 3.8000, 9.6000, 1.4000, 7.9000, 0.4000, 0.6000, 0.7000, 0.0000, 0.0000, 0.0000, 7.0000, 0.1000, 0.1000, 0.1000, 5.3000, 1.0000, 4.3000, 0.2000, 0.0000, 1.8000, 0.1000, 0.6000, 0.0000, 1.5000, 3.2000, 0.1000, 4.1000, 5.5000, 10.6000, 9.0000, 0.9000, 0.8000, 2.7000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.4000, 0.6000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1000, 0.1000, 2.5000, 5.7000, 2.3000, 2.0000, 0.6000, 0.8000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 4.2000, 9.6000, 0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.7000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 9.3000, 0.0000, 0.0000, 0.0000, 0.0000, 5.3000, 0.0000, 0.0000, 0.7000, 9.0000, 0.2000, 0.0000, 0.0000, 2.8000, 2.4000, 1.5000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 6.4000, 0.0000, 0.0000, 0.8000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 7.1000, 0.1000, 0.0000, 0.2000, 0.0000, 0.0000, 0.2000, 0.0000, 0.6000, 0.9000, 10.0000, 5.1000, 4.1000, 10.3000, 1.9000, 0.0000, 0.0000, 0.0000, 0.2000, 4.2000, 0.4000, 5.8000, 0.5000, 0.1000, 3.3000, 4.9000, 1.4000, 0.5000, 0.0000, 1.8000, 2.5000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1000, 1.4000, 0.0000, 2.4000, 7.6000, 5.2000, 11.4000, 0.1000, 1.1000, 0.7000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.8000, 0.0000, 2.3000, 0.4000, 0.0000, 0.0000, 0.0000, 0.0000, 5.2000, 2.2000, 0.0000, 10.0000, 5.3000, 1.2000, 8.0000, 30.7000, 2.9000, 0.0000, 0.0000, 0.0000, 6.8000, 0.0000, 0.0000, 0.0000, 1.4000, 0.5000, 4.1000, 0.1000, 10.6000, 11.2000, 2.5000, 6.2000, 5.3000, 4.5000, 12.8000, 0.1000, 1.0000, 0.0000, 0.0000, 22.7000, 2.5000, 5.5000, 3.7000, 0.8000, 0.0000, 1.6000, 1.7000, 3.8000, 0.2000, 0.3000, 0.0000, 0.4000, 0.0000, 0.2000, 0.5000, 1.0000, 16.3000, 0.3000, 4.3000, 14.8000, 0.0000, 2.7000, 0.0000, 2.8000, 3.2000, 5.3000, 2.1000, 0.0000, 2.2000, 0.4000, 0.3000, 0.1000, 0.0000, 0.0000, 1.8000, 0.5000, 9.4000, 11.4000, 2.4000, 9.2000, 1.1000, 11.1000, 6.4000, 8.3000, 15.3000, 0.1000, 6.8000, 2.9000, 0.0000, 0.3000, 0.4000, 0.2000, 3.3000, 6.2000, 1.0000, 9.0000, 5.5000, 0.0000, 0.0000, 3.0000, 1.1000, 0.0000, 10.8000, 0.0000, 7.1000, 2.0000, 1.6000, 7.2000, 9.4000, 0.9000, 6.1000, 1.4000, 2.5000, 0.6000, 8.1000, 0.9000, 2.8000, 5.0000, 3.3000, 2.1000, 9.5000, 0.0000, 6.0000, 7.0000, 0.0000, 2.2000, 1.8000, 0.2000, 1.1000, 5.2000, 0.0000, 0.3000, 1.6000, 0.8000, 0.4000, 0.0000, 0.2000, 1.4000, 5.9000, 7.1000, 7.0000, 1.9000, 1.5000, 0.1000, 0.3000, 5.6000, 4.1000, 4.8000, 1.5000, 1.5000, 2.7000, 11.4000, 8.6000, 3.7000, 5.7000, 1.3000, 13.4000, 5.6000, 5.9000, 5.4000, 5.3000, 0.1000, 0.1000, 0.2000, 0.0000, 0.5000, 0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 4.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1000, 0.0000, 2.9000, 3.0000, 1.0000, 14.6000, 0.6000, 5.0000, 0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1000, 1.6000, 2.2000, 0.0000, 0.0000, 0.6000, 0.0000, 0.2000, 2.4000, 0.3000, 0.0000, 0.3000, 5.8000, 1.6000, 1.6000, 5.7000, 2.8000, 1.9000, 0.6000, 2.8000, 0.0000, 8.8000, 2.5000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 3.1000, 0.0000, 0.0000, 0.0000, 0.2000, 0.5000, 0.0000, 3.7000, 5.0000, 10.2000, 1.2000, 0.4000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.6000, 0.3000, 0.0000, 0.0000, 2.2000, 8.4000, 11.5000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.8000, 12.4000, 2.8000, 3.9000, 10.1000, 4.5000, 6.6000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.5000, 0.5000, 0.0000, 0.7000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.3000, 0.7000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 3.2000, 1.4000, 7.3000, 0.0000, 3.7000, 11.1000, 1.2000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1000, 8.3000, 2.2000, 6.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.2000, 0.0000, 0.0000, 0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 11.6000, 5.9000, 0.0000, 0.0000, 8.9000, 17.1000, 0.1000, 4.9000, 2.3000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 14.5000, 2.7000, 1.9000, 3.3000, 0.0000, 0.0000, 19.9000, 2.4000, 4.1000, 2.0000, 4.2000, 0.9000, 0.3000, 0.0000, 0.1000, 0.3000, 0.0000, 3.1000, 2.5000, 0.0000, 1.6000, 3.8000, 8.2000, 5.7000, 7.7000, 0.3000, 0.0000, 5.4000, 7.9000, 1.3000, 10.0000, 0.6000, 0.7000, 0.0000, 0.0000, 0.0000, 0.9000, 0.0000, 0.0000, 0.1000, 2.6000, 6.3000, 4.7000, 0.7000, 0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.2000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 2.3000, 2.0000, 0.0000, 3.1000, 0.9000, 0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.3000, 0.4000, 7.5000, 12.4000, 2.9000, 0.5000, 7.6000, 1.6000, 2.3000, 0.0000, 0.0000, 2.1000, 2.3000, 8.0000, 2.1000, 1.7000, 0.0000, 0.0000, 17.9000, 4.5000, 0.5000, 0.7000, 0.3000, 0.0000, 1.1000, 0.1000, 0.0000, 0.0000, 1.1000, 0.1000, 0.0000, 1.2000, 0.0000, 1.2000, 0.8000, 0.7000, 0.0000, 0.1000, 0.2000, 0.2000, 0.0000, 0.4000, 1.3000, 0.0000, 0.0000, 0.0000, 0.1000, 1.4000, 0.0000, 0.0000, 2.3000, 0.2000, 0.0000, 0.1000, 0.1000, 0.0000, 0.3000, 0.4000, 0.1000, 0.1000, 1.0000, 0.0000, 0.5000, 5.3000, 1.9000, 0.1000, 0.0000, 0.4000, 1.1000, 1.2000, 2.6000, 0.0000, 1.5000, 3.4000, 6.0000, 0.7000, 4.0000, 0.1000, 0.6000, 2.0000, 0.4000, 0.1000, 0.0000, 0.0000, 0.0000, 4.1000, 0.2000, 4.0000, 0.3000, 0.6000, 3.1000, 14.1000, 3.9000, 0.1000, 3.7000, 2.4000, 4.3000, 0.0000, 0.0000, 0.0000, 0.0000, 2.7000, 1.0000, 0.1000, 0.3000, 0.2000, 0.0000, 0.2000, 8.7000, 2.0000, 1.8000, 0.9000, 0.1000, 0.2000, 0.1000, 0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1000, 0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.6000, 1.8000, 0.0000, 1.1000, 4.7000, 2.4000, 0.0000, 0.1000, 8.2000, 4.6000, 1.0000, 0.1000, 0.0000, 0.0000, 7.8000, 2.0000, 0.3000, 0.0000, 0.1000, 0.1000, 0.0000, 0.0000, 0.3000, 0.1000, 2.2000, 2.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1000, 6.7000, 0.0000, 0.0000, 0.0000, 5.4000, 2.2000, 1.0000, 10.8000, 3.6000, 3.1000, 10.1000, 0.0000, 0.3000, 2.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 1.3000, 0.0000, 0.0000, 7.6000, 3.6000, 0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1000, 4.5000, 0.0000, 12.8000, 0.0000, 4.4000, 0.0000, 0.0000, 0.0000, 0.0000, 4.9000, 0.0000, 0.8000, 0.0000, 2.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 7.1000, 0.2000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 4.4000, 1.5000, 4.6000, 1.4000, 0.8000, 0.0000, 0.0000, 0.0000, 0.0000, 5.5000, 4.6000, 1.3000, 0.1000, 2.8000, 2.6000, 0.0000, 0.1000, 3.5000, 1.0000, 8.7000, 0.5000, 0.0000, 0.4000, 0.0000, 0.0000, 0.0000, 0.0000, 3.8000, 4.9000, 4.6000, 2.5000, 7.9000, 0.1000, 4.7000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.6000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.2000, 14.4000, 2.0000, 6.2000, 0.5000, 0.3000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 3.2000, 8.1000, 1.3000, 20.2000, 13.5000, 1.1000, 1.3000, 0.0000, 0.0000, 2.1000, 13.7000, 3.9000, 0.5000, 0.1000, 0.0000, 0.0000, 0.1000, 0.0000, 0.0000, 0.2000, 4.8000, 7.2000, 0.4000, 0.0000, 4.6000, 0.2000, 0.0000, 0.0000, 0.5000, 4.8000, 9.8000, 0.6000, 0.0000, 0.0000, 0.0000, 0.0000, 3.2000, 0.0000, 0.0000, 0.0000, 0.0000, 0.4000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.5000, 8.5000, 0.5000, 1.9000, 1.2000, 0.0000, 3.2000, 1.7000, 12.3000, 1.9000, 0.0000, 4.3000, 3.6000, 1.1000, 6.7000, 5.4000, 0.0000, 0.0000, 0.9000, 10.0000, 7.8000, 0.1000, 1.3000, 0.5000, 0.1000, 0.2000, 0.5000, 0.0000, 7.2000, 0.0000, 0.0000, 10.2000, 9.7000, 0.2000, 0.1000, 0.9000, 3.5000, 1.2000, 4.9000, 4.6000, 3.5000, 1.1000, 5.8000, 0.4000, 0.0000, 0.0000, 0.6000, 0.1000, 1.2000, 0.8000, 9.4000, 1.5000, 0.1000, 0.1000, 0.2000, 0.9000, 4.8000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1000, 0.0000, 0.1000, 1.9000, 0.8000, 0.9000, 2.1000, 7.9000, 3.8000, 3.8000, 9.6000, 1.4000, 7.9000, 0.4000, 0.6000, 0.7000, 0.0000, 0.0000, 0.0000, 7.0000, 0.1000, 0.1000, 0.1000, 5.3000, 1.0000, 4.3000, 0.2000, 0.0000, 1.8000, 0.1000, 0.6000, 0.0000, 1.5000, 3.2000, 0.1000, 4.1000, 5.5000, 10.6000, 9.0000, 0.9000, 0.8000, 2.7000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.4000, 0.6000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1000, 0.1000, 2.5000, 5.7000, 2.3000, 2.0000, 0.6000, 0.8000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 4.2000, 9.6000, 0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.7000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 9.3000, 0.0000, 0.0000, 0.0000, 0.0000, 5.3000, 0.0000, 0.0000, 0.7000, 9.0000, 0.2000, 0.0000, 0.0000, 2.8000, 2.4000, 1.5000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 6.4000, 0.0000, 0.0000, 0.8000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 7.1000, 0.1000, 0.0000, 0.2000, 0.0000, 0.0000, 0.2000, 0.0000, 0.6000, 0.9000, 10.0000, 5.1000, 4.1000, 10.3000, 1.9000, 0.0000, 0.0000, 0.0000, 0.2000, 4.2000, 0.4000, 5.8000, 0.5000, 0.1000, 3.3000, 4.9000, 1.4000, 0.5000, 0.0000, 1.8000, 2.5000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1000, 1.4000, 0.0000, 2.4000, 7.6000, 5.2000, 11.4000, 0.1000, 1.1000, 0.7000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.8000, 0.0000, 2.3000, 0.4000, 0.0000, 0.0000, 0.0000, 0.0000, 5.2000, 2.2000, 0.0000, 10.0000, 5.3000, 1.2000, 8.0000, 30.7000, 2.9000, 0.0000, 0.0000, 0.0000, 6.8000, 0.0000, 0.0000, 0.0000, 1.4000, 0.5000, 4.1000, 0.1000, 10.6000, 11.2000, 2.5000, 6.2000, 5.3000, 4.5000, 12.8000, 0.1000, 1.0000, 0.0000, 0.0000, 22.7000, 2.5000, 5.5000, 3.7000, 0.8000, 0.0000, 1.6000, 1.7000, 3.8000, 0.2000, 0.3000, 0.0000, 0.4000, 0.0000, 0.2000, 0.5000, 1.0000, 16.3000, 0.3000, 4.3000, 14.8000, 0.0000, 2.7000, 0.0000, 2.8000, 3.2000, 5.3000, 2.1000, 0.0000, 2.2000, 0.4000, 0.3000, 0.1000, 0.0000, 0.0000, 1.8000, 0.5000, 9.4000, 11.4000, 2.4000, 9.2000, 1.1000, 11.1000, 6.4000, 8.3000, 15.3000, 0.1000, 6.8000, 2.9000, 0.0000, 0.3000, 0.4000, 0.2000, 3.3000, 6.2000, 1.0000, 9.0000, 5.5000, 0.0000, 0.0000, 3.0000, 1.1000, 0.0000, 10.8000, 0.0000, 7.1000, 2.0000, 1.6000, 7.2000, 9.4000, 0.9000, 6.1000, 1.4000, 2.5000, 0.6000, 8.1000, 0.9000, 2.8000, 5.0000, 3.3000, 2.1000, 9.5000, 0.0000, 6.0000, 7.0000, 0.0000, 2.2000, 1.8000, 0.2000, 1.1000, 5.2000, 0.0000, 0.3000, 1.6000, 0.8000, 0.4000, 0.0000, 0.2000, 1.4000, 5.9000, 7.1000, 7.0000, 1.9000, 1.5000, 0.1000, 0.3000, 5.6000, 4.1000, 4.8000, 1.5000, 1.5000, 2.7000, 11.4000, 8.6000, 3.7000, 5.7000, 1.3000, 13.4000, 5.6000, 5.9000, 5.4000, 5.3000, 0.1000, 0.1000, 0.2000, 0.0000, 0.5000, 0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 4.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1000, 0.0000, 2.9000, 3.0000, 1.0000, 14.6000, 0.6000, 5.0000, 0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1000, 1.6000, 2.2000, 0.0000, 0.0000, 0.6000, 0.0000, 0.2000, 2.4000, 0.3000, 0.0000, 0.3000, 5.8000, 1.6000, 1.6000, 5.7000, 2.8000, 1.9000, 0.6000, 2.8000, 0.0000, 8.8000, 2.5000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 3.1000, 0.0000, 0.0000, 0.0000, 0.2000, 0.5000, 0.0000, 3.7000, 5.0000, 10.2000, 1.2000, 0.4000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.6000, 0.3000, 0.0000, 0.0000, 2.2000, 8.4000, 11.5000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.8000, 12.4000, 2.8000, 3.9000, 10.1000, 4.5000, 6.6000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.5000, 0.5000, 0.0000, 0.7000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.3000, 0.7000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 3.2000, 1.4000, 7.3000, 0.0000, 3.7000, 11.1000, 1.2000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1000, 8.3000, 2.2000, 6.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.2000, 0.0000, 0.0000, 0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 11.6000, 5.9000, 0.0000, 0.0000, 8.9000, 17.1000, 0.1000, 4.9000, 2.3000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 14.5000, 2.7000, 1.9000, 3.3000, 0.0000, 0.0000, 19.9000, 2.4000, 4.1000, 2.0000, 4.2000, 0.9000, 0.3000, 0.0000, 0.1000, 0.3000, 0.0000, 3.1000, 2.5000, 0.0000, 1.6000, 3.8000, 8.2000, 5.7000, 7.7000, 0.3000, 0.0000, 5.4000, 7.9000, 1.3000, 10.0000, 0.6000, 0.7000, 0.0000, 0.0000, 0.0000, 0.9000, 0.0000, 0.0000, 0.1000, 2.6000, 6.3000, 4.7000, 0.7000, 0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.2000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 2.3000, 2.0000, 0.0000, 3.1000, 0.9000, 0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.3000, 0.4000, 7.5000, 12.4000, 2.9000, 0.5000, 7.6000, 1.6000, 2.3000, 0.0000, 0.0000, 2.1000, 2.3000, 8.0000, 2.1000, 1.7000, 0.0000, 0.0000, 17.9000, 4.5000, 0.5000, 0.7000, 0.3000, 0.0000, 1.1000, 0.1000, 0.0000, 0.0000, 1.1000, 0.1000, 0.0000, 1.2000, 0.0000, 1.2000, 0.8000, 0.7000, 0.0000, 0.1000, 0.2000, 0.2000, 0.0000, 0.4000, 1.3000, 0.0000, 0.0000, 0.0000, 0.1000, 1.4000 };
            HydroNumerics.Time.Core.TimestampSeries precipitationTs = new HydroNumerics.Time.Core.TimestampSeries("PrecipitationTS", startTime, numberOfTimesteps, 1, HydroNumerics.Time.Core.TimestepUnit.Days, -99999, new HydroNumerics.Core.Unit("m3PrSec", 1, 0));
            //HydroNumerics.Time.Core.TimestampSeries precipitationTs = new HydroNumerics.Time.Core.TimestampSeries("PrecipitationTS", startTime, numberOfTimesteps, 1, HydroNumerics.Time.Core.TimestepUnit.Days, -99999, new HydroNumerics.Core.Unit("mmPrDay", 1.0/(1000*24*3600), 0));
            for (int i = 0; i < numberOfTimesteps; i++)
            {
                precipitationTs.Items[i].Value = precipitation[i]  / (24 * 3600 * 1000);
                //precipitationTs.Items[i].Value = precipitation[i];
            }
            // --------------------------------------------------------------------


            // Upper Lake configuration
            //Lake upperLake = new Lake("Upper Lake", 2 * upperLakeGeometry.GetArea());
            Lake upperLake = new Lake("Upper Lake", upperLakeGeometry);
            upperLake.WaterLevel = 6.1;
            upperLake.Depth = 2;
            upperLake.Output.LogAllChemicals = true;
            

            //Lake lowerLake = new Lake("lower Lake", 2 * lowerLakeGeometry.GetArea());
            Lake lowerLake = new Lake("lower Lake", lowerLakeGeometry);
            lowerLake.Depth = 2;
            lowerLake.WaterLevel = 6.0;
            lowerLake.Output.LogAllChemicals = true;

            HydroNet.Core.Stream upperStream = new HydroNet.Core.Stream("The stream", 2000, 2, 1);
            upperStream.WaterLevel = 6.0;
            upperStream.Output.LogAllChemicals = true;
            
            HydroNet.Core.Stream lowerStream = new HydroNet.Core.Stream("Lower Stream", 1000, 2, 1);
            lowerStream.WaterLevel = 6.0;
            lowerStream.Output.LogAllChemicals = true;

            //SinkSourceBoundary upperLakePrecipitation = new SinkSourceBoundary(0.002 * contactPolygonUpperLake.GetArea() / (24 * 3600));
            SinkSourceBoundary upperLakePrecipitation = new SinkSourceBoundary(precipitationTs);
            upperLakePrecipitation.ContactGeometry = upperLakeGeometry;
            
            upperLakePrecipitation.Name = "Inflow to upperlake";


            //SinkSourceBoundary lowerLakePrecipitation = new SinkSourceBoundary(0.002 * contactPolygonLowerLake.GetArea()/ (24 * 3600));
            SinkSourceBoundary lowerLakePrecipitation = new SinkSourceBoundary(precipitationTs);
            lowerLakePrecipitation.ContactGeometry = lowerLakeGeometry;
            upperLakePrecipitation.Name = "Inflow to lowerlake";

            // -------- Groundwater boundary under upper lake ----------
            GroundWaterBoundary groundWaterBoundaryUpperLake = new GroundWaterBoundary();
            groundWaterBoundaryUpperLake.Connection = upperLake;
            groundWaterBoundaryUpperLake.ContactGeometry = upperLakeGeometry;
            groundWaterBoundaryUpperLake.Distance = 2.3;
            groundWaterBoundaryUpperLake.HydraulicConductivity = 1e-9;
            groundWaterBoundaryUpperLake.GroundwaterHead = 5.0;
            groundWaterBoundaryUpperLake.Name = "Groundwater boundary under UpperLake";
            groundWaterBoundaryUpperLake.Name = "UpperGWBoundary";
            ((WaterPacket)groundWaterBoundaryUpperLake.WaterSample).AddChemical(ChemicalFactory.Instance.GetChemical(ChemicalNames.Radon), 2.3);
            ((WaterPacket)groundWaterBoundaryUpperLake.WaterSample).AddChemical(ChemicalFactory.Instance.GetChemical(ChemicalNames.Cl), 2.3);

            // -------- Groundwater boundary under lower lake ----------
            GroundWaterBoundary groundWaterBoundaryLowerLake = new GroundWaterBoundary();
            groundWaterBoundaryLowerLake.Connection = lowerLake;
            groundWaterBoundaryLowerLake.ContactGeometry = lowerLakeGeometry;
            groundWaterBoundaryLowerLake.Distance = 2.3;
            groundWaterBoundaryLowerLake.HydraulicConductivity = 1e-12;
            groundWaterBoundaryLowerLake.GroundwaterHead = 5.0;
            groundWaterBoundaryLowerLake.Name = "Groundwater boundary under LowerLake";
            groundWaterBoundaryLowerLake.Name = "LowerGWBoundary";

            //--- Ground water boundary upper Stream ------
            GroundWaterBoundary groundWaterBoundaryUpperStream = new GroundWaterBoundary();
            groundWaterBoundaryUpperStream.Connection = upperStream;
            groundWaterBoundaryUpperStream.ContactGeometry = upperStreamGeometry;
            groundWaterBoundaryUpperStream.Distance = 2.3;
            groundWaterBoundaryUpperStream.HydraulicConductivity = 1e-12;
            groundWaterBoundaryUpperStream.GroundwaterHead = 5.0;
            groundWaterBoundaryUpperStream.Name = "Groundwater boundary Upper Stream";
            groundWaterBoundaryUpperStream.Name = "UpperStreamGWBoundary";
            
            // ---------  Ground water boundary lower stream ------------------------------------------
            GroundWaterBoundary groundWaterBoundaryLowerStream = new GroundWaterBoundary();
            groundWaterBoundaryLowerStream.Connection = lowerStream;
            groundWaterBoundaryLowerStream.ContactGeometry = lowerStreamGeometry;
            groundWaterBoundaryLowerStream.Distance = 2.3;
            groundWaterBoundaryLowerStream.HydraulicConductivity = 1e-12;
            groundWaterBoundaryLowerStream.GroundwaterHead = 5.0;
            groundWaterBoundaryLowerStream.Name = "Groundwater boundary Lower Stream";
            groundWaterBoundaryLowerStream.Name = "LowerStreamGWBoundary";
            // ------------------------------------------------------------------------------

            upperLake.SurfaceArea = upperLakeGeometry;
            lowerLake.SurfaceArea = lowerLakeGeometry;
            upperLake.Precipitation.Add(upperLakePrecipitation);
            lowerLake.Precipitation.Add(lowerLakePrecipitation);

            upperLake.GroundwaterBoundaries.Add(groundWaterBoundaryUpperLake);
            upperStream.GroundwaterBoundaries.Add(groundWaterBoundaryUpperStream);
            lowerStream.GroundwaterBoundaries.Add(groundWaterBoundaryLowerStream);
            lowerLake.GroundwaterBoundaries.Add(groundWaterBoundaryLowerLake);

 
            upperLake.DownStreamConnections.Add(upperStream);
            upperStream.DownStreamConnections.Add(lowerStream);
            lowerStream.DownStreamConnections.Add(lowerLake);

            //Creating the model
            Model model = new Model();
            model._waterBodies.Add(upperLake);
            model._waterBodies.Add(upperStream);
            model._waterBodies.Add(lowerStream);
            model._waterBodies.Add(lowerLake);
            

            WaterPacket waterPacket = new WaterPacket(1000);
            waterPacket.AddChemical(ChemicalFactory.Instance.GetChemical(ChemicalNames.Cl), 9.2);

            WaterPacket waterpacketLowerLake = new WaterPacket(lowerLake.Volume);
            waterpacketLowerLake.AddChemical(ChemicalFactory.Instance.GetChemical(ChemicalNames.Cl), 4.2);


            model.SetState("MyState", startTime, waterPacket);
            lowerLake.SetState("MyState", startTime, waterpacketLowerLake);
            
            //model.SetState("kkk", startTime, new 
            //upperLake.SetState("MyState", startTime, new WaterPacket(2));
            model.Name = "Lake model";
            model.Initialize();
            //model.Update(new DateTime(2001, 1, 1));
            return model;
        }
Exemplo n.º 27
0
        /// <summary>
        /// Calculates the length of polyline inside polygon. Lines segments on the edges of
        /// polygons are included with half their length.
        /// </summary>
        /// <param name="polyline">Polyline</param>
        /// <param name="polygon">Polygon</param>
        /// <returns>
        /// Length of polyline inside polygon.
        /// </returns>
        public static double CalculateLengthOfPolylineInsidePolygon(XYPolyline polyline, XYPolygon polygon)
        {
            double lengthInside         = 0;
            int    numberOfLineSegments = polyline.Points.Count - 1;

            for (int i = 0; i < numberOfLineSegments; i++)
            {
                XYLine line = new XYLine(polyline.GetLine(i));
                lengthInside += CalculateLengthOfLineInsidePolygon(line, polygon);
            }
            return(lengthInside);
        }
Exemplo n.º 28
0
    public void Protected_CalculateLengthOfLineInsidePolygon()
    {
      XYPolygon xypolygon = new XYPolygon();
      xypolygon.Points.Add(new XYPoint(1,1));
      xypolygon.Points.Add(new XYPoint(9,1));
      xypolygon.Points.Add(new XYPoint(5,5));
      xypolygon.Points.Add(new XYPoint(5,3));
      xypolygon.Points.Add(new XYPoint(3,3));
      xypolygon.Points.Add(new XYPoint(3,8));
      xypolygon.Points.Add(new XYPoint(9,8));
      xypolygon.Points.Add(new XYPoint(9,11));
      xypolygon.Points.Add(new XYPoint(1,11));

      Assert.AreEqual(0, AXYGeometryTools.ACalculateLengthOfLineInsidePolygon(new XYLine(-2,12,11,12),xypolygon),"Test1");
      Assert.AreEqual(4, AXYGeometryTools.ACalculateLengthOfLineInsidePolygon(new XYLine(-2,11,11,11),xypolygon),"Test2");
      Assert.AreEqual(8, AXYGeometryTools.ACalculateLengthOfLineInsidePolygon(new XYLine(-2,10,11,10),xypolygon),"Test3");
      Assert.AreEqual(8, AXYGeometryTools.ACalculateLengthOfLineInsidePolygon(new XYLine(-2,9,11,9),xypolygon),"Test4");
      
      Assert.AreEqual(5, AXYGeometryTools.ACalculateLengthOfLineInsidePolygon(new XYLine(-2,8,11,8),xypolygon),"Test5");
      Assert.AreEqual(2, AXYGeometryTools.ACalculateLengthOfLineInsidePolygon(new XYLine(-2,7,11,7),xypolygon),"Test6");
      Assert.AreEqual(2, AXYGeometryTools.ACalculateLengthOfLineInsidePolygon(new XYLine(-2,5,11,5),xypolygon),"Test7");
      Assert.AreEqual(3, AXYGeometryTools.ACalculateLengthOfLineInsidePolygon(new XYLine(-2,4,11,4),xypolygon),"Test8");

      Assert.AreEqual(3, AXYGeometryTools.ACalculateLengthOfLineInsidePolygon(new XYLine(-2,4,11,4),xypolygon),"Test9");
      Assert.AreEqual(5, AXYGeometryTools.ACalculateLengthOfLineInsidePolygon(new XYLine(-2,3,11,3),xypolygon),"Test10");
      Assert.AreEqual(7, AXYGeometryTools.ACalculateLengthOfLineInsidePolygon(new XYLine(-2,2,11,2),xypolygon),"Test11");
      Assert.AreEqual(4, AXYGeometryTools.ACalculateLengthOfLineInsidePolygon(new XYLine(-2,1,11,1),xypolygon),"Test12");
      Assert.AreEqual(0, AXYGeometryTools.ACalculateLengthOfLineInsidePolygon(new XYLine(-2,0,11,0),xypolygon),"Test13");

      Assert.AreEqual(10, AXYGeometryTools.ACalculateLengthOfLineInsidePolygon(new XYLine(2,12,2,0),xypolygon),"Test14");
      Assert.AreEqual(6,  AXYGeometryTools.ACalculateLengthOfLineInsidePolygon(new XYLine(6,12,6,0),xypolygon),"Test15");
      Assert.AreEqual(Math.Sqrt(8)+1.5*Math.Sqrt(0.5),AXYGeometryTools.ACalculateLengthOfLineInsidePolygon(new XYLine(1,0.5,10,9.5),xypolygon),"Test16");
      Assert.AreEqual(1, AXYGeometryTools.ACalculateLengthOfLineInsidePolygon(new XYLine(-2,4,2,4),xypolygon),"Test17");
      Assert.AreEqual(5, AXYGeometryTools.ACalculateLengthOfLineInsidePolygon(new XYLine(4,12,4,0),xypolygon),"Test18");
    }
Exemplo n.º 29
0
    public void Equals()
    {
      XYPolygon p1 = new XYPolygon();
      p1.Points.Add(new XYPoint(0, 3));
      p1.Points.Add(new XYPoint(3, 0));
      p1.Points.Add(new XYPoint(8, 0));
      p1.Points.Add(new XYPoint(8, 2));
      p1.Points.Add(new XYPoint(3, 1));
      p1.Points.Add(new XYPoint(3, 3));
      p1.Points.Add(new XYPoint(8, 3));
      p1.Points.Add(new XYPoint(4, 7));

      XYPolygon p2 = new XYPolygon();
      p2.Points.Add(new XYPoint(0, 3));
      p2.Points.Add(new XYPoint(3, 0));
      p2.Points.Add(new XYPoint(8, 0));
      p2.Points.Add(new XYPoint(8, 2));
      p2.Points.Add(new XYPoint(3, 1));
      p2.Points.Add(new XYPoint(3, 3));
      p2.Points.Add(new XYPoint(8, 3));
      p2.Points.Add(new XYPoint(4, 7));
      
      XYPolygon p3 = new XYPolygon();
      p3.Points.Add(new XYPoint(0, 3));
      p3.Points.Add(new XYPoint(3, 0));
      p3.Points.Add(new XYPoint(8, 0));
      p3.Points.Add(new XYPoint(8, 2));
      p3.Points.Add(new XYPoint(3, 1.1));
      p3.Points.Add(new XYPoint(3, 3));
      p3.Points.Add(new XYPoint(8, 3));
      p3.Points.Add(new XYPoint(4, 7));

      XYPolygon p4 = new XYPolygon();
      p4.Points.Add(new XYPoint(0, 3));
      p4.Points.Add(new XYPoint(3, 0));
      p4.Points.Add(new XYPoint(8, 0));
      p4.Points.Add(new XYPoint(8, 2));
      p4.Points.Add(new XYPoint(3, 1));
      p4.Points.Add(new XYPoint(3, 3));
      p4.Points.Add(new XYPoint(8, 3));
 
      XYPolyline p5 = new XYPolyline();
      p5.Points.Add(new XYPoint(0, 3));
      p5.Points.Add(new XYPoint(3, 0));
      p5.Points.Add(new XYPoint(8, 0));
      p5.Points.Add(new XYPoint(8, 2));
      p5.Points.Add(new XYPoint(3, 1.1));
      p5.Points.Add(new XYPoint(3, 3));
      p5.Points.Add(new XYPoint(8, 3));
      p5.Points.Add(new XYPoint(4, 7));
      
      Assert.AreEqual(true, p1.Equals(p1),"Test1");     
      Assert.AreEqual(true, p1.Equals(p2),"Test2");     
      Assert.AreEqual(false, p1.Equals(p3),"Test3");
      Assert.AreEqual(false, p1.Equals(p4),"Test4");
      Assert.AreEqual(false, p1.Equals(p5),"Test5");
    }
Exemplo n.º 30
0
 public void GetTriangulation()
 {
   XYPolygon p1 = new XYPolygon();
   p1.Points.Add(new XYPoint(0, 3));
   p1.Points.Add(new XYPoint(3, 0));
   p1.Points.Add(new XYPoint(8, 0));
   p1.Points.Add(new XYPoint(8, 2));
   p1.Points.Add(new XYPoint(3, 1));
   p1.Points.Add(new XYPoint(3, 3));
   p1.Points.Add(new XYPoint(8, 3));
   p1.Points.Add(new XYPoint(4, 7));
   var triangleList = p1.GetTriangulation();
   XYPolygon refTriangle1 = new XYPolygon();
   refTriangle1.Points.Add(new XYPoint(3,0));
   refTriangle1.Points.Add(new XYPoint(8,0));
   refTriangle1.Points.Add(new XYPoint(8,2));
   XYPolygon refTriangle2 = new XYPolygon();
   refTriangle2.Points.Add(new XYPoint(3,0));
   refTriangle2.Points.Add(new XYPoint(8,2));
   refTriangle2.Points.Add(new XYPoint(3,1));
   XYPolygon refTriangle3 = new XYPolygon();
   refTriangle3.Points.Add(new XYPoint(0,3));
   refTriangle3.Points.Add(new XYPoint(3,0));
   refTriangle3.Points.Add(new XYPoint(3,1));
   XYPolygon refTriangle4 = new XYPolygon();
   refTriangle4.Points.Add(new XYPoint(0,3));
   refTriangle4.Points.Add(new XYPoint(3,1));
   refTriangle4.Points.Add(new XYPoint(3,3));
   XYPolygon refTriangle5 = new XYPolygon();
   refTriangle5.Points.Add(new XYPoint(4,7));
   refTriangle5.Points.Add(new XYPoint(0,3));
   refTriangle5.Points.Add(new XYPoint(3,3));
   XYPolygon refTriangle6 = new XYPolygon();
   refTriangle6.Points.Add(new XYPoint(3,3));
   refTriangle6.Points.Add(new XYPoint(8,3));
   refTriangle6.Points.Add(new XYPoint(4,7));
   Assert.AreEqual(refTriangle1 ,(XYPolygon) triangleList[0]);
   Assert.AreEqual(refTriangle2 ,(XYPolygon) triangleList[1]);
   Assert.AreEqual(refTriangle3 ,(XYPolygon) triangleList[2]);
   Assert.AreEqual(refTriangle4 ,(XYPolygon) triangleList[3]);
   Assert.AreEqual(refTriangle5 ,(XYPolygon) triangleList[4]);
   Assert.AreEqual(refTriangle6 ,(XYPolygon) triangleList[5]);
 }	
Exemplo n.º 31
0
        /// <summary>
        /// Calculates length of line inside polygon. Parts of the line that is on the edge of
        /// the polygon only counts with half their length.
        /// </summary>
        /// <param name="line">Line</param>
        /// <param name="polygon">Polygon</param>
        /// <returns>
        /// Length of line inside polygon.
        /// </returns>
        protected static double CalculateLengthOfLineInsidePolygon(XYLine line, XYPolygon polygon)
        {
            ArrayList lineList = new ArrayList();

            lineList.Add(new XYLine(line));

            for (int i = 0; i < polygon.Points.Count; i++) // For all lines in the polygon
            {
                for (int n = 0; n < lineList.Count; n++)
                {
                    if (lineList.Count > 1000)
                    {
                        throw new Exception("Problems in ElementMapper, line has been cut in more than 1000 pieces !!!");
                    }

                    if (DoLineSegmentsIntersect((XYLine)lineList[n], polygon.GetLine(i)))
                    {
                        // Split the intersecting line into two lines
                        XYPoint IntersectionPoint = new XYPoint(CalculateIntersectionPoint((XYLine)lineList[n], polygon.GetLine(i)));
                        lineList.Add(new XYLine(IntersectionPoint, ((XYLine)lineList[n]).P2));
                        ((XYLine)lineList[n]).P2.X = IntersectionPoint.X;
                        ((XYLine)lineList[n]).P2.Y = IntersectionPoint.Y;
                        break;
                    }
                }
            }

            for (int i = 0; i < lineList.Count; i++)
            {
                if (lineList.Count > 1000)
                {
                    throw new Exception("Problems in ElementMapper, line has been cuttes in more than 100 pieces !!!");
                }
                for (int j = 0; j < polygon.Points.Count; j++)
                {
                    if (IsPointInLineInterior(polygon.GetLine(j).P1, ((XYLine)lineList[i])))
                    {
                        lineList.Add(new XYLine(polygon.GetLine(j).P1, ((XYLine)lineList[i]).P2));
                        ((XYLine)lineList[i]).P2.X = polygon.GetLine(j).P1.X;
                        ((XYLine)lineList[i]).P2.Y = polygon.GetLine(j).P1.Y;
                    }
                }
            }

            double lengthInside = 0;

            for (int i = 0; i < lineList.Count; i++)
            {
                double sharedLength = 0;
                for (int j = 0; j < polygon.Points.Count; j++)
                {
                    sharedLength += CalculateSharedLength(((XYLine)lineList[i]), polygon.GetLine(j));
                }
                if (sharedLength > EPSILON)
                {
                    lengthInside += sharedLength / 2;
                }
                else if (IsPointInPolygon(((XYLine)lineList[i]).GetMidpoint(), polygon))
                {
                    lengthInside += ((XYLine)lineList[i]).GetLength();
                }
            }
            return(lengthInside);
        }
Exemplo n.º 32
0
        /// <summary>
        /// The method calculates the intersection area of triangle a and b both
        /// of type XYPolygon.
        /// </summary>
        /// <param name="triangleA">Triangle of type XYPolygon</param>
        /// <param name="triangleB">Triangle of type XYPolygon</param>
        /// <returns>
        ///	Intersection area between the triangles triangleA and triAngleB.
        /// </returns>
        protected static double TriangleIntersectionArea(XYPolygon triangleA, XYPolygon triangleB)
        {
            try
            {
                if (triangleA.Points.Count != 3 || triangleB.Points.Count != 3)
                {
                    throw new System.Exception("Argument must be a polygon with 3 points");
                }
                int i = 1;                                       // Index for "next" node in polygon a.
                int j = -1;                                      // Index for "next" node in polygon b.
                // -1 indicates that the first has not yet been found.
                double    area = 0;                              // Intersection area. Returned.
                XYPolygon intersectionPolygon = new XYPolygon(); // Intersection polygon.
                IXYPoint  p = new XYPoint();                     // Latest intersection node found

                p.X = triangleA.Points[0].X;
                p.Y = triangleA.Points[0].Y;
                Intersect(triangleA, triangleB, ref p, ref i, ref j, ref intersectionPolygon);

                if (j != -1)
                {
                    // ERB 8/30/2012: For efficiency, allocate and initialize pFirst inside if block
                    IXYPoint pFirst = new XYPoint(); // First intersection point between triangles
                    pFirst = p;
                    int  jStop    = Increase(j, 2);
                    bool complete = false;
                    int  count    = 0;
                    while (!complete)
                    {
                        // coordinates for vectors pointing to next triangleA and triangleB point respectively
                        double vax = ((XYPoint)triangleA.Points[i]).X - p.X;
                        double vay = ((XYPoint)triangleA.Points[i]).Y - p.Y;
                        double vbx = ((XYPoint)triangleB.Points[j]).X - p.X;
                        double vby = ((XYPoint)triangleB.Points[j]).Y - p.Y;

                        if (IsPointInPolygonOrOnEdge(p.X + EPSILON * vax, p.Y + EPSILON * vay, triangleB))
                        {
                            Intersect(triangleA, triangleB, ref p, ref i, ref j, ref intersectionPolygon);
                        }
                        else if (IsPointInPolygonOrOnEdge(p.X + EPSILON * vbx, p.Y + EPSILON * vby, triangleA))
                        {
                            Intersect(triangleB, triangleA, ref p, ref j, ref i, ref intersectionPolygon);
                        }
                        else // triangleA and triangleB only touches one another but do not intersect
                        {
                            area = 0;
                            return(area);
                        }
                        if (intersectionPolygon.Points.Count > 1)
                        {
                            complete = (CalculatePointToPointDistance(p, pFirst) < EPSILON);
                        }
                        count++;
                        if (count > 20)
                        {
                            throw new System.Exception("Failed to find intersection polygon");
                        }
                    }
                    area = intersectionPolygon.GetArea();
                }
                else
                {
                    XYPoint pa = new XYPoint(); // internal point in triangle a
                    XYPoint pb = new XYPoint(); // internal point in triangle b

                    pa.X = (triangleA.GetX(0) + triangleA.GetX(1) + triangleA.GetX(2)) / 3;
                    pa.Y = (triangleA.GetY(0) + triangleA.GetY(1) + triangleA.GetY(2)) / 3;
                    pb.X = (triangleB.GetX(0) + triangleB.GetX(1) + triangleB.GetX(2)) / 3;
                    pb.Y = (triangleB.GetY(0) + triangleB.GetY(1) + triangleB.GetY(2)) / 3;

                    if (IsPointInPolygon(pa, triangleB) || IsPointInPolygon(pb, triangleA)) // triangleA is completely inside triangleB
                    {
                        area = Math.Min(triangleA.GetArea(), triangleB.GetArea());
                    }
                    else // triangleA and triangleB do dot intersect
                    {
                        area = 0;
                    }
                }
                return(area);
            }
            catch (System.Exception e)
            {
                throw new System.Exception("TriangleIntersectionArea failed", e);
            }
        }
Exemplo n.º 33
0
        /// <summary>
        /// The method calculates the intersection points of triangle a and b both
        /// of type XYPolygon.
        /// </summary>
        /// <param name="triangleA">triangle. The search is started along triangleA.</param>
        /// <param name="triangleB">triangle. Intersection with this triangle are sought.</param>
        /// <param name="p">Starting point for the search. p must be part of triangleA.</param>
        /// <param name="i">on input: End index for the first line segment of triangleA in the search.
        /// on output: End index for the last intersected line segment in triangleA.</param>
        /// <param name="j">on input: -1 if vertices before intersection is not to be added to list.
        /// on output: End index for last intersected line segment of triangleB.</param>
        /// <param name="intersectionPolygon">polygon eventuallu describing the
        /// intersection area between triangleA and triangleB</param>
        /// <returns>
        ///	The p, i, j and intersectionPolygon are called by reference and modified in the method.
        /// </returns>
        private static void Intersect(XYPolygon triangleA, XYPolygon triangleB,
                                      ref IXYPoint p, ref int i, ref int j,
                                      ref XYPolygon intersectionPolygon)
        {
            XYLine lineA;
            XYLine lineB;
            int    im1    = Decrease(i, 2); // "i-1"
            int    count1 = 0;
            bool   found  = false;

            while ((count1 < 3) && (!found))
            {
                lineA = triangleA.GetLine(im1);
                if (count1 == 0)
                {
                    lineA.P1.X = p.X;
                    lineA.P1.Y = p.Y;
                }
                double MinDist  = -1; // Distance used when a line is crossed more than once
                int    jm1      = 0;  // "j-1"
                int    jm1Store = -1;
                while (jm1 < 3)
                {
                    lineB = triangleB.GetLine(jm1);
                    found = IntersectionPoint(lineA, lineB, ref p);
                    double Dist = CalculatePointToPointDistance(lineA.P1, p);
                    if (Dist < EPSILON)
                    {
                        found = false;
                    }
                    if (found)
                    {
                        if ((MinDist < 0) || (Dist < MinDist))
                        {
                            MinDist  = Dist;
                            jm1Store = jm1;
                        }
                    }
                    jm1++;
                }
                if (jm1Store > -1)
                {
                    lineB = triangleB.GetLine(jm1Store);
                    found = IntersectionPoint(lineA, lineB, ref p);
                    XYPoint HelpCoordinate = new XYPoint(p.X, p.Y);
                    XYPoint HelpNode       = new XYPoint(HelpCoordinate);

                    intersectionPolygon.Points.Add(HelpNode);

                    j = Increase(jm1Store, 2);
                }
                if (!found)
                {
                    count1++;
                    im1 = Increase(im1, 2);
                    i   = Increase(i, 2);
                    if (j != -1)
                    {
                        XYPoint HelpCoordinate = new XYPoint(lineA.P2.X, lineA.P2.Y);
                        XYPoint HelpNode       = new XYPoint(HelpCoordinate);
                        intersectionPolygon.Points.Add(HelpNode);
                    }
                }
            }
            lineA = triangleA.GetLine(Decrease(i, 2));
            if (CalculatePointToPointDistance(p, lineA.P2) < EPSILON)
            {
                i = Increase(i, 2);
            }
            lineB = triangleB.GetLine(Decrease(j, 2));
            if (CalculatePointToPointDistance(p, lineB.P2) < EPSILON)
            {
                j = Increase(j, 2);
            }
        }
Exemplo n.º 34
0
 /// <summary>
 /// Determines if a point in inside or outside a polygon. Inside
 /// includes on the edge for this method.
 /// Works for both convex and concave polygons (Winding number test)
 /// </summary>
 /// <param name="x">x-coordinate for the point</param>
 /// <param name="y">y-coordiante for the point</param>
 /// <param name="polygon">Polygon</param>
 /// <returns>
 ///	<p>true:  If the point is inside the polygon</p>
 ///	<p>false: If the point is outside the polygon.</p>
 /// </returns>
 public static bool IsPointInPolygonOrOnEdge(double x, double y, XYPolygon polygon)
 {
   bool result = IsPointInPolygon(x, y, polygon);
   if( result )
   {
     return result;
   }
   else
   {
     int iLine = 0;
     while( (!result) && (iLine < polygon.Points.Count) )
     {
       XYLine line;
       line = polygon.GetLine(iLine);
       result = IsPointInLine(x, y, line);
       iLine++;
     }
   }
   return result;
 }
Exemplo n.º 35
0
   /// <summary>
   /// The methods calculates the shared area of two arbitrarily shaped 
   /// polygons.
   /// </summary>
   /// <param name="polygonA">Polygon</param>
   /// <param name="polygonB">Polygon</param>
   /// <returns>
   ///	<p>The shared area.</p>
   /// </returns>
   public static double CalculateSharedArea (XYPolygon polygonA, XYPolygon polygonB)
   {
 	  var triangleListA = polygonA.GetTriangulation();
     var triangleListB = polygonB.GetTriangulation();
     
     double area = 0;
     for (int ia = 0; ia < triangleListA.Count; ia++)
     {
 	    XYPolygon triangleA = new XYPolygon(triangleListA[ia]);
       for (int ib = 0; ib < triangleListB.Count; ib++)
       {
   		  XYPolygon triangleB = new XYPolygon(triangleListB[ib]);
         area = area + TriangleIntersectionArea(triangleA, triangleB);
       }
     }
     return area;
   }      
Exemplo n.º 36
0
		/// <summary>
		/// Calculates the length of polyline inside polygon. Lines segments on the edges of 
		/// polygons are included with half their length.
		/// </summary>
		/// <param name="polyline">Polyline</param>
		/// <param name="polygon">Polygon</param>
		/// <returns>
		/// Length of polyline inside polygon.
		/// </returns>
		public static double CalculateLengthOfPolylineInsidePolygon(XYPolyline polyline, XYPolygon polygon)
		{
			double lengthInside = 0;
			int numberOfLineSegments = polyline.Points.Count - 1;
			for (int i = 0; i < numberOfLineSegments; i++)
			{
				XYLine line = new XYLine(polyline.GetLine(i));
				lengthInside += CalculateLengthOfLineInsidePolygon(line,polygon);
			}
			return lengthInside;
		}
Exemplo n.º 37
0
    /// <summary>
    /// Calculates length of line inside polygon. Parts of the line that is on the edge of 
    /// the polygon only counts with half their length.
    /// </summary>
    /// <param name="line">Line</param>
    /// <param name="polygon">Polygon</param>
    /// <returns>
    /// Length of line inside polygon.
    /// </returns>
    protected static double CalculateLengthOfLineInsidePolygon(XYLine line, XYPolygon polygon)
    {
          ArrayList lineList = new ArrayList();
        lineList.Add(new XYLine(line));
          
          for (int i = 0; i < polygon.Points.Count; i++) // For all lines in the polygon
          {
              for (int n = 0; n < lineList.Count; n++)   
              {
                  if (lineList.Count > 1000)
                  {
                      throw new Exception("Problems in ElementMapper, line has been cut in more than 1000 pieces !!!");
                  }

                  if (DoLineSegmentsIntersect((XYLine)lineList[n], polygon.GetLine(i)))
                  {
                      // Split the intersecting line into two lines
                      XYPoint IntersectionPoint = new XYPoint(CalculateIntersectionPoint((XYLine)lineList[n], polygon.GetLine(i)));
                      lineList.Add(new XYLine(IntersectionPoint, ((XYLine) lineList[n]).P2));
                      ((XYLine) lineList[n]).P2.X = IntersectionPoint.X;
                      ((XYLine) lineList[n]).P2.Y = IntersectionPoint.Y;
                      break;
                  }
              }
          }
	
          for (int i = 0; i < lineList.Count; i++)
          {
              if (lineList.Count > 1000)
              {
                  throw new Exception("Problems in ElementMapper, line has been cuttes in more than 100 pieces !!!");
              }
              for (int j = 0; j < polygon.Points.Count; j++)
              {
                  if (IsPointInLineInterior( polygon.GetLine(j).P1, ((XYLine) lineList[i])))
                  {
                      lineList.Add(new XYLine(polygon.GetLine(j).P1, ((XYLine) lineList[i]).P2));
                      ((XYLine) lineList[i]).P2.X = polygon.GetLine(j).P1.X;
                      ((XYLine) lineList[i]).P2.Y = polygon.GetLine(j).P1.Y;
                  }
              }  
          }
   
          double lengthInside = 0;
          for (int i = 0; i < lineList.Count; i++)
		{
              double sharedLength = 0;
              for (int j = 0; j < polygon.Points.Count; j++)
              {
                  sharedLength += CalculateSharedLength(((XYLine) lineList[i]), polygon.GetLine(j));
              }
              if (sharedLength > EPSILON)
              {
                  lengthInside += sharedLength/2;
              }
              else if (IsPointInPolygon(((XYLine) lineList[i]).GetMidpoint(), polygon))
              {
                  lengthInside += ((XYLine) lineList[i]).GetLength();
              }
          }
          return lengthInside;
		}
Exemplo n.º 38
0
 public XYPolygon Surround(Func<double,bool> function)
 {
   XYPolygon toreturn = new XYPolygon();
   List<XYPoint> left = new List<XYPoint>();
   List<XYPoint> right = new List<XYPoint>();
   for (int i = 0; i < NumberOfRows; i++)
   {
     XYPoint x1 = null;
     XYPoint y1 = null;
     for (int j = 0; j < NumberOfColumns; j++)
     {
       if (function(GetValue(j, i).Value))
       {
         if (x1 == null)
           x1 = new XYPoint(GetXCenter(j), GetYCenter(NumberOfRows- i));
         else
           y1 = new XYPoint(GetXCenter(j), GetYCenter(NumberOfRows- i));
       }
     }
     if(x1!=null)
       left.Add(x1);
     if(y1!=null)
       right.Add(y1);
   }
   toreturn.Points.AddRange(left);
   toreturn.Points.AddRange(right);
   return toreturn;
 }
Exemplo n.º 39
0
    /// <summary>
    /// The method calculates the intersection area of triangle a and b both
    /// of type XYPolygon.
    /// </summary>
    /// <param name="triangleA">Triangle of type XYPolygon</param>
    /// <param name="triangleB">Triangle of type XYPolygon</param>
    /// <returns>
    ///	Intersection area between the triangles triangleA and triAngleB.
    /// </returns>
    protected static double TriangleIntersectionArea(XYPolygon triangleA, XYPolygon triangleB)
    {
      try
      {
        if (triangleA.Points.Count != 3 || triangleB.Points.Count != 3)
        {
          throw new System.Exception("Argument must be a polygon with 3 points");
        }
        int i = 1;       // Index for "next" node in polygon a.
        int j = -1;      // Index for "next" node in polygon b. 
        // -1 indicates that the first has not yet been found.
        double area = 0; // Intersection area. Returned.
        XYPolygon intersectionPolygon = new XYPolygon(); // Intersection polygon.
        IXYPoint p = new XYPoint(); // Latest intersection node found

        p.X = triangleA.Points[0].X;
        p.Y = triangleA.Points[0].Y;
        Intersect(triangleA, triangleB, ref p, ref i, ref j, ref intersectionPolygon);

        if (j != -1)
        {
          // ERB 8/30/2012: For efficiency, allocate and initialize pFirst inside if block
          IXYPoint pFirst = new XYPoint(); // First intersection point between triangles
          pFirst = p;
          int jStop = Increase(j, 2);
          bool complete = false;
          int count = 0;
          while (!complete)
          {
            // coordinates for vectors pointing to next triangleA and triangleB point respectively
            double vax = ((XYPoint)triangleA.Points[i]).X - p.X;
            double vay = ((XYPoint)triangleA.Points[i]).Y - p.Y;
            double vbx = ((XYPoint)triangleB.Points[j]).X - p.X;
            double vby = ((XYPoint)triangleB.Points[j]).Y - p.Y;

            if (IsPointInPolygonOrOnEdge(p.X + EPSILON * vax, p.Y + EPSILON * vay, triangleB))
            {
              Intersect(triangleA, triangleB, ref p, ref i, ref j, ref intersectionPolygon);
            }
            else if (IsPointInPolygonOrOnEdge(p.X + EPSILON * vbx, p.Y + EPSILON * vby, triangleA))
            {
              Intersect(triangleB, triangleA, ref p, ref j, ref i, ref intersectionPolygon);
            }
            else // triangleA and triangleB only touches one another but do not intersect
            {
              area = 0;
              return area;
            }
            if (intersectionPolygon.Points.Count > 1)
            {
              complete = (CalculatePointToPointDistance(p, pFirst) < EPSILON);
            }
            count++;
            if (count > 20)
            {
              throw new System.Exception("Failed to find intersection polygon");
            }
          }
          area = intersectionPolygon.GetArea();
        }
        else
        {
          XYPoint pa = new XYPoint(); // internal point in triangle a
          XYPoint pb = new XYPoint(); // internal point in triangle b

          pa.X = (triangleA.GetX(0) + triangleA.GetX(1) + triangleA.GetX(2)) / 3;
          pa.Y = (triangleA.GetY(0) + triangleA.GetY(1) + triangleA.GetY(2)) / 3;
          pb.X = (triangleB.GetX(0) + triangleB.GetX(1) + triangleB.GetX(2)) / 3;
          pb.Y = (triangleB.GetY(0) + triangleB.GetY(1) + triangleB.GetY(2)) / 3;

          if (IsPointInPolygon(pa, triangleB) || IsPointInPolygon(pb, triangleA)) // triangleA is completely inside triangleB
          {
            area = Math.Min(triangleA.GetArea(), triangleB.GetArea());
          }
          else // triangleA and triangleB do dot intersect
          {
            area = 0;
          }
        }
        return area;
      }
      catch (System.Exception e)
      {
        throw new System.Exception("TriangleIntersectionArea failed", e);
      }
    }
Exemplo n.º 40
0
        private Model CreateHydroNetModel()
        {
            DateTime startTime = new DateTime(2000, 1, 1);


            // -------------------- Polygons --------------------------------------
            HydroNumerics.Geometry.XYPolygon upperLakeGeometry = new HydroNumerics.Geometry.XYPolygon();
            upperLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(535.836, 2269.625));
            upperLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(675.768, 2187.713));
            upperLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(771.331, 2177.474));
            upperLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(887.372, 2184.300));
            upperLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(935.154, 2255.973));
            upperLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(945.392, 2385.666));
            upperLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(931.741, 2505.119));
            upperLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(877.133, 2546.075));
            upperLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(812.287, 2638.225));
            upperLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(696.246, 2675.768));
            upperLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(638.225, 2627.986));
            upperLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(573.379, 2587.031));

            HydroNumerics.Geometry.XYPolygon lowerLakeGeometry = new HydroNumerics.Geometry.XYPolygon();
            lowerLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1935.154, 1150.171));
            lowerLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1901.024, 1058.020));
            lowerLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1877.133, 965.870));
            lowerLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1894.198, 897.611));
            lowerLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1938.567, 808.874));
            lowerLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(2023.891, 761.092));
            lowerLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(2116.041, 740.614));
            lowerLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(2232.082, 747.440));
            lowerLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(2327.645, 808.874));
            lowerLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(2389.078, 969.283));
            lowerLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(2372.014, 1109.215));
            lowerLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(2262.799, 1218.430));
            lowerLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(2105.802, 1235.495));
            lowerLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1982.935, 1225.256));

            HydroNumerics.Geometry.XYPolygon upperStreamGeometry = new HydroNumerics.Geometry.XYPolygon();
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(863.481, 2177.474));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(914.676, 2129.693));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(965.870, 2071.672));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(976.109, 2027.304));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(976.109, 1989.761));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1006.826, 1959.044));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1051.195, 1918.089));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1095.563, 1877.133));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1126.280, 1808.874));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1187.713, 1781.570));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1228.669, 1730.375));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1262.799, 1665.529));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1283.276, 1597.270));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1317.406, 1535.836));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1341.297, 1484.642));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1389.078, 1457.338));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1423.208, 1440.273));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1477.816, 1402.730));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1511.945, 1358.362));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1539.249, 1327.645));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1566.553, 1354.949));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1535.836, 1406.143));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1508.532, 1457.338));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1440.273, 1522.184));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1368.601, 1580.205));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1327.645, 1631.399));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1307.167, 1696.246));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1269.625, 1767.918));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1221.843, 1819.113));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1191.126, 1843.003));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1136.519, 1894.198));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1088.737, 1935.154));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1061.433, 1976.109));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1030.717, 2040.956));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1013.652, 2105.802));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(972.696, 2177.474));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(918.089, 2228.669));

            HydroNumerics.Geometry.XYPolygon lowerStreamGeometry = new HydroNumerics.Geometry.XYPolygon();
            lowerStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1904.437, 1081.911));
            lowerStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1921.502, 1153.584));
            lowerStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1771.331, 1255.973));
            lowerStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1573.379, 1354.949));
            lowerStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1542.662, 1324.232));
            lowerStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1597.270, 1273.038));
            lowerStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1709.898, 1215.017));
            lowerStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1839.590, 1143.345));

            // --- precipitation --------------------------------------------------

            const int numberOfTimesteps = 2190;

            double[] precipitation = new double[numberOfTimesteps] {
                0.0000, 0.0000, 2.3000, 0.2000, 0.0000, 0.1000, 0.1000, 0.0000, 0.3000, 0.4000, 0.1000, 0.1000, 1.0000, 0.0000, 0.5000, 5.3000, 1.9000, 0.1000, 0.0000, 0.4000, 1.1000, 1.2000, 2.6000, 0.0000, 1.5000, 3.4000, 6.0000, 0.7000, 4.0000, 0.1000, 0.6000, 2.0000, 0.4000, 0.1000, 0.0000, 0.0000, 0.0000, 4.1000, 0.2000, 4.0000, 0.3000, 0.6000, 3.1000, 14.1000, 3.9000, 0.1000, 3.7000, 2.4000, 4.3000, 0.0000, 0.0000, 0.0000, 0.0000, 2.7000, 1.0000, 0.1000, 0.3000, 0.2000, 0.0000, 0.2000, 8.7000, 2.0000, 1.8000, 0.9000, 0.1000, 0.2000, 0.1000, 0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1000, 0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.6000, 1.8000, 0.0000, 1.1000, 4.7000, 2.4000, 0.0000, 0.1000, 8.2000, 4.6000, 1.0000, 0.1000, 0.0000, 0.0000, 7.8000, 2.0000, 0.3000, 0.0000, 0.1000, 0.1000, 0.0000, 0.0000, 0.3000, 0.1000, 2.2000, 2.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1000, 6.7000, 0.0000, 0.0000, 0.0000, 5.4000, 2.2000, 1.0000, 10.8000, 3.6000, 3.1000, 10.1000, 0.0000, 0.3000, 2.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 1.3000, 0.0000, 0.0000, 7.6000, 3.6000, 0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1000, 4.5000, 0.0000, 12.8000, 0.0000, 4.4000, 0.0000, 0.0000, 0.0000, 0.0000, 4.9000, 0.0000, 0.8000, 0.0000, 2.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 7.1000, 0.2000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 4.4000, 1.5000, 4.6000, 1.4000, 0.8000, 0.0000, 0.0000, 0.0000, 0.0000, 5.5000, 4.6000, 1.3000, 0.1000, 2.8000, 2.6000, 0.0000, 0.1000, 3.5000, 1.0000, 8.7000, 0.5000, 0.0000, 0.4000, 0.0000, 0.0000, 0.0000, 0.0000, 3.8000, 4.9000, 4.6000, 2.5000, 7.9000, 0.1000, 4.7000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.6000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.2000, 14.4000, 2.0000, 6.2000, 0.5000, 0.3000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 3.2000, 8.1000, 1.3000, 20.2000, 13.5000, 1.1000, 1.3000, 0.0000, 0.0000, 2.1000, 13.7000, 3.9000, 0.5000, 0.1000, 0.0000, 0.0000, 0.1000, 0.0000, 0.0000, 0.2000, 4.8000, 7.2000, 0.4000, 0.0000, 4.6000, 0.2000, 0.0000, 0.0000, 0.5000, 4.8000, 9.8000, 0.6000, 0.0000, 0.0000, 0.0000, 0.0000, 3.2000, 0.0000, 0.0000, 0.0000, 0.0000, 0.4000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.5000, 8.5000, 0.5000, 1.9000, 1.2000, 0.0000, 3.2000, 1.7000, 12.3000, 1.9000, 0.0000, 4.3000, 3.6000, 1.1000, 6.7000, 5.4000, 0.0000, 0.0000, 0.9000, 10.0000, 7.8000, 0.1000, 1.3000, 0.5000, 0.1000, 0.2000, 0.5000, 0.0000, 7.2000, 0.0000, 0.0000, 10.2000, 9.7000, 0.2000, 0.1000, 0.9000, 3.5000, 1.2000, 4.9000, 4.6000, 3.5000, 1.1000, 5.8000, 0.4000, 0.0000, 0.0000, 0.6000, 0.1000, 1.2000, 0.8000, 9.4000, 1.5000, 0.1000, 0.1000, 0.2000, 0.9000, 4.8000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1000, 0.0000, 0.1000, 1.9000, 0.8000, 0.9000, 2.1000, 7.9000, 3.8000, 3.8000, 9.6000, 1.4000, 7.9000, 0.4000, 0.6000, 0.7000, 0.0000, 0.0000, 0.0000, 7.0000, 0.1000, 0.1000, 0.1000, 5.3000, 1.0000, 4.3000, 0.2000, 0.0000, 1.8000, 0.1000, 0.6000, 0.0000, 1.5000, 3.2000, 0.1000, 4.1000, 5.5000, 10.6000, 9.0000, 0.9000, 0.8000, 2.7000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.4000, 0.6000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1000, 0.1000, 2.5000, 5.7000, 2.3000, 2.0000, 0.6000, 0.8000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 4.2000, 9.6000, 0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.7000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 9.3000, 0.0000, 0.0000, 0.0000, 0.0000, 5.3000, 0.0000, 0.0000, 0.7000, 9.0000, 0.2000, 0.0000, 0.0000, 2.8000, 2.4000, 1.5000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 6.4000, 0.0000, 0.0000, 0.8000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 7.1000, 0.1000, 0.0000, 0.2000, 0.0000, 0.0000, 0.2000, 0.0000, 0.6000, 0.9000, 10.0000, 5.1000, 4.1000, 10.3000, 1.9000, 0.0000, 0.0000, 0.0000, 0.2000, 4.2000, 0.4000, 5.8000, 0.5000, 0.1000, 3.3000, 4.9000, 1.4000, 0.5000, 0.0000, 1.8000, 2.5000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1000, 1.4000, 0.0000, 2.4000, 7.6000, 5.2000, 11.4000, 0.1000, 1.1000, 0.7000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.8000, 0.0000, 2.3000, 0.4000, 0.0000, 0.0000, 0.0000, 0.0000, 5.2000, 2.2000, 0.0000, 10.0000, 5.3000, 1.2000, 8.0000, 30.7000, 2.9000, 0.0000, 0.0000, 0.0000, 6.8000, 0.0000, 0.0000, 0.0000, 1.4000, 0.5000, 4.1000, 0.1000, 10.6000, 11.2000, 2.5000, 6.2000, 5.3000, 4.5000, 12.8000, 0.1000, 1.0000, 0.0000, 0.0000, 22.7000, 2.5000, 5.5000, 3.7000, 0.8000, 0.0000, 1.6000, 1.7000, 3.8000, 0.2000, 0.3000, 0.0000, 0.4000, 0.0000, 0.2000, 0.5000, 1.0000, 16.3000, 0.3000, 4.3000, 14.8000, 0.0000, 2.7000, 0.0000, 2.8000, 3.2000, 5.3000, 2.1000, 0.0000, 2.2000, 0.4000, 0.3000, 0.1000, 0.0000, 0.0000, 1.8000, 0.5000, 9.4000, 11.4000, 2.4000, 9.2000, 1.1000, 11.1000, 6.4000, 8.3000, 15.3000, 0.1000, 6.8000, 2.9000, 0.0000, 0.3000, 0.4000, 0.2000, 3.3000, 6.2000, 1.0000, 9.0000, 5.5000, 0.0000, 0.0000, 3.0000, 1.1000, 0.0000, 10.8000, 0.0000, 7.1000, 2.0000, 1.6000, 7.2000, 9.4000, 0.9000, 6.1000, 1.4000, 2.5000, 0.6000, 8.1000, 0.9000, 2.8000, 5.0000, 3.3000, 2.1000, 9.5000, 0.0000, 6.0000, 7.0000, 0.0000, 2.2000, 1.8000, 0.2000, 1.1000, 5.2000, 0.0000, 0.3000, 1.6000, 0.8000, 0.4000, 0.0000, 0.2000, 1.4000, 5.9000, 7.1000, 7.0000, 1.9000, 1.5000, 0.1000, 0.3000, 5.6000, 4.1000, 4.8000, 1.5000, 1.5000, 2.7000, 11.4000, 8.6000, 3.7000, 5.7000, 1.3000, 13.4000, 5.6000, 5.9000, 5.4000, 5.3000, 0.1000, 0.1000, 0.2000, 0.0000, 0.5000, 0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 4.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1000, 0.0000, 2.9000, 3.0000, 1.0000, 14.6000, 0.6000, 5.0000, 0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1000, 1.6000, 2.2000, 0.0000, 0.0000, 0.6000, 0.0000, 0.2000, 2.4000, 0.3000, 0.0000, 0.3000, 5.8000, 1.6000, 1.6000, 5.7000, 2.8000, 1.9000, 0.6000, 2.8000, 0.0000, 8.8000, 2.5000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 3.1000, 0.0000, 0.0000, 0.0000, 0.2000, 0.5000, 0.0000, 3.7000, 5.0000, 10.2000, 1.2000, 0.4000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.6000, 0.3000, 0.0000, 0.0000, 2.2000, 8.4000, 11.5000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.8000, 12.4000, 2.8000, 3.9000, 10.1000, 4.5000, 6.6000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.5000, 0.5000, 0.0000, 0.7000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.3000, 0.7000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 3.2000, 1.4000, 7.3000, 0.0000, 3.7000, 11.1000, 1.2000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1000, 8.3000, 2.2000, 6.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.2000, 0.0000, 0.0000, 0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 11.6000, 5.9000, 0.0000, 0.0000, 8.9000, 17.1000, 0.1000, 4.9000, 2.3000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 14.5000, 2.7000, 1.9000, 3.3000, 0.0000, 0.0000, 19.9000, 2.4000, 4.1000, 2.0000, 4.2000, 0.9000, 0.3000, 0.0000, 0.1000, 0.3000, 0.0000, 3.1000, 2.5000, 0.0000, 1.6000, 3.8000, 8.2000, 5.7000, 7.7000, 0.3000, 0.0000, 5.4000, 7.9000, 1.3000, 10.0000, 0.6000, 0.7000, 0.0000, 0.0000, 0.0000, 0.9000, 0.0000, 0.0000, 0.1000, 2.6000, 6.3000, 4.7000, 0.7000, 0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.2000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 2.3000, 2.0000, 0.0000, 3.1000, 0.9000, 0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.3000, 0.4000, 7.5000, 12.4000, 2.9000, 0.5000, 7.6000, 1.6000, 2.3000, 0.0000, 0.0000, 2.1000, 2.3000, 8.0000, 2.1000, 1.7000, 0.0000, 0.0000, 17.9000, 4.5000, 0.5000, 0.7000, 0.3000, 0.0000, 1.1000, 0.1000, 0.0000, 0.0000, 1.1000, 0.1000, 0.0000, 1.2000, 0.0000, 1.2000, 0.8000, 0.7000, 0.0000, 0.1000, 0.2000, 0.2000, 0.0000, 0.4000, 1.3000, 0.0000, 0.0000, 0.0000, 0.1000, 1.4000, 0.0000, 0.0000, 2.3000, 0.2000, 0.0000, 0.1000, 0.1000, 0.0000, 0.3000, 0.4000, 0.1000, 0.1000, 1.0000, 0.0000, 0.5000, 5.3000, 1.9000, 0.1000, 0.0000, 0.4000, 1.1000, 1.2000, 2.6000, 0.0000, 1.5000, 3.4000, 6.0000, 0.7000, 4.0000, 0.1000, 0.6000, 2.0000, 0.4000, 0.1000, 0.0000, 0.0000, 0.0000, 4.1000, 0.2000, 4.0000, 0.3000, 0.6000, 3.1000, 14.1000, 3.9000, 0.1000, 3.7000, 2.4000, 4.3000, 0.0000, 0.0000, 0.0000, 0.0000, 2.7000, 1.0000, 0.1000, 0.3000, 0.2000, 0.0000, 0.2000, 8.7000, 2.0000, 1.8000, 0.9000, 0.1000, 0.2000, 0.1000, 0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1000, 0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.6000, 1.8000, 0.0000, 1.1000, 4.7000, 2.4000, 0.0000, 0.1000, 8.2000, 4.6000, 1.0000, 0.1000, 0.0000, 0.0000, 7.8000, 2.0000, 0.3000, 0.0000, 0.1000, 0.1000, 0.0000, 0.0000, 0.3000, 0.1000, 2.2000, 2.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1000, 6.7000, 0.0000, 0.0000, 0.0000, 5.4000, 2.2000, 1.0000, 10.8000, 3.6000, 3.1000, 10.1000, 0.0000, 0.3000, 2.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 1.3000, 0.0000, 0.0000, 7.6000, 3.6000, 0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1000, 4.5000, 0.0000, 12.8000, 0.0000, 4.4000, 0.0000, 0.0000, 0.0000, 0.0000, 4.9000, 0.0000, 0.8000, 0.0000, 2.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 7.1000, 0.2000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 4.4000, 1.5000, 4.6000, 1.4000, 0.8000, 0.0000, 0.0000, 0.0000, 0.0000, 5.5000, 4.6000, 1.3000, 0.1000, 2.8000, 2.6000, 0.0000, 0.1000, 3.5000, 1.0000, 8.7000, 0.5000, 0.0000, 0.4000, 0.0000, 0.0000, 0.0000, 0.0000, 3.8000, 4.9000, 4.6000, 2.5000, 7.9000, 0.1000, 4.7000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.6000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.2000, 14.4000, 2.0000, 6.2000, 0.5000, 0.3000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 3.2000, 8.1000, 1.3000, 20.2000, 13.5000, 1.1000, 1.3000, 0.0000, 0.0000, 2.1000, 13.7000, 3.9000, 0.5000, 0.1000, 0.0000, 0.0000, 0.1000, 0.0000, 0.0000, 0.2000, 4.8000, 7.2000, 0.4000, 0.0000, 4.6000, 0.2000, 0.0000, 0.0000, 0.5000, 4.8000, 9.8000, 0.6000, 0.0000, 0.0000, 0.0000, 0.0000, 3.2000, 0.0000, 0.0000, 0.0000, 0.0000, 0.4000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.5000, 8.5000, 0.5000, 1.9000, 1.2000, 0.0000, 3.2000, 1.7000, 12.3000, 1.9000, 0.0000, 4.3000, 3.6000, 1.1000, 6.7000, 5.4000, 0.0000, 0.0000, 0.9000, 10.0000, 7.8000, 0.1000, 1.3000, 0.5000, 0.1000, 0.2000, 0.5000, 0.0000, 7.2000, 0.0000, 0.0000, 10.2000, 9.7000, 0.2000, 0.1000, 0.9000, 3.5000, 1.2000, 4.9000, 4.6000, 3.5000, 1.1000, 5.8000, 0.4000, 0.0000, 0.0000, 0.6000, 0.1000, 1.2000, 0.8000, 9.4000, 1.5000, 0.1000, 0.1000, 0.2000, 0.9000, 4.8000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1000, 0.0000, 0.1000, 1.9000, 0.8000, 0.9000, 2.1000, 7.9000, 3.8000, 3.8000, 9.6000, 1.4000, 7.9000, 0.4000, 0.6000, 0.7000, 0.0000, 0.0000, 0.0000, 7.0000, 0.1000, 0.1000, 0.1000, 5.3000, 1.0000, 4.3000, 0.2000, 0.0000, 1.8000, 0.1000, 0.6000, 0.0000, 1.5000, 3.2000, 0.1000, 4.1000, 5.5000, 10.6000, 9.0000, 0.9000, 0.8000, 2.7000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.4000, 0.6000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1000, 0.1000, 2.5000, 5.7000, 2.3000, 2.0000, 0.6000, 0.8000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 4.2000, 9.6000, 0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.7000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 9.3000, 0.0000, 0.0000, 0.0000, 0.0000, 5.3000, 0.0000, 0.0000, 0.7000, 9.0000, 0.2000, 0.0000, 0.0000, 2.8000, 2.4000, 1.5000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 6.4000, 0.0000, 0.0000, 0.8000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 7.1000, 0.1000, 0.0000, 0.2000, 0.0000, 0.0000, 0.2000, 0.0000, 0.6000, 0.9000, 10.0000, 5.1000, 4.1000, 10.3000, 1.9000, 0.0000, 0.0000, 0.0000, 0.2000, 4.2000, 0.4000, 5.8000, 0.5000, 0.1000, 3.3000, 4.9000, 1.4000, 0.5000, 0.0000, 1.8000, 2.5000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1000, 1.4000, 0.0000, 2.4000, 7.6000, 5.2000, 11.4000, 0.1000, 1.1000, 0.7000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.8000, 0.0000, 2.3000, 0.4000, 0.0000, 0.0000, 0.0000, 0.0000, 5.2000, 2.2000, 0.0000, 10.0000, 5.3000, 1.2000, 8.0000, 30.7000, 2.9000, 0.0000, 0.0000, 0.0000, 6.8000, 0.0000, 0.0000, 0.0000, 1.4000, 0.5000, 4.1000, 0.1000, 10.6000, 11.2000, 2.5000, 6.2000, 5.3000, 4.5000, 12.8000, 0.1000, 1.0000, 0.0000, 0.0000, 22.7000, 2.5000, 5.5000, 3.7000, 0.8000, 0.0000, 1.6000, 1.7000, 3.8000, 0.2000, 0.3000, 0.0000, 0.4000, 0.0000, 0.2000, 0.5000, 1.0000, 16.3000, 0.3000, 4.3000, 14.8000, 0.0000, 2.7000, 0.0000, 2.8000, 3.2000, 5.3000, 2.1000, 0.0000, 2.2000, 0.4000, 0.3000, 0.1000, 0.0000, 0.0000, 1.8000, 0.5000, 9.4000, 11.4000, 2.4000, 9.2000, 1.1000, 11.1000, 6.4000, 8.3000, 15.3000, 0.1000, 6.8000, 2.9000, 0.0000, 0.3000, 0.4000, 0.2000, 3.3000, 6.2000, 1.0000, 9.0000, 5.5000, 0.0000, 0.0000, 3.0000, 1.1000, 0.0000, 10.8000, 0.0000, 7.1000, 2.0000, 1.6000, 7.2000, 9.4000, 0.9000, 6.1000, 1.4000, 2.5000, 0.6000, 8.1000, 0.9000, 2.8000, 5.0000, 3.3000, 2.1000, 9.5000, 0.0000, 6.0000, 7.0000, 0.0000, 2.2000, 1.8000, 0.2000, 1.1000, 5.2000, 0.0000, 0.3000, 1.6000, 0.8000, 0.4000, 0.0000, 0.2000, 1.4000, 5.9000, 7.1000, 7.0000, 1.9000, 1.5000, 0.1000, 0.3000, 5.6000, 4.1000, 4.8000, 1.5000, 1.5000, 2.7000, 11.4000, 8.6000, 3.7000, 5.7000, 1.3000, 13.4000, 5.6000, 5.9000, 5.4000, 5.3000, 0.1000, 0.1000, 0.2000, 0.0000, 0.5000, 0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 4.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1000, 0.0000, 2.9000, 3.0000, 1.0000, 14.6000, 0.6000, 5.0000, 0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1000, 1.6000, 2.2000, 0.0000, 0.0000, 0.6000, 0.0000, 0.2000, 2.4000, 0.3000, 0.0000, 0.3000, 5.8000, 1.6000, 1.6000, 5.7000, 2.8000, 1.9000, 0.6000, 2.8000, 0.0000, 8.8000, 2.5000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 3.1000, 0.0000, 0.0000, 0.0000, 0.2000, 0.5000, 0.0000, 3.7000, 5.0000, 10.2000, 1.2000, 0.4000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.6000, 0.3000, 0.0000, 0.0000, 2.2000, 8.4000, 11.5000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.8000, 12.4000, 2.8000, 3.9000, 10.1000, 4.5000, 6.6000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.5000, 0.5000, 0.0000, 0.7000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.3000, 0.7000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 3.2000, 1.4000, 7.3000, 0.0000, 3.7000, 11.1000, 1.2000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1000, 8.3000, 2.2000, 6.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.2000, 0.0000, 0.0000, 0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 11.6000, 5.9000, 0.0000, 0.0000, 8.9000, 17.1000, 0.1000, 4.9000, 2.3000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 14.5000, 2.7000, 1.9000, 3.3000, 0.0000, 0.0000, 19.9000, 2.4000, 4.1000, 2.0000, 4.2000, 0.9000, 0.3000, 0.0000, 0.1000, 0.3000, 0.0000, 3.1000, 2.5000, 0.0000, 1.6000, 3.8000, 8.2000, 5.7000, 7.7000, 0.3000, 0.0000, 5.4000, 7.9000, 1.3000, 10.0000, 0.6000, 0.7000, 0.0000, 0.0000, 0.0000, 0.9000, 0.0000, 0.0000, 0.1000, 2.6000, 6.3000, 4.7000, 0.7000, 0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.2000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 2.3000, 2.0000, 0.0000, 3.1000, 0.9000, 0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.3000, 0.4000, 7.5000, 12.4000, 2.9000, 0.5000, 7.6000, 1.6000, 2.3000, 0.0000, 0.0000, 2.1000, 2.3000, 8.0000, 2.1000, 1.7000, 0.0000, 0.0000, 17.9000, 4.5000, 0.5000, 0.7000, 0.3000, 0.0000, 1.1000, 0.1000, 0.0000, 0.0000, 1.1000, 0.1000, 0.0000, 1.2000, 0.0000, 1.2000, 0.8000, 0.7000, 0.0000, 0.1000, 0.2000, 0.2000, 0.0000, 0.4000, 1.3000, 0.0000, 0.0000, 0.0000, 0.1000, 1.4000
            };
            HydroNumerics.Time.Core.TimestampSeries precipitationTs = new HydroNumerics.Time.Core.TimestampSeries("PrecipitationTS", startTime, numberOfTimesteps, 1, HydroNumerics.Time.Core.TimestepUnit.Days, -99999, new HydroNumerics.Core.Unit("m3PrSec", 1, 0));
            //HydroNumerics.Time.Core.TimestampSeries precipitationTs = new HydroNumerics.Time.Core.TimestampSeries("PrecipitationTS", startTime, numberOfTimesteps, 1, HydroNumerics.Time.Core.TimestepUnit.Days, -99999, new HydroNumerics.Core.Unit("mmPrDay", 1.0/(1000*24*3600), 0));
            for (int i = 0; i < numberOfTimesteps; i++)
            {
                precipitationTs.Items[i].Value = precipitation[i] / (24 * 3600 * 1000);
                //precipitationTs.Items[i].Value = precipitation[i];
            }
            // --------------------------------------------------------------------


            // Upper Lake configuration
            //Lake upperLake = new Lake("Upper Lake", 2 * upperLakeGeometry.GetArea());
            Lake upperLake = new Lake("Upper Lake", upperLakeGeometry);

            upperLake.WaterLevel             = 6.1;
            upperLake.Depth                  = 2;
            upperLake.Output.LogAllChemicals = true;


            //Lake lowerLake = new Lake("lower Lake", 2 * lowerLakeGeometry.GetArea());
            Lake lowerLake = new Lake("lower Lake", lowerLakeGeometry);

            lowerLake.Depth                  = 2;
            lowerLake.WaterLevel             = 6.0;
            lowerLake.Output.LogAllChemicals = true;

            HydroNet.Core.Stream upperStream = new HydroNet.Core.Stream("The stream", 2000, 2, 1);
            upperStream.WaterLevel             = 6.0;
            upperStream.Output.LogAllChemicals = true;

            HydroNet.Core.Stream lowerStream = new HydroNet.Core.Stream("Lower Stream", 1000, 2, 1);
            lowerStream.WaterLevel             = 6.0;
            lowerStream.Output.LogAllChemicals = true;

            //SinkSourceBoundary upperLakePrecipitation = new SinkSourceBoundary(0.002 * contactPolygonUpperLake.GetArea() / (24 * 3600));
            SinkSourceBoundary upperLakePrecipitation = new SinkSourceBoundary(precipitationTs);

            upperLakePrecipitation.ContactGeometry = upperLakeGeometry;

            upperLakePrecipitation.Name = "Inflow to upperlake";


            //SinkSourceBoundary lowerLakePrecipitation = new SinkSourceBoundary(0.002 * contactPolygonLowerLake.GetArea()/ (24 * 3600));
            SinkSourceBoundary lowerLakePrecipitation = new SinkSourceBoundary(precipitationTs);

            lowerLakePrecipitation.ContactGeometry = lowerLakeGeometry;
            upperLakePrecipitation.Name            = "Inflow to lowerlake";

            // -------- Groundwater boundary under upper lake ----------
            GroundWaterBoundary groundWaterBoundaryUpperLake = new GroundWaterBoundary();

            groundWaterBoundaryUpperLake.Connection            = upperLake;
            groundWaterBoundaryUpperLake.ContactGeometry       = upperLakeGeometry;
            groundWaterBoundaryUpperLake.Distance              = 2.3;
            groundWaterBoundaryUpperLake.HydraulicConductivity = 1e-9;
            groundWaterBoundaryUpperLake.GroundwaterHead       = 5.0;
            groundWaterBoundaryUpperLake.Name = "Groundwater boundary under UpperLake";
            groundWaterBoundaryUpperLake.Name = "UpperGWBoundary";
            ((WaterPacket)groundWaterBoundaryUpperLake.WaterSample).AddChemical(ChemicalFactory.Instance.GetChemical(ChemicalNames.Radon), 2.3);
            ((WaterPacket)groundWaterBoundaryUpperLake.WaterSample).AddChemical(ChemicalFactory.Instance.GetChemical(ChemicalNames.Cl), 2.3);

            // -------- Groundwater boundary under lower lake ----------
            GroundWaterBoundary groundWaterBoundaryLowerLake = new GroundWaterBoundary();

            groundWaterBoundaryLowerLake.Connection            = lowerLake;
            groundWaterBoundaryLowerLake.ContactGeometry       = lowerLakeGeometry;
            groundWaterBoundaryLowerLake.Distance              = 2.3;
            groundWaterBoundaryLowerLake.HydraulicConductivity = 1e-12;
            groundWaterBoundaryLowerLake.GroundwaterHead       = 5.0;
            groundWaterBoundaryLowerLake.Name = "Groundwater boundary under LowerLake";
            groundWaterBoundaryLowerLake.Name = "LowerGWBoundary";

            //--- Ground water boundary upper Stream ------
            GroundWaterBoundary groundWaterBoundaryUpperStream = new GroundWaterBoundary();

            groundWaterBoundaryUpperStream.Connection            = upperStream;
            groundWaterBoundaryUpperStream.ContactGeometry       = upperStreamGeometry;
            groundWaterBoundaryUpperStream.Distance              = 2.3;
            groundWaterBoundaryUpperStream.HydraulicConductivity = 1e-12;
            groundWaterBoundaryUpperStream.GroundwaterHead       = 5.0;
            groundWaterBoundaryUpperStream.Name = "Groundwater boundary Upper Stream";
            groundWaterBoundaryUpperStream.Name = "UpperStreamGWBoundary";

            // ---------  Ground water boundary lower stream ------------------------------------------
            GroundWaterBoundary groundWaterBoundaryLowerStream = new GroundWaterBoundary();

            groundWaterBoundaryLowerStream.Connection            = lowerStream;
            groundWaterBoundaryLowerStream.ContactGeometry       = lowerStreamGeometry;
            groundWaterBoundaryLowerStream.Distance              = 2.3;
            groundWaterBoundaryLowerStream.HydraulicConductivity = 1e-12;
            groundWaterBoundaryLowerStream.GroundwaterHead       = 5.0;
            groundWaterBoundaryLowerStream.Name = "Groundwater boundary Lower Stream";
            groundWaterBoundaryLowerStream.Name = "LowerStreamGWBoundary";
            // ------------------------------------------------------------------------------

            upperLake.SurfaceArea = upperLakeGeometry;
            lowerLake.SurfaceArea = lowerLakeGeometry;
            upperLake.Precipitation.Add(upperLakePrecipitation);
            lowerLake.Precipitation.Add(lowerLakePrecipitation);

            upperLake.GroundwaterBoundaries.Add(groundWaterBoundaryUpperLake);
            upperStream.GroundwaterBoundaries.Add(groundWaterBoundaryUpperStream);
            lowerStream.GroundwaterBoundaries.Add(groundWaterBoundaryLowerStream);
            lowerLake.GroundwaterBoundaries.Add(groundWaterBoundaryLowerLake);


            upperLake.DownStreamConnections.Add(upperStream);
            upperStream.DownStreamConnections.Add(lowerStream);
            lowerStream.DownStreamConnections.Add(lowerLake);

            //Creating the model
            Model model = new Model();

            model._waterBodies.Add(upperLake);
            model._waterBodies.Add(upperStream);
            model._waterBodies.Add(lowerStream);
            model._waterBodies.Add(lowerLake);


            WaterPacket waterPacket = new WaterPacket(1000);

            waterPacket.AddChemical(ChemicalFactory.Instance.GetChemical(ChemicalNames.Cl), 9.2);

            WaterPacket waterpacketLowerLake = new WaterPacket(lowerLake.Volume);

            waterpacketLowerLake.AddChemical(ChemicalFactory.Instance.GetChemical(ChemicalNames.Cl), 4.2);


            model.SetState("MyState", startTime, waterPacket);
            lowerLake.SetState("MyState", startTime, waterpacketLowerLake);

            //model.SetState("kkk", startTime, new
            //upperLake.SetState("MyState", startTime, new WaterPacket(2));
            model.Name = "Lake model";
            model.Initialize();
            //model.Update(new DateTime(2001, 1, 1));
            return(model);
        }
Exemplo n.º 41
0
    /// <summary>
    /// The method calculates the intersection points of triangle a and b both
    /// of type XYPolygon.
    /// </summary>
    /// <param name="triangleA">triangle. The search is started along triangleA.</param>
    /// <param name="triangleB">triangle. Intersection with this triangle are sought.</param>
    /// <param name="p">Starting point for the search. p must be part of triangleA.</param>
    /// <param name="i">on input: End index for the first line segment of triangleA in the search.
    /// on output: End index for the last intersected line segment in triangleA.</param>
    /// <param name="j">on input: -1 if vertices before intersection is not to be added to list.
    /// on output: End index for last intersected line segment of triangleB.</param>
    /// <param name="intersectionPolygon">polygon eventuallu describing the 
    /// intersection area between triangleA and triangleB</param>
    /// <returns>
    ///	The p, i, j and intersectionPolygon are called by reference and modified in the method.
    /// </returns>
    private static void Intersect (XYPolygon triangleA, XYPolygon triangleB, 
                                   ref IXYPoint p, ref  int i, ref int j, 
                                   ref XYPolygon intersectionPolygon)
    {
      XYLine lineA;
      XYLine lineB;
      int im1 = Decrease(i, 2); // "i-1"
      int count1 = 0;
      bool found = false;

      while ((count1 < 3) && (!found))
      {
        lineA = triangleA.GetLine(im1);
        if (count1 == 0)
        {
          lineA.P1.X = p.X;
          lineA.P1.Y = p.Y;
        }
        double MinDist = -1; // Distance used when a line is crossed more than once
        int jm1 = 0;         // "j-1"
        int jm1Store = -1;
        while (jm1 < 3)
        {
          lineB = triangleB.GetLine(jm1);
          found = IntersectionPoint(lineA, lineB, ref p);
          double Dist = CalculatePointToPointDistance(lineA.P1,p);
          if (Dist < EPSILON)
          {
            found = false;
          }
          if (found)
          {
            if ((MinDist < 0) || (Dist < MinDist))
            {
              MinDist = Dist;
              jm1Store = jm1;
            }
          }
          jm1++;
        }
        if ( jm1Store > -1 )
        {
          lineB = triangleB.GetLine(jm1Store);
          found = IntersectionPoint(lineA, lineB, ref p);          
		      XYPoint HelpCoordinate = new XYPoint(p.X, p.Y);
		      XYPoint HelpNode = new XYPoint(HelpCoordinate);

		      intersectionPolygon.Points.Add(HelpNode);

          j = Increase(jm1Store,2);  
        }
        if (!found)
        {
          count1++;
          im1 = Increase(im1,2);
          i = Increase(i,2);
          if (j!=-1) 
          {
		        XYPoint HelpCoordinate = new XYPoint(lineA.P2.X, lineA.P2.Y);
       			XYPoint HelpNode = new XYPoint(HelpCoordinate);
       			intersectionPolygon.Points.Add(HelpNode);
          }
        }
      }
      lineA = triangleA.GetLine(Decrease(i, 2));
      if ( CalculatePointToPointDistance(p, lineA.P2)<EPSILON )
      {
        i = Increase(i, 2);
      }
      lineB = triangleB.GetLine(Decrease(j, 2));
      if ( CalculatePointToPointDistance(p, lineB.P2)<EPSILON )
      {
        j = Increase(j, 2);
      }
    }
Exemplo n.º 42
0
    private bool OverLaps(XYPolygon Poly)
    {
      //Are any of the other polygon bounding box corners with in this polygon
      if (Poly.BoundingBox.Points.Any(p=>this.BoundingBox.Contains(p))) 
        foreach (var P in Poly.Points)
          if (Contains(P))
            return true;

      // Are any of this bounding box corners in the other polygon
      if (this.BoundingBox.Points.Any(p => Poly.BoundingBox.Contains(p))) 
        foreach (var P in Points)
          if (Poly.Contains(P))
            return true;
      //Do any of the bounding box lines intersect/
      for(int i =0;i<4;i++) 
        for(int j =0;j<4;j++)
          if (XYGeometryTools.DoLineSegmentsIntersect(Poly.BoundingBox.Points[i], Poly.BoundingBox.Points[i+1], BoundingBox.Points[j], BoundingBox.Points[j+1]))
          {
            foreach (var P in Points)
              if (Poly.Contains(P))
                return true;
            foreach (var P in Poly.Points)
              if (Contains(P))
                return true;
          }

      return false;
    }
Exemplo n.º 43
0
    /// <summary>
    /// Gets a rectangle from the four corners
    /// </summary>
    /// <param name="xmin"></param>
    /// <param name="xmax"></param>
    /// <param name="ymin"></param>
    /// <param name="ymax"></param>
    /// <returns></returns>
    public static XYPolygon Box(double xmin, double xmax, double ymin, double ymax)
    {
      XYPolygon boundingBox = new XYPolygon();

      boundingBox.Points.Add(new XYPoint(xmin, ymin));
      boundingBox.Points.Add(new XYPoint(xmin, ymax));
      boundingBox.Points.Add(new XYPoint(xmax, ymax));
      boundingBox.Points.Add(new XYPoint(xmax, ymin));
      boundingBox.Points.Add(new XYPoint(xmin, ymin));
      return boundingBox;

    }
Exemplo n.º 44
0
    /// <summary>
    /// Returns an ArrayList of triangles of type XYPolygon describing the 
    /// triangalation of the polygon.
    /// </summary>
    /// <param></param>
    /// <returns>
    /// A triangulation of the polygon.
    /// </returns>
    public List<XYPolygon> GetTriangulation()
    {
      if (TriangleList == null)
      {
        int i = 0;
        int im1 = 0;
        int ip1 = 0;
        int n = 0;

        XYPolygon LocalPolygon = new XYPolygon(this);
        TriangleList = new List<XYPolygon>();
        while (LocalPolygon.Points.Count > 3)
        {
          i = LocalPolygon.FindEar();
          n = LocalPolygon.Points.Count;
          im1 = i - 1;
          ip1 = i + 1;
          if (i == 0)
          {
            im1 = n - 1;
          }
          else if (i == n - 1)
          {
            ip1 = 0;
          }
          XYPoint Nodeim1 = new XYPoint((XYPoint)LocalPolygon.Points[im1]);
          XYPoint Nodei = new XYPoint((XYPoint)LocalPolygon.Points[i]);
          XYPoint Nodeip1 = new XYPoint((XYPoint)LocalPolygon.Points[ip1]);
          XYPolygon Triangle = new XYPolygon();
          Triangle.Points.Add(Nodeim1);
          Triangle.Points.Add(Nodei);
          Triangle.Points.Add(Nodeip1);
          TriangleList.Add(Triangle);
          LocalPolygon.Points.RemoveAt(i);
        }
        TriangleList.Add(LocalPolygon);
      }
      return TriangleList;
    }
Exemplo n.º 45
0
    /// <summary>
    /// Determines if a point in inside or outside a polygon.
    /// Works for both convex and concave polygons (Winding number test)
    /// </summary>
    /// <param name="point">Point</param>
    /// <param name="polygon">Polygon</param>
    /// <returns>
    ///	<p>true:  If the point is inside the polygon</p>
    ///	<p>false: Otherwise.</p>
    /// </returns>
    public static bool IsPointInPolygon(IXYPoint point, XYPolygon polygon)
    {
		  return IsPointInPolygon(point.X, point.Y, polygon);
    }  
Exemplo n.º 46
0
    /// <summary>
    /// Reads the next shape
    /// </summary>
    /// <returns></returns>
    public IGeometry ReadNext(int RecordNumber)
    {
      IntPtr pShape = ShapeLib.SHPReadObject(_shapePointer, RecordNumber);
      ShapeLib.SHPObject shpObject = new ShapeLib.SHPObject();
      Marshal.PtrToStructure(pShape, shpObject);
      double[] x = new double[shpObject.nVertices];
      Marshal.Copy(shpObject.padfX, x, 0, x.Length);
      double[] y = new double[shpObject.nVertices];
      Marshal.Copy(shpObject.padfY, y, 0, y.Length);
      double[] z = new double[shpObject.nVertices];
      Marshal.Copy(shpObject.padfZ, z, 0, z.Length);

      int[] partstarts = null;
      if (shpObject.nParts > 0)
      {
        partstarts = new int[shpObject.nParts];
        Marshal.Copy(shpObject.paPartStart, partstarts, 0, partstarts.Length);
      }

      ShapeLib.SHPDestroyObject(pShape);

      IGeometry geom = null;

      switch (type)
      {
        case ShapeLib.ShapeType.NullShape:
          break;
        case ShapeLib.ShapeType.MultiPoint:
        case ShapeLib.ShapeType.MultiPointZ:
        case ShapeLib.ShapeType.MultiPointM:
        case ShapeLib.ShapeType.PointM:
        case ShapeLib.ShapeType.PointZ:
        case ShapeLib.ShapeType.Point:
          geom = new XYPoint(x[0], y[0]);
          break;
        case ShapeLib.ShapeType.PolyLineM:
        case ShapeLib.ShapeType.PolyLineZ:
        case ShapeLib.ShapeType.PolyLine:
          geom = new XYPolyline();
          for (int i = 0; i < x.Length; i++)
            ((XYPolyline)geom).Points.Add(new XYPoint(x[i], y[i]));
          break;
        case ShapeLib.ShapeType.PolygonM:
        case ShapeLib.ShapeType.PolygonZ:
        case ShapeLib.ShapeType.Polygon:

          if (partstarts.Count() == 1)
          {
            geom = new XYPolygon();

            for (int i = 0; i < x.Length; i++)
              ((XYPolygon)geom).Points.Add(new XYPoint(x[i], y[i]));
            ((XYPolygon)geom).Points.Reverse();
          }
          else
          {
            geom = new MultiPartPolygon();

            //foreach (var partstart in partstarts.Reverse())
            //{
            //  var poly = new XYPolygon();
            //  for (int i = end; i > partstart; i--)
            //    poly.Points.Add(new XYPoint(x[i], y[i]));
            //  end = partstart;
            //  ((MultiPartPolygon)geom).Polygons.Add(poly); 
            //}
            for (int j = 0; j < partstarts.Count(); j++)
            {
              int end;
              if (j < partstarts.Count() - 1)
                end = partstarts[j + 1];
              else
                end = x.Length;

              var poly = new XYPolygon();
              for (int i = partstarts[j]; i < end; i++)
                poly.Points.Add(new XYPoint(x[i], y[i]));
              poly.Points.Reverse();
              ((MultiPartPolygon)geom).Polygons.Add(poly);
            }

          }
          break;
        case ShapeLib.ShapeType.MultiPatch:
          break;
        default:
          break;
      }
      return geom;
    }
Exemplo n.º 47
0
    /// <summary>
    /// Determines if a point in inside or outside a polygon.
    /// Works for both convex and concave polygons (Winding number test)
    /// </summary>
    /// <param name="x">x-coordinate for the point</param>
    /// <param name="y">y-coordiante for the point</param>
    /// <param name="polygon">Polygon</param>
    /// <returns>
    ///	<p>true:  If the point is inside the polygon</p>
    ///	<p>false: If the point is outside the polygon.</p>
    /// </returns>
    public static bool IsPointInPolygon(double x, double y, XYPolygon polygon)
    {
        double x1,x2,y1,y2;
        double xinters;
        bool isInside = false;
        int  n = polygon.Points.Count;

        for (int i = 0; i < n; i++)
        {
          if (i < n - 1)
          {
            x1 = polygon.Points[i].X;
            x2 = polygon.Points[i + 1].X;
            y1 = polygon.Points[i].Y;
            y2 = polygon.Points[i + 1].Y;
          }
          else
          {
            x1 = polygon.Points[n - 1].X;
            x2 = polygon.Points[0].X;
            y1 = polygon.Points[n - 1].Y;
            y2 = polygon.Points[0].Y;
          }

        if (y > Math.Min(y1,y2))
        {
          if (y <= Math.Max(y1,y2))
          {
            if ( x <= Math.Max(x1,x2))
            {
              if (y1 != y2)
              {
                xinters = (y - y1)*(x2 - x1)/(y2 - y1) + x1;
								
                if (x1 == x2 || x <= xinters)
                {
                  isInside = !isInside;
                }
              }
            }
          }
        }
      }
      return isInside;
    }
Exemplo n.º 48
0
 public static double ATriangleIntersectionArea(XYPolygon triangleA, XYPolygon triangleB)
 {
   return TriangleIntersectionArea(triangleA, triangleB);
 }
Exemplo n.º 49
0
 /// <summary>
 /// Determines if a point in inside or outside a polygon.
 /// Works for both convex and concave polygons (Winding number test)
 /// </summary>
 /// <param name="point">Point</param>
 /// <param name="polygon">Polygon</param>
 /// <returns>
 ///	<p>true:  If the point is inside the polygon</p>
 ///	<p>false: Otherwise.</p>
 /// </returns>
 public static bool IsPointInPolygon(IXYPoint point, XYPolygon polygon)
 {
     return(IsPointInPolygon(point.X, point.Y, polygon));
 }