Exemple #1
0
        }   //  end ProcessSecondary

        private void ProcessRecovered(StreamWriter strWriteOut, reportHeaders rh, ref int pageNumb, string volType, List <POPDO> popList)
        {
            //  Reports ST1/ST2
            foreach (StratumDO s in Global.BL.getStratum())
            {
                //  first capture the sum of x and x squared
                foreach (POPDO p in POPmethods.GetStratumData(popList, s.Code, currCL))
                {
                    StatList slOne = new StatList();
                    StatList slTwo = new StatList();
                    //  need method for stratum
                    string currMethod = Utilities.MethodLookup(p.Stratum);
                    switch (volType)
                    {
                    case "NET":
                        slOne.SumOfX  = p.Stg1NetXRP;
                        slOne.SumOfX2 = p.Stg1NetXRsqrdRP;
                        break;

                    case "GROSS":
                        slOne.SumOfX  = p.Stg1GrossXRP;
                        slOne.SumOfX2 = p.Stg1GrossXsqrdRP;
                        break;
                    }   //  end switch on volume type (gross or net)

                    stage1Stats.Add(slOne);
                    CalcAllStats(p, 1, currMethod);

                    //  Stage 2?
                    switch (volType)
                    {
                    case "NET":
                        slTwo.SumOfX  = p.Stg2NetXRP;
                        slTwo.SumOfX2 = p.Stg2NetXsqrdRP;
                        break;

                    case "GROSS":
                        slTwo.SumOfX  = p.Stg2GrossXRP;
                        slTwo.SumOfX2 = p.Stg2GrossXsqrdRP;
                        break;
                    }   //  end switch on volume type (gross or net)


                    if (slTwo.SumOfX > 0)
                    {
                        stage2Stats.Add(slTwo);
                        CalcAllStats(p, 2, currMethod);
                        CalcCombinedError(currMethod);
                        WriteCurrentGroup(p, strWriteOut, rh, ref pageNumb, 1, 3, currMethod);
                        WriteCurrentGroup(p, strWriteOut, rh, ref pageNumb, 2, 3, currMethod);
                    }
                    else if (slOne.SumOfX > 0)
                    {
                        if (slOne.SumOfX > 0 && slOne.SumOfX2 > 0)
                        {
                            CalcCombinedError(currMethod);
                            WriteCurrentGroup(p, strWriteOut, rh, ref pageNumb, 1, 3, currMethod);
                        } //  endif
                    }     //  endif stage 2
                    stage1Stats.Clear();
                    stage2Stats.Clear();
                }   //  end foreach loop
                if (numOlines > 0)
                {
                    strWriteOut.WriteLine();
                    numOlines++;
                } //  endif
            }     //  end foreach on stratum
            //  print footnote
            strWriteOut.WriteLine("  * CANNOT CALCULATE SAMPLING ERROR IF SMALL N EQUALS 1.");
            return;
        }   //  end ProcessRecovered
