示例#1
0
        /// <summary>
        /// 根据点创建要素
        /// </summary>
        /// <param name="pGeom"></param>
        private void CreateFeature(IGeometry pGeom)
        {
            try
            {
                if (pGeom == null)
                {
                    return;
                }
                if (m_pCurrentLayer == null)
                {
                    return;
                }

                IWorkspaceEdit pWorkspaceEdit = DataEditCommon.g_CurWorkspaceEdit;// GetWorkspaceEdit();
                IFeatureLayer  pFeatureLayer  = (IFeatureLayer)m_pCurrentLayer;
                IFeatureClass  pFeatureClass  = pFeatureLayer.FeatureClass;

                pWorkspaceEdit.StartEditOperation();
                IFeature pFeature = pFeatureClass.CreateFeature();

                // 处理Z/M值
                DrawCommon.HandleZMValue(pFeature, pGeom, 0);

                pFeature.Shape = pGeom;
                pFeature.Store();
                pWorkspaceEdit.StopEditOperation();
                m_GeometryCollection = null;
                m_pMap.SelectFeature(m_pCurrentLayer, pFeature);
                m_pMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics | esriViewDrawPhase.esriViewGeoSelection, null, null);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message.ToString());
            }
        }
示例#2
0
        /// <summary>
        /// 根据点创建要素
        /// </summary>
        /// <params name="pGeom"></params>
        private void CreateFeature(IGeometry pGeom)
        {
            try
            {
                if (pGeom == null)
                {
                    return;
                }
                if (m_pCurrentLayer == null)
                {
                    return;
                }

                IWorkspaceEdit pWorkspaceEdit = DataEditCommon.g_CurWorkspaceEdit;// GetWorkspaceEdit();
                IFeatureLayer  pFeatureLayer  = (IFeatureLayer)m_pCurrentLayer;
                IFeatureClass  pFeatureClass  = pFeatureLayer.FeatureClass;

                pWorkspaceEdit.StartEditOperation();
                IFeature pFeature = pFeatureClass.CreateFeature();

                // 处理Z/M值
                DrawCommon.HandleZMValue(pFeature, pGeom, 0);

                pFeature.Shape = pGeom;
                pFeature.Store();
                pWorkspaceEdit.StopEditOperation();

                IActiveView pActiveView = (IActiveView)m_pMap;
                m_GeometryCollection = null;

                IGraphicsContainer pGra = m_pMapControl.Map as IGraphicsContainer;
                for (int i = 0; i < m_ElementArray.Count; i++)
                {
                    pGra.DeleteElement(m_ElementArray.get_Element(i) as IElement);
                }
                m_ElementArray.RemoveAll();
                m_pMap.SelectFeature(m_pCurrentLayer, pFeature);
                m_pMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics | esriViewDrawPhase.esriViewGeoSelection, null, null);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message.ToString());
            }
        }
示例#3
0
        /// <summary>
        /// 根据点坐标绘制点要素
        /// </summary>
        /// <params name="featureLayer"></params>
        /// <params name="point"></params>
        /// <params name="id"></params>
        /// <params name="wirePoint"></params>
        public void CreatePoint(IFeatureLayer featureLayer, IPoint point, string id, WirePoint wirePoint)
        {
            try
            {
                IFeatureClass featureClass = featureLayer.FeatureClass;
                IGeometry     geometry     = point;

                if (featureClass.ShapeType == esriGeometryType.esriGeometryPoint)
                {
                    IDataset       dataset       = (IDataset)featureClass;
                    IWorkspace     workspace     = dataset.Workspace;
                    IWorkspaceEdit workspaceEdit = workspace as IWorkspaceEdit;
                    DataEditCommon.CheckEditState();
                    workspaceEdit.StartEditOperation();
                    IFeature feature = featureClass.CreateFeature();

                    DrawCommon.HandleZMValue(feature, geometry);//几何图形Z值处理

                    feature.Shape = point;
                    feature.Value[feature.Fields.FindField(GIS_Const.FIELD_BID)]  = id;
                    feature.Value[feature.Fields.FindField(GIS_Const.FIELD_HDID)] = wirePoint.wire.tunnel.id;
                    feature.Value[feature.Fields.FindField(GIS_Const.FIELD_NAME)] = wirePoint.name;
                    feature.Value[feature.Fields.FindField(GIS_Const.FIELD_ID)]   = wirePoint.id;
                    feature.Store();
                    workspaceEdit.StopEditOperation();

                    IEnvelope envelop = point.Envelope;
                    DataEditCommon.g_pMyMapCtrl.ActiveView.Extent = envelop;
                    DataEditCommon.g_pMyMapCtrl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewBackground, null, null);
                }
                else
                {
                    MessageBox.Show(@"请选择点图层。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch
            {
                return;
            }
        }
示例#4
0
        /// <summary>
        /// 根据点集坐标绘制线要素
        /// </summary>
        /// <params name="featureLayer"></params>
        /// <params name="lstPoint"></params>
        public void CreateLine(IFeatureLayer featureLayer, List <IPoint> lstPoint, int ID)
        {
            //try
            //{
            IFeatureClass featureClass = featureLayer.FeatureClass;

            if (featureClass.ShapeType == esriGeometryType.esriGeometryPolyline)
            {
                IPointCollection multipoint = new MultipointClass();
                if (lstPoint.Count < 2)
                {
                    MessageBox.Show(@"请选择两个及两个以上点数。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                ISegmentCollection pPath = new PathClass();
                ILine    pLine;
                ISegment pSegment;
                object   o = Type.Missing;
                for (int i = 0; i < lstPoint.Count - 1; i++)
                {
                    pLine = new LineClass();
                    pLine.PutCoords(lstPoint[i], lstPoint[i + 1]);
                    pSegment = pLine as ISegment;
                    pPath.AddSegment(pSegment, ref o, ref o);
                }
                IGeometryCollection pPolyline = new PolylineClass();
                pPolyline.AddGeometry(pPath as IGeometry, ref o, ref o);

                IDataset       dataset       = (IDataset)featureClass;
                IWorkspace     workspace     = dataset.Workspace;
                IWorkspaceEdit workspaceEdit = workspace as IWorkspaceEdit;

                workspaceEdit.StartEditing(true);
                workspaceEdit.StartEditOperation();

                IFeature feature = featureClass.CreateFeature();

                IGeometry geometry = pPolyline as IGeometry;
                DrawCommon.HandleZMValue(feature, geometry);//几何图形Z值处理

                feature.Shape = pPolyline as PolylineClass;
                int iFieldID = feature.Fields.FindField(GIS_Const.FIELD_BID);
                feature.Value[iFieldID] = ID.ToString();
                feature.Store();
                workspaceEdit.StopEditOperation();
                workspaceEdit.StopEditing(false);

                IEnvelope envelop = feature.Shape.Envelope;
                DataEditCommon.g_pMyMapCtrl.ActiveView.Extent = envelop;
                DataEditCommon.g_pMyMapCtrl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewBackground, null, null);
            }
            else
            {
                MessageBox.Show(@"请选择线图层。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            //}
            //catch
            //{
            //    return;
            //}
        }