Пример #1
0
 private static void GenerateCountryCodes(MapData target)
 {
     Parallel.ForEach(Enumerable.Range(0, target.Width - 1), i =>
     {
         for (int j = 0; j < target.Height; j++)
         {
             double lat, lon;
             target.DataXYToLatLon(i, j, out lat, out lon);
             string cc = ReverseGeocodeService.CountryCodeForLatAndLong(lat, lon);
             target.CellData[i, j].CountryCode = cc;
             if ((i + j) % 10 == 0)
             {
                 Console.WriteLine($"Latitude {lat:F0}, Longitude {lon:F0} : {cc}");
             }
         }
     });
 }
Пример #2
0
        private void InfectAtVoxel(object sender, MouseEventArgs args)
        {
            double lat, lon;
            int    x, y;

            GraphicalUtilities.GraphicsCoordsToMapCoords(m_mapControl1.Size, m_mapControl1.MyWorldModel.Size, args.X,
                                                         args.Y, out x, out y);
            m_mapControl1.MyWorldModel.MapData.DataXYToLatLon(x, y, out lat, out lon);
            m_mapControl1.MyWorldModel.InfectAt(x, y);
            m_mapControl1.MouseMove -= InfectAtVoxel;
            m_mapControl1.Cursor     = Cursors.Default;
            DateTime when = m_mapControl1.MyWorldModel.Executive.Now;

            if (when == DateTime.MinValue) when = m_mapControl1.MyWorldModel.ExecutionParameters.StartTime;
            string countryName = ReverseGeocodeService.CountryNameForLatAndLong(lat, lon + 2) ?? "Unknown";
            string text        =
                $"{when} : Infection introduced at Lat = {Math.Abs(lat):F0} degrees {(lat < 0 ? "North" : "South")}, Lon = {Math.Abs(lon):F0} degrees {(lon > 0 ? "East" : "West")}. ({countryName})";

            Console.WriteLine(text);

            SetMapMode(MapMode.Informational);
        }
Пример #3
0
        private void InitialUI_Load(object sender, EventArgs e)
        {
            m_worldModel = new WorldModel(m_data, SimCountryData.LoadFrom(@"../../../Data/CountryData.dat"));
            m_mapControl.AssignWorldModel(m_worldModel);

            PlotForm dc1 = new PlotForm("Mortality");

            dc1.Bind(m_worldModel,
                     new[] {
                GetTotal(n => n.Killed),
                GetTotal(n => n.Dead)
            },
                     new[] {
                "Killed",
                "Dead"
            });

            PlotForm dc2 = new PlotForm("Disease Stages");

            dc2.Bind(m_worldModel,
                     new[] {
                GetTotal(n => n.ContagiousAsymptomatic),
                GetTotal(n => n.ContagiousSymptomatic),
                GetTotal(n => n.NonContagiousInfected),
                GetTotal(n => n.Immune),
            },
                     new[]
            {
                "ContagiousAsymptomatic",
                "ContagiousSymptomatic",
                "NonContagiousInfected",
                "Immune"
            });

            m_mapControl.Show();
            dc1.Show();
            dc2.Show();



            /*PlotForm m_plotWindow1 = new PlotForm("Killed");
             * m_plotWindow1.Bind(m_worldModel, GetTotal(n => n.Killed));
             * m_plotWindow1.Show();
             *
             * PlotForm m_plotWindow2 = new PlotForm("Immune");
             * m_plotWindow2.Bind(m_worldModel, GetTotal(n => n.Immune));
             * m_plotWindow2.Show();
             *
             * PlotForm m_plotWindow3 = new PlotForm("Total Population");
             * m_plotWindow3.Bind(m_worldModel, GetTotal(n => n.Population));
             * m_plotWindow3.Show();
             *
             * PlotForm m_plotWindow4 = new PlotForm("Immunization Effort");
             * m_plotWindow4.Bind(m_worldModel, GetTotal(n => n.Flows[2](n)));
             * m_plotWindow4.Show();*/


            m_mapControl.MouseMove += (o, args) =>
            {
                double lat, lon;
                int    x, y;
                GraphicalUtilities.GraphicsCoordsToMapCoords(panel1.Size, m_worldModel.Size, args.X, args.Y, out x,
                                                             out y);
                m_data.DataXYToLatLon(x, y, out lat, out lon);
                string where = ReverseGeocodeService.CountryNameForLatAndLong(lat, lon + 2) ?? "Unknown";
                DiseaseNode n = m_worldModel.NodeAt(x, y);
                toolStripStatusLabel1.Text = $"data[{x},{y}] is {where}, Lat {lat:f2}/Lon {lon:f2} {n:d4}";
                Console.WriteLine(toolStripStatusLabel1.Text);
            };

            toolStripStatusLabel1.TextChanged += (o, args) => Console.WriteLine(((ToolStripStatusLabel)o).Text);
        }