//墨卡托投影反算程序
        Point_new reverse_Mercator(Point_new point, double K, double e, double B)
        {
            Point_new new_Point;
            double    B_old = 0;
            double    B_new = 0;
            double    L0    = 0;

            while (true)
            {
                B_new = PI / 2 - 2 * Math.Atan(Math.Exp(-point.y / K) * Math.Exp(e / 2 *
                                                                                 Math.Log((1 - e * Math.Sin(B_old)) / (1 + e * Math.Sin(B_old)))));
                if (B_new - B_old < eps)
                {
                    break;
                }
                B_old = B_new;
            }
            new_Point.x = (point.x / K + L0) * 180 / PI;
            new_Point.y = B_new * 180 / PI;

            return(new_Point);
        }
        //绘制江苏省地图
        private void display_Click(object sender, EventArgs e)
        {
            int i = 0, j = 0;

            bitmap = new Bitmap(width, height);
            panel1.Refresh();
            Graphics g = Graphics.FromImage(bitmap);

            double scaleX, scaleY;

            Pen my_pen = new Pen(Color.Blue, 1);

            try
            {
                using (StreamReader sr = new StreamReader(fileName))
                {
                    string str = sr.ReadLine();
                    while (str != "END")
                    {
                        List <Point_new> line = new List <Point_new>();
                        while ((str = sr.ReadLine()) != "END")
                        {
                            string[] split = str.Split(',');
                            line.Add(new Point_new(Convert.ToDouble(split[0]), Convert.ToDouble(split[1])));
                        }
                        Point_new[] line_new = new Point_new[line.Count];
                        for (i = 0; i < line.Count; ++i)
                        {
                            line_new[i] = line[i];
                        }

                        pointsArrayList.Add(line_new);
                        str = sr.ReadLine();
                    }

                    scaleX = (maxJSX - minJSX) / width;
                    scaleY = (maxJSY - minJSY) / height;

                    if (scaleX > scaleY)
                    {
                        for (i = 0; i < pointsArrayList.Count; i++)
                        {
                            Point[] MapPoints = new Point[pointsArrayList[i].Length];
                            for (j = 0; j < pointsArrayList[i].Length; j++)
                            {
                                MapPoints[j].X = (int)((pointsArrayList[i][j].x - minJSX) / scaleX);
                                MapPoints[j].Y = (int)((maxJSY - pointsArrayList[i][j].y) / scaleX);
                            }
                            g.DrawLines(my_pen, MapPoints);
                        }
                    }
                    else
                    {
                        for (i = 0; i < pointsArrayList.Count; i++)
                        {
                            Point[] MapPoints = new Point[pointsArrayList[i].Length];
                            for (j = 0; j < pointsArrayList[i].Length; j++)
                            {
                                MapPoints[j].X = (int)((pointsArrayList[i][j].x - minJSX) / scaleY);
                                MapPoints[j].Y = (int)((maxJSY - pointsArrayList[i][j].y) / scaleY);
                            }
                            g.DrawLines(my_pen, MapPoints);
                        }
                    }
                    panel1.BackgroundImage = bitmap;
                    panel1.Refresh();
                }
            }
            catch (Exception ep11)
            {
                MessageBox.Show("The file cannot be read properly,because" + ep11.Message);
            }
        }
        //求平面坐标系下的地市面积
        private void button1_Click_1(object sender, EventArgs e)
        {
            richTextBox1.Clear();
            area.Clear();
            double temp = 0;

            try
            {
                using (StreamReader sr = new StreamReader(fileName))
                {
                    string str = sr.ReadLine();
                    while (str != "END")
                    {
                        List <Point_new> line = new List <Point_new>();
                        while ((str = sr.ReadLine()) != "END")
                        {
                            string[] split = str.Split(',');
                            line.Add(new Point_new(Convert.ToDouble(split[0]), Convert.ToDouble(split[1])));
                        }
                        Point_new[] line_new = new Point_new[line.Count];
                        for (int i = 0; i < line.Count; ++i)
                        {
                            line_new[i] = line[i];
                        }

                        pointsArrayList.Add(line_new);
                        str = sr.ReadLine();
                    }
                    for (int i = 0; i < pointsArrayList.Count; ++i)
                    {
                        if (i >= 1 && i <= 6)
                        {
                            for (int j = 1; j < pointsArrayList[i].Length; ++j)
                            {
                                if (j == pointsArrayList[i].Length - 1)
                                {
                                    temp = temp + pointsArrayList[i][j].x * (pointsArrayList[i][1].y - pointsArrayList[i][j - 1].y) / 2;
                                }
                                else
                                {
                                    temp = temp + pointsArrayList[i][j].x * (pointsArrayList[i][j + 1].y - pointsArrayList[i][j - 1].y) / 2;
                                }
                            }
                            if (i == 6)
                            {
                                area.Add(Math.Abs(temp));
                            }
                        }
                        else
                        {
                            for (int j = 1; j < pointsArrayList[i].Length; ++j)
                            {
                                if (j == pointsArrayList[i].Length - 1)
                                {
                                    temp = temp + pointsArrayList[i][j].x * (pointsArrayList[i][1].y - pointsArrayList[i][j - 1].y) / 2;
                                }
                                else
                                {
                                    temp = temp + pointsArrayList[i][j].x * (pointsArrayList[i][j + 1].y - pointsArrayList[i][j - 1].y) / 2;
                                }
                            }
                            area.Add(Math.Abs(temp));
                        }
                        temp = 0;
                    }
                }
            }
            catch (Exception ep11)
            {
                MessageBox.Show("The file cannot be read properly,because" + ep11.Message);
            }
            for (int i = 0; i < 13; ++i)
            {
                richTextBox1.Text += "第" + (i + 1) + "块地市的面积为:" + Form1.area[i].ToString() + "m²" + Environment.NewLine;
            }
        }