using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using ESRI.ArcGIS.Geodatabase; namespace Kingo.RuleCheck.XJRuleCheck { /// /// 数学基础规范性检查 /// public class SJJCCheck_DTB : RuleCheckBase_DTB { List ruleMethodNames = new List() { "JC001" //, "JC002", "JC003" }; public override List ExcuteCheck(string sourePath, IWorkspace workspace) { return this.StartCheck(sourePath, workspace, ruleMethodNames); } public override List ExcuteCheck(IWorkspace workspace, List layerNames, List dataSetNames) { return this.StartCheck(workspace, ruleMethodNames, layerNames, dataSetNames); } public override List ExcuteCheck(string sourePath, Dictionary workspace) { return this.StartCheck(sourePath, workspace, ruleMethodNames); } public override List ExcuteCheck(string tbbsm, string sourePath, Dictionary workspace) { return this.StartCheck(tbbsm, sourePath, workspace, ruleMethodNames); } /// /// 矢量图形平面坐标系检查 /// /// public List JC001() { List result = new List(); try { if (DicFeatureClass == null || !DicFeatureClass.ContainsKey("JC_DLTB") || DicFeatureClass["JC_DLTB"] == null) { throw new Exception("未找到“基础_地类图斑”层!"); //return result; } IFeatureClass featureClass = DicFeatureClass["JC_DLTB"]; string name = (featureClass as IGeoDataset).SpatialReference.Name.ToUpper(); if (!name.StartsWith("CGCS2000")) { result.Add(new RuleEntity() { ErrorId = "-1", CheckObject = "内业预处理、单图斑建库所有矢量图层", ErrorTip = $"【基础_地类图斑】坐标系错误,未采用2000国家大地坐标系", ErrorType = "一类错误", RuleCode = "JC001", RuleContent = "检查矢量数据是否采用2000 国家大地坐标系,若不是,认定为错误图斑。", RuleName = "矢量图形平面坐标系检查" }); } if (!name.Contains("GK") || !name.Contains("CGCS2000_3")) { result.Add(new RuleEntity() { ErrorId = "-1", CheckObject = "内业预处理、单图斑建库所有矢量图层", ErrorTip = $"【基础_地类图斑】投影方式错误,未采用高斯-克吕格投影,或按 3°分带", ErrorType = "一类错误", RuleCode = "JC003", RuleContent = "检查矢量数据是否采用高斯-克吕格投影,并按 3°分带,若不是,认定为错误图斑。", RuleName = "矢量图形投影方式检查" }); } //IWorkspace workspace = this.DicFeatureClass.FirstOrDefault(x => x.Key.Equals("DTBWorkspace")).Value as IWorkspace; //IEnumDataset enumDataset = workspace.Datasets[esriDatasetType.esriDTAny]; //if (enumDataset != null) //{ // IDataset dataset = null; // while ((dataset = enumDataset.Next()) != null) // { // IGeoDataset geoDataset = dataset as IGeoDataset; // if (geoDataset == null) // continue; // string name = geoDataset.SpatialReference.Name.ToUpper(); // if ((LayerNames != null && !LayerNames.Contains(dataset.Name)) || (DataSetNames != null && !DataSetNames.Contains(dataset.Name))) // { // break; // } // if (!name.StartsWith("CGCS2000")) // { // result.Add(new RuleEntity() // { // ErrorId = dataset.Name, // CheckObject = "内业预处理、单图斑建库所有矢量图层", // ErrorTip = $"【{dataset.Name}】坐标系错误,未采用2000国家大地坐标系", // ErrorType = "一类错误", // RuleCode = "JC001", // RuleContent = "检查矢量数据是否采用2000 国家大地坐标系,若不是,认定为错误图斑。", // RuleName = "矢量图形平面坐标系检查" // }); // } // //else if (!name.Contains("GK") || !name.Contains("CGCS2000_3")) // //{ // // result.Add(new RuleEntity() // // { // // ErrorId = dataset.Name, // // CheckObject = "内业预处理、单图斑建库所有矢量图层", // // ErrorTip = $"【{dataset.Name}】投影方式错误,未采用高斯-克吕格投影,或按 3°分带", // // ErrorType = "一类错误", // // RuleCode = "JC003", // // RuleContent = "检查矢量数据是否采用高斯-克吕格投影,并按 3°分带,若不是,认定为错误图斑。", // // RuleName = "矢量图形投影方式检查" // // }); // //} // } //} } catch (Exception ex) { RuleEntity ruleEntity = new RuleEntity() { ErrorId = this.TBBSM, CheckObject = "内业预处理、单图斑建库所有矢量图层", ErrorTip = $"【图层名称】坐标系错误,未采用2000国家大地坐标系规则检查失败:" + ex.Message, ErrorType = "一类错误", RuleCode = "JC001", RuleContent = "检查矢量数据是否采用2000 国家大地坐标系,若不是,认定为错误图斑。", RuleName = "矢量图形平面坐标系检查" }; result.Add(ruleEntity); } return result; } /// /// 矢量图形高程系统检查 /// /// public List JC002() { return null; } /// /// 矢量图形投影方式检查 /// /// //public List JC003() //{ // List result = new List(); // try // { // if (this.DicFeatureClass == null || !this.DicFeatureClass.ContainsKey("DTBWorkspace")) // { // return result; // } // IWorkspace workspace = this.DicFeatureClass.FirstOrDefault(x => x.Key.Equals("DTBWorkspace")).Value as IWorkspace; // IEnumDataset enumDataset = workspace.Datasets[esriDatasetType.esriDTAny]; // if (enumDataset != null) // { // IDataset dataset = null; // while ((dataset = enumDataset.Next()) != null) // { // IGeoDataset geoDataset = dataset as IGeoDataset; // if (geoDataset == null) // continue; // string name = geoDataset.SpatialReference.Name.ToUpper(); // if ((LayerNames != null && !LayerNames.Contains(dataset.Name)) || (DataSetNames != null && !DataSetNames.Contains(dataset.Name))) // { // break; // } // if (!name.Contains("GK") || !name.Contains("CGCS2000_3")) // { // result.Add(new RuleEntity() // { // ErrorId = dataset.Name, // CheckObject = "内业预处理、单图斑建库所有矢量图层", // ErrorTip = $"【{dataset.Name}】投影方式错误,未采用高斯-克吕格投影,或按 3°分带", // ErrorType = "一类错误", // RuleCode = "JC003", // RuleContent = "检查矢量数据是否采用高斯-克吕格投影,并按 3°分带,若不是,认定为错误图斑。", // RuleName = "矢量图形投影方式检查" // }); // } // } // } // } // catch (Exception ex) // { // RuleEntity ruleEntity = new RuleEntity() // { // ErrorId = this.TBBSM, // CheckObject = "内业预处理、单图斑建库所有矢量图层", // ErrorTip = $"【图层名称】坐标系错误,未采用2000国家大地坐标系规则检查失败:" + ex.Message, // ErrorType = "一类错误", // RuleCode = "JC003", // RuleContent = "检查矢量数据是否采用高斯-克吕格投影,并按 3°分带,若不是,认定为错误图斑。", // RuleName = "矢量图形投影方式检查" // }; // result.Add(ruleEntity); // } // return result; //} } }