コード例 #1
0
        private void ShowFalshFeature(int iColumnIndex, int iRowIndex, string strLayerCoum)
        {
            if (iRowIndex == -1)
            {
                return;
            }
            int    iOID         = Convert.ToInt32(DataGridErrs.Rows[iRowIndex].Cells[iColumnIndex].Value);
            string strLayer     = DataGridErrs.Rows[iRowIndex].Cells[strLayerCoum].Value.ToString();
            ILayer pLayer       = ModDBOperator.GetLayer(_MapControl, strLayer);
            double d_mapx       = -1;
            double d_mapy       = -1;
            string errFeaGepStr = string.Empty;

            try
            {
                d_mapx = Convert.ToDouble(DataGridErrs.CurrentRow.Cells["定位点X"].FormattedValue.ToString());
                d_mapy = Convert.ToDouble(DataGridErrs.CurrentRow.Cells["定位点Y"].FormattedValue.ToString());
            }
            catch
            {
                d_mapx = 0; d_mapy = 0;
            }
            try
            {
                errFeaGepStr = DataGridErrs.CurrentRow.Cells["错误几何形状"].FormattedValue.ToString();
            }
            catch
            {
                errFeaGepStr = string.Empty;
            }

            if (iOID != -1)
            {
                if (pLayer != null && pLayer is IFeatureLayer)
                {
                    IFeatureClass pFeatureClass = (pLayer as IFeatureLayer).FeatureClass;
                    if (pFeatureClass == null)
                    {
                        return;
                    }
                    try
                    {
                        IFeature pFeature = pFeatureClass.GetFeature(iOID);
                        //ModOperator.FlashFeature(pFeature, m_hookHelper.ActiveView);
                        //IHookActions pHookActions = m_hookHelper as IHookActions;
                        //pHookActions.DoAction(pFeature.Shape, esriHookActions.esriHookActionsPan);
                        //Application.DoEvents();
                        //pHookActions.DoAction(pFeature.Shape, esriHookActions.esriHookActionsFlash);
                        _MapControl.Map.ClearSelection();
                        _MapControl.Map.SelectFeature(pLayer, pFeature);
                        ShowErrorGeo(d_mapx, d_mapy, errFeaGepStr);
                        _MapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, _MapControl.ActiveView.Extent);
                        //Application.DoEvents();
                        //pHookActions.DoAction(pFeature.Shape, esriHookActions.esriHookActionsCallout);
                    }
                    catch { return; }
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// 选中并定位到选中行中的所有要素
        /// </summary>
        /// <param name="iColumnIndex"></param>
        /// <param name="iRowIndex"></param>
        private void ShowAllFeature(int iColumnIndex, int iRowIndex)
        {
            if (iRowIndex == -1)
            {
                return;
            }
            int    iOID1        = Convert.ToInt32(DataGridErrs.Rows[iRowIndex].Cells["要素OID1"].Value);
            int    iOID2        = Convert.ToInt32(DataGridErrs.Rows[iRowIndex].Cells["要素OID2"].Value);
            string strSLayer    = DataGridErrs.Rows[iRowIndex].Cells["数据图层1"].Value.ToString();
            string strTLayer    = DataGridErrs.Rows[iRowIndex].Cells["数据图层2"].Value.ToString();
            double d_mapx       = -1;
            double d_mapy       = -1;
            string errFeaGepStr = string.Empty;

            try
            {
                d_mapx = Convert.ToDouble(DataGridErrs.CurrentRow.Cells["定位点X"].FormattedValue.ToString());
                d_mapy = Convert.ToDouble(DataGridErrs.CurrentRow.Cells["定位点Y"].FormattedValue.ToString());
            }
            catch
            {
                d_mapx = 0; d_mapy = 0;
            }
            try
            {
                errFeaGepStr = DataGridErrs.CurrentRow.Cells["错误几何形状"].FormattedValue.ToString();
            }
            catch
            {
                errFeaGepStr = string.Empty;
            }


            ILayer           pSLayer   = ModDBOperator.GetLayer(_MapControl as ESRI.ArcGIS.Controls.IMapControlDefault, strSLayer);
            ILayer           pTLayer   = ModDBOperator.GetLayer(_MapControl as ESRI.ArcGIS.Controls.IMapControlDefault, strTLayer);
            IFeature         pSFeature = null;
            IFeature         pTFeature = null;
            IList <IFeature> vFeaList  = new List <IFeature>();

            if (iOID1 != -1)
            {
                if (pSLayer != null && pSLayer is IFeatureLayer)
                {
                    IFeatureClass pSFeatureClass = (pSLayer as IFeatureLayer).FeatureClass;
                    if (pSFeatureClass == null)
                    {
                        return;
                    }
                    try
                    {
                        pSFeature = pSFeatureClass.GetFeature(iOID1);
                    }
                    catch { return; }
                }
            }
            if (iOID2 != -1)
            {
                if (pTLayer != null && pTLayer is IFeatureLayer)
                {
                    IFeatureClass pTFeatureClass = (pTLayer as IFeatureLayer).FeatureClass;
                    if (pTFeatureClass == null)
                    {
                        return;
                    }
                    try
                    {
                        pTFeature = pTFeatureClass.GetFeature(iOID2);
                    }
                    catch { }
                }
            }
            IGeometry pGeometry = null;

            _MapControl.Map.ClearSelection();
            _MapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, _MapControl.ActiveView.Extent);
            if (pTFeature == null)
            {
                if (pSFeature != null)
                {
                    _MapControl.Map.SelectFeature(pSLayer, pSFeature);
                    pGeometry = pSFeature.ShapeCopy;
                }
            }
            else
            {
                if (pSFeature.ShapeCopy.GeometryType == esriGeometryType.esriGeometryPoint && pTFeature.ShapeCopy.GeometryType == esriGeometryType.esriGeometryPoint)
                {
                    object _missing = Type.Missing;

                    IGeometryCollection geometryCollection = new PolylineClass();
                    IPointCollection    pointCollection    = new PathClass();
                    pointCollection.AddPoint(pSFeature.ShapeCopy as IPoint, ref _missing, ref _missing);
                    pointCollection.AddPoint(pTFeature.ShapeCopy as IPoint, ref _missing, ref _missing);
                    geometryCollection.AddGeometry(pointCollection as IGeometry, ref _missing, ref _missing);
                    MakeZAware(geometryCollection as IGeometry);
                    pGeometry = geometryCollection as IGeometry;
                    pGeometry.Project(pSFeature.Shape.SpatialReference);
                }
                else
                {
                    vFeaList.Add(pSFeature); vFeaList.Add(pTFeature);
                    pGeometry = GetLyrUnionPlygon(vFeaList);
                }
                _MapControl.Map.SelectFeature(pTLayer, pTFeature);
            }
            _MapControl.Map.SelectFeature(pSLayer, pSFeature);
            ModDBOperator.ZoomToFeature(_MapControl.Map, pGeometry);
            ShowErrorGeo(d_mapx, d_mapy, errFeaGepStr);
            _MapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, _MapControl.ActiveView.Extent);
            //ShowErrState();
        }