gpx转换为shp格式

时间:2021-01-23 05:44:37

用vb做gpx转换为shp格式后点,线均可正常显示,但是用c#做转换后为什么点可以显示而线却不能显示
下面附上c#的代码,还请高手指点迷津!

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Xml;
using ArcViewShapeFileOCX_crp;
using AxArcViewShapeFileOCX_crp;

namespace 地图格式转换_gpx_shp_
{
    public partial class MainFrm : Form
    {


        string[,] layerPoint = new string[7, 2];
        string[,] layerLine = new string[6, 2];

        public MainFrm()
        {
            InitializeComponent();
        }

        public void ShpPointSave1(string LC, string LE, object id1, object idEle)
        {
            //
            //航点转换为shp
            object newVert = null;
            object newField = null;
            string gpxPath = "";
            string shpPath = "";
            string pointId = "";
            string pointName = "";
            string pointEle = "";
            string s = "";
            double pointLon = 0;
            double pointLat = 0;
            int pos = 0;
            gpxPath = txtGpxPath.Text.ToString().Trim() + "\\" + LC + ".gpx";
            shpPath = txtShpPath.Text.ToString().Trim() + "\\" + LC + ".shp";

            //if()
            axShapeFiles1.OpenShape(shpPath, ArcViewShapeFileOCX_crp.eNew.shpCreate, ArcViewShapeFileOCX_crp.eShapeType.shpPoint);
            newField = axShapeFiles1.ShapeFields.CreateField(id1.ToString(), ArcViewShapeFileOCX_crp.eFieldType.shpText, 20, 0);
            //newField = axShapeFiles1.ShapeFields.CreateField(id2.ToString(), ArcViewShapeFileOCX_crp.eFieldType.shpText, 50, 0);
            newField = axShapeFiles1.ShapeFields.CreateField(idEle.ToString(), ArcViewShapeFileOCX_crp.eFieldType.shpText, 30, 0);
            axShapeFiles1.AppendFieldDefs();

            DataSet ds = new DataSet();
            DataTable dt = new DataTable();
            ds.ReadXml(gpxPath);
            dt = ds.Tables["wpt"];
            if (dt == null)
            {
                ds.Dispose();
                return;
            }
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                s = dt.Rows[i]["name"].ToString().Trim();
                pos = s.IndexOf(" ");
                pointName = s.Substring(0, pos);
                pointId = s.Substring(pos);
                pointEle = dt.Rows[i]["ele"].ToString().Trim();
                //

                object o_pointId = (object)pointId;
                object o_pointName = (object)pointName;
                object o_pointEle = (object)pointEle;
                axShapeFiles1.ShapeFields.get_Item(ref(id1)).set_Value(ref(o_pointId));
                //axShapeFiles1.ShapeFields.get_Item(ref(id2)).set_Value(ref(o_pointName));
                axShapeFiles1.ShapeFields.get_Item(ref(idEle)).set_Value(ref(o_pointEle));

                pointLat = Convert.ToDouble(dt.Rows[i]["lat"]);
                pointLon = Convert.ToDouble(dt.Rows[i]["lon"]);
                newVert = axShapeFiles1.Vertices.AddVertice(pointLon, pointLat, 0, null, null, 0, null);
                axShapeFiles1.CreateShape();
            }

