夏之倒影吧 关注:36贴子:4,990
  • 10回复贴,共1

AE二次开发之位置查询

只看楼主收藏回复

用点,线,面,圆进行查询,得到相交几何要素,并输出要素类的名字(NAME字段)


IP属地:湖北来自Android客户端1楼2016-10-01 00:52回复
    窗体部分


    IP属地:湖北来自Android客户端3楼2016-10-01 00:56
    回复
      控制台部分


      IP属地:湖北来自Android客户端5楼2016-10-01 00:59
      回复
        用一个全局变量MouseFlag来触发四种不同的操作。
        一方面进行选中要素的NAME字段在showresult.text里的展示,另一方面进行选中要素在图上的高亮展示
        主窗体


        IP属地:湖北来自Android客户端6楼2016-10-01 01:02
        回复
          public override void OnCreate(object hook)
          {
          if (m_hookHelper == null)
          m_hookHelper = new HookHelperClass();
          m_hookHelper.Hook = hook;
          // TODO: Add ZoomIn.OnCreate implementation
          }


          IP属地:湖北8楼2016-10-04 01:50
          回复
            public override void OnMouseDown(int Button, int Shift, int X, int Y)
            {
            // TODO: Add ZoomIn.OnMouseDown implementation
            //当前地图为空是视图返回
            if (m_hookHelper.ActiveView == null) return;
            //获取鼠标点击位置
            m_point = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
            m_isMouseDown = true;
            }


            IP属地:湖北9楼2016-10-04 01:50
            回复
              public override void OnMouseMove(int Button, int Shift, int X, int Y)
              {
              // TODO: Add ZoomIn.OnMouseMove implementation
              //mouseDown时返回
              if (!m_isMouseDown) return;
              IActiveView pActiveview = m_hookHelper.ActiveView;
              //m_feedback追踪鼠标移动
              if (m_feedBack == null)
              {
              m_feedBack = new NewEnvelopeFeedbackClass();
              m_feedBack.Display = pActiveview.ScreenDisplay;
              //开始追踪
              m_feedBack.Start(m_point);
              }
              //追踪鼠标移动位置
              m_feedBack.MoveTo(pActiveview.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y));
              }


              IP属地:湖北10楼2016-10-04 01:51
              回复
                public override void OnMouseUp(int Button, int Shift, int X, int Y)
                {
                // TODO: Add ZoomIn.OnMouseUp implementation
                //MouseDown为发生时返回
                if (!m_isMouseDown) return;
                IActiveView pActiveView = m_hookHelper.ActiveView;
                //获取MouseUp发生时的范围并放大
                IEnvelope pEnvelope;
                if (m_feedBack == null)
                {
                pEnvelope = pActiveView.Extent;
                pEnvelope.Expand(0.5, 0.5, true);
                pEnvelope.CenterAt(m_point);
                }
                else
                {
                //停止追踪
                pEnvelope = m_feedBack.Stop();
                //判断新的范围的宽度和高的是否为0
                if (pEnvelope.Width == 0 || pEnvelope.Height == 0)
                {
                m_feedBack = null;
                m_isMouseDown = false;
                }
                }
                //获取新的范围
                pActiveView.Extent = pEnvelope;
                //刷新视图
                pActiveView.Refresh();
                m_feedBack = null;
                m_isMouseDown = false;
                }


                IP属地:湖北11楼2016-10-04 01:51
                回复
                  创建点图层
                  IWorkspaceFactory pShpWksFact = new ShapefileWorkspaceFactory();
                  IFeatureWorkspace pFeatWks;
                  pFeatWks = (IFeatureWorkspace)pShpWksFact.OpenFromFile(filePath, 0);
                  const string strShapeFieldName = "Shape";
                  //定义属性字段
                  IFields pFields;
                  IFieldsEdit pFieldsEdit;
                  pFields = new FieldsClass();
                  pFieldsEdit = (IFieldsEdit)pFields;
                  IField pField = new FieldClass();
                  IFieldEdit pFieldEdit = new FieldClass();
                  pFieldEdit.Name_2 = strShapeFieldName;
                  pFieldEdit.Type_2 = esriFieldType.esriFieldTypeGeometry;
                  pField = (IField)pFieldEdit;
                  //定义几何属性
                  IGeometryDef pGeomDef = new GeometryDefClass();
                  IGeometryDefEdit pGeomDefEdit = new GeometryDefClass();
                  pGeomDefEdit = (IGeometryDefEdit)pGeomDef;
                  pGeomDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPoint;
                  pGeomDefEdit.SpatialReference_2 = (ISpatialReference)new UnknownCoordinateSystem();
                  pFieldEdit.GeometryDef_2 = pGeomDef;
                  pFieldsEdit.AddField(pField);
                  pFields = (IFields)pFieldsEdit;
                  IFeatureClass pFeatureClass;
                  pFeatureClass = pFeatWks.CreateFeatureClass(fileName, pFields, null, null, esriFeatureType.esriFTSimple, strShapeFieldName, "");


                  IP属地:湖北18楼2016-10-09 20:13
                  回复
                    for (int i = 0; i < addFieldListBox.Items.Count; i++)
                    {
                    IField pfield = new FieldClass();
                    IFieldEdit pfieldEdit = new FieldClass();
                    pfieldEdit.Name_2 = addFieldListBox.Items[i].ToString();
                    pfieldEdit.Type_2 = esriFieldType.esriFieldTypeString;
                    pfield = (IField)pfieldEdit;
                    pFeatureClass.AddField(pfield);
                    }


                    IP属地:湖北19楼2016-10-09 20:13
                    回复
                      A=GF,B=FG
                      Ax=GFx=kx
                      Fx=y
                      FGFx=FGy=Fkx=kFx=ky


                      IP属地:湖北来自Android客户端21楼2016-12-13 02:14
                      回复