private float MercX(float lon)
        {
            lon = (float)ExtensionClass.DegreeToRadian(lon);
            float a = (256 / (float)Math.PI) * (float)Math.Pow(2, Zoom);
            float b = lon + (float)Math.PI;

            return(a * b);
        }
        private float MercY(float lat)
        {
            lat = (float)ExtensionClass.DegreeToRadian(lat);
            var a = (256 / (float)Math.PI) * (float)Math.Pow(2, Zoom);
            var b = (float)Math.Tan(Math.PI / 4 + lat / 2);
            var c = (float)Math.PI - (float)Math.Log(b);

            return(a * c);
        }
        private void FindEarthQuakes()
        {
            float cx          = MercX(Clon);
            float cy          = MercY(Clat);
            var   earthquakes = new List <CSVCells>();

            switch (_periodChooser)
            {
            case "Important":
                earthquakes = _csvParser.SplitCSVFile("https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/significant_month.csv");
                break;

            case "Last day":
                earthquakes = _csvParser.SplitCSVFile("http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_day.csv");
                break;

            case "Last week":
                earthquakes = _csvParser.SplitCSVFile("http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_week.csv");
                break;

            case "Last month":
                earthquakes = _csvParser.SplitCSVFile("http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_month.csv");
                break;

            default:
                earthquakes = _csvParser.SplitCSVFile("http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_day.csv");
                break;
            }
            earthQ.Clear();
            foreach (var eq in earthquakes)
            {
                using (var g = pictureBox1.CreateGraphics())
                {
                    try
                    {
                        float x = MercX(eq.Longitude) - cx;
                        float y = MercY(eq.Latitude) - cy;
                        earthQ.Add(new CSVCells(eq.Place, new Point((int)x, (int)y), eq.Updated, eq.Magnitude, eq.Type));
                        float mag = (float)Math.Pow(10, eq.Magnitude);
                        mag = (float)Math.Sqrt(mag);
                        float magmax = (float)Math.Sqrt(Math.Pow(10, 10));
                        float d      = ExtensionClass.Map(mag, 0, magmax, 1, 500);
                        g.TranslateTransform(pictureBox1.ClientSize.Width / 2 - (d / 2),
                                             pictureBox1.ClientSize.Height / 2 - (d / 2));
                        g.FillEllipse(eq.Magnitude < 5 ? Brushes.Magenta : Brushes.Red, x, y, d, d);
                        g.Dispose();
                    }
                    catch (Exception)
                    {
                    }
                }
            }

            //Changing the label's text in a cross thread
            label1.Invoke(new Action(() =>
            {
                if (_periodChooser.Contains("Important"))
                {
                    label1.Location = new Point(680, 441);
                    label1.Text     = $@"Done. In the last month there were {earthquakes.Count}  important earthquakes.";
                }
                else
                {
                    label1.Text     = $@"Done. There were {earthquakes.Count} earthquakes in the{_periodChooser.ToLower()}";
                    label1.Location = new Point(710, 441);
                }
            }));
            _earthQ.Abort();
        }