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.
1117 lines
65 KiB
1117 lines
65 KiB
using System; |
|
using System.Collections.Generic; |
|
using System.Linq; |
|
using System.Runtime.InteropServices; |
|
using System.Text.RegularExpressions; |
|
using System.Threading; |
|
using ESRI.ArcGIS.Geodatabase; |
|
using ESRI.ArcGIS.Geometry; |
|
using KGIS.Framework.AE.ExtensionMethod; |
|
using KGIS.Framework.DBOperator; |
|
using KGIS.Framework.Maps; |
|
using KGIS.Framework.Platform; |
|
using KGIS.Framework.Utils; |
|
using KGIS.Framework.Utils.ExtensionMethod; |
|
using Kingo.PluginServiceInterface; |
|
|
|
namespace Kingo.Plugin.DataCheck |
|
{ |
|
public class DLTBBGDataCheck : IDataCheckInterface |
|
{ |
|
//分类编号+规则编号+字段编号+错误类别 |
|
|
|
bool _inspectionCompleted = false; |
|
DLTBBGEntity dltbBGEntity = null; |
|
List<DataCheckResult> dataCheckResults = null; |
|
ProjectInfo projectInfo = null; |
|
private string AttributeErrorCode = "1001" + "0002"; |
|
private List<DataDicTionary> DLBMdataDic = null; |
|
private List<DataDicTionary> TBXHdataDic = null; |
|
private List<DataDicTionary> ZZSXdataDic = null; |
|
public bool inspectionCompleted |
|
{ |
|
get { return _inspectionCompleted; } |
|
set { InspectionCompleted(); } |
|
} |
|
public bool isMultithreading { get; set; } |
|
public event InspectionCompleted InspectionCompleted; |
|
public DLTBBGDataCheck() |
|
{ |
|
isMultithreading = false; |
|
} |
|
/// <summary> |
|
/// 单个Feature属性检查 |
|
/// </summary> |
|
/// <param name="ifeature"></param> |
|
/// <returns></returns> |
|
public List<DataCheckResult> AttributeCheck(IFeature ifeature) |
|
{ |
|
try |
|
{ |
|
dataCheckResults = new List<DataCheckResult>(); |
|
if (isMultithreading) |
|
{ |
|
Thread thread = new Thread(new ParameterizedThreadStart(ExecuteAttributeCheck)); |
|
thread.SetApartmentState(ApartmentState.STA); |
|
thread.Start(ifeature); |
|
} |
|
else |
|
{ |
|
ExecuteAttributeCheck(ifeature); |
|
} |
|
return dataCheckResults; |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug($"单个Feature属性检查异常:{ex.Message}"); |
|
throw ex; |
|
} |
|
} |
|
/// <summary> |
|
/// 单独图层属性检查 |
|
/// </summary> |
|
/// <param name="featureClass"></param> |
|
/// <returns></returns> |
|
public List<DataCheckResult> AttributeCheck(IFeatureClass featureClass) |
|
{ |
|
IFeature feature = null; |
|
IFeatureCursor featureCursor = null; |
|
try |
|
{ |
|
dataCheckResults = new List<DataCheckResult>(); |
|
if (featureClass != null) |
|
{ |
|
featureCursor = featureClass.Search(null, true); |
|
while ((feature = featureCursor.NextFeature()) != null) |
|
{ |
|
ExecuteAttributeCheck(feature); |
|
} |
|
} |
|
return dataCheckResults; |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug($"单独图层属性检查异常:{ex.Message}"); |
|
throw ex; |
|
} |
|
finally |
|
{ |
|
if (feature != null) |
|
Marshal.ReleaseComObject(feature); |
|
if (featureCursor != null) |
|
Marshal.ReleaseComObject(featureCursor); |
|
} |
|
} |
|
/// <summary> |
|
/// 单个Feature图形检查 |
|
/// </summary> |
|
/// <param name="ifeature"></param> |
|
/// <returns></returns> |
|
public List<DataCheckResult> GraphicCheck(IFeature ifeature) |
|
{ |
|
try |
|
{ |
|
dataCheckResults = new List<DataCheckResult>(); |
|
ExecuteGraphicCheck(ifeature); |
|
return dataCheckResults; |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug($"单个Feature图形检查异常:{ex.Message}"); |
|
throw ex; |
|
} |
|
} |
|
/// <summary> |
|
/// 单图层图形检查 |
|
/// </summary> |
|
/// <param name="featureClass"></param> |
|
/// <returns></returns> |
|
public List<DataCheckResult> GraphicCheck(IFeatureClass featureClass) |
|
{ |
|
IFeature feature = null; |
|
IFeatureCursor featureCursor = null; |
|
try |
|
{ |
|
dataCheckResults = new List<DataCheckResult>(); |
|
if (featureClass != null) |
|
{ |
|
featureCursor = featureClass.Search(null, true); |
|
while ((feature = featureCursor.NextFeature()) != null) |
|
{ |
|
ExecuteGraphicCheck(feature); |
|
} |
|
} |
|
return dataCheckResults; |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug($"单图层图形检查异常:{ex.Message}"); |
|
throw ex; |
|
} |
|
finally |
|
{ |
|
if (feature != null) |
|
Marshal.ReleaseComObject(feature); |
|
if (featureCursor != null) |
|
Marshal.ReleaseComObject(featureCursor); |
|
} |
|
} |
|
/// <summary> |
|
/// 图层间图形检查 |
|
/// </summary> |
|
/// <param name="FirstfeatureClass"></param> |
|
/// <param name="SecondfeatureClass"></param> |
|
/// <returns></returns> |
|
public List<DataCheckResult> GraphicCheck(IFeatureClass FirstfeatureClass, IFeatureClass SecondfeatureClass) |
|
{ |
|
//图层间逻辑性检查 |
|
throw new NotImplementedException(); |
|
} |
|
|
|
#region 属性检查 |
|
/// <summary> |
|
/// 属性检查 |
|
/// </summary> |
|
/// <param name="row"></param> |
|
/// <param name="pfeature"></param> |
|
/// <param name="featureLayer"></param> |
|
public void ExecuteAttributeCheck(object feature) |
|
{ |
|
List<string> liststr = null; |
|
List<string> dlbmliststr = null; |
|
try |
|
{ |
|
AssignmentEntity(feature as IFeature); |
|
DLBMdataDic = Platform.Instance.DicHelper.GetDic(DicTypeEnum.DLBM); |
|
TBXHdataDic = Platform.Instance.DicHelper.GetDic(DicTypeEnum.TBXHLX); |
|
ZZSXdataDic = Platform.Instance.DicHelper.GetDic(DicTypeEnum.ZZSX); |
|
projectInfo = (MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo); |
|
|
|
#region 1.1、地类图斑变更层DLBM和DLMC在第三次全国土地调查工作分类表(最末级分类)中有对应项且匹配。 |
|
if (string.IsNullOrWhiteSpace(dltbBGEntity.DLBM) || string.IsNullOrEmpty(dltbBGEntity.DLMC)) |
|
{ |
|
LogicCheck(true, "地类编码/地类名称不允许为空!", AttributeErrorCode + dltbBGEntity.iDLBM.ToString().PadLeft(4, '0') + "0001", dltbBGEntity.OBJECTID.ToString()); |
|
return; |
|
} |
|
if (DLBMdataDic != null) |
|
{ |
|
LogicCheck(DicFirstOrDefault(DLBMdataDic, dltbBGEntity.DLBM, dltbBGEntity.DLMC), "地类图斑变更层DLBM和DLMC在第三次全国土地调查工作分类表(最末级分类)中有对应项且匹配!", AttributeErrorCode + dltbBGEntity.iDLBM.ToString().PadLeft(4, '0') + "0001", dltbBGEntity.OBJECTID.ToString()); |
|
} |
|
#endregion |
|
|
|
#region 1.2、地类图斑变更层KCDLBM取值在1203、空范围内 |
|
LogicCheck(!string.IsNullOrEmpty(dltbBGEntity.KCDLBM) && dltbBGEntity.KCDLBM != "1203", "地类图斑变更层KCDLBM取值应在1203、空范围内!", AttributeErrorCode + dltbBGEntity.iKCDLBM.ToString().PadLeft(4, '0') + "0002", dltbBGEntity.OBJECTID.ToString()); |
|
#endregion |
|
|
|
#region 1.3、地类图斑变更层QSDWDM不能为空,长度为19位,必须为纯数值 |
|
LogicCheck(!Regex.IsMatch(dltbBGEntity.QSDWDM, "^\\d{19}$"), "地类图斑变更层QSDWDM不能为空,长度为19位,必须为纯数值!", AttributeErrorCode + dltbBGEntity.iQSDWDM.ToString().PadLeft(4, '0') + "0003", dltbBGEntity.OBJECTID.ToString()); |
|
#endregion |
|
|
|
#region 1.4地类图斑变更层ZLDWDM不能为空,长度为19位,必须为纯数值 |
|
LogicCheck(!Regex.IsMatch(dltbBGEntity.ZLDWDM, "^\\d{19}$"), "地类图斑变更层ZLDWDM不能为空,长度为19位,必须为纯数值!", AttributeErrorCode + dltbBGEntity.iZLDWDM.ToString().PadLeft(4, '0') + "0004", dltbBGEntity.OBJECTID.ToString()); |
|
#endregion |
|
|
|
#region 1.5、地类图斑变更层QSXZ字段取值规范性,不能为空。 |
|
LogicCheck(string.IsNullOrEmpty(dltbBGEntity.QSXZ), "地类图斑变更层QSXZ字段取值规范性,不能为空!", AttributeErrorCode + dltbBGEntity.iQSXZ.ToString().PadLeft(4, '0') + "0005", dltbBGEntity.OBJECTID.ToString()); |
|
#endregion |
|
|
|
#region 1.6、地类图斑变更层ZLDWDM前6位为县级行政区代码; |
|
LogicCheck(!string.IsNullOrEmpty(dltbBGEntity.ZLDWDM) && projectInfo.CODE != dltbBGEntity.ZLDWDM.Substring(0, 6), "地类图斑变更层ZLDWDM前6位为县级行政区代码!", AttributeErrorCode + dltbBGEntity.iZLDWDM.ToString().PadLeft(4, '0') + "0006", dltbBGEntity.OBJECTID.ToString()); |
|
#endregion |
|
|
|
#region 1.7、地类图斑变更层QSDWMC不能为空、不存在特殊字符 |
|
LogicCheck(string.IsNullOrEmpty(dltbBGEntity.QSDWMC) && !Regex.IsMatch(dltbBGEntity.QSDWMC, @"^[\u4e00-\u9fa5]+$"), "地类图斑变更层QSDWMC不能为空、不存在特殊字符!", AttributeErrorCode + dltbBGEntity.iQSDWMC.ToString().PadLeft(4, '0') + "0007", dltbBGEntity.OBJECTID.ToString()); |
|
#endregion |
|
|
|
#region 1.8、地类图斑变更层ZLDWMC不能为空、不存在特殊字符 |
|
LogicCheck(string.IsNullOrEmpty(dltbBGEntity.ZLDWMC) && !Regex.IsMatch(dltbBGEntity.ZLDWMC, @"^[\u4e00-\u9fa5]+$"), "地类图斑变更层ZLDWMC不能为空、不存在特殊字符!", AttributeErrorCode + dltbBGEntity.iZLDWMC.ToString().PadLeft(4, '0') + "0008", dltbBGEntity.OBJECTID.ToString()); |
|
#endregion |
|
|
|
#region 1.9、地类图斑变更层BZ字段为空; |
|
LogicCheck(!string.IsNullOrEmpty(dltbBGEntity.BZ), "地类图斑变更层BZ字段为须为空!", AttributeErrorCode + dltbBGEntity.iBZ.ToString().PadLeft(4, '0') + "0009", dltbBGEntity.OBJECTID.ToString()); |
|
#endregion |
|
|
|
#region 1.10、地类图斑变更层线状地物宽度字段小数位数检查,保留1位小数 |
|
LogicCheck(!Regex.IsMatch(dltbBGEntity.XZDWKD, "^[0-9]+(.[0-9]{1})?$"), "地类图斑变更层线状地物宽度字段小数位数检查,保留1位小数!", AttributeErrorCode + dltbBGEntity.iXZDWKD.ToString().PadLeft(4, '0') + "0010", dltbBGEntity.OBJECTID.ToString()); |
|
#endregion |
|
|
|
#region 1.11、地类图斑变更层FRDBS字段取值规范性,0或者1. |
|
LogicCheck(dltbBGEntity.FRDBS != "0" && dltbBGEntity.FRDBS != "1", "地类图斑变更层FRDBS字段取值规范性,0或者1!", AttributeErrorCode + dltbBGEntity.iFRDBS.ToString().PadLeft(4, '0') + "0011", dltbBGEntity.OBJECTID.ToString()); |
|
#endregion |
|
|
|
#region 1.12、地类图斑变更层MSSM字段取值为'00'或'01' |
|
LogicCheck(dltbBGEntity.MSSM != "00" && dltbBGEntity.MSSM != "01", "地类图斑变更层MSSM字段取值为00或01!", AttributeErrorCode + dltbBGEntity.iMSSM.ToString().PadLeft(4, '0') + "0012", dltbBGEntity.OBJECTID.ToString()); |
|
#endregion |
|
|
|
#region 2.1、地类图斑变更层TBXHMC与TBXHDM字段取值匹配; |
|
if (TBXHdataDic != null) |
|
{ |
|
LogicCheck(!string.IsNullOrEmpty(dltbBGEntity.TBXHMC) && !string.IsNullOrEmpty(dltbBGEntity.TBXHDM) && DicFirstOrDefault(TBXHdataDic, dltbBGEntity.TBXHDM, dltbBGEntity.TBXHMC), "地类图斑变更层TBXHMC与TBXHDM字段取值匹配!", AttributeErrorCode + dltbBGEntity.iTBXHDM.ToString().PadLeft(4, '0') + "0013", dltbBGEntity.OBJECTID.ToString()); |
|
} |
|
#endregion |
|
|
|
#region 2.2、地类图斑变更层DLBM字段前2位非01、02、03、04,且DLBM不在0601、0602、1001、1003取值范围内,或属于湿地的地类,不能进行图斑细化标注 |
|
liststr = new List<string>() { "01", "02", "03", "04", "0601", "0602", "1001", "1003", "0303", "0304", "0306", "0402", "0603", "1105", "1106", "1108" }; |
|
LogicCheck(!liststr.Contains(dltbBGEntity.DLBM.Substring(0, 2)) && !liststr.Contains(dltbBGEntity.DLBM) && (!string.IsNullOrEmpty(dltbBGEntity.TBXHDM) || !string.IsNullOrEmpty(dltbBGEntity.TBXHMC)), "地类图斑变更层DLBM字段前2位非01、02、03、04,且DLBM不在0601、0602、1001、1003取值范围内,或属于湿地的地类,不能进行图斑细化标注!", AttributeErrorCode + dltbBGEntity.iTBXHDM.ToString().PadLeft(4, '0') + "0014", dltbBGEntity.OBJECTID.ToString()); |
|
#endregion |
|
|
|
#region 2.3、地类图斑变更层工业用地,TBXHDM字段为HDGY、GTGY、MTGY、SNGY、BLGY、DLGY,或空值 |
|
liststr = new List<string>() { "HDGY", "GTGY", "MTGY", "SNGY", "BLGY", "DLGY" }; |
|
LogicCheck(dltbBGEntity.DLBM == "0601" && !liststr.Contains(dltbBGEntity.TBXHDM) && !string.IsNullOrEmpty(dltbBGEntity.TBXHDM), "地类图斑变更层工业用地(0601),TBXHDM字段为HDGY、GTGY、MTGY、SNGY、BLGY、DLGY,或空值!", AttributeErrorCode + dltbBGEntity.iTBXHDM.ToString().PadLeft(4, '0') + "0015", dltbBGEntity.OBJECTID.ToString()); |
|
#endregion |
|
|
|
#region 2.4、地类图斑变更层TBXHDM字段取值在HDGY、GTGY、MTGY、SNGY、BLGY、DLGY范围内时,DLBM等于0601 |
|
LogicCheck(dltbBGEntity.DLBM != "0601" && liststr.Contains(dltbBGEntity.TBXHDM), "地类图斑变更层TBXHDM字段取值在HDGY、GTGY、MTGY、SNGY、BLGY、DLGY范围内时,DLBM等于0601!", AttributeErrorCode + dltbBGEntity.iTBXHDM.ToString().PadLeft(4, '0') + "0016", dltbBGEntity.OBJECTID.ToString()); |
|
#endregion |
|
|
|
#region 2.5、地类图斑变更层DLBM为0602、1001、1003时,TBXHDM字段为FQ或空值 |
|
LogicCheck((dltbBGEntity.DLBM == "0602" || dltbBGEntity.DLBM == "1001" || dltbBGEntity.DLBM == "1003") && dltbBGEntity.TBXHDM != "FQ" && !string.IsNullOrEmpty(dltbBGEntity.TBXHDM), "地类图斑变更层DLBM为0602、1001、1003时,TBXHDM字段为FQ或空值!", AttributeErrorCode + dltbBGEntity.iTBXHDM.ToString().PadLeft(4, '0') + "0017", dltbBGEntity.OBJECTID.ToString()); |
|
#endregion |
|
|
|
#region 2.6、地类图斑变更层DLBM前2位为01时,TBXHDM字段取值在HDGD、HQGD、LQGD、MQGD、SHGD、SMGD、YJGD或空范围内 |
|
liststr = new List<string>() { "HDGD", "HQGD", "LQGD", "MQGD", "SHGD", "SMGD", "YJGD" }; |
|
LogicCheck(dltbBGEntity.DLBM.Substring(0, 2) == "01" && !liststr.Contains(dltbBGEntity.TBXHDM) && !string.IsNullOrEmpty(dltbBGEntity.TBXHDM), "地类图斑变更层DLBM前2位为01时,TBXHDM字段取值在HDGD、HQGD、LQGD、MQGD、SHGD、SMGD、YJGD或空范围内!", AttributeErrorCode + dltbBGEntity.iTBXHDM.ToString().PadLeft(4, '0') + "0018", dltbBGEntity.OBJECTID.ToString()); |
|
#endregion |
|
|
|
#region 2.7、地类图斑变更层TBXHDM字段取值在HDGD、HQGD、LQGD、MQGD、SHGD、SMGD、YJGD范围内时,DLBM前2位为01 |
|
LogicCheck(dltbBGEntity.DLBM.Substring(0, 2) != "01" && liststr.Contains(dltbBGEntity.TBXHDM), "地类图斑变更层TBXHDM字段取值在HDGD、HQGD、LQGD、MQGD、SHGD、SMGD、YJGD范围内时,DLBM前2位为01!", AttributeErrorCode + dltbBGEntity.iTBXHDM.ToString().PadLeft(4, '0') + "0019", dltbBGEntity.OBJECTID.ToString()); |
|
#endregion |
|
|
|
#region 2.8、地类图斑变更层DLBM前2位为04时(不含0404),TBXHDM取值在GCCD、空范围内 |
|
LogicCheck(dltbBGEntity.DLBM.Substring(0, 2) == "04" && dltbBGEntity.DLBM != "0404" && dltbBGEntity.TBXHDM != "GCCD" && string.IsNullOrEmpty(dltbBGEntity.TBXHDM), "地类图斑变更层DLBM前2位为04时(不含0404),TBXHDM取值在GCCD、空范围内!", AttributeErrorCode + dltbBGEntity.iTBXHDM.ToString().PadLeft(4, '0') + "0020", dltbBGEntity.OBJECTID.ToString()); |
|
#endregion |
|
|
|
#region 2.9、地类图斑变更层DLBM为0404时,TBXHDM取值在LJTM、GCCD、空范围内 |
|
LogicCheck(dltbBGEntity.DLBM == "0404" && !string.IsNullOrEmpty(dltbBGEntity.TBXHDM) && dltbBGEntity.TBXHDM != "LJTM" && dltbBGEntity.TBXHDM != "GCCD", "地类图斑变更层DLBM为0404时,TBXHDM取值在LJTM、GCCD、空范围内!", AttributeErrorCode + dltbBGEntity.iTBXHDM.ToString().PadLeft(4, '0') + "0021", dltbBGEntity.OBJECTID.ToString()); |
|
#endregion |
|
|
|
#region 2.10、地类图斑变更层DLBM前2位为03时,TBXHDM取值在LJTM、空范围内 |
|
LogicCheck(dltbBGEntity.DLBM.Substring(0, 2) == "03" && !string.IsNullOrEmpty(dltbBGEntity.TBXHDM) && dltbBGEntity.TBXHDM != "LJTM", "地类图斑变更层DLBM前2位为03时,TBXHDM取值在LJTM、空范围内!", AttributeErrorCode + dltbBGEntity.iTBXHDM.ToString().PadLeft(4, '0') + "0022", dltbBGEntity.OBJECTID.ToString()); |
|
#endregion |
|
|
|
#region 2.11地类图斑变更层DLBM前2位为02时,TBXHDM取值在LQYD、空范围内 |
|
LogicCheck(dltbBGEntity.DLBM.Substring(0, 2) == "02" && !string.IsNullOrEmpty(dltbBGEntity.TBXHDM) && dltbBGEntity.TBXHDM != "LQYD", "地类图斑变更层DLBM前2位为02时,TBXHDM取值在LQYD、空范围内!", AttributeErrorCode + dltbBGEntity.iTBXHDM.ToString().PadLeft(4, '0') + "0023", dltbBGEntity.OBJECTID.ToString()); |
|
#endregion |
|
|
|
#region 3.1、地类图斑变更层DLBM前2位为01时,ZZSXDM取值在LS、FLS、LYFL、XG、LLJZ、WG范围内 |
|
liststr = new List<string>() { "LS", "FLS", "LYFL", "XG", "LLJZ", "WG" }; |
|
LogicCheck(dltbBGEntity.DLBM.Substring(0, 2) == "01" && !liststr.Contains(dltbBGEntity.ZZSXDM.ToTrim()), "地类图斑变更层DLBM前2位为01时,ZZSXDM取值在LS、FLS、LYFL、XG、LLJZ、WG范围内!", AttributeErrorCode + dltbBGEntity.iZZSXDM.ToString().PadLeft(4, '0') + "0024", dltbBGEntity.OBJECTID.ToString()); |
|
#endregion |
|
|
|
#region 3.2、地类图斑变更层ZZSXMC与ZZSXDM字段取值匹配; |
|
if (ZZSXdataDic != null) |
|
{ |
|
LogicCheck(!string.IsNullOrEmpty(dltbBGEntity.ZZSXMC) && !string.IsNullOrEmpty(dltbBGEntity.ZZSXDM) && DicFirstOrDefault(ZZSXdataDic, dltbBGEntity.ZZSXDM.ToTrim(), dltbBGEntity.ZZSXMC), "地类图斑变更层ZZSXMC与ZZSXDM字段取值匹配!", AttributeErrorCode + dltbBGEntity.iZZSXDM.ToString().PadLeft(4, '0') + "0025", dltbBGEntity.OBJECTID.ToString()); |
|
} |
|
#endregion |
|
|
|
#region 3.3、地类图斑变更层DLBM为0301、0302、0305、0307、0404、1104、1104A时,ZZSXDM取值在JKHF、GCHF、空范围内 |
|
dlbmliststr = new List<string>() { "0301", "0302", "0305", "0307", "0404", "1104", "1104A" }; |
|
liststr = new List<string>() { "JKHF", "GCHF" }; |
|
LogicCheck(dlbmliststr.Contains(dltbBGEntity.DLBM) && !liststr.Contains(dltbBGEntity.ZZSXDM.ToTrim()) && !string.IsNullOrEmpty(dltbBGEntity.ZZSXDM), "地类图斑变更层DLBM为0301、0302、0305、0307、0404、1104、1104A时,ZZSXDM取值在JKHF、GCHF、空范围内!", AttributeErrorCode + dltbBGEntity.iZZSXDM.ToString().PadLeft(4, '0') + "0026", dltbBGEntity.OBJECTID.ToString()); |
|
#endregion |
|
|
|
#region 3.4、地类图斑变更层DLBM为0201、0202、0203、0204,且TBXHDM为空时,ZZSXDM取值在JKHF、GCHF、空范围内 |
|
dlbmliststr = new List<string>() { "0201", "0202", "0203", "0204" }; |
|
liststr = new List<string>() { "JKHF", "GCHF" }; |
|
LogicCheck(dlbmliststr.Contains(dltbBGEntity.DLBM) && string.IsNullOrEmpty(dltbBGEntity.TBXHDM) && !liststr.Contains(dltbBGEntity.ZZSXDM.ToTrim()) && !string.IsNullOrEmpty(dltbBGEntity.ZZSXDM), "地类图斑变更层DLBM为0201、0202、0203、0204,且TBXHDM为空时,ZZSXDM取值在JKHF、GCHF、空范围内!", AttributeErrorCode + dltbBGEntity.iZZSXDM.ToString().PadLeft(4, '0') + "0027", dltbBGEntity.OBJECTID.ToString()); |
|
#endregion |
|
|
|
#region 3.5、地类图斑变更层DLBM前2位为04(不包括0404、0403K)、05、06、07、08、09、10、11(不包括1104、1104A、1104K)、12,或属于湿地的,不允许填写种植属性代码 |
|
liststr = new List<string>() { "04", "05", "06", "07", "08", "09", "10", "11", "12", "0303", "0304", "0306", "0402", "0603", "1105", "1106", "1108" }; |
|
var liststr1 = new List<string>() { "0404", "0403K", "1104", "1104A", "1104K" }; |
|
LogicCheck((liststr.Contains(dltbBGEntity.DLBM.Substring(0, 2)) || liststr.Contains(dltbBGEntity.DLBM)) && !liststr1.Contains(dltbBGEntity.DLBM) && !string.IsNullOrEmpty(dltbBGEntity.ZZSXDM), "地类图斑变更层DLBM前2位为04(不包括0404、0403K)、05、06、07、08、09、10、11(不包括1104、1104A、1104K)、12,或属于湿地的,不允许填写种植属性代码!", AttributeErrorCode + dltbBGEntity.iZZSXDM.ToString().PadLeft(4, '0') + "0028", dltbBGEntity.OBJECTID.ToString()); |
|
#endregion |
|
|
|
#region 3.6、地类图斑变更层地类为0201、0202、0203、0204,且标注林区种植园用地的不能标注种植属性 |
|
dlbmliststr = new List<string>() { "0201", "0202", "0203", "0204" }; |
|
LogicCheck(dlbmliststr.Contains(dltbBGEntity.DLBM) && dltbBGEntity.TBXHDM == "LQYD" && string.IsNullOrEmpty(dltbBGEntity.ZZSXDM), "地类图斑变更层地类为0201、0202、0203、0204,且标注林区种植园用地的不能标注种植属性!", AttributeErrorCode + dltbBGEntity.iZZSXDM.ToString().PadLeft(4, '0') + "0029", dltbBGEntity.OBJECTID.ToString()); |
|
#endregion |
|
|
|
#region 3.7、地类图斑变更层DLBM为0201K、0202K、0203K、0204K、0301K、0302K、0307K、0403K、1104K时,ZZSXDM取值在JKHF、GCHF、空范围内 |
|
dlbmliststr = new List<string>() { "0201K", "0202K", "0203K", "0204K", "0301K", "0302K", "0307K", "0403K", "1104K" }; |
|
liststr = new List<string>() { "JKHF", "GCHF" }; |
|
LogicCheck(dlbmliststr.Contains(dltbBGEntity.DLBM) && !liststr.Contains(dltbBGEntity.ZZSXDM.ToTrim()) && !string.IsNullOrEmpty(dltbBGEntity.ZZSXDM), "地类图斑变更层DLBM为0201K、0202K、0203K、0204K、0301K、0302K、0307K、0403K、1104K时,ZZSXDM取值在JKHF、GCHF、空范围内!", AttributeErrorCode + dltbBGEntity.iZZSXDM.ToString().PadLeft(4, '0') + "0030", dltbBGEntity.OBJECTID.ToString()); |
|
#endregion |
|
|
|
#region 4.1、地类图斑变更层权属性质为21或41,描述说明为海岛 |
|
LogicCheck((dltbBGEntity.QSXZ == "21" || dltbBGEntity.QSXZ == "41") && dltbBGEntity.MSSM != "海岛", "地类图斑变更层权属性质为21或41,描述说明为海岛!", AttributeErrorCode + dltbBGEntity.iMSSM.ToString().PadLeft(4, '0') + "0031", dltbBGEntity.OBJECTID.ToString()); |
|
#endregion |
|
|
|
#region 4.2、地类图斑变更层权属和坐落属于同一区县的国有土地飞入地标识不能为1; |
|
LogicCheck(!string.IsNullOrEmpty(dltbBGEntity.QSDWDM) && !string.IsNullOrEmpty(dltbBGEntity.ZLDWDM) && dltbBGEntity.QSDWDM.Substring(0, 6) == dltbBGEntity.ZLDWDM.Substring(0, 6) && (dltbBGEntity.QSXZ == "10" || dltbBGEntity.QSXZ == "20") && dltbBGEntity.FRDBS == "1", "地类图斑变更层权属和坐落属于同一区县的国有土地飞入地标识不能为1!", AttributeErrorCode + dltbBGEntity.iFRDBS.ToString().PadLeft(4, '0') + "0032", dltbBGEntity.OBJECTID.ToString()); |
|
#endregion |
|
|
|
#region 4.3、地类图斑变更层FRDBS字段值为1时,ZLDWDM前12位与QSDWDM前12位不一致 |
|
LogicCheck(!string.IsNullOrEmpty(dltbBGEntity.QSDWDM) && !string.IsNullOrEmpty(dltbBGEntity.ZLDWDM) && dltbBGEntity.QSDWDM.Substring(0, 12) == dltbBGEntity.ZLDWDM.Substring(0, 12) && dltbBGEntity.FRDBS == "1", "地类图斑变更层FRDBS字段值为1时,ZLDWDM前12位与QSDWDM前12位不一致!", AttributeErrorCode + dltbBGEntity.iZLDWDM.ToString().PadLeft(4, '0') + "0033", dltbBGEntity.OBJECTID.ToString()); |
|
#endregion |
|
|
|
#region 5.1、地类图斑变更层CZCSXM字段取值为201A、202A、203A时,DLBM字段取值为0601 |
|
liststr = new List<string>() { "201A", "202A", "203A" }; |
|
LogicCheck(liststr.Contains(dltbBGEntity.CZCSXM) && dltbBGEntity.DLBM != "0601", "地类图斑变更层CZCSXM字段取值为201A、202A、203A时,DLBM字段取值为0601!", AttributeErrorCode + dltbBGEntity.iCZCSXM.ToString().PadLeft(4, '0') + "0034", dltbBGEntity.OBJECTID.ToString()); |
|
#endregion |
|
|
|
#region 5.2、地类图斑变更层建设用地(05H1、0508、0602、0603、0701、0702、08H1、08H2、08H2A、0809、0810、0810A、09、1004、1005、1201),CZCSXM取值在201、202、203、204、205范围内,不允许为空 |
|
dlbmliststr = new List<string>() { "05H1", "0508", "0602", "0603", "0701", "0702", "08H1", "08H2", "08H2A", "0809", "0810", "0810A", "09", "1004", "1005", "1201" }; |
|
LogicCheck(dlbmliststr.Contains(dltbBGEntity.DLBM) && string.IsNullOrEmpty(dltbBGEntity.CZCSXM), "地类图斑变更层建设用地(05H1、0508、0602、0603、0701、0702、08H1、08H2、08H2A、0809、0810、0810A、09、1004、1005、1201),CZCSXM取值在201、202、203、204、205范围内,不允许为空!", AttributeErrorCode + dltbBGEntity.iCZCSXM.ToString().PadLeft(4, '0') + "0035", dltbBGEntity.OBJECTID.ToString()); |
|
#endregion |
|
|
|
#region 5.3、地类图斑变更层工业用地0601,CZCSXM字段取值在201、202、203、201A、202A、203A、204、205范围内 |
|
liststr = new List<string>() { "201", "202", "203", "204", "205", "201A", "202A", "203A" }; |
|
LogicCheck(dltbBGEntity.DLBM == "0601" && !liststr.Contains(dltbBGEntity.CZCSXM), "地类图斑变更层工业用地0601,CZCSXM字段取值在201、202、203、201A、202A、203A、204、205范围内!", AttributeErrorCode + dltbBGEntity.iCZCSXM.ToString().PadLeft(4, '0') + "0036", dltbBGEntity.OBJECTID.ToString()); |
|
#endregion |
|
|
|
#region 5.4、地类图斑变更层非建设用地、交通运输用地(1001, 1002, 1003, 1006, 1007, 1008, 1009)、水工建筑用地(1109),CZCSXM字段取值在201、202、203、204、205范围内,或取值为空 |
|
dlbmliststr = new List<string>() { "1001", "1002", "1003", "1006", "1007", "1008", "1009", "1109" }; |
|
liststr = new List<string>() { "201", "202", "203", "204", "205" }; |
|
LogicCheck(dlbmliststr.Contains(dltbBGEntity.DLBM) && !liststr.Contains(dltbBGEntity.CZCSXM) && !string.IsNullOrEmpty(dltbBGEntity.CZCSXM), "地类图斑变更层非建设用地、交通运输用地(1001, 1002, 1003, 1006, 1007, 1008, 1009)、水工建筑用地(1109),CZCSXM字段取值在201、202、203、204、205范围内,或取值为空!", AttributeErrorCode + dltbBGEntity.iCZCSXM.ToString().PadLeft(4, '0') + "0037", dltbBGEntity.OBJECTID.ToString()); |
|
#endregion |
|
|
|
#region 5.5、地类图斑变更层要素的城镇村属性码,应与其所在城镇村等用地范围的城镇村等用地类型一致 |
|
|
|
#endregion |
|
|
|
#region 5.6、地类图斑变更层非建设用地不在城镇村等用地范围内的要素,城镇村属性码应为空 |
|
|
|
#endregion |
|
|
|
#region 7.1、地类图斑变更层DLBM前2位非01时,GDLX为空 |
|
LogicCheck(dltbBGEntity.DLBM.Substring(0, 2) != "01" && !string.IsNullOrEmpty(dltbBGEntity.GDLX), "地类图斑变更层DLBM前2位非01时,GDLX为空!", AttributeErrorCode + dltbBGEntity.iGDLX.ToString().PadLeft(4, '0') + "0038", dltbBGEntity.OBJECTID.ToString()); |
|
#endregion |
|
|
|
#region 7.2、地类图斑变更层DLBM前2位非01时,GDPDJB为空 |
|
LogicCheck(dltbBGEntity.DLBM.Substring(0, 2) != "01" && !string.IsNullOrEmpty(dltbBGEntity.GDPDJB), "地类图斑变更层DLBM前2位非01时,GDLX为空!", AttributeErrorCode + dltbBGEntity.iGDPDJB.ToString().PadLeft(4, '0') + "0039", dltbBGEntity.OBJECTID.ToString()); |
|
#endregion |
|
|
|
#region 7.3、地类图斑变更层DLBM前2位非01时,KCXS等于0 |
|
LogicCheck(dltbBGEntity.DLBM.Substring(0, 2) != "01" && !string.IsNullOrEmpty(dltbBGEntity.KCXS) && Convert.ToDouble(dltbBGEntity.KCXS) != 0, "地类图斑变更层DLBM前2位非01时,KCXS等于0!", AttributeErrorCode + dltbBGEntity.iKCXS.ToString().PadLeft(4, '0') + "0040", dltbBGEntity.OBJECTID.ToString()); |
|
#endregion |
|
|
|
#region 7.4、地类图斑变更层扣除系数(KCXS)与省级提交田坎系数表一致性检查 |
|
|
|
#endregion |
|
|
|
#region 7.5、地类图斑变更层DLBM前2位非01时,GDDB字段取值为空 |
|
LogicCheck(dltbBGEntity.DLBM.Substring(0, 2) != "01" && !string.IsNullOrEmpty(dltbBGEntity.GDDB), "地类图斑变更层DLBM前2位非01时,KCXS等于0!", AttributeErrorCode + dltbBGEntity.iGDDB.ToString().PadLeft(4, '0') + "0041", dltbBGEntity.OBJECTID.ToString()); |
|
#endregion |
|
|
|
#region 8.1、地类图斑变更层铁路、公路、管道用地、农村道路和沟渠等线形地物,线状图斑宽度XZDWKD大于0 |
|
dlbmliststr = new List<string>() { "1001", "1002", "1003", "1006", "1007", "1008", "1009", "1109", "1107", "1107A" }; |
|
LogicCheck(dlbmliststr.Contains(dltbBGEntity.DLBM) && (string.IsNullOrEmpty(dltbBGEntity.XZDWKD) || Convert.ToDouble(dltbBGEntity.XZDWKD) < 0), "地类图斑变更层铁路、公路、管道用地、农村道路和沟渠等线形地物,线状图斑宽度XZDWKD大于0!", AttributeErrorCode + dltbBGEntity.iXZDWKD.ToString().PadLeft(4, '0') + "0042", dltbBGEntity.OBJECTID.ToString()); |
|
#endregion |
|
|
|
#region 8.2、地类图斑变更层非河流、铁路、公路、管道用地、农村道路和沟渠等线形地物,线状图斑宽度XZDWKD等于0,允许为空 |
|
dlbmliststr = new List<string>() { "1001", "1002", "1003", "1006", "1007", "1008", "1009", "1109", "1107", "1107A", "1101" }; |
|
LogicCheck(!dlbmliststr.Contains(dltbBGEntity.DLBM) && !string.IsNullOrEmpty(dltbBGEntity.XZDWKD) && Convert.ToDouble(dltbBGEntity.XZDWKD) > 0, "地类图斑变更层非河流、铁路、公路、管道用地、农村道路和沟渠等线形地物,线状图斑宽度XZDWKD等于0,允许为空!", AttributeErrorCode + dltbBGEntity.iXZDWKD.ToString().PadLeft(4, '0') + "0043", dltbBGEntity.OBJECTID.ToString()); |
|
#endregion |
|
|
|
#region 不存在碎片多边形(要求面积大于30平方米),不检查以下地类'1001','1002','1003','1004','1006','1009','1101','1107','1107A','1203' |
|
//1、不存在碎片多边形(要求面积大于30平方米),不检查以下地类'1001','1002','1003','1004','1006','1009','1101','1107','1107A','1203' |
|
dlbmliststr = new List<string>() { "1001", "1002", "1003", "1004", "1006", "1009", "1101", "1107", "1107A", "1203" }; |
|
LogicCheck(!dlbmliststr.Contains(dltbBGEntity.DLBM) && Convert.ToDecimal(dltbBGEntity.SHAPE_Area) < 30, "存在碎片多边形(要求面积大于30平方米)不检查以下地'1001','1002','1003','1004','1006','1009','1101','1107','1107A','1203'!", AttributeErrorCode + dltbBGEntity.iTBXHDM.ToString().PadLeft(4, '0') + "0010", dltbBGEntity.OBJECTID.ToString()); |
|
#endregion |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug("DLTBBG属性检查失败信息:" + ex.Message); |
|
throw ex; |
|
} |
|
} |
|
/// <summary> |
|
/// 保存检查结果到DB文件 |
|
/// </summary> |
|
private void SaveCheckResultForDB(string ErrorCode, int OBJECTID) |
|
{ |
|
string dbPath = string.Empty; |
|
try |
|
{ |
|
dbPath = System.IO.Path.Combine(projectInfo.ProjDir, "DataCheckrResult.db"); |
|
SQLiteDBOperate.Instance.ExecuteNonQuery(dbPath, $"CREATE TABLE IF NOT exists DataCheckResults (`ID` INTEGER, `ErrorLayer` TEXT,`PrimaryKey` TEXT, `PrimaryKeyValue` TEXT,`PrimaryKey2` TEXT, `PrimaryKeyValue2` TEXT,`ErrorType` TEXT,`ErrorCode` TEXT,`ErrorDesc` TEXT,`ErrorData` TEXT,`ErrorArea` TEXT,`ErrorMJ` NUMERIC,PRIMARY KEY(`ID`))", null); |
|
if (OBJECTID > 0) |
|
{ |
|
SQLiteDBOperate.Instance.ExecuteNonQuery(dbPath, $"delete from DataCheckResults WHERE PrimaryKeyValue='{OBJECTID}' and ErrorCode like '{ErrorCode}%' ;", null);//删除当前数据相关的核查结果 |
|
} |
|
else |
|
{ |
|
SQLiteDBOperate.Instance.ExecuteNonQuery(dbPath, $"delete from DataCheckResults WHERE ErrorCode like '{ErrorCode}%' ;", null);//删除当前数据相关的核查结果 |
|
} |
|
List<string> sqlList = new List<string>(); |
|
foreach (var item in dataCheckResults) |
|
{ |
|
sqlList.Add(string.Format("INSERT INTO DataCheckResults (ErrorLayer,PrimaryKey, PrimaryKeyValue,PrimaryKey2, PrimaryKeyValue2,ErrorType,ErrorCode,ErrorDesc,ErrorData,ErrorArea,ErrorMJ) values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}',{10})", item.ErrorLayer, item.PrimaryKey, item.PrimaryKeyValue, item.PrimaryKey2, item.PrimaryKeyValue2, item.ErrorType, item.ErrorCode, item.ErrorDesc, item.ErrorData, item.ErrorArea, item.ErrorMJ)); |
|
} |
|
InsertSQLiteData(dbPath, sqlList); |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug("批量插入SQLite数据(地址:" + dbPath + ") 执行失败,异常原因: " + ex.Message + " ; "); |
|
throw ex; |
|
} |
|
} |
|
private void InsertSQLiteData(string dbPath, List<string> sqlList) |
|
{ |
|
try |
|
{ |
|
using (System.Data.SQLite.SQLiteConnection conn = new System.Data.SQLite.SQLiteConnection("Data Source=" + dbPath)) |
|
{ |
|
conn.Open(); |
|
using (System.Data.SQLite.SQLiteTransaction pTrans = conn.BeginTransaction()) |
|
{ |
|
using (System.Data.SQLite.SQLiteCommand cmd = new System.Data.SQLite.SQLiteCommand(conn)) |
|
{ |
|
for (int i = 0; i < sqlList.Count(); i++) |
|
{ |
|
cmd.CommandText = sqlList[i]; |
|
cmd.ExecuteNonQuery(); |
|
} |
|
pTrans.Commit(); |
|
} |
|
} |
|
conn.Close(); |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug("批量插入SQLite数据(地址:" + dbPath + ") 执行失败,异常原因: " + ex.Message + " ; "); |
|
return; |
|
} |
|
} |
|
#endregion |
|
|
|
#region 图形检查 |
|
public void ExecuteGraphicCheck(object feature) |
|
{ |
|
try |
|
{ |
|
if (dltbBGEntity == null) |
|
AssignmentEntity(feature as IFeature); |
|
int oid = dltbBGEntity.feature.OID; |
|
//2、不存在不规则图斑(除地类1001、1002、1006、1009、1107、1109外,其余地类满足面积 / 周长 < 0.2,并且有一个角度小于20) |
|
//自相交/多部件 |
|
List<DataCheckResult> liststr = CheckGeometry(dltbBGEntity.feature); |
|
if (liststr != null && liststr.Count > 0) |
|
{ |
|
dataCheckResults.AddRange(liststr); |
|
} |
|
//3、地类图斑变更层要素所有角度均应大于10度,同时不存在局部狭长图形 |
|
liststr = AcuteAngle(dltbBGEntity.feature); |
|
if (liststr.Count > 0) |
|
{ |
|
dataCheckResults.AddRange(liststr); |
|
} |
|
//4、地类图斑变更层平均节点密度大于1米小于70米 |
|
DataCheckResult result = PointToPoint(dltbBGEntity.feature); |
|
if (result != null) |
|
{ |
|
dataCheckResults.Add(result); |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug("变更数据检查异常:" + ex.Message); |
|
LogAPI.Debug(ex); |
|
} |
|
} |
|
#endregion |
|
|
|
private void AssignmentEntity(IFeature feature) |
|
{ |
|
dltbBGEntity = new DLTBBGEntity(); |
|
try |
|
{ |
|
if (feature != null) |
|
{ |
|
dltbBGEntity.OBJECTID = feature.OID; |
|
int iDLBM = feature.Fields.FindField("DLBM"); |
|
int iDLMC = feature.Fields.FindField("DLMC"); |
|
int iQSDWDM = feature.Fields.FindField("QSDWDM"); |
|
int iQSDWMC = feature.Fields.FindField("QSDWMC"); |
|
int iZLDWDM = feature.Fields.FindField("ZLDWDM"); |
|
int iZLDWMC = feature.Fields.FindField("ZLDWMC"); |
|
int iGDLX = feature.Fields.FindField("GDLX"); |
|
int iGDPDJB = feature.Fields.FindField("GDPDJB"); |
|
int iTBXHDM = feature.Fields.FindField("TBXHDM"); |
|
int iTBXHMC = feature.Fields.FindField("TBXHMC"); |
|
int iZZSXDM = feature.Fields.FindField("ZZSXDM"); |
|
int iZZSXMC = feature.Fields.FindField("ZZSXMC"); |
|
int iKCDLBM = feature.Fields.FindField("KCDLBM"); |
|
int iQSXZ = feature.Fields.FindField("QSXZ"); |
|
int iBZ = feature.Fields.FindField("BZ"); |
|
int iXZDWKD = feature.Fields.FindField("XZDWKD"); |
|
int iFRDBS = feature.Fields.FindField("FRDBS"); |
|
int iMSSM = feature.Fields.FindField("MSSM"); |
|
int iCZCSXM = feature.Fields.FindField("CZCSXM"); |
|
int iKCXS = feature.Fields.FindField("KCXS"); |
|
int iGDDB = feature.Fields.FindField("GDDB"); |
|
int iSHAPE_Area = feature.Fields.FindField("SHAPE_Area"); |
|
dltbBGEntity.iDLBM = iDLBM; |
|
dltbBGEntity.iDLMC = iDLMC; |
|
dltbBGEntity.iQSDWDM = iQSDWDM; |
|
dltbBGEntity.iQSDWMC = iQSDWMC; |
|
dltbBGEntity.iZLDWDM = iZLDWDM; |
|
dltbBGEntity.iZLDWMC = iZLDWMC; |
|
dltbBGEntity.iGDLX = iGDLX; |
|
dltbBGEntity.iGDPDJB = iGDPDJB; |
|
dltbBGEntity.iTBXHDM = iTBXHDM; |
|
dltbBGEntity.iTBXHMC = iTBXHMC; |
|
dltbBGEntity.iZZSXDM = iZZSXDM; |
|
dltbBGEntity.iZZSXMC = iZZSXMC; |
|
dltbBGEntity.iKCDLBM = iKCDLBM; |
|
dltbBGEntity.iQSXZ = iQSXZ; |
|
dltbBGEntity.iBZ = iBZ; |
|
dltbBGEntity.iXZDWKD = iXZDWKD; |
|
dltbBGEntity.iFRDBS = iFRDBS; |
|
dltbBGEntity.iMSSM = iMSSM; |
|
dltbBGEntity.iCZCSXM = iCZCSXM; |
|
dltbBGEntity.iKCXS = iKCXS; |
|
dltbBGEntity.iGDDB = iGDDB; |
|
dltbBGEntity.iSHAPE_Area = iSHAPE_Area; |
|
|
|
dltbBGEntity.DLBM = feature.Value[iDLBM].ToString();//地类编码 |
|
dltbBGEntity.DLMC = feature.Value[iDLMC].ToString();//地类名称 |
|
dltbBGEntity.QSDWDM = feature.Value[iQSDWDM].ToString();//权属单位代码 |
|
dltbBGEntity.QSDWMC = feature.Value[iQSDWMC].ToString();//权属单位名称 |
|
dltbBGEntity.ZLDWDM = feature.Value[iZLDWDM].ToString();//坐落单位代码 |
|
dltbBGEntity.ZLDWMC = feature.Value[iZLDWMC].ToString();//坐落单位名称 |
|
dltbBGEntity.GDLX = feature.Value[iGDLX].ToString();//耕地类型 |
|
dltbBGEntity.GDPDJB = feature.Value[iGDPDJB].ToString();//耕地坡度级别 |
|
dltbBGEntity.TBXHDM = feature.Value[iTBXHDM].ToString();//图斑细化代码 |
|
dltbBGEntity.TBXHMC = feature.Value[iTBXHMC].ToString();//图斑细化代码 |
|
dltbBGEntity.ZZSXDM = feature.Value[iZZSXDM].ToString();//种植属性代码 |
|
dltbBGEntity.ZZSXMC = feature.Value[iZZSXMC].ToString();//种植属性名称 |
|
dltbBGEntity.KCDLBM = feature.Value[iKCDLBM].ToString();//扣除地类编码 |
|
dltbBGEntity.QSXZ = feature.Value[iQSXZ].ToString();//权属性质 |
|
dltbBGEntity.BZ = feature.Value[iBZ].ToString();//备注 |
|
dltbBGEntity.XZDWKD = feature.Value[iXZDWKD].ToString();//线状地物宽度 |
|
dltbBGEntity.FRDBS = feature.Value[iFRDBS].ToString();//飞入地标识 |
|
dltbBGEntity.MSSM = feature.Value[iMSSM].ToString();//描述说明 |
|
dltbBGEntity.CZCSXM = feature.Value[iCZCSXM].ToString();//城镇村属性码 |
|
dltbBGEntity.KCXS = feature.Value[iKCXS].ToString();//扣除系数 |
|
dltbBGEntity.GDDB = feature.Value[iGDDB].ToString();//扣除系数 |
|
dltbBGEntity.SHAPE_Area = feature.Value[iSHAPE_Area].ToString();//SHAPE_Area |
|
dltbBGEntity.feature = feature; |
|
dltbBGEntity.CheckResult = new List<DataCheckResult>(); |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
throw ex; |
|
} |
|
} |
|
|
|
private void LogicCheck(bool iserror, string ErrorDesc, string ErrorCode, string PrimaryKeyValue) |
|
{ |
|
if (iserror) |
|
{ |
|
dataCheckResults.Add( |
|
new DataCheckResult() |
|
{ |
|
ErrorDesc = ErrorDesc, |
|
ErrorCode = ErrorCode, |
|
ErrorLayer = "DLTBBG", |
|
PrimaryKey = "OBJECTID", |
|
PrimaryKeyValue = PrimaryKeyValue, |
|
ErrorType = EnumErrorType.错误 |
|
}); |
|
} |
|
} |
|
private bool DicFirstOrDefault(List<DataDicTionary> dataDics, string Code, string Name) |
|
{ |
|
bool exist = true; |
|
try |
|
{ |
|
if (Code.Length >= 2) |
|
{ |
|
var code = dataDics.FirstOrDefault(x => x.CODE == Code.Substring(0, 2)); |
|
if (code == null) |
|
{ |
|
foreach (var item in dataDics) |
|
{ |
|
if (item.SubDic == null) |
|
{ |
|
if (item.NAME == Name && item.CODE == Code) |
|
{ |
|
exist = false; |
|
break; |
|
} |
|
} |
|
else |
|
{ |
|
var DataDicTionary = item.SubDic.FirstOrDefault(x => x.CODE == Code); |
|
if (DataDicTionary != null && DataDicTionary.NAME == Name && DataDicTionary.CODE == Code) |
|
{ |
|
exist = false; |
|
break; |
|
} |
|
} |
|
} |
|
} |
|
else |
|
{ |
|
if (code.SubDic == null) |
|
{ |
|
if (code.NAME == Name && code.CODE == Code) |
|
{ |
|
exist = false; |
|
return exist; |
|
} |
|
} |
|
else |
|
{ |
|
foreach (var item in code.SubDic) |
|
{ |
|
if (item.SubDic == null) |
|
{ |
|
if (item.NAME == Name && item.CODE == Code) |
|
{ |
|
exist = false; |
|
break; |
|
} |
|
} |
|
else |
|
{ |
|
if (item.CODE == Code && item.NAME == Name) |
|
{ |
|
exist = false; |
|
break; |
|
} |
|
var DataDicTionary = item.SubDic.FirstOrDefault(x => x.CODE == Code); |
|
if (DataDicTionary != null && DataDicTionary.NAME == Name && DataDicTionary.CODE == Code) |
|
{ |
|
exist = false; |
|
break; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
return exist; |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug("变更数据检查异常:" + ex.Message); |
|
throw ex; |
|
} |
|
} |
|
|
|
/// <summary> |
|
/// 检查单个图形 |
|
/// </summary> |
|
/// <param name="pGeometry"></param> |
|
/// <returns></returns> |
|
private static List<DataCheckResult> CheckGeometry(IFeature pfeature) |
|
{ |
|
List<DataCheckResult> result = new List<DataCheckResult>(); |
|
try |
|
{ |
|
int idxBGBSM = pfeature.Fields.FindField("BSM"); |
|
int idxBGArea = pfeature.Fields.FindField("SHAPE_AREA"); |
|
IPointCollection polygonVertices = new PolygonClass(); |
|
IPointCollection lineVertices = pfeature.ShapeCopy as IPointCollection; |
|
polygonVertices.AddPointCollection(lineVertices); |
|
ITopologicalOperator3 pTopology = polygonVertices as ITopologicalOperator3; |
|
esriNonSimpleReasonEnum reason = esriNonSimpleReasonEnum.esriNonSimpleOK; |
|
pTopology.IsKnownSimple_2 = false; |
|
if (!pTopology.get_IsSimpleEx(out reason)) |
|
{ |
|
if (reason == esriNonSimpleReasonEnum.esriNonSimpleSelfIntersections)//自相交 |
|
{ |
|
result.Add(new DataCheckResult() |
|
{ |
|
ErrorDesc = string.Format("地类图斑变更层OBJECTID等于【{0}】的要素,要素存在自相交,变更图斑面积为[{1}]的图斑。", pfeature.OID.ToTrim(), pfeature.Value[idxBGArea].ToTrim()), |
|
ErrorCode = "200600", |
|
ErrorData = pfeature.Value[idxBGBSM].ToTrim(), |
|
ErrorLayer = "DLTBBG", |
|
PrimaryKey = "OBJECTID", |
|
PrimaryKeyValue = pfeature.OID.ToTrim(), |
|
ErrorType = EnumErrorType.错误, |
|
}); |
|
} |
|
if (reason == esriNonSimpleReasonEnum.esriNonSimpleUnclosedRing)//存在不闭合的环 |
|
{ |
|
IPolygon4 polygon = pfeature.ShapeCopy as IPolygon4; |
|
IGeometryBag bag = polygon.ExteriorRingBag;//获取多边形的所有外环 |
|
var xx = (bag as IGeometryCollection).GeometryCount; |
|
if ((bag as IGeometryCollection).GeometryCount > 1) |
|
{ |
|
result.Add(new DataCheckResult() |
|
{ |
|
ErrorDesc = string.Format("地类图斑变更层OBJECTID等于【{0}】的要素,要素存在组合图斑(多部件),变更图斑面积为[{1}]的图斑。", pfeature.OID.ToTrim(), pfeature.Value[idxBGArea].ToTrim()), |
|
ErrorCode = "200700", |
|
ErrorData = pfeature.Value[idxBGBSM].ToTrim(), |
|
ErrorLayer = "DLTBBG", |
|
PrimaryKey = "OBJECTID", |
|
PrimaryKeyValue = pfeature.OID.ToTrim(), |
|
ErrorType = EnumErrorType.错误 |
|
}); |
|
} |
|
} |
|
if (reason == esriNonSimpleReasonEnum.esriNonSimpleShortSegments) |
|
{ |
|
result.Add(new DataCheckResult() |
|
{ |
|
ErrorDesc = string.Format("地类图斑变更层OBJECTID等于【{0}】的要素,要素存在短线段,变更图斑面积为[{1}]的图斑。", pfeature.OID.ToTrim(), pfeature.Value[idxBGArea].ToTrim()), |
|
ErrorCode = "200800", |
|
ErrorData = pfeature.Value[idxBGBSM].ToTrim(), |
|
ErrorLayer = "DLTBBG", |
|
PrimaryKey = "OBJECTID", |
|
PrimaryKeyValue = pfeature.OID.ToTrim(), |
|
ErrorType = EnumErrorType.错误, |
|
}); |
|
} |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
throw ex; |
|
} |
|
return result; |
|
} |
|
|
|
#region 要素不存在尖锐角和局部狭长图形(即不允许存在一个角度小于10度,或局部图形狭长的情况) |
|
private List<DataCheckResult> AcuteAngle(IFeature pFeature) |
|
{ |
|
List<DataCheckResult> result = new List<DataCheckResult>(); |
|
IGeometry refgeometry = null; |
|
int idxBGBSM = pFeature.Fields.FindField("BSM"); |
|
int idxBGArea = pFeature.Fields.FindField("SHAPE_AREA"); |
|
double angle = GetMinAngle(pFeature.ShapeCopy, ref refgeometry);//获取图形的最小角度 |
|
if (angle < 10) |
|
{ |
|
result.Add(new DataCheckResult() |
|
{ |
|
ErrorDesc = string.Format("地类图斑变更层OBJECTID等于【{0}】的要素,要素存在尖锐角,变更图斑面积为[{1}]的图斑。", pFeature.OID.ToTrim(), pFeature.Value[idxBGArea].ToTrim()), |
|
ErrorCode = "200500", |
|
ErrorData = pFeature.Value[idxBGBSM].ToTrim(), |
|
ErrorLayer = "DLTBBG", |
|
PrimaryKey = "OBJECTID", |
|
PrimaryKeyValue = pFeature.OID.ToTrim(), |
|
ErrorType = EnumErrorType.错误, |
|
ErrorArea = refgeometry.ToJson() |
|
}); |
|
} |
|
ITopologicalOperator topo = pFeature.ShapeCopy as ITopologicalOperator; |
|
IPolyline line1 = topo.Boundary as IPolyline; |
|
double length1 = line1.Length; |
|
int pointCount1 = (pFeature.ShapeCopy as IPointCollection).PointCount; |
|
IGeometry geo = topo.Buffer(-0.05); |
|
ITopologicalOperator topo2 = geo as ITopologicalOperator; |
|
IPolyline line2 = topo2.Boundary as IPolyline; |
|
double length2 = line2.Length; |
|
int pointCount2 = (geo as IPointCollection).PointCount - 1; |
|
double delta_length = length1 - length2; |
|
double avg_halfangle = 180 * (pointCount1 - 1 - 2) / (pointCount1 - 1) / 2; |
|
double conner_normal_length = 2 * 0.05 / Math.Tan(avg_halfangle * (Math.PI / 180)); |
|
if (delta_length > 8 * conner_normal_length * (pointCount1 - 1)) |
|
{ |
|
result.Add(new DataCheckResult() |
|
{ |
|
ErrorDesc = string.Format("地类图斑变更层OBJECTID等于【{0}】的要素,要素存在局部狭长图形,变更图斑面积为[{1}]的图斑。", pFeature.OID.ToTrim(), pFeature.Value[idxBGArea].ToTrim()), |
|
ErrorCode = "200900", |
|
ErrorData = pFeature.Value[idxBGBSM].ToTrim(), |
|
ErrorLayer = "DLTBBG", |
|
PrimaryKey = "OBJECTID", |
|
PrimaryKeyValue = pFeature.OID.ToTrim(), |
|
ErrorType = EnumErrorType.错误, |
|
//ErrorArea = pFeature.ShapeCopy.ToJson() |
|
}); |
|
} |
|
return result; |
|
} |
|
|
|
/// <summary> |
|
/// 获取最小角度 |
|
/// </summary> |
|
/// <param name="pGeo"></param> |
|
/// <returns></returns> |
|
private static double GetMinAngle(IGeometry pGeo, ref IGeometry refgeometry) |
|
{ |
|
double result = -1; |
|
try |
|
{ |
|
if (pGeo == null || pGeo.IsEmpty) |
|
return result; |
|
IPolygon4 poly4 = pGeo as IPolygon4; |
|
ITopologicalOperator topo = poly4 as ITopologicalOperator; |
|
if (topo != null) |
|
{ |
|
topo.Simplify(); |
|
} |
|
GeometryBag geoBag = poly4.ExteriorRingBag as GeometryBag; |
|
if (geoBag == null) return result; |
|
IGeometryCollection geoCollection = geoBag as IGeometryCollection; |
|
List<IGeometry> rings = new List<IGeometry>(); |
|
for (int j = 0; j < geoCollection.GeometryCount; j++) |
|
{ |
|
IGeometry geo = geoCollection.get_Geometry(j); |
|
rings.Add(geo); |
|
//内环图形 |
|
IGeometryBag InteriorBag = (pGeo as IPolygon4).get_InteriorRingBag(geo as IRing); |
|
if (InteriorBag != null) |
|
{ |
|
IGeometryCollection InteriorRingGeometryCollection = InteriorBag as IGeometryCollection; |
|
for (int IR = 0; IR < InteriorRingGeometryCollection.GeometryCount; IR++) |
|
{ |
|
rings.Add(InteriorRingGeometryCollection.get_Geometry(IR)); |
|
} |
|
} |
|
} |
|
foreach (IGeometry ring in rings) |
|
{ |
|
if (ring.IsEmpty) continue; |
|
IPointCollection points = ring as IPointCollection; |
|
int num = points.PointCount - 1; |
|
for (int i = 0; i < num; i++) |
|
{ |
|
IPoint p1 = null; |
|
IPoint p2 = points.get_Point(i); |
|
IPoint p3 = null; |
|
if (i == 0) |
|
{ |
|
p1 = points.get_Point(num - 1); |
|
p3 = points.get_Point(i + 1); |
|
} |
|
else if (i == num - 1) |
|
{ |
|
p1 = points.get_Point(i - 1); |
|
p3 = points.get_Point(0); |
|
} |
|
else |
|
{ |
|
p1 = points.get_Point(i - 1); |
|
p3 = points.get_Point(i + 1); |
|
} |
|
double angle = GetAngle(p2, p1, p3); |
|
IGeometryCollection geometryCollection = new Polyline() as IGeometryCollection; |
|
IPointCollection pointCollection = new Path(); |
|
if (result == -1) |
|
{ |
|
result = angle; |
|
pointCollection.AddPoint(p1); |
|
pointCollection.AddPoint(p2); |
|
pointCollection.AddPoint(p3); |
|
geometryCollection.AddGeometry(pointCollection as IGeometry); |
|
refgeometry = geometryCollection as IGeometry; |
|
refgeometry.SpatialReference = pGeo.SpatialReference; |
|
} |
|
else |
|
{ |
|
if (result > angle) |
|
{ |
|
result = angle; |
|
pointCollection.AddPoint(p1); |
|
pointCollection.AddPoint(p2); |
|
pointCollection.AddPoint(p3); |
|
geometryCollection.AddGeometry(pointCollection as IGeometry); |
|
refgeometry = geometryCollection as IGeometry; |
|
refgeometry.SpatialReference = pGeo.SpatialReference; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
throw ex; |
|
} |
|
return result; |
|
} |
|
/// <summary> |
|
/// 计算角度 |
|
/// </summary> |
|
/// <param name="cenPoint"></param> |
|
/// <param name="firstPoint"></param> |
|
/// <param name="secondPoint"></param> |
|
/// <returns></returns> |
|
private static double GetAngle(IPoint cenPoint, IPoint firstPoint, IPoint secondPoint) |
|
{ |
|
double ma_x = firstPoint.X - cenPoint.X; |
|
double ma_y = firstPoint.Y - cenPoint.Y; |
|
double mb_x = secondPoint.X - cenPoint.X; |
|
double mb_y = secondPoint.Y - cenPoint.Y; |
|
double v1 = (ma_x * mb_x) + (ma_y * mb_y); |
|
double ma_val = Math.Sqrt(ma_x * ma_x + ma_y * ma_y); |
|
double mb_val = Math.Sqrt(mb_x * mb_x + mb_y * mb_y); |
|
if (ma_val * mb_val == 0) |
|
{ |
|
return -1; |
|
} |
|
double cosM = v1 / (ma_val * mb_val); |
|
double angleAMB = Math.Acos(cosM) * 180 / Math.PI; |
|
return angleAMB; |
|
} |
|
#endregion |
|
|
|
#region 地类图斑变更层平均节点密度大于1米小于70米 |
|
/// <summary> |
|
/// 地类图斑变更层平均节点密度大于1米小于70米 |
|
/// </summary> |
|
/// <param name="pFeature"></param> |
|
/// <returns></returns> |
|
private DataCheckResult PointToPoint(IFeature pFeature) |
|
{ |
|
int idxBGBSM = pFeature.Fields.FindField("BSM"); |
|
int idxBGArea = pFeature.Fields.FindField("SHAPE_AREA"); |
|
DataCheckResult result = null; |
|
List<double> Segmentslength = new List<double>(); |
|
IGeometryCollection _GeoColl = pFeature.ShapeCopy as IGeometryCollection; |
|
for (int i = 0; i < _GeoColl.GeometryCount; i++) |
|
{ |
|
ISegmentCollection _segmColl = _GeoColl.Geometry[i] as ISegmentCollection; |
|
for (int j = 0; j < _segmColl.SegmentCount; j++) |
|
{ |
|
Segmentslength.Add(_segmColl.Segment[j].Length); |
|
} |
|
} |
|
if (Segmentslength.Average() > 70 || Segmentslength.Average() < 1) |
|
{ |
|
result = new DataCheckResult() |
|
{ |
|
ErrorDesc = string.Format("地类图斑变更层OBJECTID等于【{0}】的要素,要素节点间的最大距离超过70米,变更图斑面积为[{1}]的图斑。", pFeature.OID.ToTrim(), pFeature.Value[idxBGArea].ToTrim()), |
|
ErrorCode = "200400", |
|
ErrorData = pFeature.Value[idxBGBSM].ToTrim(), |
|
ErrorLayer = "DLTBBG", |
|
PrimaryKey = "OBJECTID", |
|
PrimaryKeyValue = pFeature.OID.ToTrim(), |
|
ErrorType = EnumErrorType.错误, |
|
}; |
|
} |
|
return result; |
|
} |
|
|
|
#endregion |
|
|
|
private Func<T> ThreadWithReturn<T>(Func<T> func) |
|
{ |
|
T t = default(T); |
|
Thread thread = new Thread(() => |
|
{ |
|
t = func.Invoke(); |
|
}); |
|
thread.Start(); |
|
return () => |
|
{ |
|
thread.Join(); |
|
return t; |
|
}; |
|
} |
|
|
|
public List<DataCheckResult> DLTBBGCheck(IFeature ifeature) |
|
{ |
|
try |
|
{ |
|
dataCheckResults = new List<DataCheckResult>(); |
|
if (isMultithreading) |
|
{ |
|
//Func<List<DataCheckResult>> func = this.ThreadWithReturn<List<DataCheckResult>>(() => |
|
//{ |
|
// ExecuteAttributeCheck(ifeature); |
|
// ExecuteGraphicCheck(ifeature); |
|
// return dataCheckResults; |
|
//}); |
|
//return func.Invoke(); |
|
Thread thread = new Thread(new ParameterizedThreadStart(ExecuteAttributeCheck)); |
|
thread.SetApartmentState(ApartmentState.STA); |
|
thread.Start(ifeature); |
|
thread = new Thread(new ParameterizedThreadStart(ExecuteGraphicCheck)); |
|
thread.SetApartmentState(ApartmentState.STA); |
|
thread.Start(ifeature); |
|
} |
|
else |
|
{ |
|
ExecuteAttributeCheck(ifeature); |
|
ExecuteGraphicCheck(ifeature); |
|
} |
|
return dataCheckResults; |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug($"DLTBBGCheck:{ex.Message}"); |
|
throw ex; |
|
} |
|
} |
|
|
|
public List<DataCheckResult> DLTBBGCheck(IFeatureClass featureClass) |
|
{ |
|
IFeature feature = null; |
|
IFeatureCursor featureCursor = null; |
|
try |
|
{ |
|
dataCheckResults = new List<DataCheckResult>(); |
|
if (featureClass != null) |
|
{ |
|
featureCursor = featureClass.Search(null, true); |
|
while ((feature = featureCursor.NextFeature()) != null) |
|
{ |
|
ExecuteAttributeCheck(feature); |
|
ExecuteGraphicCheck(feature); |
|
} |
|
} |
|
return dataCheckResults; |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug($"DLTBBGCheck:{ex.Message}"); |
|
throw ex; |
|
} |
|
finally |
|
{ |
|
if (feature != null) |
|
Marshal.ReleaseComObject(feature); |
|
if (featureCursor != null) |
|
Marshal.ReleaseComObject(featureCursor); |
|
} |
|
} |
|
} |
|
public class DLTBBGEntity |
|
{ |
|
public List<DataCheckResult> CheckResult { get; set; } |
|
public IFeature feature { get; set; } |
|
public int OBJECTID { get; set; } |
|
public string DLBM { get; set; } |
|
public string DLMC { get; set; } |
|
public string QSXZ { get; set; } |
|
public string QSDWDM { get; set; } |
|
public string QSDWMC { get; set; } |
|
public string ZLDWDM { get; set; } |
|
public string ZLDWMC { get; set; } |
|
public string KCDLBM { get; set; } |
|
public string KCXS { get; set; } |
|
public string GDLX { get; set; } |
|
public string GDPDJB { get; set; } |
|
public string XZDWKD { get; set; } |
|
public string TBXHDM { get; set; } |
|
public string TBXHMC { get; set; } |
|
public string ZZSXDM { get; set; } |
|
public string ZZSXMC { get; set; } |
|
public string GDDB { get; set; } |
|
public string FRDBS { get; set; } |
|
public string CZCSXM { get; set; } |
|
public string MSSM { get; set; } |
|
public string BZ { get; set; } |
|
public string SHAPE_Area { get; set; } |
|
public int iDLBM { get; set; } |
|
public int iDLMC { get; set; } |
|
public int iQSXZ { get; set; } |
|
public int iQSDWDM { get; set; } |
|
public int iQSDWMC { get; set; } |
|
public int iZLDWDM { get; set; } |
|
public int iZLDWMC { get; set; } |
|
public int iKCDLBM { get; set; } |
|
public int iKCXS { get; set; } |
|
public int iGDLX { get; set; } |
|
public int iGDPDJB { get; set; } |
|
public int iXZDWKD { get; set; } |
|
public int iTBXHDM { get; set; } |
|
public int iTBXHMC { get; set; } |
|
public int iZZSXDM { get; set; } |
|
public int iZZSXMC { get; set; } |
|
public int iGDDB { get; set; } |
|
public int iFRDBS { get; set; } |
|
public int iCZCSXM { get; set; } |
|
public int iMSSM { get; set; } |
|
public int iBZ { get; set; } |
|
public int iSHAPE_Area { get; set; } |
|
} |
|
}
|
|
|