年度变更建库软件5.0版本
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

175 lines
7.7 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ESRI.ArcGIS.Geodatabase;
namespace Kingo.RuleCheck
{
/// <summary>
/// 数学基础规范性检查
/// </summary>
public class SXJCCheck : RuleCheckBase
{
List<string> ruleMethodNames = new List<string>() { "JC001", "JC002", "JC003" };
public override List<RuleEntity> ExcuteCheck(string sourePath, IWorkspace workspace)
{
return this.StartCheck(sourePath, workspace, ruleMethodNames);
}
public override List<RuleEntity> ExcuteCheck(IWorkspace workspace, List<string> layerNames, List<string> dataSetNames)
{
return this.StartCheck(workspace, ruleMethodNames, layerNames, dataSetNames);
}
public override List<RuleEntity> ExcuteCheck(string sourePath, Dictionary<string, IWorkspace> workspace)
{
return this.StartCheck(sourePath, workspace, ruleMethodNames);
}
/// <summary>
/// 矢量图形平面坐标系检查
/// </summary>
/// <returns></returns>
public List<RuleEntity> JC001()
{
List<RuleEntity> result = new List<RuleEntity>();
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;
}
/// <summary>
/// 矢量图形高程系统检查
/// </summary>
/// <returns></returns>
public List<RuleEntity> JC002()
{
return null;
}
/// <summary>
/// 矢量图形投影方式检查
/// </summary>
/// <returns></returns>
public List<RuleEntity> JC003()
{
List<RuleEntity> result = new List<RuleEntity>();
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;
}
}
}