private void btnOK_Click(object sender, EventArgs e)
        {
            // Edits the coordinates of selected turbine and calls background worker to perform turbine calcs (if they were done before)

            string name = txtName.Text;
            double UTMX = Convert.ToDouble(txtUTMX.Text);
            double UTMY = Convert.ToDouble(txtUTMY.Text);

            if (name == "" || UTMX == 0 || UTMY == 0)
            {
                MessageBox.Show("Need valid entries for all fields", "Continuum 3");
                return;
            }

            Check_class Check        = new Check_class();
            bool        inputTurbine = Check.NewTurbOrMet(thisInst.topo, name, UTMX, UTMY, true);

            if (inputTurbine == true)
            {
                thisInst.turbineList.EditTurbine(name, UTMX, UTMY);
            }

            Update updateThe = new Update();

            updateThe.AllTABs(thisInst);

            Close();
        }
        /// <summary>  Finds and returns array of grid points surrounding met/node for P10 exposure calculation. </summary>
        public TopoInfo.TopoGrid[] GetGridArray(double UTMX, double UTMY, Continuum thisInst) //
        {
            double minX = UTMX - gridRadius;
            double minY = UTMY - gridRadius;

            double maxX = UTMX + gridRadius;
            double maxY = UTMY + gridRadius;

            // Find closest nodes to minX and minY and maxX and maxY with a minimum distance of 10 km from edge of topography
            TopoInfo.TopoGrid closestNodeToMin = thisInst.topo.GetClosestNodeFixedGrid(minX, minY, reso, 10000);
            TopoInfo.TopoGrid closestNodeToMax = thisInst.topo.GetClosestNodeFixedGrid(maxX, maxY, reso, 10000);

            minX = closestNodeToMin.UTMX;
            minY = closestNodeToMin.UTMY;
            maxX = closestNodeToMax.UTMX;
            maxY = closestNodeToMax.UTMY;

            Check_class check = new Check_class();

            int gridCount = 0;

            TopoInfo.TopoGrid[] gridArray = new TopoInfo.TopoGrid[1];

            double dirBinSize = (double)360 / thisInst.metList.numWD;

            double[] windRose     = thisInst.metList.GetAvgWindRose(thisInst.modeledHeight, Met.TOD.All, Met.Season.All);
            bool[]   sectorsToUse = FindSectorsForGrid(windRose);

            for (double i = minX; i <= maxX; i = i + reso)
            {
                for (double j = minY; j <= maxY; j = j + reso)
                {
                    double dist     = thisInst.topo.CalcDistanceBetweenPoints(i, j, UTMX, UTMY);
                    double deltaX   = i - UTMX;
                    double deltaY   = j - UTMY;
                    int    dirInd   = thisInst.topo.CalcDirInd(deltaX, deltaY, dirBinSize);
                    int    goodToGo = check.NewNodeCheck(thisInst.topo, i, j, 10000, "Calcs");
                    //  bool gridOk = thisInst.topo.newNode(i, j, thisInst.radiiList, gridRadius);

                    if (goodToGo == 100 && ((dist < gridRadius && sectorsToUse[dirInd] == true) || dist < gridRadius / 2))
                    {
                        gridCount = gridCount + 1;
                        Array.Resize(ref gridArray, gridCount);

                        gridArray[gridCount - 1].UTMX = i;
                        gridArray[gridCount - 1].UTMY = j;
                    }
                }
            }

            return(gridArray);
        }
Example #3
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            // Reads in entered name, UTMX, UTMY, and string number. if ( valid, adds to turbine list and calls background worker to perform turbine calcs (if done before)
            string name      = "";
            double UTMX      = 0;
            double UTMY      = 0;
            int    stringNum = 0;

            bool        inputTurbine = false;
            Check_class check        = new Check_class();

            try
            {
                name = txtName.Text;
            }
            catch
            {
                MessageBox.Show("Invalid entry for turbine name", "Continuum 3");
                return;
            }

            try
            {
                UTMX = Convert.ToSingle(txtUTMX.Text);
            }
            catch
            {
                MessageBox.Show("Invalid entry for easting", "Continuum 3");
                return;
            }

            try
            {
                UTMY = Convert.ToSingle(txtUTMY.Text);
            }
            catch
            {
                MessageBox.Show("Invalid entry for northing", "Continuum 3");
                return;
            }

            try
            {
                stringNum = Convert.ToInt16(txtStrNum.Text);
            }
            catch
            {
                stringNum = 0;
            }

            if (name == "" || UTMX == 0 || UTMY == 0)
            {
                MessageBox.Show("Need valid entries for all fields", "Continuum 3");
                return;
            }
            else
            {
                inputTurbine = check.NewTurbOrMet(thisInst.topo, name, UTMX, UTMY, true);
                if (inputTurbine == true)
                {
                    thisInst.turbineList.AddTurbine(name, UTMX, UTMY, stringNum);
                }

                thisInst.updateThe.AllTABs(thisInst);
                thisInst.ChangesMade();

                Close();
            }
        }