Exemplo n.º 1
0
        private void queyBySpatialRelMenuItem_Click(object sender, EventArgs e)
        {
            //新建空间查询窗体
            FormQueryBySpatial formQueryBySpatial = new FormQueryBySpatial();

            //地图作为参数传入到窗体中
            formQueryBySpatial.CurrentMap = axMapControl1.Map;
            //显示窗体
            formQueryBySpatial.Show();
        }
Exemplo n.º 2
0
        private void 空间查询ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //新创建空间查询窗体
            FormQueryBySpatial formQueryBySpatial = new FormQueryBySpatial();

            //将当前主窗体中MapControl控件中的Map对象赋值给FormSelection窗体的CurrentMap属性
            formQueryBySpatial.CurrentMap = axMapControl1.Map;
            //显示空间查询窗体
            formQueryBySpatial.Show();
        }
Exemplo n.º 3
0
        //最短路径分析
        private void routeSolverMenuItem_Click(object sender, EventArgs e)
        {
            ICommand pCommand;

            pCommand = new ShortPathSolveCommand();  //新建自定义的“执行分析”命令
            pCommand.OnCreate(axMapControl1.Object); //创建该命令
            pCommand.OnClick();                      //启动该命令
            pCommand = null;
            #region 道路详细信息
            //获取最短路径的长度
            string        totalLengthOfRoute = "";
            IFeatureLayer shortRouteLayer    = NetWorkAnalysClass.GetLayerByName(
                m_mapControl.Map, "Routes") as IFeatureLayer;
            IFeatureCursor featureCursor = shortRouteLayer.Search(null, false);
            IFeature       featue        = featureCursor.NextFeature();
            for (int i = 0; i < featue.Fields.FieldCount; i++)
            {
                if (featue.Fields.get_Field(i).Name == "Total_Shape_Length")
                {
                    totalLengthOfRoute = featue.get_Value(i).ToString();
                }
            }
            //获取与最短路径有关的道路的名字
            FormQueryBySpatial formQueryBySpatial   = new FormQueryBySpatial();
            ArrayList          containRouteNameList = formQueryBySpatial.selectRouteNameBySpatial(
                esriSpatialRelEnum.esriSpatialRelContains, m_mapControl.Map);
            ArrayList overlapRouteNameList = formQueryBySpatial.selectRouteNameBySpatial(
                esriSpatialRelEnum.esriSpatialRelOverlaps, m_mapControl.Map);
            m_mapControl.Map.ClearSelection();
            string output = "经过道路有:";

            for (int i = 0; i < containRouteNameList.Count; i++)
            {
                output += containRouteNameList[i].ToString() + ",";
            }
            output  = output.Substring(0, output.Length - 1);
            output += "\n" + "站点所在道路为:";
            for (int i = 0; i < overlapRouteNameList.Count; i++)
            {
                output += overlapRouteNameList[i].ToString() + ",";
            }
            output = output.Substring(0, output.Length - 1);
            output = output + "\n" + "路径长度:" + totalLengthOfRoute + "米";
            MessageBox.Show(output);
            #endregion
        }