/// <summary>
        /// 面拓扑检查
        /// </summary>
        /// <param name="pDataCheckClass"></param>
        /// <param name="pFeaDataset"></param>
        /// <param name="pTable"></param>
        /// <param name="topoRule"></param>
        /// <param name="eError"></param>
        public void AreaTopoCheck(IArcgisDataCheckHook hook, IFeatureDataset pFeaDataset, DataTable pTable, esriTopologyRuleType topoRule, out Exception eError)
        {
            eError = null;

            //设置进度条
            ProgressChangeEvent eInfo = new ProgressChangeEvent();

            eInfo.Max = pTable.Rows.Count;
            int pValue = 0;

            for (int i = 0; i < pTable.Rows.Count; i++)
            {
                string FeaClsName = pTable.Rows[i]["图层"].ToString().Trim();  //图层名
                if ((FeaClsName == "") || (!FeaClsName.Contains(";")))
                {
                    eError = new Exception("图层名为空或配置不正确!");
                    return;
                }

                string[] feaNameArr    = FeaClsName.Split(new char[] { ';' });
                string   oriFeaClsName = feaNameArr[0].Trim(); //源要素类名
                string   desFeaClsName = feaNameArr[1].Trim(); //目标要素名

                CommonTopologyCheckClass commonTopologyCheckClass = new CommonTopologyCheckClass();
                commonTopologyCheckClass.DataErrTreat += new DataErrTreatHandle(DataCheckRealize_DataErrTreat);
                commonTopologyCheckClass.OrdinaryTopoCheck(hook, pFeaDataset, oriFeaClsName, desFeaClsName, topoRule, out eError);
                if (eError != null)
                {
                    return;
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 同层线重叠检查
        /// </summary>
        /// <param name="hook"></param>
        /// <param name="pFeaDataset"></param>
        /// <param name="pTable"></param>
        /// <param name="eError"></param>
        public void SpecialFeaClsTopoCheck(IArcgisDataCheckHook hook, IFeatureDataset pFeaDataset, DataTable pTable, esriTopologyRuleType pTopoRule, out Exception eError)
        {
            eError = null;

            //设置进度条
            ProgressChangeEvent eInfo = new ProgressChangeEvent();

            eInfo.Max = pTable.Rows.Count;
            int pValue = 0;


            for (int i = 0; i < pTable.Rows.Count; i++)
            {
                string FeaClsName = pTable.Rows[i]["图层"].ToString().Trim();  //图层名
                if (FeaClsName == "")
                {
                    eError = new Exception("图层名为空!");
                    return;
                }
                CommonTopologyCheckClass commonTopologyCheckClass = new CommonTopologyCheckClass();
                commonTopologyCheckClass.DataErrTreat += new DataErrTreatHandle(DataCheckRealize_DataErrTreat);
                commonTopologyCheckClass.OrdinaryTopoCheck(hook, pFeaDataset, FeaClsName, pTopoRule, out eError);
                if (eError != null)
                {
                    return;
                }

                //进度条加1
                pValue++;
                eInfo.Value = pValue;
                GeoDataChecker.GeoDataChecker_ProgressShow((object)GeoDataChecker._ProgressBarInner, eInfo);
            }
        }
Esempio n. 3
0
 public static void GeoDataChecker_ProgressShow(object sender, ProgressChangeEvent e)
 {
     DevComponents.DotNetBar.Controls.ProgressBarX pProgress = sender as DevComponents.DotNetBar.Controls.ProgressBarX;
     //pProgress.Minimum = 0;
     //pProgress.Maximum = e.Max;
     //pProgress.Value = e.Value;
     if (_CheckForm != null)
     {
         _CheckForm.Invoke(new ChangeProgress(ChangeProgressBar), new object[] { pProgress, 0, e.Max, e.Value });
     }
 }
Esempio n. 4
0
        private static void DataCheckRelizeFunction(string name, int pValue, ProgressChangeEvent eInfo, IDataCheckHook hook, IDataCheckLogic dataCheckLogic)
        {
            object objLock = new object();

            lock (objLock)
            {
                if (DicCheck.ContainsKey(name))
                {
                    DicCheck[name].OnCreate(hook);
                    (DicCheck[name] as ICheckEvent).DataErrTreat += new DataErrTreatHandle(dataCheckLogic.DataCheckLogic_DataErrTreat);
                    (DicCheck[name] as ICheckEvent).ProgressShow += new ProgressChangeHandle(GeoDataChecker_ProgressShow);
                    DicCheck[name].OnDataCheck();
                    //进度条加1
                    pValue++;
                    eInfo.Value = pValue;
                    //_CheckForm.Invoke(new ChangeProgressBarOut(changeProgressOut), new object[] { pValue });
                    //进度条控制
                    GeoDataChecker_ProgressShow((object)_PrgressBarOut, eInfo);
                }
            }
        }
        public void OnDataCheck()
        {
            Exception eError = null;

            if (Hook == null)
            {
                return;
            }
            IArcgisDataCheckParaSet dataCheckParaSet = Hook.DataCheckParaSet as IArcgisDataCheckParaSet;

            if (dataCheckParaSet == null)
            {
                return;
            }
            if (dataCheckParaSet.Workspace == null)
            {
                return;
            }

            //实现代码
            SysCommon.DataBase.SysTable pSysTable = new SysCommon.DataBase.SysTable();
            pSysTable.DbConn    = dataCheckParaSet.DbConnPara;
            pSysTable.DBConType = SysCommon.enumDBConType.OLEDB;
            pSysTable.DBType    = SysCommon.enumDBType.ACCESS;

            //获取所有数据集
            SysCommon.Gis.SysGisDataSet sysGisDataSet = new SysCommon.Gis.SysGisDataSet(dataCheckParaSet.Workspace);
            List <string> featureDatasetNames         = sysGisDataSet.GetAllFeatureDatasetNames();

            if (featureDatasetNames.Count == 0)
            {
                return;
            }

            //设置进度条
            ProgressChangeEvent eInfo = new ProgressChangeEvent();

            eInfo.Max = featureDatasetNames.Count;
            int pValue = 0;

            //遍历数据集,并进行检查
            foreach (string name in featureDatasetNames)
            {
                IFeatureDataset featureDataset = sysGisDataSet.GetFeatureDataset(name, out eError);
                if (eError != null)
                {
                    continue;
                }

                //线线重合检查,参数为45
                DataTable mTable = TopologyCheckClass.GetParaValueTable(featureDataset, pSysTable, 45, out eError);
                if (eError != null)
                {
                    //SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", eError.Message);
                    return;
                }
                if (mTable.Rows.Count == 0)
                {
                    continue;
                }
                AreaTopoCheck2(Hook, featureDataset, mTable, esriTopologyRuleType.esriTRTLineCoveredByLineClass, out eError);
                if (eError != null)
                {
                    eError = new Exception("线线重合检查失败!" + eError.Message);
                    return;
                }

                //进度条加1
                pValue++;
                eInfo.Value = pValue;
                GeoDataChecker.GeoDataChecker_ProgressShow((object)GeoDataChecker._ProgressBarInner, eInfo);
            }
        }
 /// <summary>
 /// 显示进度条
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 public void DataCheck_ProgressShow(object sender, ProgressChangeEvent e)
 {
 }
Esempio n. 7
0
        //加载执行检查功能
        public static void LoadDataCheckLogicFunction(string logicFunName, IDataCheckHook hook, IDataCheckLogic dataCheckLogic)
        {
            IArcgisDataCheckHook dataCheckHook = hook as IArcgisDataCheckHook;

            if (dataCheckHook == null)
            {
                return;
            }
            IArcgisDataCheckParaSet checkParaSet = dataCheckHook.DataCheckParaSet as IArcgisDataCheckParaSet;

            if (checkParaSet == null)
            {
                return;
            }
            if (checkParaSet.XmlDocDataCheckSet == null)
            {
                return;
            }
            XmlNode aNode = checkParaSet.XmlDocDataCheckSet.DocumentElement.SelectSingleNode(".//LogicCheckFunction[@Name='" + logicFunName + "']");

            if (aNode == null)
            {
                return;
            }
            if (aNode.ChildNodes.Count == 0)
            {
                return;
            }
            if (DicCheck == null)
            {
                return;
            }
            //设置进度条
            //int pMax = aNode.ChildNodes.Count;
            //_CheckForm.Invoke(new IntiProgressBarOut(intiaProgressout), new object[] { pMax });

            m_DicTopoDataCheck = new Dictionary <string, string>();
            int pValue = 0;
            ProgressChangeEvent eInfo = new ProgressChangeEvent();

            eInfo.Max = aNode.ChildNodes.Count;

            foreach (XmlNode childNode in aNode.ChildNodes)
            {
                XmlElement childElement = childNode as XmlElement;
                if (!childElement.HasAttribute("Name"))
                {
                    continue;
                }
                string name  = childElement.GetAttribute("Name");
                string pText = childElement.GetAttribute("text").Trim();
                string pType = childElement.GetAttribute("type").Trim();
                if (pType == "拓扑检查")
                {
                    if (!m_DicTopoDataCheck.ContainsKey(name))
                    {
                        m_DicTopoDataCheck.Add(name, pText);
                    }
                    continue;
                }

                //if (DicCheck.ContainsKey(name))
                //{
                //    _CheckForm.Invoke(new ShowErrorInfo(showEInfo), new object[] { pText });

                //    DicCheck[name].OnCreate(hook);
                //    (DicCheck[name] as ICheckEvent).DataErrTreat += new DataErrTreatHandle(dataCheckLogic.DataCheckLogic_DataErrTreat);
                //    (DicCheck[name] as ICheckEvent).ProgressShow += new ProgressChangeHandle(GeoDataChecker_ProgressShow);
                //    DicCheck[name].OnDataCheck();
                //    //进度条加1
                //    pValue++;
                //    eInfo.Value = pValue;
                //    //进度条控制
                //    GeoDataChecker_ProgressShow((object)_PrgressBarOut, eInfo);
                //}
            }

            if (m_DicTopoDataCheck != null && m_DicTopoDataCheck.Count != 0)
            {
                //进行拓扑检查
                if (DicCheck.ContainsKey("GeoDataChecker.GeoTopologyCheck"))
                {
                    _CheckForm.Invoke(new ShowErrorInfo(showEInfo), new object[] { "进行拓扑检查" });

                    DicCheck["GeoDataChecker.GeoTopologyCheck"].OnCreate(hook);
                    (DicCheck["GeoDataChecker.GeoTopologyCheck"] as ICheckEvent).DataErrTreat += new DataErrTreatHandle(dataCheckLogic.DataCheckLogic_DataErrTreat);
                    (DicCheck["GeoDataChecker.GeoTopologyCheck"] as ICheckEvent).ProgressShow += new ProgressChangeHandle(GeoDataChecker_ProgressShow);
                    DicCheck["GeoDataChecker.GeoTopologyCheck"].OnDataCheck();

                    pValue++;
                    eInfo.Value = pValue;
                    //进度条控制
                    GeoDataChecker_ProgressShow((object)_PrgressBarOut, eInfo);
                }
            }
            foreach (XmlNode childNode in aNode.ChildNodes)
            {
                XmlElement childElement = childNode as XmlElement;
                if (!childElement.HasAttribute("Name"))
                {
                    continue;
                }
                string name  = childElement.GetAttribute("Name");
                string pText = childElement.GetAttribute("text").Trim();
                string pType = childElement.GetAttribute("type").Trim();
                if (pType == "拓扑检查")
                {
                    continue;
                }
                if (DicCheck.ContainsKey(name))
                {
                    _CheckForm.Invoke(new ShowErrorInfo(showEInfo), new object[] { pText });

                    DicCheck[name].OnCreate(hook);
                    (DicCheck[name] as ICheckEvent).DataErrTreat += new DataErrTreatHandle(dataCheckLogic.DataCheckLogic_DataErrTreat);
                    (DicCheck[name] as ICheckEvent).ProgressShow += new ProgressChangeHandle(GeoDataChecker_ProgressShow);
                    DicCheck[name].OnDataCheck();
                    //进度条加1
                    pValue++;
                    eInfo.Value = pValue;
                    //进度条控制
                    GeoDataChecker_ProgressShow((object)_PrgressBarOut, eInfo);
                }
            }


            /*
             * int pValue = 0;
             * ProgressChangeEvent eInfo = new ProgressChangeEvent();
             * eInfo.Max=aNode.ChildNodes.Count;
             *
             * foreach (XmlNode childNode in aNode.ChildNodes)
             * {
             *  XmlElement childElement = childNode as XmlElement;
             *  if (!childElement.HasAttribute("Name")) continue;
             *  string name = childElement.GetAttribute("Name");
             *  string pText = childElement.GetAttribute("text").Trim();
             *
             *  //如果不是库体结构检查,就用多线程
             *  //Thread pThread = new Thread(new ThreadStart(delegate { DataCheckRelizeFunction(name, pValue, eInfo, hook, dataCheckLogic); }));
             *  //pThread.Start();
             *  if (DicCheck.ContainsKey(name))
             *  {
             *      _CheckForm.Invoke(new ShowErrorInfo(showEInfo), new object[] { pText });
             *
             *      DicCheck[name].OnCreate(hook);
             *      (DicCheck[name] as ICheckEvent).DataErrTreat += new DataErrTreatHandle(dataCheckLogic.DataCheckLogic_DataErrTreat);
             *      (DicCheck[name] as ICheckEvent).ProgressShow += new ProgressChangeHandle(GeoDataChecker_ProgressShow);
             *      DicCheck[name].OnDataCheck();
             *      //进度条加1
             *      pValue++;
             *      eInfo.Value = pValue;
             *      //_CheckForm.Invoke(new ChangeProgressBarOut(changeProgressOut), new object[] { pValue });
             *      //进度条控制
             *      GeoDataChecker_ProgressShow((object)_PrgressBarOut, eInfo);
             *  }
             * }
             * */
        }
        private void ExcuteCheck(List <IDataset> LstDataset, string path)
        {
            Exception eError = null;

            string pClassifyName = GetClassifyName1(out eError);

            if (eError != null || pClassifyName == "")
            {
                return;
            }

            //用来存储MapControl上的图层的分类代码的相关信息
            Dictionary <IFeatureClass, Dictionary <string, List <int> > > DicFea = new Dictionary <IFeatureClass, Dictionary <string, List <int> > >();

            foreach (IDataset pDT in LstDataset)
            {
                IFeatureClass pFeatureClass = pDT as IFeatureClass;
                if (pFeatureClass == null)
                {
                    return;
                }
                string pFeaClsName = pDT.Name.Trim();

                #region 首先检查Mapcontrol上的要素类是否具有分类代码这个字段
                int index = -1;   //分类代码索引
                index = pFeatureClass.Fields.FindField(pClassifyName);
                if (index == -1)
                {
                    //SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "不存在分类代码字段!");
                    //return;
                    continue;
                }
                #endregion

                #region 将MapControl上的图层相关信息用字典存储起来
                IFeatureCursor pFeaCursor = pFeatureClass.Search(null, false);
                if (pFeaCursor == null)
                {
                    return;
                }
                IFeature pFeature = pFeaCursor.NextFeature();
                if (pFeature == null)
                {
                    continue;
                }
                while (pFeature != null)
                {
                    string pGISID = pFeature.get_Value(index).ToString().Trim(); //分类代码
                    int    pOID   = pFeature.OID;                                //OID

                    if (!DicFea.ContainsKey(pFeatureClass))
                    {
                        //用来保存GISID和对应的OID
                        Dictionary <string, List <int> > DicCode = new Dictionary <string, List <int> >();
                        List <int> LstOID = new List <int>();
                        LstOID.Add(pOID);
                        DicCode.Add(pGISID, LstOID);
                        DicFea.Add(pFeatureClass, DicCode);
                    }
                    else
                    {
                        if (!DicFea[pFeatureClass].ContainsKey(pGISID))
                        {
                            List <int> LstOID = new List <int>();
                            LstOID.Add(pOID);
                            DicFea[pFeatureClass].Add(pGISID, LstOID);
                        }
                        else
                        {
                            DicFea[pFeatureClass][pGISID].Add(pOID);
                        }
                    }
                    pFeature = pFeaCursor.NextFeature();
                }

                //释放cursor
                System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeaCursor);

                #endregion
            }
            //设置进度条
            ProgressChangeEvent eInfo = new ProgressChangeEvent();
            eInfo.Max = DicFea.Count;
            int pValue = 0;

            //int pMax =DicFea.Count;
            //int pValue = 0;
            //GeoDataChecker._CheckForm.Invoke(new GeoDataChecker.IntiProgressBar(GeoDataChecker.intiaProgress), new object[] { pMax });

            #region 进行分类代码检查
            //遍历要素类
            foreach (KeyValuePair <IFeatureClass, Dictionary <string, List <int> > > FeaCls in DicFea)
            {
                IFeatureClass pFeaCls  = FeaCls.Key;
                IDataset      pDataset = pFeaCls as IDataset;
                if (pDataset == null)
                {
                    return;
                }
                string pFeaClsNameStr = pDataset.Name;
                if (pFeaClsNameStr.Contains("."))
                {
                    pFeaClsNameStr = pFeaClsNameStr.Substring(pFeaClsNameStr.IndexOf('.') + 1);
                }


                //遍历分类代码值,进行检查
                foreach (KeyValuePair <string, List <int> > pGISIDItem in FeaCls.Value)
                {
                    //分类代码的值
                    string ppGISID = pGISIDItem.Key;
                    string sqlStr  = "select * from GeoCheckCode where 分类代码 ='" + ppGISID + "'";
                    //执行检查
                    int pResult = CodeStandardizeCheck(sqlStr);
                    #region 对检查结果进行判断
                    if (pResult == -1)
                    {
                        return;
                    }
                    if (pResult == 1)
                    {
                        continue;
                    }
                    if (pResult == 0)
                    {
                        //该分类代码不存在
                        #region 保存错误结果
                        //遍历该分类代码对应的要素OID集合
                        for (int m = 0; m < pGISIDItem.Value.Count; m++)
                        {
                            int pOID = pGISIDItem.Value[m];

                            IFeature pFeature = pFeaCls.GetFeature(pOID);
                            IPoint   pPoint   = ModCommonFunction.GetPntOfFeature(pFeature);

                            double pMapx = 0; // pPoint.X; ;
                            double pMapy = 0; // pPoint.Y;
                            if (pPoint != null)
                            {
                                pMapx = pPoint.X;
                                pMapy = pPoint.Y;
                            }

                            //用来保存错误结果
                            List <object> ErrorLst = new List <object>();
                            ErrorLst.Add("批量检查");
                            ErrorLst.Add("分类代码检查");
                            ErrorLst.Add(path);
                            ErrorLst.Add(enumErrorType.分类代码不存在.GetHashCode());
                            ErrorLst.Add("分类代码" + ppGISID + "不存在!");
                            ErrorLst.Add(pMapx);     //...
                            ErrorLst.Add(pMapy);     //...
                            ErrorLst.Add(pFeaClsNameStr);
                            ErrorLst.Add(pOID);
                            ErrorLst.Add("");
                            ErrorLst.Add(-1);
                            ErrorLst.Add(false);
                            ErrorLst.Add(System.DateTime.Now.ToString());

                            //传递错误日志
                            IDataErrInfo      dataErrInfo       = new DataErrInfo(ErrorLst);
                            DataErrTreatEvent dataErrTreatEvent = new DataErrTreatEvent(dataErrInfo);
                            DataErrTreat(Hook.DataCheckParaSet as object, dataErrTreatEvent);
                        }
                        #endregion
                    }
                    #endregion
                }

                //进度条加1
                //进度条加1
                pValue++;
                eInfo.Value = pValue;
                //GeoDataChecker._CheckForm.Invoke(new GeoDataChecker.GEODataCheckerProgressShow(GeoDataChecker.GeoDataChecker_ProgressShow), new object[] { (object)GeoDataChecker._ProgressBarInner, eInfo });
                GeoDataChecker.GeoDataChecker_ProgressShow((object)GeoDataChecker._ProgressBarInner, eInfo);

                //pValue++;
                //GeoDataChecker._CheckForm.Invoke(new GeoDataChecker.ChangeProgressBar(GeoDataChecker.changeProgress), new object[] {pValue});
            }
            #endregion
        }
Esempio n. 9
0
        /// <summary>
        /// 等高线点线矛盾一致性检查
        /// </summary>
        /// <param name="pFeatureDataset"></param>
        /// <param name="lineFeaClsName">等高线要素类名称</param>
        /// <param name="lineFieldName">等高线高程字段名</param>
        /// <param name="pointFeaClsName">高程点要素类名称</param>
        /// <param name="pointFieldName">高程点字段名</param>
        /// <param name="radiu">高程点搜索半径</param>
        /// <param name="intervalValue">等高线间距值</param>
        /// <param name="eError"></param>
        private void PointLineElevCheck(IArcgisDataCheckHook hook, IFeatureDataset pFeatureDataset, string lineFeaClsName, string lineFieldName, string pointFeaClsName, string pointFieldName, double intervalValue, out Exception eError)
        {
            eError = null;
            try
            {
                //等高线要素类
                IFeatureClass lineFeaCls = (pFeatureDataset.Workspace as IFeatureWorkspace).OpenFeatureClass(lineFeaClsName);
                //等高线高程字段索引值
                int lineIndex = lineFeaCls.Fields.FindField(lineFieldName);
                if (lineIndex == -1)
                {
                    eError = new Exception("等高线图层的高程字段不存在,字段名为:" + lineFieldName);
                    return;
                }
                //高程点要素类
                IFeatureClass pointFeaCls = (pFeatureDataset.Workspace as IFeatureWorkspace).OpenFeatureClass(pointFeaClsName);
                int           pointIndex  = pointFeaCls.Fields.FindField(pointFieldName);
                if (lineIndex == -1)
                {
                    eError = new Exception("高程点图层的高程字段不存在,字段名为:" + pointFieldName);
                    return;
                }

                //遍历高程点要素
                IFeatureCursor pCusor = pointFeaCls.Search(null, false);
                if (pCusor == null)
                {
                    return;
                }
                IFeature pointFeature = pCusor.NextFeature();

                //设置进度条
                ProgressChangeEvent eInfo = new ProgressChangeEvent();
                eInfo.Max = pointFeaCls.FeatureCount(null);
                int pValue = 0;

                while (pointFeature != null)
                {
                    //高程点要素的高程值
                    double pointElevValue = Convert.ToDouble(pointFeature.get_Value(pointIndex).ToString());
                    //查找高程点相邻的两条高程线要素

                    //与高程点最近的等高线要素以及最短距离
                    Dictionary <double, IFeature> nearestFeaDic = GetShortestDis(lineFeaCls, pointFeature, out eError);
                    if (eError != null || nearestFeaDic == null)
                    {
                        eError = new Exception("在搜索范围内的未找到要素!");
                        return;
                    }
                    double   pShortestDis = -1;
                    IFeature nearestFea   = null;
                    foreach (KeyValuePair <double, IFeature> item in nearestFeaDic)
                    {
                        pShortestDis = item.Key;
                        nearestFea   = item.Value;
                        break;
                    }
                    if (eError != null || pShortestDis == -1)
                    {
                        return;
                    }
                    //获得等高线上离高程点最近的点
                    IPoint             nearestPoint = new PointClass();//等高线上的最近点
                    IProximityOperator mProxiOpe    = nearestFea.Shape as IProximityOperator;
                    if (mProxiOpe == null)
                    {
                        return;
                    }
                    nearestPoint = mProxiOpe.ReturnNearestPoint(pointFeature.Shape as IPoint, esriSegmentExtension.esriNoExtension);
                    //将高程点和等高线上的点连成线段并进行两端延长

                    PointLineAccordanceCheck2(hook, pFeatureDataset, lineFeaCls, pointFeaCls, pointFeature, lineFieldName, lineIndex, pointIndex, nearestFea, pShortestDis, intervalValue, out eError);
                    //PointLineAccordanceCheck(pFeatureDataset, lineFeaCls, pointFeaCls, pointFeature, lineIndex, pointIndex, pShortestDis, nearestFea, intervalValue, out eError);
                    if (eError != null)
                    {
                        return;
                    }
                    pointFeature = pCusor.NextFeature();

                    //进度条加1
                    pValue++;
                    eInfo.Value = pValue;
                    GeoDataChecker.GeoDataChecker_ProgressShow((object)GeoDataChecker._ProgressBarInner, eInfo);
                }

                //释放cursor
                System.Runtime.InteropServices.Marshal.ReleaseComObject(pCusor);
            }
            catch (Exception ex)
            {
                eError = ex;
            }
        }
Esempio n. 10
0
        /// <summary>
        /// 注记高程值一致性检查
        /// </summary>
        /// <param name="hook"></param>
        /// <param name="pFeatureDataset"></param>
        /// <param name="codeName">分类代码字段名</param>
        /// <param name="oriFeaClsName">源要素类名称</param>
        /// <param name="oriCodeValue">源要素类分类代码值</param>
        /// <param name="oriElevFieldName">源高程值字段名</param>
        /// <param name="desFeaClsName">目标要素类名称</param>
        /// <param name="desCodeValue">目标要素类分类代码值</param>
        /// <param name="labelFieldName">目标要素类高程值</param>
        /// <param name="radius">搜索半径</param>
        /// <param name="precision">精度控制</param>
        /// <param name="outError"></param>
        public void ElevAccordanceCheck(IArcgisDataCheckHook hook, IFeatureDataset pFeatureDataset, string codeName, string oriFeaClsName, string oriCodeValue, string oriElevFieldName, string desFeaClsName, string desCodeValue, string labelFieldName, double radius, long precision, out Exception outError)
        {
            outError = null;
            try
            {
                //源要素类
                IFeatureClass pOriFeaCls = (pFeatureDataset.Workspace as IFeatureWorkspace).OpenFeatureClass(oriFeaClsName);
                //源要素类高程字段索引值
                int oriEleIndex = pOriFeaCls.Fields.FindField(oriElevFieldName);
                if (oriEleIndex == -1)
                {
                    outError = new Exception("要素类" + oriFeaClsName + "字段" + oriElevFieldName + "不存在!");
                    return;
                }

                //目标要素类
                IFeatureClass pDesFeaCls = (pFeatureDataset.Workspace as IFeatureWorkspace).OpenFeatureClass(desFeaClsName);
                //目标要素类高程字段索引值
                int desElevIndex = pDesFeaCls.Fields.FindField(labelFieldName);
                if (desElevIndex == -1)
                {
                    outError = new Exception("要素类" + desFeaClsName + "字段" + labelFieldName + "不存在!");
                    return;
                }

                //查找源要素类中符合分类代码限制条件的要素
                string whereStr = "";
                if (oriCodeValue != "")
                {
                    whereStr = codeName + " ='" + oriCodeValue + "'";
                }
                IQueryFilter pFilter = new QueryFilterClass();
                pFilter.WhereClause = whereStr;
                IFeatureCursor pCursor = pOriFeaCls.Search(pFilter, false);
                if (pCursor == null)
                {
                    return;
                }
                IFeature pOriFea = pCursor.NextFeature();

                //设置进度条
                ProgressChangeEvent eInfo = new ProgressChangeEvent();
                eInfo.Max = pOriFeaCls.FeatureCount(null);
                int pValue = 0;

                //遍历源要素,进行比较
                while (pOriFea != null)
                {
                    #region 进行检查
                    string oriElevValue = pOriFea.get_Value(oriEleIndex).ToString();
                    //根据原高程值求出精度允许的高程值用于比较
                    if (oriElevValue.Contains("."))
                    {
                        //原高程值包含小数点
                        int oriDotIndex = oriElevValue.IndexOf('.');
                        if (precision == 0)
                        {
                            oriElevValue = oriElevValue.Substring(0, oriDotIndex);
                        }
                        else if (oriElevValue.Substring(oriDotIndex + 1).Length > precision && precision > 0)
                        {
                            //原高程值的小数点位数大于精度控制
                            int oriLen = oriDotIndex + 1 + Convert.ToInt32(precision);
                            oriElevValue = oriElevValue.Substring(0, oriLen);
                        }
                    }

                    IFeature desFeature = GetNearestFeature(pDesFeaCls, codeName, desCodeValue, pOriFea, radius, out outError);
                    if (outError != null)
                    {
                        return;
                    }
                    if (desFeature == null)
                    {
                        pOriFea = pCursor.NextFeature();
                        //进度条加1
                        pValue++;
                        eInfo.Value = pValue;
                        GeoDataChecker.GeoDataChecker_ProgressShow((object)GeoDataChecker._ProgressBarInner, eInfo);

                        continue;
                    }
                    string desElevValue = desFeature.get_Value(desElevIndex).ToString();
                    if (desElevValue.Contains("."))
                    {
                        //目标高程值包含小数点
                        int desDotIndex = desElevValue.IndexOf('.');
                        if (precision == 0)
                        {
                            desElevValue = desElevValue.Substring(0, desDotIndex);
                        }
                        else if (desElevValue.Substring(desDotIndex + 1).Length > precision && precision > 0)
                        {
                            //目标高程值的小数点位数大于精度
                            int desLen = desDotIndex + 1 + Convert.ToInt32(precision);
                            desElevValue = desElevValue.Substring(0, desLen);
                        }
                    }

                    //根据精度进行比较,在容许的范围内不相同不算错误
                    if (Convert.ToDouble(oriElevValue) != Convert.ToDouble(desElevValue))
                    {
                        //说明点,或线与相应注记的高程值不一致。将错误结果显示出来
                        double pMapx  = 0.0;
                        double pMapy  = 0.0;
                        IPoint pPoint = new PointClass();
                        if (pOriFeaCls.ShapeType != esriGeometryType.esriGeometryPoint)
                        {
                            pPoint = TopologyCheckClass.GetPointofFeature(pOriFea);
                        }
                        else
                        {
                            //点要素类
                            pPoint = pOriFea.Shape as IPoint;
                        }
                        pMapx = pPoint.X;
                        pMapy = pPoint.Y;

                        List <object> ErrorLst = new List <object>();
                        ErrorLst.Add("要素属性检查");                                                //功能组名称
                        ErrorLst.Add("点线注记高程值一致性检查");                                          //功能名称
                        ErrorLst.Add((pFeatureDataset as IDataset).Workspace.PathName);        //数据文件名
                        ErrorLst.Add(0);                                                       //错误id;
                        ErrorLst.Add("图层" + oriFeaClsName + "与图层" + desFeaClsName + "高程值不一致"); //错误描述
                        ErrorLst.Add(pMapx);                                                   //...
                        ErrorLst.Add(pMapy);                                                   //...
                        ErrorLst.Add(oriFeaClsName);
                        ErrorLst.Add(pOriFea.OID);
                        ErrorLst.Add(desFeaClsName);
                        ErrorLst.Add(desFeature.OID);
                        ErrorLst.Add(false);
                        ErrorLst.Add(System.DateTime.Now.ToString());

                        //传递错误日志
                        IDataErrInfo      dataErrInfo       = new DataErrInfo(ErrorLst);
                        DataErrTreatEvent dataErrTreatEvent = new DataErrTreatEvent(dataErrInfo);
                        DataErrTreat(hook.DataCheckParaSet as object, dataErrTreatEvent);
                    }
                    pOriFea = pCursor.NextFeature();
                    #endregion

                    //进度条加1
                    pValue++;
                    eInfo.Value = pValue;
                    GeoDataChecker.GeoDataChecker_ProgressShow((object)GeoDataChecker._ProgressBarInner, eInfo);
                }

                //释放cursor
                System.Runtime.InteropServices.Marshal.ReleaseComObject(pCursor);
            }
            catch (Exception ex)
            {
                outError = ex;
            }
        }
Esempio n. 11
0
        /// <summary>
        /// 空值检查
        /// </summary>
        /// <param name="hook"></param>
        /// <param name="pFeatureDataset"></param>
        /// <param name="FeaClsNameDic">图层名和属性非空的字段名对</param>
        /// <param name="outError"></param>
        public void IsNullableCheck(IArcgisDataCheckHook hook, IFeatureDataset pFeatureDataset, Dictionary <string, List <string> > FeaClsNameDic, out Exception outError)
        {
            outError = null;
            try
            {
                //设置进度条
                ProgressChangeEvent eInfo = new ProgressChangeEvent();
                eInfo.Max = FeaClsNameDic.Count;
                int pValue = 0;

                foreach (KeyValuePair <string, List <string> > item in FeaClsNameDic)
                {
                    IFeatureClass pFeaCls = (pFeatureDataset.Workspace as IFeatureWorkspace).OpenFeatureClass(item.Key.Trim());
                    for (int i = 0; i < item.Value.Count; i++)
                    {
                        string fieldName = item.Value[i].Trim();
                        int    index     = pFeaCls.Fields.FindField(fieldName);
                        if (index == -1)
                        {
                            outError = new Exception("找不到字段名为" + fieldName + "的字段");
                            return;
                        }
                        if (pFeaCls.Fields.get_Field(index).IsNullable == true)
                        {
                            //字段属性为空,与标准不一致,将结果保存起来
                            List <object> ErrorLst = new List <object>();
                            ErrorLst.Add("要素属性检查");                                         //功能组名称
                            ErrorLst.Add("空值检查");                                           //功能名称
                            ErrorLst.Add((pFeatureDataset as IDataset).Workspace.PathName); //数据文件名
                            ErrorLst.Add(enumErrorType.空值检查.GetHashCode());                 //错误id;
                            ErrorLst.Add("图层" + item.Key + "的字段" + fieldName + "属性值不允许为空"); //错误描述
                            ErrorLst.Add(0);                                                //...
                            ErrorLst.Add(0);                                                //...
                            ErrorLst.Add(item.Key);
                            ErrorLst.Add(-1);
                            ErrorLst.Add("");
                            ErrorLst.Add(-1);
                            ErrorLst.Add(false);
                            ErrorLst.Add(System.DateTime.Now.ToString());

                            //传递错误日志
                            IDataErrInfo      dataErrInfo       = new DataErrInfo(ErrorLst);
                            DataErrTreatEvent dataErrTreatEvent = new DataErrTreatEvent(dataErrInfo);
                            DataErrTreat(hook.DataCheckParaSet as object, dataErrTreatEvent);
                        }
                        else
                        {
                            IFeatureCursor pFeaCusor = pFeaCls.Search(null, false);
                            if (pFeaCusor == null)
                            {
                                return;
                            }
                            IFeature pFeature = pFeaCusor.NextFeature();
                            if (pFeature == null)
                            {
                                continue;
                            }
                            while (pFeature != null)
                            {
                                object fieldValue = pFeature.get_Value(index);
                                if (fieldValue == null || fieldValue.ToString() == "")
                                {
                                    //字段值不能为空,将检查结果保存起来
                                    double pMapx  = 0.0;
                                    double pMapy  = 0.0;
                                    IPoint pPoint = new PointClass();
                                    if (pFeaCls.ShapeType != esriGeometryType.esriGeometryPoint)
                                    {
                                        pPoint = TopologyCheckClass.GetPointofFeature(pFeature);
                                    }
                                    else
                                    {
                                        pPoint = pFeature.Shape as IPoint;
                                    }
                                    pMapx = pPoint.X;
                                    pMapy = pPoint.Y;
                                    List <object> ErrorLst = new List <object>();
                                    ErrorLst.Add("要素属性检查");                                         //功能组名称
                                    ErrorLst.Add("空值检查");                                           //功能名称
                                    ErrorLst.Add((pFeatureDataset as IDataset).Workspace.PathName); //数据文件名
                                    ErrorLst.Add(enumErrorType.空值检查.GetHashCode());                 //错误id;
                                    ErrorLst.Add("图层" + item.Key + "的字段" + fieldName + "的值不能为空");   //错误描述
                                    ErrorLst.Add(pMapx);                                            //...
                                    ErrorLst.Add(pMapy);                                            //...
                                    ErrorLst.Add(item.Key);
                                    ErrorLst.Add(pFeature.OID);
                                    ErrorLst.Add("");
                                    ErrorLst.Add(-1);
                                    ErrorLst.Add(false);
                                    ErrorLst.Add(System.DateTime.Now.ToString());

                                    //传递错误日志
                                    IDataErrInfo      dataErrInfo       = new DataErrInfo(ErrorLst);
                                    DataErrTreatEvent dataErrTreatEvent = new DataErrTreatEvent(dataErrInfo);
                                    DataErrTreat(hook.DataCheckParaSet as object, dataErrTreatEvent);
                                }
                                pFeature = pFeaCusor.NextFeature();
                            }

                            //释放cursor
                            System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeaCusor);
                        }
                    }


                    //进度条加1
                    pValue++;
                    eInfo.Value = pValue;
                    GeoDataChecker.GeoDataChecker_ProgressShow((object)GeoDataChecker._ProgressBarInner, eInfo);
                }
            }
            catch (Exception ex)
            {
                outError = ex;
            }
        }