Пример #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();
     }
 }
Пример #2
0
        private void MonitorRollbackSettings2_Load(object sender, EventArgs e)
        {
            try
            {
                if (CommonClass.GBenMAPGrid == null)
                {
                    return;
                }
                mainMap.ProjectionModeReproject = ActionMode.Never;
                mainMap.ProjectionModeDefine    = ActionMode.Never;
                if (_monitorRollbackLine.RollbackGrid is ShapefileGrid)
                {
                    if (File.Exists(CommonClass.DataFilePath + @"\Data\Shapefiles\" + CommonClass.MainSetup.SetupName + "\\" + (_monitorRollbackLine.RollbackGrid as ShapefileGrid).ShapefileName + ".shp"))
                    {
                        mainMap.Layers.Add(CommonClass.DataFilePath + @"\Data\Shapefiles\" + CommonClass.MainSetup.SetupName + "\\" + (_monitorRollbackLine.RollbackGrid as ShapefileGrid).ShapefileName + ".shp");
                    }
                }
                else if (_monitorRollbackLine.RollbackGrid is RegularGrid)
                {
                    if (File.Exists(CommonClass.DataFilePath + @"\Data\Shapefiles\" + CommonClass.MainSetup.SetupName + "\\" + (_monitorRollbackLine.RollbackGrid as RegularGrid).ShapefileName + ".shp"))
                    {
                        mainMap.Layers.Add(CommonClass.DataFilePath + @"\Data\Shapefiles\" + CommonClass.MainSetup.SetupName + "\\" + (_monitorRollbackLine.RollbackGrid as RegularGrid).ShapefileName + ".shp");
                    }
                }
                PolygonLayer playerRegion = mainMap.Layers[mainMap.Layers.Count - 1] as PolygonLayer;
                playerRegion.DataSet.DataTable.Columns.Add("MyColorIndex", typeof(int));
                for (int i = 0; i < playerRegion.DataSet.DataTable.Rows.Count; i++)
                {
                    playerRegion.DataSet.DataTable.Rows[i]["MyColorIndex"] = i;
                    dicMyColorIndex.Add(Convert.ToInt32(playerRegion.DataSet.DataTable.Rows[i]["COL"]).ToString() + "," + Convert.ToInt32(playerRegion.DataSet.DataTable.Rows[i]["ROW"]).ToString(), i);
                }
                Color             cRegion           = Color.Transparent;
                PolygonSymbolizer TransparentRegion = new PolygonSymbolizer(cRegion);

                TransparentRegion.OutlineSymbolizer = new LineSymbolizer(Color.Black, 1); playerRegion.Symbolizer = TransparentRegion;

                lstMonitorValues = DataSourceCommonClass.GetMonitorData(_monitorRollbackLine.GridType, _monitorRollbackLine.Pollutant, _monitorRollbackLine);
                IFeatureSet  fsPoints = new FeatureSet();
                MonitorValue mv       = null;
                Feature      feature  = null;
                List <DotSpatial.Topology.Coordinate> lstCoordinate = new List <DotSpatial.Topology.Coordinate>();
                List <double> fsInter = new List <double>();
                if (lstMonitorValues != null && lstMonitorValues.Count > 0)
                {
                    PolygonScheme   myScheme = new PolygonScheme();
                    PolygonCategory pcin     = new PolygonCategory();
                    pcin.Symbolizer.SetFillColor(Color.Red);
                    myScheme.Categories.Add(pcin);
                    DotSpatial.Topology.Point point;
                    for (int i = 0; i < lstMonitorValues.Count; i++)
                    {
                        mv      = lstMonitorValues[i];
                        point   = new DotSpatial.Topology.Point(mv.Longitude, mv.Latitude);
                        feature = new Feature(point);
                        fsPoints.AddFeature(feature);
                    }
                    mainMap.Layers.Add(fsPoints);
                }
            }
            catch (Exception ex)
            {
                Logger.LogError(ex);
            }
        }
Пример #3
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);
            }
        }
Пример #4
0
 private void btnExport_Click(object sender, EventArgs e)
 {
     try
     {
         SaveFileDialog saveFileDialog1 = new SaveFileDialog();
         saveFileDialog1.Filter = "CSV File|*.csv";
         if (saveFileDialog1.ShowDialog() == DialogResult.Cancel)
         {
             return;
         }
         lblExport.Text = "Checking the monitor filter setting...";
         lblExport.Refresh();
         updataMonitorAdvance();
         if (!settingcorrect)
         {
             lblExport.Text = "";
             return;
         }
         lblExport.Text = "";
         lblExport.Refresh();
         prgBarExport.Visible     = true;
         mDataLine.MonitorAdvance = MonitorAdvanceFilterTemp;
         List <MonitorValue> lstMonitorValues = DataSourceCommonClass.GetMonitorData(bcg.GridType, bcg.Pollutant, mDataLine);
         prgBarExport.Maximum = lstMonitorValues.Count();
         prgBarExport.Value   = 0;
         FileStream   fs = new FileStream(saveFileDialog1.FileName, FileMode.Create);
         StreamWriter sw = new StreamWriter(fs, Encoding.UTF8);
         sw.WriteLine("Monitor Name,Monitor Description,Latitude,Longitude,Metric,Seasonal Metric,Statistic,Values");
         foreach (MonitorValue mv in lstMonitorValues)
         {
             sw.Write(mv.MonitorName);
             sw.Write(",");
             sw.Write("\"" + mv.MonitorMethod + "\"");
             sw.Write(",");
             sw.Write(mv.Latitude);
             sw.Write(",");
             sw.Write(mv.Longitude);
             sw.Write(",");
             if (mv.Metric != null)
             {
                 sw.Write(mv.Metric.MetricName);
             }
             sw.Write(",");
             if (mv.SeasonalMetric != null)
             {
                 sw.Write(mv.SeasonalMetric.SeasonalMetricName);
             }
             sw.Write(",");
             sw.Write(mv.Statistic);
             sw.Write(",");
             string value       = string.Empty;
             string commandText = string.Format("select VValues from MonitorEntries where MonitorID={0}", mv.MonitorID);
             ESIL.DBUtility.FireBirdHelperBase fb = new ESIL.DBUtility.ESILFireBirdHelper();
             byte[] blob = null;
             object ob   = fb.ExecuteScalar(CommonClass.Connection, CommandType.Text, commandText);
             blob  = ob as byte[];
             value = System.Text.Encoding.Default.GetString(blob);
             sw.Write("\"" + value + "\"");
             sw.WriteLine();
             prgBarExport.Value++;
             prgBarExport.Refresh();
         }
         sw.Flush();
         sw.Close();
         fs.Close();
         prgBarExport.Visible = false;
         MessageBox.Show("Export is complete.", "File saved", MessageBoxButtons.OK);
     }
     catch
     {
         prgBarExport.Visible = false;
     }
 }