mapxtreme 添加图元

                        Table tblTemp1 = Session.Current.Catalog.GetTable("lyrPPHOLine");
                        tblTemp1.BeginAccess(TableAccessMode.Write);
                        //==================================================================================


                        CoordSys crdsys = ConstPar.map.GetDisplayCoordSys();
                        Feature ftr = new Feature(tblTemp.TableInfo.Columns);


                        frmp.Show();
                        frmp.TopMost = true;


                        frmp.ProgressBar1.Maximum = dt.Rows.Count + 10;
                        frmp.ProgressBar1.Value = 0;
                        frmp.Label1.Text = @"开始处理:...";


                        DataTable dtxy = new DataTable("dtxy");
                        DataColumn dc1 = new DataColumn("Lon");
                        dc1.DataType = System.Type.GetType("System.String");
                        dtxy.Columns.Add(dc1);


                        DataColumn dc2 = new DataColumn("Lat");
                        dc2.DataType = System.Type.GetType("System.String");
                        dtxy.Columns.Add(dc2);


                        Int32 i = 0;


                        foreach (DataRow dr in dt.Rows)
                        {
                            double x1 = 0;
                            double y1 = 0;
                            double x2 = 0;
                            double y2 = 0;
                            double x3 = 0;
                            double y3 = 0;
                            //====================================
                            try
                            {
                                x1 = Convert.ToDouble(dr["Long"]);
                            }
                            catch (Exception ex)
                            {
                                Debug.Print(ex.ToString());
                            }


                            try
                            {
                                y1 = Convert.ToDouble(dr["Lat"]);
                            }
                            catch (Exception ex)
                            {
                                Debug.Print(ex.ToString());
                            }
                            //===================================


                            try
                            {
                                string cn = dr["LAC_CI"].ToString();
                                if (cn.Trim().Length > 0)
                                {
                                    SearchFeature(cn, ref x2, ref y2);
                                }


                            }
                            catch (Exception ex)
                            {
                                ConLog.Writelog(ex.ToString());
                            }
                            //=====================================


                            try
                            {
                                string cn = dr["Oldcellid"].ToString();
                                if (cn.Trim().Length > 0)
                                {
                                    SearchFeature(cn, ref x3, ref y3);
                                }


                            }
                            catch (Exception ex)
                            {
                                ConLog.Writelog(ex.ToString());
                            }
                            //=========================================


                            if (x1 > 0 & y1 > 0)
                            {
                                DataRow drow = null;
                                drow = dtxy.NewRow();
                                drow[0] = x1;
                                drow[1] = y1;
                                dtxy.Rows.Add(drow);


                                //=========添加点======
                                FeatureGeometry pt = new MapInfo.Geometry.Point((new FeatureLayer(tblTemp)).CoordSys, x1,
                                                                                y1);
                                FontPointStyle sty = new FontPointStyle();
                                sty.Code = 35;
                                sty.PointSize = 6;
                                sty.Color = System.Drawing.Color.DarkGreen;
                                sty.Font.Name = "MapInfo Symbols";


                                ftr.Geometry = pt;
                                ftr.Style = sty;
                                tblTemp.InsertFeature(ftr);
                                //===================
                            }


                            if (x1 != 0 & y1 != 0 & y2 != 0 & y2 != 0)
                            {
                                CreateLine(x1, y1, x2, y2, Color.LimeGreen, "lyrPPHOLine", "", 2);
                            }


                            if (x1 != 0 & y1 != 0 & x3 != 0 & y3 != 0)
                            {
                                CreateLine(x1, y1, x3, y3, Color.OrangeRed, "lyrPPHOLine", "", 2);
                            }


                            i = i + 1;
                            frmp.ProgressBar1.Value = i;
                            frmp.Label1.Text = "开始处理:... " + i.ToString() + "/" + (dt.Rows.Count + 10).ToString();
                            Application.DoEvents();


                        }


                        tblTemp.EndAccess();
                        //tabinfo.WriteTabFile();
                        //保存Point tab文件

原文地址:https://www.cnblogs.com/googlegis/p/2978817.html