Exemple #2
0
        private void on_GO(object sender, EventArgs e)
        {
            processingStatus.Text = "READY TO BEGIN?  Click GO.";
            Cursor.Current        = Cursors.WaitCursor;
            //  perform edit checks --
            processingStatus.Text = "Edit checking the data.  Please wait.";
            processingStatus.Refresh();
            //  calls edit check routines

            /*            string outputFileName;
             *          //  check for errors from FScruiser before running edit checks
             *          //  generate an error report
             *          //  June 2013
             *          List<ErrorLogDO> fscList = bslyr.getErrorMessages("E", "FScruiser");
             *          if (fscList.Count > 0)
             *          {
             *              ErrorReport eRpt = new ErrorReport();
             *              eRpt.fileName = fileName;
             *              eRpt.bslyr.fileName = bslyr.fileName;
             *              eRpt.bslyr.DAL = bslyr.DAL;
             *              outputFileName = eRpt.PrintFScruiserErrors(fscList);
             *              string outputMessage = "ERRORS FROM FSCRUISER FOUND!\nCorrect data and rerun\nOutput file is:" + outputFileName;
             *              MessageBox.Show(outputMessage, "ERRORS", MessageBoxButtons.OK, MessageBoxIcon.Stop);
             *              //  request made to open error report in preview -- May 2015
             *              PrintPreview pp = new PrintPreview();
             *              pp.fileName = outputFileName;
             *              pp.setupDialog();
             *              pp.ShowDialog();
             *              Environment.Exit(0);
             *          }   //  endif report needed
             *
             *          //  clear out error log table for just CruiseProcessing before performing checks
             *          bslyr.DeleteErrorMessages();
             *
             *          EditChecks eChecks = new EditChecks();
             *          eChecks.fileName = fileName;
             *          eChecks.bslyr.fileName = bslyr.fileName;
             *          eChecks.bslyr.DAL = bslyr.DAL;
             *
             *          int errors = eChecks.TableEditChecks();
             *          if (errors == -1)
             *          {
             *              //  no measured trees detected in the cruise.  critical errpor stops the program.
             *              Close();
             *              return;
             *          }   //  endif
             *          errors = eChecks.MethodChecks();
             *          if (errors == -1)
             *          {
             *              //  empty stratum detected and user wants to quit
             *              Close();
             *              return;
             *          }   //  endif
             *          //  just check the ErrorLog table for entries
             *          List<ErrorLogDO> errList = bslyr.getErrorMessages("E", "CruiseProcessing");
             *          if (errList.Count > 0)
             *          {
             *              ErrorReport er = new ErrorReport();
             *              er.fileName = fileName;
             *              er.bslyr.fileName = fileName;
             *              er.bslyr.DAL = bslyr.DAL;
             *              outputFileName = er.PrintErrorReport(errList);
             *              string outputMessage = "ERRORS FOUND!\nCorrect data and rerun\nOutput file is:" + outputFileName;
             *              MessageBox.Show(outputMessage, "ERRORS", MessageBoxButtons.OK, MessageBoxIcon.Stop);
             *              //  request made to open error report in preview -- May 2015
             *              PrintPreview pp = new PrintPreview();
             *              pp.fileName = outputFileName;
             *              pp.setupDialog();
             *              pp.ShowDialog();
             *              Environment.Exit(0);
             *          }   //  endif report needed
             * moved to EditCheck routine*/
            //  Show editCheck message -- edit checks complete

            EditChecks eChecks = new EditChecks();

            eChecks.fileName = fileName;
            eChecks.DAL      = DAL;

            int err = eChecks.CheckErrors();

            if (err < 0)
            {
                Close();
                return;
            }

            editCheck.Enabled = true;

            //  next show preparation of data
            processingStatus.Text = "Preparing data for processing.";
            processingStatus.Refresh();

            //  before making IDs, need to check for blank or null secondary products in sample groups
            //  if blank, default to 02 for every region but 6 where it will be 08 instead
            //  put a warning message in the error log table indicating the secondary product was set to a default
            //  June 2013
            List <SaleDO> saleList = new List <SaleDO>();

            saleList = DAL.From <SaleDO>().Read().ToList();
            string currRegion = saleList[0].Region;

            //string currRegion = bslyr.getRegion();

            DefaultSecondaryProduct(currRegion);

            CalculateTreeValues calcTreeVal = new CalculateTreeValues();
            CalculatedValues    calcVal     = new CalculatedValues();


            //  retrieve lists needed and sets up population IDs
            calcVal.fileName = fileName;
            calcVal.DAL      = DAL;
            //   List<SampleGroupDO> sgList = bslyr.getSampleGroups();
            //   List<TreeDefaultValueDO> tdvList = bslyr.getTreeDefaults();
            //   List<CountTreeDO> ctList = bslyr.getCountTrees();
            //   List<PlotDO> pList = bslyr.getPlots();

            //   calcVal.ClearCalculatedTables();
            //   calcVal.MakePopulationIDs(sgList, tdvList);

            calcVal.CalcValues();

            CPbusinessLayer bslyr = new CPbusinessLayer();

            bslyr.DAL = DAL;
            //  now need some other tables to start summing values
            List <LCDDO>              lcdList = bslyr.getLCD();
            List <POPDO>              popList = bslyr.getPOP();
            List <PRODO>              proList = bslyr.getPRO();
            List <StratumDO>          sList   = bslyr.getStratum();
            List <SampleGroupDO>      sgList  = bslyr.getSampleGroups();
            List <TreeDefaultValueDO> tdvList = bslyr.getTreeDefaults();
            List <CountTreeDO>        ctList  = bslyr.getCountTrees();
            List <PlotDO>             pList   = bslyr.getPlots();
            List <TreeDO>             tList   = bslyr.getTrees();

            calcTreeVal.fileName       = fileName;
            calcTreeVal.bslyr.fileName = fileName;
            calcTreeVal.bslyr.DAL      = bslyr.DAL;

            //  show preparation of data is complete
            prepareCheck.Enabled = true;
            //  now loop through strata and show status message updating for each stratum
            StringBuilder sb = new StringBuilder();

            foreach (StratumDO sdo in sList)
            {
                //  update status message for next stratum
                sb.Clear();
                sb.Append("Calculating stratum ");
                sb.Append(sdo.Code);
                processingStatus.Text = sb.ToString();
                processingStatus.Refresh();

                //  Sum counts and KPI for LCD table
                List <PlotDO> justPlots = PlotMethods.GetStrata(pList, sdo.Code);
                //  need cut and leave trees for this
                List <LCDDO> justCurrentLCD = LCDmethods.GetStratum(lcdList, sdo.Code);
                calcVal.SumTreeCountsLCD(sdo.Code, ctList, justPlots, justCurrentLCD, sdo.Method, lcdList);

                //  Sum counts and KPI for POP table
                List <POPDO> justCurrentPOP = POPmethods.GetStratumData(popList, sdo.Code, "");
                calcVal.SumTreeCountsPOP(sdo.Code, ctList, justPlots, justCurrentPOP, sdo.Method, popList);

                //  Sum counts and KPI for PRO table
                List <PRODO> justCurrentPRO = PROmethods.GetCutTrees(proList, sdo.Code, "", "", 0);
                calcVal.SumTreeCountsPRO(sdo.Code, ctList, justPlots, justCurrentPRO, sdo.Method, proList);

                //  Calculate expansion factor
                calcVal.CalcExpFac(sdo, justPlots, justCurrentPOP);

                //  Calculate volumes
                calcTreeVal.ProcessTrees(sdo.Code, sdo.Method, (long)sdo.Stratum_CN);

                //  Update 3P tally
                if (sdo.Method == "3P")
                {
                    List <LCDDO> LCDstratum = LCDmethods.GetStratumGroupedBy(fileName, sdo.Code, bslyr);

                    Update3Ptally(fileName, ctList, justCurrentLCD, tList, LCDstratum);
                    //  Save
                    bslyr.SaveLCD(justCurrentLCD);
                }   //  endif method is 3P


                //  Update expansion factors for methods 3PPNT, F3P, and P3P
                if (sdo.Method == "3PPNT" || sdo.Method == "F3P" || sdo.Method == "P3P")
                {
                    List <TreeDO> justCurrentStratum = tList.FindAll(
                        delegate(TreeDO td)
                    {
                        return(td.Stratum.Code == sdo.Code);
                    });
                    List <TreeCalculatedValuesDO> tcvList = bslyr.getTreeCalculatedValues((int)sdo.Stratum_CN);
                    UpdateExpansionFactors(justCurrentStratum, tcvList);
                    //  Save update
                    bslyr.SaveTrees(justCurrentStratum);
                }   //  endif on method

                //  Sum data for the LCD, POP and PRO table
                SumAll Sml = new SumAll();
                Sml.fileName       = fileName;
                Sml.bslyr.fileName = bslyr.fileName;
                Sml.bslyr.DAL      = bslyr.DAL;
                Sml.SumAllValues(sdo.Code, sdo.Method, (int)sdo.Stratum_CN, sList, pList, justCurrentLCD,
                                 justCurrentPOP, justCurrentPRO);

                //  Update STR tally after expansion factors are summed
                if (sdo.Method == "STR")
                {
                    UpdateSTRtally(fileName, sdo.Code, justCurrentLCD, ctList, lcdList);
                    //  save
                    bslyr.SaveLCD(lcdList);
                } //  endif method is STR
            }     //  end foreach stratum

            //  show volume calculation is finished
            volumeCheck.Enabled   = true;
            processingStatus.Text = "Processing is DONE";
            processingStatus.Refresh();
            System.Threading.Thread.Sleep(5000);
            Cursor.Current = this.Cursor;

            Close();
            return;
        }   //  end on_GO
