コード例 #1
0
 /// <summary>
 /// 显示结果。
 /// Show result
 /// </summary>
 public void ShowResult()
 {
     try
     {
         // 删除原有结果
         // Delete the original result
         int count = m_trackingLayer.Count;
         for (int i = 0; i < count; i++)
         {
             int index = m_trackingLayer.IndexOf("result");
             if (index != -1)
             {
                 m_trackingLayer.Remove(index);
             }
         }
         FillDataGridView(0);
         for (int i = 0; i < m_result.Routes.Length; i++)
         {
             GeoLineM geoLineM = m_result.Routes[0];
             m_style.LineColor = Color.Blue;
             m_style.LineWidth = 1;
             geoLineM.Style    = m_style;
             m_trackingLayer.Add(geoLineM, "result");
         }
         m_mapControl.Map.RefreshTrackingLayer();
     }
     catch (Exception e)
     {
         Trace.WriteLine(e.Message);
     }
 }
コード例 #2
0
        /// <summary>
        /// 显示结果。
        /// Show result
        /// </summary>
        public void ShowResult()
        {
            try
            {
                GeoLineM[] geoLineMs = m_analystResult.Routes;
                GeoLineM   geoLineM  = geoLineMs[0];
                GeoStyle   style     = new GeoStyle();
                style.LineColor = Color.Blue;
                style.LineWidth = 1;
                geoLineM.Style  = style;
                for (Int32 i = 0; i < m_trackingLayer.Count; i++)
                {
                    // 清除上次结果
                    // Clear the last result
                    if (m_trackingLayer.Get(i).Type == GeometryType.GeoLineM)
                    {
                        m_trackingLayer.Remove(i);
                    }
                }
                m_trackingLayer.Add(geoLineM, "route");

                m_mapControl.Map.Refresh();
            }
            catch (System.Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
        }
コード例 #3
0
        /// <summary>
        /// 选择特定的路由。
        /// Select a specified route
        /// </summary>
        /// <param name="index"></param>
        public void SelectRoute(int index)
        {
            try
            {
                FillDataGridView(index);

                int lineIndex = m_trackingLayer.IndexOf("selectedLineM");
                if (lineIndex != -1)
                {
                    m_trackingLayer.Remove(lineIndex);
                }
                m_count = 0;
                m_lineM = m_result.Routes[index];
                GeoStyle style = new GeoStyle();
                style.LineColor = Color.Red;
                style.LineWidth = 0.8;
                m_lineM.Style   = style;
                m_mapControl.Map.EnsureVisible(m_lineM, 0.5);
                m_trackingLayer.Add(m_lineM, "selectedLineM");
                m_mapControl.Map.Refresh();
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
        }
コード例 #4
0
        /// <summary>
        /// 显示结果。
        /// Show result
        /// </summary>
        public void ShowResult()
        {
            try
            {
                // 删除原有结果
                // Delete the original result
                int count = m_trackingLayer.Count;
                for (int i = 0; i < count; i++)
                {
                    int index = m_trackingLayer.IndexOf("result");
                    if (index != -1)
                    {
                        m_trackingLayer.Remove(index);
                    }
                }

                // 填充路由列表
                // Fill the routing table
                for (int i = 0; i < m_result.Routes.Length; i++)
                {
                    GeoLineM geoLineM = m_result.Routes[i];
                    GeoStyle style    = new GeoStyle();
                    style.LineColor = Color.Blue;
                    style.LineWidth = 0.8;
                    geoLineM.Style  = style;
                    m_trackingLayer.Add(geoLineM, "result");
                    if (SuperMap.Data.Environment.CurrentCulture != "zh-CN")
                    {
                        m_comboBoxRoutes.Items.Add("The" + (i + 1) + "th path");
                    }
                    else
                    {
                        m_comboBoxRoutes.Items.Add("第" + (i + 1) + "条路径");
                    }
                }
                m_comboBoxRoutes.SelectedIndex = 0;
                SelectRoute(0);
                m_mapControl.Map.ViewEntire();
                m_mapControl.Map.Refresh();
            }
            catch (Exception e)
            {
                Trace.WriteLine(e.Message);
            }
        }
コード例 #5
0
        /// <summary>
        /// 进行行驶导引。
        /// Path guide
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void m_timer_Tick(object sender, EventArgs e)
        {
            try
            {
                int index = m_trackingLayer.IndexOf("playPoint");
                if (index != -1)
                {
                    m_trackingLayer.Remove(index);
                }

                GeoLineM lineM  = m_result.Routes[0];
                PointM   pointM = lineM.GetPart(0)[m_count];

                // 构造模拟对象
                // Build simulation object
                GeoPoint point = new GeoPoint(pointM.X, pointM.Y);
                GeoStyle style = new GeoStyle();
                style.LineColor  = Color.Red;
                style.MarkerSize = new Size2D(5, 5);
                point.Style      = style;
                m_trackingLayer.Add(point, "playPoint");

                // 跟踪对象
                // Tracking object
                m_count++;
                if (m_count >= lineM.GetPart(0).Count)
                {
                    m_count = 0;
                }
                m_mapControl.Map.RefreshTrackingLayer();
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
        }
コード例 #6
0
        // 通过线性参考 处理数据
        private void DataHandling(Dataset currentDs, DatasetVector routesDataset)
        {
            if(currentDs.Type==DatasetType.Tabular){
                SuperMap.Desktop.Application.ActiveApplication.Output.Output("DatasetType.Tabular");
            }

            DatasetVector datasetVector=currentDs as DatasetVector;
            Recordset rd = datasetVector.GetRecordset(false, CursorType.Dynamic);
            Recordset routeRd = routesDataset.GetRecordset(false, CursorType.Dynamic);

            rd.MoveFirst();
            while (!rd.IsEOF)
            {
                String _id = rd.GetFieldValue("ID").ToString();
                String _name = rd.GetFieldValue("NAME").ToString();
                String _xbh = rd.GetFieldValue("XBH").ToString();
                String _licheng = rd.GetFieldValue("LICHENG").ToString();
                String _x = rd.GetFieldValue("X").ToString();
                String _y = rd.GetFieldValue("Y").ToString();

                //质量差的数据过滤
                if (_id.Trim() == "" || _xbh.Trim() == "" || _licheng.Trim() == "") {
                    rd.MoveNext();
                    continue;
                }

                // 如果有xy坐标,使用xy坐标;如果没有,使用线性参考获得坐标
                if (_x.Trim() != "" && _y.Trim() != "")
                {
                    //使用xy
                    try
                    {
                        double x=0, y=0;
                        double.TryParse(_x, out x);
                        double.TryParse(_y, out y);

                        //add list
                        Vehicle vehicle = new Vehicle();
                        vehicle.Id = _id;
                        vehicle.Name = _name;
                        vehicle.X = x;
                        vehicle.Y = y;
                        vehicle.Xbh = _xbh;
                        vehicleList.Add(vehicle);

                    }
                    catch (Exception)
                    {

                        this.MyLog("经纬度坐标格式有误,请使用如下格式:111.67,23.89");
                    }
                }
                else {
                    //使用 线性参考
                    GeoLineM geoLineM = new GeoLineM();

                    //游标移到开头
                    routeRd.MoveFirst();
                    while (!routeRd.IsEOF)
                    {
                        String xbh = routeRd.GetFieldValue("线编号").ToString();
                        if (xbh == _xbh)
                        {

                            geoLineM = (GeoLineM)routeRd.GetGeometry();
                            double mValue = 0;
                            //解析里程值
                            mValue = GetMValue(_licheng);
                            Point2D point = geoLineM.GetPointAtM(mValue);
                            this.MyLog("坐标:" + point.X + "," + point.Y);
                            rd.SetFieldValue("X", point.X.ToString());
                            rd.SetFieldValue("Y", point.Y.ToString());

                            //add list
                            Vehicle vehicle = new Vehicle();
                            vehicle.Id = _id;
                            vehicle.Name = _name;
                            vehicle.X = point.X;
                            vehicle.Y = point.Y;
                            vehicle.Xbh = _xbh;
                            vehicleList.Add(vehicle);
                            break;
                        }
                        //
                        routeRd.MoveNext();
                    }

                }//---else end

                rd.MoveNext();

            }
            //update
            //rd.Update();

            rd.Close();
            rd.Dispose();
            routeRd.Close();
            routeRd.Dispose();

            this.MyLog("rd---------end");

            //creat new dataset
            //处理后的数据 存储在新建要素集
            CopyToNewDataset(vehicleList);
        }
コード例 #7
0
        // 通过线性参考 处理数据
        private void DataHandling(Dataset currentDs, DatasetVector routesDataset)
        {
            if (currentDs.Type == DatasetType.Tabular)
            {
                SuperMap.Desktop.Application.ActiveApplication.Output.Output("DatasetType.Tabular");
            }

            DatasetVector datasetVector = currentDs as DatasetVector;
            Recordset     rd            = datasetVector.GetRecordset(false, CursorType.Dynamic);
            Recordset     routeRd       = routesDataset.GetRecordset(false, CursorType.Dynamic);


            rd.MoveFirst();
            while (!rd.IsEOF)
            {
                String _id      = rd.GetFieldValue("ID").ToString();
                String _name    = rd.GetFieldValue("NAME").ToString();
                String _xbh     = rd.GetFieldValue("XBH").ToString();
                String _licheng = rd.GetFieldValue("LICHENG").ToString();
                String _x       = rd.GetFieldValue("X").ToString();
                String _y       = rd.GetFieldValue("Y").ToString();



                //质量差的数据过滤
                if (_id.Trim() == "" || _xbh.Trim() == "" || _licheng.Trim() == "")
                {
                    rd.MoveNext();
                    continue;
                }

                // 如果有xy坐标,使用xy坐标;如果没有,使用线性参考获得坐标
                if (_x.Trim() != "" && _y.Trim() != "")
                {
                    //使用xy
                    try
                    {
                        double x = 0, y = 0;
                        double.TryParse(_x, out x);
                        double.TryParse(_y, out y);

                        //add list
                        Vehicle vehicle = new Vehicle();
                        vehicle.Id   = _id;
                        vehicle.Name = _name;
                        vehicle.X    = x;
                        vehicle.Y    = y;
                        vehicle.Xbh  = _xbh;
                        vehicleList.Add(vehicle);
                    }
                    catch (Exception)
                    {
                        this.MyLog("经纬度坐标格式有误,请使用如下格式:111.67,23.89");
                    }
                }
                else
                {
                    //使用 线性参考
                    GeoLineM geoLineM = new GeoLineM();

                    //游标移到开头
                    routeRd.MoveFirst();
                    while (!routeRd.IsEOF)
                    {
                        String xbh = routeRd.GetFieldValue("线编号").ToString();
                        if (xbh == _xbh)
                        {
                            geoLineM = (GeoLineM)routeRd.GetGeometry();
                            double mValue = 0;
                            //解析里程值
                            mValue = GetMValue(_licheng);
                            Point2D point = geoLineM.GetPointAtM(mValue);
                            this.MyLog("坐标:" + point.X + "," + point.Y);
                            rd.SetFieldValue("X", point.X.ToString());
                            rd.SetFieldValue("Y", point.Y.ToString());

                            //add list
                            Vehicle vehicle = new Vehicle();
                            vehicle.Id   = _id;
                            vehicle.Name = _name;
                            vehicle.X    = point.X;
                            vehicle.Y    = point.Y;
                            vehicle.Xbh  = _xbh;
                            vehicleList.Add(vehicle);
                            break;
                        }
                        //
                        routeRd.MoveNext();
                    }
                }//---else end

                rd.MoveNext();
            }
            //update
            //rd.Update();

            rd.Close();
            rd.Dispose();
            routeRd.Close();
            routeRd.Dispose();

            this.MyLog("rd---------end");

            //creat new dataset
            //处理后的数据 存储在新建要素集
            CopyToNewDataset(vehicleList);
        }