using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using ESRI.ArcGIS.Geodatabase; namespace Kingo.RuleCheck { /// /// 数学基础规范性检查 /// public class SXJCCheck : RuleCheckBase { 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 List JC001() { List result = new List(); try { if (this.Workspace == null) return null; IWorkspace workspace = this.Workspace 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 = "规则检查失败:" + ex.Message, CheckObject = "内业预处理、单图斑建库所有矢量图层", ErrorTip = $"【图层名称】坐标系错误,未采用2000国家大地坐标系", 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.Workspace == null) return null; IWorkspace workspace = this.Workspace 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 = "规则检查失败:" + ex.Message, CheckObject = "内业预处理、单图斑建库所有矢量图层", ErrorTip = $"【图层名称】坐标系错误,未采用2000国家大地坐标系", ErrorType = "一类错误", RuleCode = "JC003", RuleContent = "检查矢量数据是否采用高斯-克吕格投影,并按 3°分带,若不是,认定为错误图斑。", RuleName = "矢量图形投影方式检查" }; result.Add(ruleEntity); } return result; } } }