Exemple #3
0
        }   //  end SumTreeCountsLCD

        public void SumTreeCountsPOP(string currST, List <CountTreeDO> ctList, List <PlotDO> justPlots,
                                     string currMethod, List <POPDO> popList)
        {
            //  also need first and second stage sample counts
            double stage1 = 0.0;

            double stage2 = 0.0;

            //  Sums trees and counts from either the Count Tree table or tree count records

            foreach (POPDO pop in POPmethods.GetStratumData(popList, currST, ""))
            {
                firstSum         = 0.0;
                talliedSum       = 0.0;
                totalKPI         = 0.0;
                totalMeasuredKPI = 0.0;
                //  find measured trees for current POP group
                var popTrees = Global.BL.getPOPtrees(pop, "M");
                //  measured tree is just a count of the trees for the current group
                pop.MeasuredTrees = popTrees.Count();

                //  now need count trees from tree count records
                var popCntTrees = Global.BL.getPOPtrees(pop, "C");

                //  sum all tree counts for first stage and total tallied
                if (currMethod == "STR" || currMethod == "100")
                {
                    firstSum = popTrees.Count();
                    //  I thought tree count was supposed to default to 1 for 100% -- Feb 2014
                    //  Apparently, FScruiser can put whatever it wants in tree count
                }
                else if (currMethod != "3P")
                {
                    firstSum  = popTrees.Sum(tdo => tdo.TreeCount);
                    firstSum += popCntTrees.Sum(tdo => tdo.TreeCount);
                }
                if (pop.STM == "Y")
                {
                    firstSum   += pop.MeasuredTrees;
                    talliedSum += pop.MeasuredTrees;
                    //talliedSum = popTrees.Sum(tdo => tdo.TreeCount);
                }
                else
                {
                    //  see note above on 100% method
                    //if (currMethod == "3P" || currMethod == "100")
                    if (currMethod == "100")
                    {
                        talliedSum += pop.MeasuredTrees;
                    }
                    else
                    {
                        talliedSum  = popTrees.Sum(tdo => tdo.TreeCount);
                        talliedSum += popCntTrees.Sum(tdo => tdo.TreeCount);
                    } //  endif on current method
                }     //  endif
                //  insurance trees go into just the tallied tree count
                var lcdInsurance = Global.BL.getPOPtrees(pop, "I");
                talliedSum += lcdInsurance.Sum(tdo => tdo.TreeCount);
                //  Complete totals for tree count and stage samples and KPIs based on method
                stage1 = justPlots.Count();
                List <CountTreeDO> popCountCounts = new List <CountTreeDO>();
                switch (currMethod)
                {
                case "100":
                    stage1 = popTrees.Count();
                    break;

                case "STR":
                    stage1 = popTrees.Count();
                    //popCountCounts = ctList.FindAll(
                    //    delegate(CountTreeDO ctd)
                    //    {
                    //        return pop.CutLeave == ctd.SampleGroup.CutLeave &&
                    //               pop.Stratum == ctd.SampleGroup.Stratum.Code &&
                    //               pop.SampleGroup == ctd.SampleGroup.Code &&
                    //               pop.PrimaryProduct == ctd.SampleGroup.PrimaryProduct &&
                    //               pop.SecondaryProduct == ctd.SampleGroup.SecondaryProduct &&
                    //               pop.UOM == ctd.SampleGroup.UOM;
                    //   });
                    talliedSum += Global.BL.getPOPCounts(pop).Sum(ctd => ctd.TreeCount);
                    break;

                case "S3P":
                case "3P":
                    if (currMethod == "S3P")
                    {
                        stage2 = popTrees.Count();
                    }
                    // popCountCounts = ctList.FindAll(
                    //     delegate(CountTreeDO ctd)
                    //     {
                    //         return pop.CutLeave == ctd.SampleGroup.CutLeave &&
                    //                pop.Stratum == ctd.SampleGroup.Stratum.Code &&
                    //                pop.SampleGroup == ctd.SampleGroup.Code &&
                    //               pop.PrimaryProduct == ctd.SampleGroup.PrimaryProduct &&
                    //               pop.SecondaryProduct == ctd.SampleGroup.SecondaryProduct &&
                    //               pop.UOM == ctd.SampleGroup.UOM;
                    //    });
                    if (pop.STM == "N")
                    {
                        stage1    = popTrees.Count();
                        firstSum += pop.MeasuredTrees;

                        foreach (CountTreeDO ctd in Global.BL.getPOPCounts(pop))
                        {
                            talliedSum += ctd.TreeCount;
                            totalKPI   += ctd.SumKPI;
                        }
                        //talliedSum += popCountCounts.Sum(ctd => ctd.TreeCount);
                        //totalKPI += popCountCounts.Sum(ctd => ctd.SumKPI);
                    }
                    //  Sum measured KPI from trees
                    totalMeasuredKPI = popTrees.Sum(tdo => tdo.KPI);
                    //  for S3P and 3P, sum of KPI is total of count and measured KPI from the trees == November 2013
                    //  even though individual KPI may be zero for either one.
                    //  however, countTree has sum of count and measured KPI for 3P so adding measured and count
                    //  from trees will double count for 3P ONLY -- December 2013
                    if (currMethod == "S3P")
                    {
                        totalKPI += popCntTrees.Sum(lc => lc.KPI);
                        totalKPI += popTrees.Sum(lt => lt.KPI);
                    }       //  endif on method
                    break;

                case "PCM":
                case "PCMTRE":
                    stage2 = popTrees.Count();
                    break;

                case "F3P":
                case "P3P":
                    stage2           = popTrees.Count();
                    totalMeasuredKPI = popTrees.Sum(tdo => tdo.KPI);
                    totalKPI         = popCntTrees.Sum(tdo => tdo.KPI);
                    totalKPI        += totalMeasuredKPI;
                    totalKPI        += popCountCounts.Sum(ctd => ctd.SumKPI);
                    break;

                case "FCM":
                    //  August 2014 -- according to Ken C. this needs to be just the total measured trees
                    //  and not the sum of tree counts.  Some tree counts could be zero when they should be one.
                    //stage2 = popTrees.Sum(p => p.TreeCount);
                    stage2 = pop.MeasuredTrees;
                    break;

                case "3PPNT":
                    //  Stage 2 samples
                    foreach (PlotDO pdo in justPlots)
                    {
                        TreeDO tree = popTrees.FirstOrDefault(tdo => tdo.Plot_CN == pdo.Plot_CN);
                        if (tree != null)
                        {
                            stage2++;
                            //nthRow = -1;
                        }   //  endif nthRow
                    }       //  end foreach loop
                    //  this will probably no longer work on legacy data until
                    //  the conversion program handles this change
                    if (popTrees.Count() > 0)
                    {
                        //  means there are measured trees so this was a measured plot
                        //  KPI in the plot table is measured
                        totalMeasuredKPI = justPlots.Sum(pd => pd.KPI);
                        //  plus add to total KPI
                        totalKPI = justPlots.Sum(pd => pd.KPI);
                    }
                    else
                    {
                        //  no measured trees means this is a count plot
                        //  just add plot KPI to total KPI
                        totalKPI += justPlots.Sum(pd => pd.KPI);
                    }       //  endif
                    //  this piece of code will no longer work -- September 2013
                    //totalMeasuredKPI = lcdTrees.Sum(tdo => tdo.KPI);
                    //totalKPI += lcdCountCounts.Sum(ctd => ctd.SumKPI);
                    //  Add plot KPI to total KPI
                    //totalKPI += justPlots.Sum(pd => pd.KPI);
                    //totalMeasuredKPI = popTrees.Sum(tdo => tdo.KPI);
                    //totalKPI += popCntTrees.Sum(tdo => tdo.KPI);
                    //  Also need plot KPI for this method
                    //totalKPI += justPlots.Sum(pd => pd.KPI);
                    break;
                }   //  end switch on method
                pop.FirstStageTrees = firstSum;
                pop.TalliedTrees    = talliedSum;
                pop.SumKPI          = totalKPI;
                pop.SumMeasuredKPI  = totalMeasuredKPI;
                pop.StageOneSamples = stage1;
                pop.StageTwoSamples = stage2;
            }   //  end foreach loop

            //  Save list before continuing
            Global.BL.SavePOP(popList);

            return;
        }   //  end SumTreeCountsPOP
