FeatureLayer featurelayer = this.mobileService1.Layers[0] as FeatureLayer;
QueryFilter queryfilter = new QueryFilter(); FeatureDataTable featuredatatable = featurelayer.GetDataTable(queryfilter, null);
foreach (FeatureDataRow row in featuredatatable.Rows) row.Delete();
featuredatatable.SaveInFeatureLayer(); }
private void ShowCar(int t) {
ESRI.ArcGIS.Mobile.Geometries.Point tp = new ESRI.ArcGIS.Mobile.Geometries.Point(Pointkindscc[t]); string selectlayername = \;
m_selectedFeatureLayer = this.mobileService1.Layers[selectlayername] as FeatureLayer;
FeatureDataTable featureDataTable = m_selectedFeatureLayer.GetDataTable(); //要素表对象featureDataTable新增一条空的记录
FeatureDataRow editedFeature = featureDataTable.NewRow();
//获取要素图层对象的几何列,并把SketchGraphicLayer图层的几何值赋值给他
int geometryIndex = m_selectedFeatureLayer.GeometryColumnIndex;
editedFeature[geometryIndex] = tp; // 把新增的记录赋回到要素数据表中
featureDataTable.Rows.Add(editedFeature);
//保存结果
featureDataTable.SaveInFeatureLayer();
string X = tp.Coordinate.X.ToString();
string Y = tp.Coordinate.Y.ToString();
this.listBox1.Items.Add(name[t] + \ + X + \ + Y); this.listBox1.SelectedIndex = k++; UpLoad(name[t], X, Y); }
6)双击自动显示button控件,写入代码,实现每隔一秒显示汽车的当前位置,代码如下: this.timer1.Enabled = true;
private void timer1_Tick(object sender, EventArgs e) {
DeleteAll(); ShowCar(t); if (t < 29) {
t = t + 1; } else t = 0; }
7)双击停止button控件,写入代码,实现程序的停止,代码如下: this.timer1.Enabled = false; 截图如下所示: 图1为显示系统界面 图2为单步显示结果 图3为自动显示结果 图4为停止结果
图1
图2
图3
图4 (3)GPS数据上传至服务器数据库
1)建立Webservices,进行数据库连接,代码如下: public Service () {
//如果使用设计的组件,请取消注释以下行 //InitializeComponent(); } public
SqlConnection
connection
=
new
SqlConnection(\
Source=du-96e8d5846746;Initial Catalog=GISshixi;User ID=sa;Password=sa\ [WebMethod(Description = \
public void WriteGPS(string dianming, string X,string Y,string datetime) {
connection.Open();
string dian = string.Format(\ string XX = string.Format(\ string YY = string.Format(\ string tt = string.Format(\
string sqlstr = \信息(点号,X坐标,Y坐标,时间) VALUES (\+ dian + \
System.Data.SqlClient.SqlCommand sqlCommand = new SqlCommand(sqlstr, connection);
sqlCommand.ExecuteNonQuery(); connection.Close();
}2)将GPS信息写入到数据库中,代码如下:
汽车导航终端.shixi.Service hh = new 汽车导航终端.shixi.Service(); string datetime = DateTime.Now.ToString(); hh.WriteGPS(dianming, X, Y, datetime); 车辆GIS管理服务器端软件系统 (1)窗口界面设计
向窗口拖入2个button控件,修改它们的text属性,分别为历史轨迹查询、查询当前位置;向窗体拖入1个dataGridView1控件。窗口设计如下:
(2)读取终端上传过来的GPS数据,并存储
connectionString = \; myConnection = new SqlConnection(connectionString); string Olestr = \信息\;
SqlCommand cmd = new SqlCommand(Olestr, myConnection); SqlDataAdapter adp = new SqlDataAdapter(cmd);