Ejemplo n.º 1
0
        internal List <SliceDataResults> SliceAndQueryAll(string direction, string sliceType, int colNum, float sliceWidth, float startPosition,
                                                          float endPosition, DataRecords.ColumnManager columnManager, List <int> variableColumnsToCalculate,
                                                          float domainToQuery, out string messages, bool weightByVol, bool weightByTonnes, int domainColumnID,
                                                          BackgroundWorker workerProcessData, int startPerc, int endPerc, string statsusTagMessage, bool weightByLength)
        {
            messages = "";
            workerProcessData.ReportProgress(startPerc, "Gathering slice data for " + statsusTagMessage);
            List <SliceData> allSlices = columnManager.SliceBy(colNum, sliceWidth, startPosition, endPosition, out messages, workerProcessData, startPerc, endPerc, statsusTagMessage);

            // now pick out all the sample IDs for the desired slice
            messages += "\n\nSlice num";
            foreach (int vc in variableColumnsToCalculate)
            {
                messages += ",Wt avg (" + vc + "), Vol (" + vc + ") , Num blocks (" + vc + ")";
            }
            messages += "\n";

            int sliceID = 0;
            List <SliceDataResults> sliceResults = new List <SliceDataResults>();

            foreach (SliceData aSlice in allSlices)
            {
                SliceDataResults sres = columnManager.QuerySliceData(direction, sliceType, aSlice, variableColumnsToCalculate, sliceID, domainToQuery, weightByVol, weightByTonnes, domainColumnID, weightByLength);
                sliceResults.Add(sres);
                messages += sres.GetMessages();
                sliceID++;
            }
            return(sliceResults);
        }
Ejemplo n.º 2
0
        internal SliceDataResults QuerySliceData(string direction, string sliceType,  SliceData aSlice, List<int> variableColumnsToCalculate, int sliceNum, float domainToQuery, bool weightByVol, bool weightByTonnes, int domainColumnID, bool weightByLength)
        {
            SliceDataResults sres = new SliceDataResults();
            
            // pick out all records for the slice
            
            // get the variable columns
            int numCols = variableColumnsToCalculate.Count;
            sres.Initialise(numCols,sliceNum);
            Object[] cols = new Object[numCols];

            for (int i = 0; i < numCols; i++) {
                cols[i] = columnData[variableColumnsToCalculate[i]];
            }

            List<int> sliceRowIDs = aSlice.rowIDList;
            
            sres.sliceCentrePoint = aSlice.sliceCentre;
            
            
         


                    for (int col = 0; col < numCols; col++)
                    {

                        DataColumn<float> varColumn = (DataColumn<float>)cols[col];
                        double tot = 0;
                        double totVol = 0;
                        double totVolAdjustedWt = 0;
                        int dataRecords = 0;
                        
                        double tonnes = 0;
                        foreach (int zz in sliceRowIDs)
                        {
                            int domain = 0;
                            domain = GetDomainForRow(zz, domainColumnID);
                            double ff = varColumn.GetRecordAt(zz);
                            if (ff != columnNullVal && domain == domainToQuery)
                            {

                                float weighting = 1;
                                if (weightByVol == true && weightByTonnes == false)
                                {
                                    weighting = GetVolumeForRow(zz);

                                }
                                else if (weightByVol == true && weightByTonnes == true)
                                {
                                    weighting = GetTonnesForRow(zz);
                                }
                                else
                                {
                                    // no weighting for composites
                                    weighting = 1.0f;
                                    if (weightByLength) {
                                        GetWeightForRow(zz);
                                    }
                                }

                                tot += ff;
                                dataRecords++;
                                double vaw = weighting * ff;
                                totVolAdjustedWt += vaw;
                                totVol += weighting;
                                if (weightByTonnes)
                                {
                                    tonnes += GetTonnesForRow(zz);
                                }

                                // write the data to a datafile
                               // string dtLine = "";
                               // dtLine =  ff + ", " + weighting;
                               // dtLine = GetDebugDataPrintout(zz) + ", Val, " + ff + " , Vol, " + weighting;
                             //   sw.WriteLine(dtLine);


                            }
                        }

                        sres.wtAvg[col] = totVolAdjustedWt / totVol;
                        sres.total[col] = tot;
                        sres.ave[col] = tot / dataRecords;
                        sres.totVolArr[col] = totVol;
                        sres.totTonneArr[col] = tonnes;

                        sres.dataRecordsUsed[col] = dataRecords;
                        sres.maxCoord = aSlice.sliceMax;
                        sres.minCoord = aSlice.sliceMin;
                        sres.midCoord = aSlice.sliceCentre;


                    }
                    //sw.WriteLine("\nSummary: ");
                    //sw.WriteLine("Ave, " + sres.ave[0]);
                    //sw.WriteLine("wtAvg, " + sres.wtAvg[0]);
                    //sw.WriteLine("Records, " + sres.dataRecordsUsed[0]);
                    //sw.WriteLine("Tot volume, " + sres.totVolArr[0]);
                    //sw.WriteLine("Tot tonnes, " + sres.totTonneArr[0]);
               // }
            
            return sres;


        }