            /*int i = 0;
            int j = 0;
            int num = 0;
            string s = "";
            string sId = "";
            //string sName = "";
            //axShapeFiles1.Vertices newVer = null;
            object newVert = null;
            object newField = null;
            string myPath = txtGpxPath + "\\" + LC + ".gpx";
            //string myName = "";
            XmlDocument xmldocument = new XmlDocument();
            XmlElement xmlelement = null;

            //
            s = txtShpPath.Text.ToString().Trim() + "\\" + LC + ".shp";
            axShapeFiles1.OpenShape(s, ArcViewShapeFileOCX_crp.eNew.shpCreate, ArcViewShapeFileOCX_crp.eShapeType.shpPoint);
            newField = axShapeFiles1.ShapeFields.CreateField(id1, ArcViewShapeFileOCX_crp.eFieldType.shpText, 20, 0);
            newField = axShapeFiles1.ShapeFields.CreateField(idEle, ArcViewShapeFileOCX_crp.eFieldType.shpText, 30, 0);
            //newField=axShapeFiles1.ShapeFields.CreateField(

            axShapeFiles1.AppendFieldDefs();
            xmldocument.Load(txtGpxPath.Text.ToString().Trim() + "\\" + LC + ".gpx");
            j = xmldocument.ChildNodes[1].ChildNodes.Count - 1;
            for (i = 0; i < j; i++)
            {
                xmlelement = (XmlElement)xmldocument.ChildNodes[1].ChildNodes[i];
                s = xmlelement.ChildNodes[1].ToString();
                num = s.IndexOf(" ");
                sId = s.Substring(0, num - 1);
                s = xmlelement.ChildNodes[0].ToString();
                //axShapeFiles1.ShapeFields
                object a;
                object b;
                object osId = (object)sId;
                object os = (object)s;
                a = id1;
                b = idEle;
                axShapeFiles1.ShapeFields.get_Item(ref(a)).set_Value(ref(osId));
                axShapeFiles1.ShapeFields.get_Item(ref(b)).set_Value(ref(os));
                newVert = axShapeFiles1.Vertices.AddVertice(Convert.ToDouble(xmlelement.GetAttribute("lon")), Convert.ToDouble(xmlelement.GetAttribute("lat")),0,null,null,0,null);

                axShapeFiles1.CreateShape();
            }*/
        }

        public void ShpPointSave2(string LC, string LE, object id1, object id2, object idEle)
        {
            //航点转换为shp
            object newVert = null;
            object newField = null;
            string gpxPath = "";
            string shpPath = "";
            string pointId = "";
            string pointName = "";
            string pointEle = "";
            string s = "";
            double pointLon = 0;
            double pointLat = 0;
            int pos = 0;
            gpxPath = txtGpxPath.Text.ToString().Trim() + "\\" + LC + ".gpx";
            shpPath = txtShpPath.Text.ToString().Trim() + "\\" + LC + ".shp";

            //if()
            axShapeFiles1.OpenShape(shpPath, ArcViewShapeFileOCX_crp.eNew.shpCreate, ArcViewShapeFileOCX_crp.eShapeType.shpPoint);
            newField = axShapeFiles1.ShapeFields.CreateField(id1.ToString(), ArcViewShapeFileOCX_crp.eFieldType.shpText, 20, 0);
            newField = axShapeFiles1.ShapeFields.CreateField(id2.ToString(), ArcViewShapeFileOCX_crp.eFieldType.shpText, 50, 0);
            newField = axShapeFiles1.ShapeFields.CreateField(idEle.ToString(), ArcViewShapeFileOCX_crp.eFieldType.shpText, 30, 0);
            axShapeFiles1.AppendFieldDefs();

            DataSet ds=new DataSet();
            DataTable dt=new DataTable();
            ds.ReadXml(gpxPath);
            dt=ds.Tables["wpt"];
            if(dt==null)
            {
                ds.Dispose();
                return;
            }
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                s = dt.Rows[i]["name"].ToString().Trim();
                pos = s.IndexOf(" ");
                pointName = s.Substring(0, pos);
                pointId = s.Substring(pos);
                pointEle = dt.Rows[i]["ele"].ToString().Trim();
                //

                object o_pointId = (object)pointId;
                object o_pointName = (object)pointName;
                object o_pointEle = (object)pointEle;
                axShapeFiles1.ShapeFields.get_Item(ref(id1)).set_Value(ref(o_pointId));
                axShapeFiles1.ShapeFields.get_Item(ref(id2)).set_Value(ref(o_pointName));
                axShapeFiles1.ShapeFields.get_Item(ref(idEle)).set_Value(ref(o_pointEle));

                pointLat = Convert.ToDouble(dt.Rows[i]["lat"]);
                pointLon = Convert.ToDouble(dt.Rows[i]["lon"]);
                newVert = axShapeFiles1.Vertices.AddVertice(pointLon, pointLat, 0, null, null, 0, null);
                axShapeFiles1.CreateShape();
            }
            //newVert=axShapeFiles1.Vertices.AddVertice()

