Esempio n. 1
0
 private void btnMap_Click(object sender, EventArgs e)
 {
     try
     {
         updataMonitorAdvance();
         if (!settingcorrect)
         {
             return;
         }
         WaitShow("Filtering monitors. Please wait.");
         mDataLine.MonitorAdvance = MonitorAdvanceFilterTemp;
         List <MonitorValue> lstMonitorValues = DataSourceCommonClass.GetMonitorData(bcg.GridType, bcg.Pollutant, mDataLine);
         DataSourceCommonClass.UpdateMonitorDicMetricValue(bcg.Pollutant, lstMonitorValues);
         string     shapeFile = CommonClass.DataFilePath + @"\Data\Shapefiles\United States\State_epa2.shp";
         MonitorMap frm       = new MonitorMap();
         frm.GridShapeFile    = shapeFile;
         frm.LstMonitorPoints = lstMonitorValues;
         WaitClose();
         frm.ShowDialog();
     }
     catch
     {
         waitMess.Close();
     }
 }
Esempio n. 2
0
        private void btnMap_Click(object sender, EventArgs e)
        {
            bool   ok    = false;
            double value = 0;
            string msg   = string.Empty;

            try
            {
                if (rbtnClosestMonitor.Checked)
                {
                    _mDataLine.InterpolationMethod = InterpolationMethodEnum.ClosestMonitor;
                }
                else if (rbtnVoronoi.Checked)
                {
                    _mDataLine.InterpolationMethod = InterpolationMethodEnum.VoronoiNeighborhoodAveragin;
                }
                else if (rbtnFixedRadiums.Checked)
                {
                    _mDataLine.InterpolationMethod = InterpolationMethodEnum.FixedRadius;
                    ok = double.TryParse(txtRadiums.Text, out value);
                    if (!ok)
                    {
                        msg             = "To select fixed radius interpolation you must provide a radius in kilometers.";
                        txtRadiums.Text = string.Empty;
                        return;
                    }
                    _mDataLine.FixedRadius = value;
                }
                int selectedIndex = cboMonitorType.SelectedIndex;
                switch (selectedIndex)
                {
                case 0:
                    _mDataLine.MonitorDirectType = selectedIndex;
                    if (cboMonitorDataSet.Text != string.Empty && cboMonitorLibraryYear.Text != string.Empty)
                    {
                        DataRowView drv  = cboMonitorDataSet.SelectedItem as DataRowView;
                        int         dsID = int.Parse(drv["MonitorDataSetID"].ToString());
                        _mDataLine.MonitorDataSetID = dsID;
                        drv = cboMonitorLibraryYear.SelectedItem as DataRowView;
                        _mDataLine.MonitorLibraryYear = int.Parse(drv["Yyear"].ToString());
                    }
                    else
                    {
                        msg = string.Format("Settings are not complete."); return;
                    }
                    _strPath = "Monitor data: library";
                    break;

                case 1:
                    _mDataLine.MonitorDirectType = selectedIndex;
                    if (txtMonitorDataFile.Text != string.Empty)
                    {
                        _mDataLine.MonitorDataFilePath = txtMonitorDataFile.Text;
                    }
                    else
                    {
                        msg = string.Format("Settings are not complete."); return;
                    }
                    _strPath = "Monitor data: " + txtMonitorDataFile.Text;
                    break;
                }
                if (_monitorAdvance != null)
                {
                    _mDataLine.MonitorAdvance = _monitorAdvance;
                }
                _mDataLine.GridType  = _bgcMonitor.GridType;
                _mDataLine.Pollutant = _bgcMonitor.Pollutant;
                _mDataLine.ShapeFile = _mDataLine.Pollutant.PollutantID + "G" + CommonClass.GBenMAPGrid.GridDefinitionID + "M" + _currentStat + ".shp";
                string shapeFile = string.Format("{0}\\Tmp\\{1}", CommonClass.DataFilePath, _mDataLine.ShapeFile);
                List <MonitorValue> lstMonitorValues = DataSourceCommonClass.GetMonitorData(_bgcMonitor.GridType, _bgcMonitor.Pollutant, _mDataLine);
                DataSourceCommonClass.UpdateMonitorDicMetricValue(_bgcMonitor.Pollutant, lstMonitorValues);
                if (_bgcMonitor.GridType is ShapefileGrid)
                {
                    shapeFile = CommonClass.DataFilePath + @"\Data\Shapefiles\" + CommonClass.MainSetup.SetupName + "\\" + (_bgcMonitor.GridType as ShapefileGrid).ShapefileName + ".shp";
                }
                else if (_bgcMonitor.GridType is RegularGrid)
                {
                    shapeFile = CommonClass.DataFilePath + @"\Data\Shapefiles\" + CommonClass.MainSetup.SetupName + "\\" + (_bgcMonitor.GridType as RegularGrid).ShapefileName + ".shp";
                }

                MonitorMap frm = new MonitorMap();
                frm.GridShapeFile    = shapeFile;
                frm.LstMonitorPoints = lstMonitorValues;
                frm.ShowDialog();
            }
            catch (Exception ex)
            {
                Logger.LogError(ex);
            }
        }