Exemple #4
0
        }   //  end SumTreeCountsPRO

        public void CalcExpFac(StratumDO sdo, List <PlotDO> justPlots, List <POPDO> popList)
        {
            //  Calculates expansion factor, tree factor and point factor for each tree in the current population
            double EF = 0.0;        //  expansion factor
            double TF = 0.0;        //  tree factor
            double PF = 0.0;        //  point factor

            //  Need total number of plots and measured plots (3PPNT only)
            double totalPlots     = justPlots.Count();
            double totalMeasPlots = 0.0;

            //  process by population
            foreach (POPDO pdo in POPmethods.GetStratumData(popList, sdo.Code, ""))
            {
                //  pull trees for population
                List <TreeDO> justTrees = Global.BL.getPOPtrees(pdo, sdo.Method == "FIXCNT" ? "C" : "M").ToList();
                //if (sdo.Method == "FIXCNT")
                //    justTrees = Global.BL.getPOPtrees(pdo, "C");
                //else
                //    justTrees = Global.BL.getPOPtrees(pdo, "M");

                //  3PPNT uses measured plots
                if (sdo.Method == "3PPNT")
                {
                    foreach (PlotDO p in justPlots)
                    {
                        TreeDO tdo = justTrees.FirstOrDefault(td => td.Plot_CN == p.Plot_CN && td.Stratum_CN == p.Stratum_CN);
                        if (tdo != null)
                        {
                            totalMeasPlots++;
                        }
                    } //  end foreach loop
                }     //  endif Method is 3PPNT

                //  calculate factors on each tree
                foreach (TreeDO tdo in justTrees)
                {
                    //  Calculate point factor for P3P S3P F3P PCM FCM and 3PPNT
                    switch (sdo.Method)
                    {
                    case "P3P":
                    case "S3P":
                    case "F3P":
                        PF = CommonEquations.Frequency3P(pdo.SumKPI, tdo.KPI, pdo.MeasuredTrees);
                        break;

                    case "PCM":
                    case "PCMTRE":
                        PF = CommonEquations.CalcTreeFactor(pdo.FirstStageTrees, pdo.MeasuredTrees, 0.0, 1, 2);
                        break;

                    case "FCM":
                        PF = CommonEquations.CalcTreeFactor(0.0, pdo.MeasuredTrees, pdo.TalliedTrees, 3, 2);
                        break;

                    case "3PPNT":
                        //  uses plot KPI
                        PlotDO plotKPI = justPlots.Find(
                            delegate(PlotDO p)
                        {
                            return(p.Plot_CN == tdo.Plot_CN);
                        });
                        PF = CommonEquations.Frequency3P(pdo.SumKPI, plotKPI.KPI, totalMeasPlots);
                        break;
                    }   //  end switch on method to calculate point factor

                    //  Calculate tree factor for FIXCNT FIX F3P FCM PNT P3P PCM 3PPNT and S3P
                    switch (sdo.Method)
                    {
                    case "FIXCNT":
                    case "FIX":
                    case "F3P":
                        TF = sdo.FixedPlotSize;
                        break;

                    case "FCM":
                        if (totalPlots > 0)
                        {
                            TF = sdo.FixedPlotSize / totalPlots;
                        }
                        break;

                    case "PNT":
                    case "P3P":
                    case "PCM":
                    case "PCMTRE":
                    case "3PPNT":
                        if (tdo.DBH > 0)
                        {
                            TF = CommonEquations.PointSampleFrequency(sdo.BasalAreaFactor, tdo.DBH);
                        }
                        else if (tdo.DRC > 0)
                        {
                            TF = CommonEquations.PointSampleFrequency(sdo.BasalAreaFactor, tdo.DRC);
                        }
                        break;

                    case "S3P":
                        TF = CommonEquations.CalcTreeFactor(pdo.FirstStageTrees, 0.0, pdo.TalliedTrees, 3, 1);
                        break;
                    }   //  end switch on method to calculate tree factor

                    //  Calculate expansion factor
                    switch (sdo.Method)
                    {
                    case "100":
                        EF = 1.0;
                        break;

                    case "FIXCNT":
                        if (totalPlots > 0)
                        {
                            EF = (sdo.FixedPlotSize / totalPlots) * tdo.TreeCount;
                        }
                        break;

                    case "FIX":
                        if (totalPlots > 0)
                        {
                            EF = sdo.FixedPlotSize / totalPlots;
                        }
                        break;

                    case "PNT":
                        if (totalPlots > 0)
                        {
                            EF = TF / totalPlots;
                        }
                        break;

                    case "STR":
                        EF = CommonEquations.CalcTreeFactor(0.0, pdo.MeasuredTrees, pdo.TalliedTrees, 3, 2);
                        break;

                    case "P3P":
                    case "F3P":
                    case "PCM":
                    case "PCMTRE":
                    case "3PPNT":
                        if (totalPlots > 0)
                        {
                            EF = (TF * PF) / totalPlots;
                        }
                        break;

                    case "FCM":
                    case "S3P":
                        EF = TF * PF;
                        break;

                    case "3P":
                        EF = CommonEquations.Frequency3P(pdo.SumKPI, tdo.KPI, pdo.MeasuredTrees);
                        break;
                    }   //  end switch on method to calculate expansion factor
                    if (tdo.STM == "Y")
                    {
                        EF = 1.0;
                    }

                    //  round just the expansion factor
                    EF = CommonEquations.RoundExpansionFactor(EF);
                    //  store factors
                    tdo.ExpansionFactor = (float)EF;
                    tdo.TreeFactor      = (float)TF;
                    tdo.PointFactor     = (float)PF;
                }   //  end foreach loop on justTrees
                //  save this bunch of trees
                Global.BL.SaveTrees(justTrees);
            }   //  end foreach loop on justCurrentPOP

            return;
        } //  end CalcExpFac
