/// <summary> /// 向数据库添加点数据 /// </summary> public static bool ImportSFCLSData(DataTable dataTable, string className) { DataBase gdb = DataBase.OpenByURL("GDBP://MapGisLocal/Templates"); //打开简单要素类 SFeatureCls sfcls = gdb.GetXClass(XClsType.SFCls) as SFeatureCls; bool op = sfcls.Open(className, 0); GeoPoints pnts = null; Dot3D newdot = new Dot3D(); //PntInfo pntInfo = new PntInfo(); int i = 0; foreach (DataRow dr in dataTable.Rows) { double.TryParse(dr["x 坐标"].ToString(), out double x); double.TryParse(dr["y 坐标"].ToString(), out double y); //点要素坐标 newdot.X = y; newdot.Y = x; newdot.Z = 0; pnts = new GeoPoints(); pnts.Append(newdot); Record rcd = new Record(); Fields Flds = sfcls.Fields; if (Flds == null) { return(false); } PntInfo pntInfo = new PntInfo(); //点参数 pntInfo.LibID = 0; pntInfo.SymID = 1; pntInfo.Width = 10; pntInfo.Height = 10; rcd.Fields = Flds; //设置属性字段的值 rcd.set_FldVal(1, (i++).ToString()); rcd.set_FldVal(2, dr["车牌"].ToString()); string time = dr["时间"].ToString().Replace('T', ' '); rcd.set_FldVal(3, time); rcd.set_FldVal(4, time); rcd.set_FldVal(5, x); rcd.set_FldVal(6, y); //添加点要素 long oid = sfcls.Append(pnts, rcd, pntInfo); } Debug.WriteLine("Done."); return(true); }