示例#1
0
        private void RefreshCalculatedValues()
        {
            DataRow drProp = this.DataFeed.GetDataSheet(Strings.DATASHEET_SPPIC_NAME).GetDataRow();

            if (drProp == null)
            {
                return;
            }

            //Num Cells
            int NumCells = DataTableUtilities.GetDataInt(drProp[Strings.DATASHEET_SPPIC_NUM_CELLS_COLUMN_NAME]);

            this.TextBoxNumCells.Text = NumCells.ToString(CultureInfo.InvariantCulture);

            //Get the units and refresh the units labels - the default Raster Cell Units is Metres^2
            string          srcSizeUnits = DataTableUtilities.GetDataStr(drProp[Strings.DATASHEET_SPPIC_CELL_SIZE_UNITS_COLUMN_NAME]);
            string          srcAreaUnits = srcSizeUnits + "^2";
            string          amountlabel  = null;
            TerminologyUnit destUnitsVal = 0;

            TerminologyUtilities.GetAmountLabelTerminology(
                this.Project.GetDataSheet(Strings.DATASHEET_TERMINOLOGY_NAME), ref amountlabel, ref destUnitsVal);

            string destAreaLbl = TerminologyUtilities.TerminologyUnitToString(destUnitsVal);

            srcAreaUnits = srcAreaUnits.ToLower(CultureInfo.InvariantCulture);
            amountlabel  = amountlabel.ToLower(CultureInfo.InvariantCulture);
            destAreaLbl  = destAreaLbl.ToLower(CultureInfo.InvariantCulture);

            this.LabelRasterCellArea.Text = string.Format(CultureInfo.InvariantCulture, "Cell size ({0}):", srcAreaUnits);
            this.LabelCalcCellArea.Text   = string.Format(CultureInfo.InvariantCulture, "Cell size ({0}):", destAreaLbl);
            this.LabelCalcTtlAmount.Text  = string.Format(CultureInfo.InvariantCulture, "Total {0} ({1}):", amountlabel, destAreaLbl);

            // Calculate Cell Area in raster's native units
            float  cellSize = DataTableUtilities.GetDataSingle(drProp[Strings.DATASHEET_SPPIC_CELL_SIZE_COLUMN_NAME]);
            double cellArea = Math.Pow(cellSize, 2);

            this.TextBoxCellArea.Text = cellArea.ToString("N4", CultureInfo.InvariantCulture);

            // Calc Cell Area in terminology units
            double cellAreaTU = 0;

            if (!CheckBoxCellSizeOverride.Checked)
            {
                cellAreaTU = InitialConditionsSpatialDataSheet.CalcCellArea(cellArea, srcSizeUnits, destUnitsVal);
                this.TextBoxCellAreaCalc.Text = cellAreaTU.ToString("N4", CultureInfo.InvariantCulture);
                drProp[Strings.DATASHEET_SPPIC_CELL_AREA_COLUMN_NAME] = cellAreaTU;
                TextBoxCellAreaCalc.ReadOnly = true;
            }
            else
            {
                cellAreaTU = DataTableUtilities.GetDataDbl(drProp[Strings.DATASHEET_SPPIC_CELL_AREA_COLUMN_NAME]);
                TextBoxCellAreaCalc.ReadOnly = false;
            }

            // Now calculate total area in the specified terminology units
            var ttlArea = cellAreaTU * NumCells;

            this.TextBoxTotalArea.Text = ttlArea.ToString("N4", CultureInfo.InvariantCulture);
        }
示例#2
0
        /// <summary>
        /// Initializes the amount per cell
        /// </summary>
        /// <remarks></remarks>
        private void InitializeCellArea()
        {
            if (!this.IsSpatial)
            {
                DataRow drta = this.ResultScenario.GetDataSheet(Strings.DATASHEET_NSIC_NAME).GetDataRow();

                this.m_TotalAmount          = Convert.ToDouble(drta[Strings.DATASHEET_NSIC_TOTAL_AMOUNT_COLUMN_NAME], CultureInfo.InvariantCulture);
                this.m_CalcNumCellsFromDist = DataTableUtilities.GetDataBool(drta, Strings.DATASHEET_NSIC_CALC_FROM_DIST_COLUMN_NAME);
            }
            else
            {
                DataRow drics      = this.ResultScenario.GetDataSheet(Strings.DATASHEET_SPPIC_NAME).GetDataRow();
                double  cellAreaTU = DataTableUtilities.GetDataDbl(drics[Strings.DATASHEET_SPPIC_CELL_AREA_COLUMN_NAME]);

                if (cellAreaTU.Equals(0))
                {
                    throw new STSimException(MessageStrings.ERROR_SPATIAL_NO_CELL_AREA);
                }

                this.m_TotalAmount = cellAreaTU * this.m_Cells.Count;
                DataRow drISC = this.ResultScenario.GetDataSheet(Strings.DATASHEET_SPPIC_NAME).GetDataRow();

                //Save the Number of Cells count, now that we have a potentially more accurate value than at config time.

                if (Convert.ToInt32(drISC[Strings.DATASHEET_SPPIC_NUM_CELLS_COLUMN_NAME], CultureInfo.InvariantCulture) != this.m_Cells.Count)
                {
                    drISC[Strings.DATASHEET_SPPIC_NUM_CELLS_COLUMN_NAME] = this.m_Cells.Count;
                }
            }

            this.m_AmountPerCell = (this.m_TotalAmount / Convert.ToDouble(this.m_Cells.Count, CultureInfo.InvariantCulture));
        }
示例#3
0
        private void RefreshNonCalculatedValues()
        {
            DataRow drProp = this.DataFeed.GetDataSheet(Strings.DATASHEET_SPPIC_NAME).GetDataRow();

            if (drProp == null)
            {
                return;
            }

            this.CheckBoxCellSizeOverride.Checked   = DataTableUtilities.GetDataBool(drProp[Strings.DATASHEET_SPPIC_CELL_AREA_OVERRIDE_COLUMN_NAME]);
            this.CheckBoxCellSizeOverride.Enabled   = true;
            this.CheckBoxCellSizeOverride.AutoCheck = true;

            int    NumRows      = DataTableUtilities.GetDataInt(drProp[Strings.DATASHEET_SPPIC_NUM_ROWS_COLUMN_NAME]);
            int    NumCols      = DataTableUtilities.GetDataInt(drProp[Strings.DATASHEET_SPPIC_NUM_COLUMNS_COLUMN_NAME]);
            float  CellArea     = DataTableUtilities.GetDataSingle(drProp[Strings.DATASHEET_SPPIC_CELL_SIZE_COLUMN_NAME]);
            double cellAreaCalc = DataTableUtilities.GetDataDbl(drProp[Strings.DATASHEET_SPPIC_CELL_AREA_COLUMN_NAME]);

            this.TextBoxNumRows.Text      = NumRows.ToString(CultureInfo.InvariantCulture);
            this.TextBoxNumColumns.Text   = NumCols.ToString(CultureInfo.InvariantCulture);
            this.TextBoxCellArea.Text     = CellArea.ToString("N4", CultureInfo.InvariantCulture);
            this.TextBoxCellAreaCalc.Text = cellAreaCalc.ToString("N4", CultureInfo.InvariantCulture);
        }