Exemple #5
0
        }   //  end ProcessPrimary

        private void ProcessSecondary(StreamWriter strWriteOut, reportHeaders rh, ref int pageNumb, string volType)
        {
            //  Reports ST1/ST2
            List <StratumDO> sList = bslyr.getStratum();

            foreach (StratumDO s in sList)
            {
                List <POPDO> justStratum = POPmethods.GetStratumData(popList, s.Code, currCL);
                //  first capture the sum of x and x squared
                foreach (POPDO p in justStratum)
                {
                    StatList slOne = new StatList();
                    StatList slTwo = new StatList();
                    //  need method for stratum
                    string currMethod = Utilities.MethodLookup(p.Stratum, bslyr);

                    switch (volType)
                    {
                    case "NET":
                        slOne.SumOfX  = p.Stg1NetXSP;
                        slOne.SumOfX2 = p.Stg1NetXsqrdSP;
                        break;

                    case "GROSS":
                        slOne.SumOfX  = p.Stg1GrossXSP;
                        slOne.SumOfX2 = p.Stg1GrossXsqrdSP;
                        break;
                    }   //  end switch on volume type (gross or net)

                    stage1Stats.Add(slOne);
                    CalcAllStats(p, 1, currMethod);

                    //  Stage 2?
                    switch (volType)
                    {
                    case "NET":
                        slTwo.SumOfX  = p.Stg2NetXSP;
                        slTwo.SumOfX2 = p.Stg2NetXsqrdSP;
                        break;

                    case "GROSS":
                        slTwo.SumOfX  = p.Stg2GrossXSP;
                        slTwo.SumOfX2 = p.Stg2GrossXsqrdSP;
                        break;
                    }   //  end switch on volume type (gross or net)

                    if (slTwo.SumOfX > 0)
                    {
                        stage2Stats.Add(slTwo);
                        CalcAllStats(p, 2, currMethod);
                        CalcCombinedError(currMethod);
                        WriteCurrentGroup(p, strWriteOut, rh, ref pageNumb, 1, 2, currMethod);
                        WriteCurrentGroup(p, strWriteOut, rh, ref pageNumb, 2, 2, currMethod);
                    }
                    else if (slOne.SumOfX > 0)
                    {
                        if (slOne.SumOfX > 0 && slOne.SumOfX2 > 0)
                        {
                            CalcCombinedError(currMethod);
                            WriteCurrentGroup(p, strWriteOut, rh, ref pageNumb, 1, 2, currMethod);
                        } //  endif
                    }     //  endif stage 2
                    stage1Stats.Clear();
                    stage2Stats.Clear();
                }   //  end foreach loop
                if (numOlines > 0)
                {
                    strWriteOut.WriteLine();
                    numOlines++;
                } //  endif
            }     //  end foreach on stratum
            //  print footnote
            //strWriteOut.Write("\x00B9");   this puts a funny character at the beginning that I can't get rid of
            strWriteOut.WriteLine("  * CANNOT CALCULATE SAMPLING ERROR IF SMALL N EQUALS 1.");
            return;
        }   //  end ProcessSecondary