Пример #1
0
        public double Getdistance(RoadpointReader.TaskFileData goal, soGeoPoint V)
        {
            double deltax = goal.x - V.x;
            double deltay = goal.y - V.y;

            return(Math.Sqrt(deltax * deltax + deltay * deltay));//得到距离
        }
Пример #2
0
        public double Getdistance(_soPoint goal, soGeoPoint V)
        {
            double deltax = goal.x - V.x;
            double deltay = goal.y - V.y;

            return(Math.Sqrt(deltax * deltax + deltay * deltay));//得到距离
        }
Пример #3
0
        private void show_Click(object sender, EventArgs e)
        {
            soGeoPoint   TaskPointAfterChange = new soGeoPoint();
            FileStream   fs;
            StreamWriter sw;

            fs = new FileStream(f1.TaskFile_Path, FileMode.Create, FileAccess.Write);
            sw = new StreamWriter(fs);
            sw.BaseStream.Seek(0, SeekOrigin.Begin);
            string string_temp;

            for (int i = 0; i < f1.rpr.num; i++)
            {
                string_temp = (i + 1) + "\t" + dataGridView1.Rows[i].Cells[1].Value.ToString() + "\t"
                              + dataGridView1.Rows[i].Cells[2].Value.ToString() + "\t" + dataGridView1.Rows[i].Cells[3].Value.ToString()
                              + "\t" + dataGridView1.Rows[i].Cells[4].Value.ToString() + "\t" + dataGridView1.Rows[i].Cells[5].Value.ToString();
                sw.WriteLine(string_temp);
            }
            sw.Close();
            fs.Close();
            rpr1.dispose();
            rpr1.Read(f1.TaskFile_Path, f1);
            f1.clear();
            //显示任务点
            if (f1.blnOpen)
            {
                for (int length = 0; length < rpr1.num; length++)
                {
                    soGeoPoint temp = new soGeoPoint();

                    // temp = f1.convert(rpr1.TaskData[length].longitude, rpr1.TaskData[length].latitude);//x-经度 ,y-纬度

                    rpr1.TaskData[length].x = temp.x - f1.GetMapCoordinateAllignmentX();
                    rpr1.TaskData[length].y = temp.y - f1.GetMapCoordinateAllignmentY();
                    temp.x = rpr1.TaskData[length].x;
                    temp.y = rpr1.TaskData[length].y;
                    if (rpr1.TaskData[length].status1 == TASKPROPERTY_STARTPOINT)
                    {
                        f1.show(temp, (length + 1).ToString(), Color.Blue);
                    }
                    else if (rpr1.TaskData[length].status1 == TASKPROPERTY_ENDPOINT)
                    {
                        f1.show(temp, (length + 1).ToString(), Color.Purple);
                    }
                    else
                    {
                        f1.show(temp, (length + 1).ToString(), Color.Red);
                    }
                }
            }
            else
            {
                MessageBox.Show("未打开工作空间");
            }
            this.Close();
        }
Пример #4
0
        private void 修改位置_Click(object sender, EventArgs e)
        {
            int index;

            if (!Int32.TryParse(tb_point_index.Text, out index))
            {
                MessageBox.Show("请输入正确的ID");
                return;
            }
            else
            {
                index = Convert.ToInt32(tb_point_index.Text) - 1;//要改变位置的点的序号

                if (!this.IsDisposed)
                {
                    mf1.rpr.TaskData[index].x = rpr_x;
                    mf1.rpr.TaskData[index].y = rpr_y;//将鼠标按下的位置赋给要改变的点
                }
                else
                {
                    MessageBox.Show("请打开地图窗口");
                    return;
                }
                mf1.clear();
                for (int length = 0; length < mf1.rpr.num; length++)
                {
                    soGeoPoint temp = new soGeoPoint();
                    temp.x = mf1.rpr.TaskData[length].x;
                    temp.y = mf1.rpr.TaskData[length].y;
                    if (mf1.rpr.TaskData[length].status1 == MainForm.TASKPROPERTY_STARTPOINT)
                    {
                        mf1.show(temp, Color.Blue, 50);
                    }
                    else if (mf1.rpr.TaskData[length].status1 == MainForm.TASKPROPERTY_ENDPOINT)
                    {
                        mf1.show(temp, Color.Purple, 50);
                    }
                    else
                    {
                        mf1.show(temp, Color.Red, 50);
                    }
                }
                SaveModifyTaskFile();
            }
        }