            /*int i = 0;
            int j = 0;
            int num = 0;
            int iName = 0;
            int iEle = 0;
            string s = "";
            string sId = "";
            string sName = "";
            //axShapeFiles1.Vertices newVer = null;
            object newVert = null;
            object newField = null;
            string myPath = txtGpxPath.Text.ToString().Trim() + "\\" + LC + ".gpx";
            //string myName = "";
            //XmlDocument xmldocument = new XmlDocument();
            //XmlElement xmlelement = null;
            DataTable dt = new DataTable();
            DataSet ds = new DataSet();

            //
            s = txtShpPath.Text.ToString().Trim() + "\\" + LC + ".shp";

            dt.ReadXml(myPath);
            dt = ds.Tables["wpt"];

            //MessageBox.Show(s);
            axShapeFiles1.OpenShape(s, ArcViewShapeFileOCX_crp.eNew.shpCreate, ArcViewShapeFileOCX_crp.eShapeType.shpPoint);
            newField = axShapeFiles1.ShapeFields.CreateField(id1.ToString(), ArcViewShapeFileOCX_crp.eFieldType.shpText, 20, 0);
            newField = axShapeFiles1.ShapeFields.CreateField(id2.ToString(), ArcViewShapeFileOCX_crp.eFieldType.shpText, 50, 0);
            newField = axShapeFiles1.ShapeFields.CreateField(idEle.ToString(), ArcViewShapeFileOCX_crp.eFieldType.shpText, 30, 0);
            //newField=axShapeFiles1.ShapeFields.CreateField(

            axShapeFiles1.AppendFieldDefs();
            //xmldocument.Load(txtGpxPath.Text.ToString().Trim() + "\\" + LC + ".gpx");
            j = xmldocument.ChildNodes[1].ChildNodes.Count - 1;
            for (i = 0; i < j; i++)
            {
                xmlelement = (XmlElement)xmldocument.ChildNodes[1].ChildNodes[i];
                for (int k = 0; k < xmlelement.ChildNodes.Count - 1; k++)
                {
                    if (xmlelement.ChildNodes[k].LocalName == "name")
                    {
                        iName = k;
                    }
                    else if (xmlelement.ChildNodes[k].LocalName == "ele")
                    {
                        iEle = k;
                    }
                }
                s = xmlelement.ChildNodes[iName].ToString();
                num = s.IndexOf(" ");

                if (num > 1)
                {

                    sId = s.Substring(0, num - 1);
                }
                else
                {
                    num = s.Length;
                }
                s = xmlelement.ChildNodes[0].ToString();
                if (s.Length > 0)
                {
                    if (s.Contains(" ") == true)
                    {
                        s.Replace(sId, " ");
                    }
                    s = s.Trim();
                }

                if (num > 0)
                {
                    sName = s.Substring(0, num - 1);
                }
                else
                {
                    sName = s;
                }
                s = xmlelement.ChildNodes[iEle].ToString();
                //axShapeFiles1.ShapeFields
                //object a;
                object osName = (object)sName;
                object osId = (object)sId;
                object os = (object)s;
                //a = id1;
                //b = idEle;
                axShapeFiles1.ShapeFields.get_Item(ref(id1)).set_Value(ref(osId));
                axShapeFiles1.ShapeFields.get_Item(ref(id2)).set_Value(ref(osName));
                axShapeFiles1.ShapeFields.get_Item(ref(idEle)).set_Value(ref(os));

                if (xmlelement.GetAttribute("lon") == null)
                {
                    return;
                }
                string x1 = "123";// xmlelement.GetAttribute("lon");
                string y1 = "234";// xmlelement.GetAttribute("lat");
                newVert = axShapeFiles1.Vertices.AddVertice(Convert.ToDouble(x1), Convert.ToDouble(y1), 0, null, null, 0, null);
           
                axShapeFiles1.CreateShape();
            }*/
        }

        public void ShpPointSave3(string LC, string LE, object id1, object id2, object id3, object idEle)
        {
            //
            object newVert = null;
            object newField = null;
            string gpxPath = "";
            string shpPath = "";
            string pointId = "";
            string pointName = "";
            string pointEle = "";
            string pointCode = "";
            string s = "";
            double pointLon = 0;
            double pointLat = 0;
            int pos = 0;
            gpxPath = txtGpxPath.Text.ToString().Trim() + "\\" + LC + ".gpx";
            shpPath = txtShpPath.Text.ToString().Trim() + "\\" + LC + ".shp";

            //if()
            axShapeFiles1.OpenShape(shpPath, ArcViewShapeFileOCX_crp.eNew.shpCreate, ArcViewShapeFileOCX_crp.eShapeType.shpPoint);
            newField = axShapeFiles1.ShapeFields.CreateField(id1.ToString(), ArcViewShapeFileOCX_crp.eFieldType.shpText, 30, 0);
            newField = axShapeFiles1.ShapeFields.CreateField(id2.ToString(), ArcViewShapeFileOCX_crp.eFieldType.shpText, 50, 0);
            newField = axShapeFiles1.ShapeFields.CreateField(id3.ToString(), ArcViewShapeFileOCX_crp.eFieldType.shpText, 30, 0);
            newField = axShapeFiles1.ShapeFields.CreateField(idEle.ToString(), ArcViewShapeFileOCX_crp.eFieldType.shpText, 30, 0);
            axShapeFiles1.AppendFieldDefs();

            DataSet ds = new DataSet();
            DataTable dt = new DataTable();
            ds.ReadXml(gpxPath);
            dt = ds.Tables["wpt"];
            if (dt == null)
            {
                ds.Dispose();
                return;
            }
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                s = dt.Rows[i]["name"].ToString().Trim();
                pos = s.IndexOf(" ");
                pointCode = s.Substring(0, pos);
                s = s.Replace(pointCode, "").Trim();
                pos = s.IndexOf(" ");
                pointName = s.Substring(0, pos);
                pointId = s.Substring(pos);
                pointEle = dt.Rows[i]["ele"].ToString().Trim();
                //

                object o_pointId = (object)pointId;
                object o_pointName = (object)pointName;
                object o_pointEle = (object)pointEle;
                object o_pointCode = (object)pointCode;
                axShapeFiles1.ShapeFields.get_Item(ref(id1)).set_Value(ref(o_pointId));
                axShapeFiles1.ShapeFields.get_Item(ref(id2)).set_Value(ref(o_pointName));
                axShapeFiles1.ShapeFields.get_Item(ref(id3)).set_Value(ref(o_pointCode));
                axShapeFiles1.ShapeFields.get_Item(ref(idEle)).set_Value(ref(o_pointEle));

                pointLat = Convert.ToDouble(dt.Rows[i]["lat"]);
                pointLon = Convert.ToDouble(dt.Rows[i]["lon"]);
                newVert = axShapeFiles1.Vertices.AddVertice(pointLon, pointLat, 0, null, null, 0, null);
                axShapeFiles1.CreateShape();
            }
        }

        public void ShpLineSave2(string LC, string LE)
        {
            //
            object newField = null;
            object newVert = null;
            object Code = "Code";
            object Name = "Name";
            string gpxPath = "";
            string shpPath = "";
            string lineId = "";
            string lineName = "";
            //string s = "";
            string lineLon = "";
            string lineLat = "";
            int pos = 0;
            gpxPath = txtGpxPath.Text.ToString().Trim() + "\\" + LC + ".gpx";
            shpPath = txtShpPath.Text.ToString().Trim() + "\\" + LC + ".shp";

            //if()
            axShapeFiles1.OpenShape(shpPath, ArcViewShapeFileOCX_crp.eNew.shpCreate, ArcViewShapeFileOCX_crp.eShapeType.shpPolyLine);
            newField = axShapeFiles1.ShapeFields.CreateField(Code.ToString(), ArcViewShapeFileOCX_crp.eFieldType.shpText, 20, 0);
            newField = axShapeFiles1.ShapeFields.CreateField(Name.ToString(), ArcViewShapeFileOCX_crp.eFieldType.shpText, 50, 0);
            axShapeFiles1.AppendFieldDefs();

            DataSet ds = new DataSet();
            DataTable dt = new DataTable();
            ds.ReadXml(gpxPath);
            dt = ds.Tables["trk"];
            if (dt == null)
            {
                ds.Dispose();
                return;
            }
            /*for (int i = 0; i < dt.Rows.Count; i++)
            {
                s = dt.Rows[i]["name"].ToString().Trim();
                pos = s.IndexOf(" ");
                lineId = s.Substring(0, pos);
                lineName = s.Substring(pos);

                DataRelation dr = ds.Tables["trk"].ChildRelations[0];
                for (int j = 0; j < ds.Tables["trk"].Rows.Count; j++ )
                {
                    //lineLat=Convert.ToDouble()
                    //newVert=axShapeFiles1.Vertices.AddVertice()
                }
                //foreach(DataRow row in dt.Rows[i]["trkseg"])
            }*/
            DataRelation dralTrk = ds.Tables["trk"].ChildRelations[0];
            string trkname = "";
            string trkcode = "";
            string trkpname = "";
            double trklon = 0;
            double trklat = 0;
            double trkele = 0;
            //short n = 0;

            //trk
            foreach (DataRow drTrk in ds.Tables["trk"].Rows)
            {
                //DataTable dtTrk = new DataTable();
                trkname = drTrk["name"].ToString();
                string[] s = trkname.Split(' ');
                trkcode = s[0];
                trkpname = s[1];

                object o_trkcode = (object)trkcode;
                object o_trkpname = (object)trkpname;
                axShapeFiles1.ShapeFields.get_Item(ref(Code)).set_Value(ref(o_trkcode));
                axShapeFiles1.ShapeFields.get_Item(ref(Name)).set_Value(ref(o_trkpname));
               
                //trkreg
                foreach (DataRow drTrkreg in drTrk.GetChildRows(dralTrk))
                {
                    DataRelation dralTrkreg = ds.Tables[drTrkreg.Table.TableName].ChildRelations[0];

                    /*object o_trkcode = null;
                    object o_trkpname = null;
                    axShapeFiles1.ShapeFields.get_Item(ref(Code)).set_Value(ref())*/
                    //point
                    int n = 1;
                    foreach (DataRow drLine in drTrkreg.GetChildRows(dralTrkreg))
                    {
                        trklat = Convert.ToDouble(drLine["lat"].ToString());
                        trklon = Convert.ToDouble(drLine["lon"].ToString());
                        trkele = Convert.ToDouble(drLine["ele"].ToString());
                        short m = (short)n;
                        newVert = axShapeFiles1.Vertices.AddVertice(trklon, trklat, m, null, trkele, 0, null);
                        n = (int)m;
                        n = n + 1;
                    }
                    axShapeFiles1.CreateShape();
                }
            }
        }

        public void ShpLineSave3(string LC, string LE)
        {
            //
            object newField = null;
            object newVert = null;
            object Code = "Code";
            object Name = "Name";
            object Ldbm = "Ldbm";
            string gpxPath = "";
            string shpPath = "";
            //string lineId = "";
            //string lineName = "";
            //string s = "";
            //string lineLon = "";
            //string lineLat = "";
            int pos = 0;
            gpxPath = txtGpxPath.Text.ToString().Trim() + "\\" + LC + ".gpx";
            shpPath = txtShpPath.Text.ToString().Trim() + "\\" + LC + ".shp";

            //if()
            axShapeFiles1.OpenShape(shpPath, ArcViewShapeFileOCX_crp.eNew.shpCreate, ArcViewShapeFileOCX_crp.eShapeType.shpPolyLine);
            //axShapeFiles1.OpenShape(shpPath, ArcViewShapeFileOCX_crp.eNew.shpCreate, ArcViewShapeFileOCX_crp.eShapeType.shpPoint);
            newField = axShapeFiles1.ShapeFields.CreateField(Code.ToString(), ArcViewShapeFileOCX_crp.eFieldType.shpText, 20, 0);
            newField = axShapeFiles1.ShapeFields.CreateField(Name.ToString(), ArcViewShapeFileOCX_crp.eFieldType.shpText, 50, 0);
            newField = axShapeFiles1.ShapeFields.CreateField(Ldbm.ToString(), ArcViewShapeFileOCX_crp.eFieldType.shpText, 30, 0);
            axShapeFiles1.AppendFieldDefs();

            DataSet ds = new DataSet();
            DataTable dt = new DataTable();
            ds.ReadXml(gpxPath);
            dt = ds.Tables["trk"];
            if (dt == null)
            {
                ds.Dispose();
                return;
            }
            /*for (int i = 0; i < dt.Rows.Count; i++)
            {
                s = dt.Rows[i]["name"].ToString().Trim();
                pos = s.IndexOf(" ");
                lineId = s.Substring(0, pos);
                lineName = s.Substring(pos);

                DataRelation dr = ds.Tables["trk"].ChildRelations[0];
                for (int j = 0; j < ds.Tables["trk"].Rows.Count; j++ )
                {
                    //lineLat=Convert.ToDouble()
                    //newVert=axShapeFiles1.Vertices.AddVertice()
                }
                //foreach(DataRow row in dt.Rows[i]["trkseg"])
            }*/
            DataRelation dralTrk = ds.Tables["trk"].ChildRelations[0];
            string trkname = "";
            string trkcode = "";
            string trkpname = "";
            string trkldbm = "";
            double trklon = 0;
            double trklat = 0;
            double trkele = 0;

            //trk
            foreach (DataRow drTrk in ds.Tables["trk"].Rows)
            {
                //DataTable dtTrk = new DataTable();
                trkname = drTrk["name"].ToString();
                string[] s = trkname.Split(' ');
                trkcode = s[0];
                trkpname = s[1];
                trkldbm = s[2];

                object o_trkcode = (object)trkcode;
                object o_trkpname = (object)trkpname;
                object o_trkldbm = (object)trkldbm;
                axShapeFiles1.ShapeFields.get_Item(ref(Code)).set_Value(ref(o_trkcode));
                axShapeFiles1.ShapeFields.get_Item(ref(Name)).set_Value(ref(o_trkpname));
                axShapeFiles1.ShapeFields.get_Item(ref(Ldbm)).set_Value(ref(o_trkldbm));
                //axShapeFiles1.AppendFieldDefs();

               
                //trkreg
                foreach (DataRow drTrkreg in drTrk.GetChildRows(dralTrk))
                {
                    DataRelation dralTrkreg = ds.Tables[drTrkreg.Table.TableName].ChildRelations[0];

                    /*object o_trkcode = null;
                    object o_trkpname = null;
                    axShapeFiles1.ShapeFields.get_Item(ref(Code)).set_Value(ref())*/
                    //point
                    //int n = 0;
                    //short m = 0;
                    foreach (DataRow drLine in drTrkreg.GetChildRows(dralTrkreg))
                    {
                        //m = (short)n;
                        trklat = Convert.ToDouble(drLine["lat"].ToString());
                        trklon = Convert.ToDouble(drLine["lon"].ToString());
                        //trkele = Convert.ToDouble(drLine["ele"].ToString());
                        newVert = axShapeFiles1.Vertices.AddVertice(trklon, trklat, 0, null, null, 0, null);
                        axShapeFiles1.CreateShape();
                        //n = (int)m;
                        //n = n + 1;
                    }
                    //axShapeFiles1.CreateShape();
                    //return;
                }
                //axShapeFiles1.CreateShape();)
            }
        }

        public void testLine()
        {
            object Code = "Code";
            object Name = "Name";
            object Ldbm = "Ldbm";
            string gpxPath = "";
            string shpPath = "";
            //string lineId = "";
            //string lineName = "";
            //string s = "";
            //string lineLon = "";
            //string lineLat = "";
            int pos = 0;
            gpxPath = txtGpxPath.Text.ToString().Trim() + "\\" + "线路" + ".gpx";
            shpPath = txtShpPath.Text.ToString().Trim() + "\\" + "test" + ".shp";

            //if()
            axShapeFiles1.OpenShape(shpPath, eNew.shpCreate, eShapeType.shpPolyLine);
            //axShapeFiles1.OpenShape(shpPath, ArcViewShapeFileOCX_crp.eNew.shpCreate, ArcViewShapeFileOCX_crp.eShapeType.shpPoint);
            ShapeField newField = axShapeFiles1.ShapeFields.CreateField(Code.ToString(), eFieldType.shpText, 20, 0);
            //newField = axShapeFiles1.ShapeFields.CreateField(Name.ToString(), ArcViewShapeFileOCX_crp.eFieldType.shpText, 50, 0);
            //newField = axShapeFiles1.ShapeFields.CreateField(Ldbm.ToString(), ArcViewShapeFileOCX_crp.eFieldType.shpText, 30, 0);
            axShapeFiles1.AppendFieldDefs();

            object o_trkcode = "1234";
            //object o_trkpname = "xyz";
            //object o_trkldbm = "lxbm";
            axShapeFiles1.ShapeFields.get_Item(ref(Code)).set_Value(ref(o_trkcode));
            //axShapeFiles1.ShapeFields.get_Item(ref(Name)).set_Value(ref(o_trkpname));
            //axShapeFiles1.ShapeFields.get_Item(ref(Ldbm)).set_Value(ref(o_trkldbm));

            for (int i = 0; i < 10; i++)
            {
                Vertice Vert = axShapeFiles1.Vertices.AddVertice(113.456778 + 0.01 * i, 34.324345 + 0.01 * i, 0, null, null, 0, null);
               
            }axShapeFiles1.CreateShape();
            return;
        }

                private void btnShpPath_Click(object sender, EventArgs e)
        {
            //选择存放shp文件路径
            FolderBrowserDialog fbd = new FolderBrowserDialog();
            if (fbd.ShowDialog() == DialogResult.OK && fbd.SelectedPath != "")
            {
                txtShpPath.Text = fbd.SelectedPath.ToString().Trim();
            }
        }

        private void btnStart_Click(object sender, EventArgs e)
        {
            //开始gpx到shp的转换
            arrayOpenration();
            startSwtch();
            MessageBox.Show("转换完毕!");
        }

        private void btnQuit_Click(object sender, EventArgs e)
        {
            //退出
            Application.Exit();
        }

        private void btnGpxPath_Click(object sender, EventArgs e)
        {
            //选择gpx文件路径
            FolderBrowserDialog fbd = new FolderBrowserDialog();
            fbd.ShowNewFolderButton = false;
            if (fbd.ShowDialog() == DialogResult.OK && fbd.SelectedPath != "")
            {
                txtGpxPath.Text = fbd.SelectedPath.ToString().Trim();
            }
        }

    }
}