Пример #5
0
        /// <summary>
        /// 查询统计范围
        /// </summary>
        private void searchBound()
        {
            String key = this.comboBoxQueryKey.Text.Trim();
            Double radius = this.doubleInputRadius.Value;
            if (key.Length == 0 || key == tipDistrictKey)
            {
                MessageBox.Show("请输入搜索关键字!", msgCaption);
                return;
            }

            this.listBoxPoiResult.Items.Clear();
            this.axSuperMap1.TrackingLayer.ClearEvents();

            if (!poiSearch.IsOpen)
            {
                MessageBox.Show("找不到POI索引!", msgCaption);
                return;
            }

            // poi查询
            PoiResult poiResult = poiSearch.search(key);

            if (poiResult == null || poiResult.Count == 0)
            {
                MessageBox.Show("找不到数据!", msgCaption);
            }

            soStyle style = new soStyle();
            style.PenColor = Util.ColorToUInt32(Color.Blue);
            style.SymbolSize = 30;

            //获取第一个查询结果
            PoiInfo poiInfo = poiResult.getPoiInfoAt(0);

            //坐标转换(wgs84 -> 地图坐标)
            coordSysTranslator.convert(ref poiInfo);

            // 加入跟踪层高亮显示
            soGeoPoint geoPoint = new soGeoPoint();
            geoPoint.x = poiInfo.x;
            geoPoint.y = poiInfo.y;
            this.axSuperMap1.TrackingLayer.AddEvent((soGeometry)geoPoint, style, poiInfo.name);

            //计算扩大一圈的面
            searchBoundGeometry = geoPoint.SpatialOperator.Buffer(radius, 25);

            ////将查询结果加入到选择集中,使其高亮显示
            //objSelection = this.axSuperMap1.selection;
            //objSelection.FromRecordset(objRd);

            this.axSuperMap1.TrackingLayer.RemoveEvent("SearchBound");
            style = new soStyle();
            style.PenColor = Util.ColorToUInt32(Color.Blue);
            style.BrushStyle = 1;
            this.axSuperMap1.TrackingLayer.AddEvent((soGeometry)searchBoundGeometry, style, "SearchBound");

            //刷新地图窗口
            viewBounds(searchBoundGeometry.Bounds);

            if (!this.comboBoxQueryKey.Items.Contains(key))
            {
                this.comboBoxQueryKey.Items.Add(key);
            }
        }
Пример #6
0
        private void listBoxPoiResult_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.axSuperMap1.TrackingLayer.RemoveEvent("selectPoiInfo");
            PoiInfo poiInfo = (PoiInfo)this.listBoxPoiResult.SelectedItem;
            if (poiInfo != null)
            {
                // 加入跟踪层高亮显示

                soStyle style = new soStyle();
                style.PenColor = Util.ColorToUInt32(Color.Red);
                style.SymbolSize = 30;

                soGeoPoint geoPoint = new soGeoPoint();
                geoPoint.x = poiInfo.x;
                geoPoint.y = poiInfo.y;
                this.axSuperMap1.TrackingLayer.AddEvent((soGeometry)geoPoint, style, "selectPoiInfo");
                this.axSuperMap1.TrackingLayer.Refresh();
            }
        }
Пример #7
0
        /// <summary>
        /// 查询poi
        /// </summary>
        private void searchpoi()
        {
            String key = this.textBoxItemSearchKey.TextBox.Text.Trim();
            if (key.Length == 0 || key == tipPOIKey)
            {
                MessageBox.Show("请输入搜索关键字!", msgCaption);
                return;
            }

            this.listBoxPoiResult.Items.Clear();
            this.axSuperMap1.TrackingLayer.ClearEvents();

            if (!poiSearch.IsOpen)
            {
                MessageBox.Show("找不到POI索引!", msgCaption);
                return;
            }

            // poi查询
            PoiResult poiResult = poiSearch.search(key);

            if (poiResult == null || poiResult.Count == 0)
            {
                MessageBox.Show("找不到数据!", msgCaption);
                return;
            }

            soStyle style = new soStyle();
            style.PenColor = Util.ColorToUInt32(Color.Blue);
            style.SymbolSize = 30;

            soRect rect = new soRect();

            //获取查询结果
            for (int i = 0; i < Math.Min(poiResult.Count,200); i++)
            {
                PoiInfo poiInfo = poiResult.getPoiInfoAt(i);

                //坐标转换(wgs84 -> 地图坐标)
                coordSysTranslator.convert(ref poiInfo);

                // 加了结果列表
                this.listBoxPoiResult.Items.Add(poiInfo);

                // 加入跟踪层高亮显示
                soGeoPoint geoPoint = new soGeoPoint();
                geoPoint.x = poiInfo.x;
                geoPoint.y = poiInfo.y;
                this.axSuperMap1.TrackingLayer.AddEvent((soGeometry)geoPoint, style, poiInfo.name);

                //计算范围
                if (i==0)
                {
                    //第一个
                    rect.Left = poiInfo.x;
                    rect.Right = poiInfo.x;
                    rect.Bottom = poiInfo.y;
                    rect.Top = poiInfo.y;
                }
                else
                {
                    //向外扩张
                    if (rect.Left > poiInfo.x)
                    {
                        rect.Left = poiInfo.x;
                    }
                    if (rect.Right < poiInfo.x)
                    {
                        rect.Right = poiInfo.x;
                    }
                    if (rect.Bottom > poiInfo.y)
                    {
                        rect.Bottom = poiInfo.y;
                    }
                    if (rect.Top < poiInfo.y)
                    {
                        rect.Top = poiInfo.y;
                    }
                }
            }

            //viewAllPoi(this.listBoxPoiResult.Items);
            showRigthPanel(true, 1);

            if (poiResult.Count == 1)
            {
                axSuperMap1.CenterX = rect.CenterPoint().x;
                axSuperMap1.CenterY = rect.CenterPoint().y;
            }
            else
            {
                viewBounds(rect);
            }

            axSuperMap1.Refresh();
        }