年度变更建库软件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.

2928 lines
159 KiB

using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.Geometry;
using Kingo.RuleCheck.CheckHelper;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
namespace Kingo.RuleCheck.XJRuleCheck
{
/// <summary>
/// 通用类表间逻辑性检查
/// </summary>
public class TYLBJLJXCheck_DTB : RuleCheckBase_DTB
{
public TYLBJLJXCheck_DTB()
{
var list = GetConfigList("TYLBJLJXCheck_DTB");
if (list.Count > 0)
ruleMethodNames = list;
}
private List<string> ruleMethodNames = new List<string>()
{
"LS101","GFB101","TTQ101","CCWJQ101","DDTC101","LMFW101","LMFW102","CZC101","CZC102","CZC103","GD103","HDGD001","TTQ001","LHGD101","LHGD102","HFSX001","HFSX002","HFSX003","HFSX004","HFSX005","GFBQ201","GFBQ202","TTQ201","TTQ202","TTQ203","CCWJQ201","CCWJQ202","HFSX006","XZQ001","XZQ002","TX990","CNGD001","PDSX001"
};
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, IFeatureClass> workspace)
{
return this.StartCheck(sourePath, workspace, ruleMethodNames);
}
public override List<RuleEntity> ExcuteCheck(string tbbsm, string sourePath, Dictionary<string, IFeatureClass> dicFeatureClass)
{
return this.StartCheck(tbbsm, sourePath, dicFeatureClass, ruleMethodNames);
}
/// <summary>
/// 临时用地上图范围检查(临时用地图斑上图范围需与地类图斑层相应图斑范围保持一致。)
/// </summary>
/// <returns></returns>
public List<RuleEntity> LS101()
{
List<RuleEntity> rst = new List<RuleEntity>();
try
{
string sql = $"select BSM from DTBDLTBGX where TBBSM='{TBBSM}' AND DDTCBZ='1301' AND bsm NOT IN (SELECT BSM FROM DTBLSYDGX)";
DataTable dt = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, sql);
if (dt == null || dt.Rows.Count <= 0)
return null;
foreach (DataRow item in dt.Rows)
{
rst.Add(new RuleEntity()
{
CheckObject = "DTBLSYDGX",
ErrorId = $"{item["BSM"].ToString()}",
BGFWBSM = $"{item["BSM"].ToString()}",
ErrorTip = "临时用地图斑上图范围需与地类图斑层相应图斑范围保持一致。",
ErrorType = "一类错误",
RuleCode = "LS101",
RuleName = "临时用地上图范围检查",
RuleContent = "通过DTBDLTBGX层中,“单独图层代码”为“1301”的图斑“标识码”字段,其均需位于DTBLSYDGX表中的“关联图斑标识码”字段中;否则,认定为错误图斑。"
});
}
}
catch (Exception ex)
{
RuleEntity ruleEntity = new RuleEntity()
{
CheckObject = "DTBLSYDGX",
ErrorId = this.TBBSM,
ErrorTip = "临时用地图斑上图范围需与地类图斑层相应图斑范围保持一致规则检查失败:" + ex.Message,
ErrorType = "一类错误",
RuleCode = "LS101",
RuleName = "临时用地上图范围检查",
RuleContent = "通过DTBDLTBGX层中,“单独图层代码”为“1301”的图斑“标识码”字段,其均需位于DTBLSYDGX表中的“关联图斑标识码”字段中;否则,认定为错误图斑。"
};
rst.Add(ruleEntity);
}
return rst;
}
/// <summary>
/// 不在省级临时用地备案范围内的临时用地图斑不可上单独图层
/// </summary>
/// <returns></returns>
public List<RuleEntity> LS102()
{
IFeatureWorkspace lsydWorkspace = null;
IFeatureClass lsydFeatureClass = null;
List<RuleEntity> rst = new List<RuleEntity>();
//try
//{
// if (WorkspaceDic.ContainsKey("LSYD"))
// {
// lsydWorkspace = WorkspaceDic["LSYD"] as IFeatureWorkspace;
// lsydFeatureClass = lsydWorkspace.OpenFeatureClass("LSYD");
// }
// else
// {
// //不存在省级下发临时用地范围,则全部判定位错误图斑
// string sql = $"SELECT BSM FROM DTBDLTBGX WHERE TBBSM='{TBBSM}' AND DDTCBZ='1301' ";
// DataTable dt = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, sql);
// if (dt == null || dt.Rows.Count <= 0)
// return null;
// foreach (DataRow item in dt.Rows)
// {
// rst.Add(new RuleEntity()
// {
// CheckObject = "DTBDLTBGX",
// ErrorId = $"{item["BSM"].ToString()}",
// ErrorTip = "不在省级临时用地备案范围内的临时用地图斑不可上单独图层",
// ErrorType = "一类错误",
// RuleCode = "LS102",
// RuleName = "临时用地上图范围检查",
// RuleContent = "将DTBLSYDGX层图斑与省级临时用地备案范围进行叠加,若重叠部分占DTBLSYDGX层图斑面积比例小于70%,认定为错误图斑"
// });
// }
// return rst;
// }
// //待实现
// if (sourceWorkSpace == null) return null;
// bool isExist = (sourceWorkSpace as IWorkspace2).get_NameExists(esriDatasetType.esriDTFeatureClass, "DTBDLTBGX");
// if (!isExist)
// {
// return null;
// }
// IFeatureClass pFeatureClass = (sourceWorkSpace as IFeatureWorkspace).OpenFeatureClass("DTBDLTBGX");
// //判断如果图层没有数据则跳过
// if (pFeatureClass.FeatureCount(null) <= 0)
// {
// return null;
// }
// IQueryFilter queryFilter = new QueryFilterClass()
// {
// WhereClause = " DDTCBZ='1301' "
// };
// IFeatureCursor featureCursor = pFeatureClass.Search(queryFilter, true);
// IFeature feature = null;
// ISpatialFilter geoFilter = new SpatialFilterClass();
// geoFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
// int fieldIndex = pFeatureClass.FindField("BSM");
// while ((feature = featureCursor.NextFeature()) != null)
// {
// geoFilter.Geometry = feature.ShapeCopy;
// IFeatureCursor lsydCursor = lsydFeatureClass.Search(geoFilter, false);
// IFeature lsydFeature = null;
// double intersectArea = 0;
// while ((lsydFeature = lsydCursor.NextFeature()) != null)
// {
// IGeometry geo = this.InterSect(feature.ShapeCopy, lsydFeature.ShapeCopy);
// if (geo == null) continue;
// intersectArea += (geo as IArea).Area;
// }
// double gxMj = (feature.ShapeCopy as IArea).Area;
// if (intersectArea / gxMj < 0.7)
// {
// rst.Add(new RuleEntity()
// {
// CheckObject = "DTBDLTBGX",
// ErrorId = feature.Value[fieldIndex].ToString(),
// ErrorTip = "不在省级临时用地备案范围内的临时用地图斑不可上单独图层",
// ErrorType = "一类错误",
// RuleCode = "LS102",
// RuleName = "临时用地上图范围检查",
// RuleContent = "将DTBLSYDGX层图斑与省级临时用地备案范围进行叠加,若重叠部分占DTBLSYDGX层图斑面积比例小于70%,认定为错误图斑"
// });
// }
// }
//}
//catch (Exception ex)
//{
// RuleEntity ruleEntity = new RuleEntity()
// {
// ErrorId = TBBSM,
// CheckObject = "DTBDLTBGX",
// ErrorTip = "不在省级临时用地备案范围内的临时用地图斑不可上单独图层规则检查失败:" + ex.Message,
// ErrorType = "一类错误",
// RuleCode = "LS102",
// RuleName = "临时用地上图范围检查",
// RuleContent = "将DTBLSYDGX层图斑与省级临时用地备案范围进行叠加,若重叠部分占DTBLSYDGX层图斑面积比例小于70%,认定为错误图斑"
// };
// rst.Add(ruleEntity);
//}
return rst;
}
/// <summary>
/// 光伏板区图斑上图范围(光伏板区图斑上图范围需与地类图斑层相应图斑范围保持一致)
/// </summary>
/// <returns></returns>
public List<RuleEntity> GFB101()
{
List<RuleEntity> rst = new List<RuleEntity>();
try
{
string sql = $"select BSM from DTBDLTBGX where TBBSM='{TBBSM}' AND DDTCBZ='1302' AND bsm NOT IN (SELECT BSM FROM DTBGFBQGX)";
DataTable dt = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, sql);
if (dt == null || dt.Rows.Count <= 0)
return null;
foreach (DataRow item in dt.Rows)
{
rst.Add(new RuleEntity()
{
CheckObject = "DTBGFBQGX",
ErrorId = $"{item["BSM"].ToString()}",
BGFWBSM = $"{item["BSM"].ToString()}",
ErrorTip = "光伏板区图斑上图范围需与地类图斑层相应图斑范围保持一致。",
ErrorType = "一类错误",
RuleCode = "GFB101",
RuleName = "光伏板区上图范围检查",
RuleContent = "通过DTBDLTBGX层中,“单独图层代码”为“1302”的图斑“标识码”字段,其均需位于DTBGFBQGX表中的“标识码”字段中;否则,认定为错误图斑。"
});
}
}
catch (Exception ex)
{
RuleEntity ruleEntity = new RuleEntity()
{
CheckObject = "DTBGFBQGX",
ErrorId = this.TBBSM,
ErrorTip = "光伏板区图斑上图范围需与地类图斑层相应图斑范围保持一致规则检查失败:" + ex.Message,
ErrorType = "一类错误",
RuleCode = "GFB101",
RuleName = "光伏板区上图范围检查",
RuleContent = "通过DTBDLTBGX层中,“单独图层代码”为“1302”的图斑“标识码”字段,其均需位于DTBGFBQGX表中的“标识码”字段中;否则,认定为错误图斑。"
};
rst.Add(ruleEntity);
}
return rst;
}
/// <summary>
/// 推土区区图斑上图范围(推土区区图斑上图范围需与地类图斑层相应图斑范围保持一致)
/// </summary>
/// <returns></returns>
public List<RuleEntity> TTQ101()
{
List<RuleEntity> rst = new List<RuleEntity>();
try
{
string sql = $"select BSM from DTBDLTBGX where TBBSM='{TBBSM}' AND DDTCBZ='1303' AND bsm NOT IN (SELECT BSM FROM DTBTTQGX)";
DataTable dt = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, sql);
if (dt == null || dt.Rows.Count <= 0)
return null;
foreach (DataRow item in dt.Rows)
{
rst.Add(new RuleEntity()
{
CheckObject = "DTBTTQGX",
ErrorId = $"{item["BSM"].ToString()}",
BGFWBSM = $"{item["BSM"].ToString()}",
ErrorTip = "推土区图斑上图范围需与地类图斑层相应图斑范围保持一致。",
ErrorType = "一类错误",
RuleCode = "TTQ101",
RuleName = "推土区上图范围检查",
RuleContent = "通过DTBDLTBGX层中,“单独图层代码”为“1303”的图斑“标识码”字段,其均需位于DTBTTQGX表中的“标识码”字段中;否则,认定为错误图斑。"
});
}
}
catch (Exception ex)
{
RuleEntity ruleEntity = new RuleEntity()
{
CheckObject = "DTBTTQGX",
ErrorId = this.TBBSM,
ErrorTip = "推土区图斑上图范围需与地类图斑层相应图斑范围保持一致规则检查失败:" + ex.Message,
ErrorType = "一类错误",
RuleCode = "TTQ101",
RuleName = "推土区上图范围检查",
RuleContent = "通过DTBDLTBGX层中,“单独图层代码”为“1303”的图斑“标识码”字段,其均需位于DTBTTQGX表中的“标识码”字段中;否则,认定为错误图斑。"
};
rst.Add(ruleEntity);
}
return rst;
}
/// <summary>
/// 拆除未尽区图斑上图范围(拆除未尽区图斑上图范围需与地类图斑层相应图斑范围保持一致)
/// </summary>
/// <returns></returns>
public List<RuleEntity> CCWJQ101()
{
List<RuleEntity> rst = new List<RuleEntity>();
try
{
string sql = $"select BSM from DTBDLTBGX where TBBSM='{TBBSM}' AND DDTCBZ='1304' AND bsm NOT IN (SELECT BSM FROM DTBCCWJQGX)";
DataTable dt = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, sql);
if (dt == null || dt.Rows.Count <= 0)
return null;
foreach (DataRow item in dt.Rows)
{
rst.Add(new RuleEntity()
{
CheckObject = "DTBCCWJQGX",
ErrorId = $"{item["BSM"].ToString()}",
BGFWBSM = $"{item["BSM"].ToString()}",
ErrorTip = "拆除未尽区图斑上图范围需与地类图斑层相应图斑范围保持一致。",
ErrorType = "一类错误",
RuleCode = "CCWJQ101",
RuleName = "拆除未尽区上图范围检查",
RuleContent = "通过DTBDLTBGX层中,“单独图层代码”为“1304”的图斑“标识码”字段,其均需位于DTBCCWJQGX表中的“标识码”字段中;否则,认定为错误图斑。"
});
}
}
catch (Exception ex)
{
RuleEntity ruleEntity = new RuleEntity()
{
CheckObject = "DTBCCWJQGX",
ErrorId = this.TBBSM,
ErrorTip = "拆除未尽区图斑上图范围需与地类图斑层相应图斑范围保持一致规则检查失败:" + ex.Message,
ErrorType = "一类错误",
RuleCode = "CCWJQ101",
RuleName = "拆除未尽区上图范围检查",
RuleContent = "通过DTBDLTBGX层中,“单独图层代码”为“1304”的图斑“标识码”字段,其均需位于DTBCCWJQGX表中的“标识码”字段中;否则,认定为错误图斑。"
};
rst.Add(ruleEntity);
}
return rst;
}
/// <summary>
/// 单独图层多余上图检查(未标记单独图层的地类图斑处不应存在单独图层)
/// </summary>
/// <returns></returns>
public List<RuleEntity> DDTC101()
{
string sql = string.Empty;
List<RuleEntity> rst = new List<RuleEntity>();
try
{
List<string> dltcTableNames = new List<string>() { "DTBLSYDGX", "DTBGFBQGX", "DTBTTQGX", "DTBCCWJQGX", "DTBLMFWGX" };
foreach (string item in dltcTableNames)
{
sql = $"SELECT BSM FROM {item} WHERE BSM NOT IN (SELECT BSM FROM DTBDLTBGX WHERE DDTCBZ is not null and DDTCBZ<>'' and DDTCBZ<>'一般地类')";
DataTable dt = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, sql);
if (dt == null || dt.Rows.Count <= 0)
continue;
foreach (DataRow row in dt.Rows)
{
rst.Add(new RuleEntity()
{
CheckObject = item,
ErrorId = $"{row["BSM"].ToString()}",
BGFWBSM = $"{row["BSM"].ToString()}",
ErrorTip = $"【{item}】未标记单独图层的地类图斑处不应存在单独图层",
ErrorType = "一类错误",
RuleCode = "DDTC101",
RuleName = "单独图层多余上图检查",
RuleContent = "对于DTBDLTBGX层未标记“单独图层代码”字段的图斑,若相应位置处存在DTBLSYDGX层、DTBGFBQGX层、DTBTTQGX层、DTBCCWJQGX层、DTBLMFWGX层图斑,认定为错误图斑"
});
}
}
}
catch (Exception ex)
{
RuleEntity ruleEntity = new RuleEntity()
{
CheckObject = "DTBDLTBGX层",
ErrorId = this.TBBSM,
ErrorTip = "【单独图层】未标记单独图层的地类图斑处不应存在单独图层规则检查失败:" + ex.Message,
ErrorType = "一类错误",
RuleCode = "DDTC101",
RuleName = "单独图层多余上图检查",
RuleContent = "对于DTBDLTBGX层未标记“单独图层代码”字段的图斑,若相应位置处存在DTBLSYDGX层、DTBGFBQGX层、DTBTTQGX层、DTBCCWJQGX层、DTBLMFWGX层图斑,认定为错误图斑"
};
rst.Add(ruleEntity);
}
return rst;
}
/// <summary>
/// 单独图层重叠情况检查
/// </summary>
/// <returns></returns>
public List<RuleEntity> DDTC102()
{
List<RuleEntity> rst = new List<RuleEntity>();
try
{
Dictionary<string, string> dicBsmLName = new Dictionary<string, string>();
string sql = $"select BSM,LNAME from (select BSM,'DTBLSYDGX' as LNAME from DTBLSYDGX UNION select BSM,'DTBGFBQGX' as LNAME from DTBGFBQGX UNION select BSM,'DTBTTQGX' as LNAME from DTBTTQGX UNION select BSM,'DTBCCWJQGX' as LNAME from DTBCCWJQGX UNION select BSM,'DTBLMFWGX' as LNAME from DTBLMFWGX) where BSM in (select BSM from DTBDLTBGX where TBBSM='{TBBSM}' AND DDTCBZ<>'' AND DDTCBZ<>'一般地类')";
DataTable dt = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, sql);
if (dt == null || dt.Rows.Count <= 0)
return null;
foreach (DataRow item in dt.Rows)
{
string bsm = item[0] + string.Empty;
string lname = item[1] + string.Empty;
if (dicBsmLName.ContainsKey(bsm))
{
rst.Add(new RuleEntity()
{
CheckObject = "DTBLSYDGX层(表)、DTBGFBQGX层(表)、DTBTTQGX层(表)、DTBCCWJQGX层(表)、DTBLMFWGX层(表)",
ErrorId = $"{item["BSM"].ToString()}",
BGFWBSM = $"{item["BSM"].ToString()}",
ErrorTip = $"【{lname}】与【{dicBsmLName[bsm]}】存在重叠",
ErrorType = "一类错误",
RuleCode = "DDTC102",
RuleName = "单独图层重叠情况检查",
RuleContent = "通过DLTDLTBGX层中“单独图层代码”不为空的图斑,依据其“标识码”,查看其“标识码”是否同时位于DTBLSYDGX层、DTBGFBQGX层、DTBTTQGX层、DTBCCWJQGX层、DTBLMFWGX层中两个以上图层的标识码字段中,若存在,认定为错误图斑。"
});
continue;
}
dicBsmLName[bsm] = lname;
}
}
catch (Exception ex)
{
RuleEntity ruleEntity = new RuleEntity()
{
CheckObject = "DTBLSYDGX层(表)、DTBGFBQGX层(表)、DTBTTQGX层(表)、DTBCCWJQGX层(表)、DTBLMFWGX层(表)",
ErrorId = this.TBBSM,
ErrorTip = "【单独图层】与【单独图层】存在重叠规则检查失败:" + ex.Message,
ErrorType = "一类错误",
RuleCode = "DDTC102",
RuleName = "单独图层重叠情况检查",
RuleContent = "通过DLTDLTBGX层中“单独图层代码”不为空的图斑,依据其“标识码”,查看其“标识码”是否同时位于DTBLSYDGX层、DTBGFBQGX层、DTBTTQGX层、DTBCCWJQGX层、DTBLMFWGX层中两个以上图层的标识码字段中,若存在,认定为错误图斑。"
};
rst.Add(ruleEntity);
}
return rst;
}
/// <summary>
/// 路面范围图层上图检查
/// </summary>
/// <returns></returns>
public List<RuleEntity> LMFW101()
{
List<RuleEntity> rst = new List<RuleEntity>();
try
{
string sql = $"select BSM from DTBDLTBGX where TBBSM='{TBBSM}' AND DDTCBZ='1305' AND bsm NOT IN (SELECT BSM FROM DTBLMFWGX)";
DataTable dt = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, sql);
if (dt == null || dt.Rows.Count <= 0)
return null;
foreach (DataRow item in dt.Rows)
{
rst.Add(new RuleEntity()
{
CheckObject = "DTBLMFWGX",
ErrorId = $"{item["BSM"].ToString()}",
BGFWBSM = $"{item["BSM"].ToString()}",
ErrorTip = "路面范围图层范围应与公路图斑和铁路图斑范围相一致。",
ErrorType = "一类错误",
RuleCode = "LMFW101",
RuleName = "路面范围图层上图检查",
RuleContent = "通过DTBDLTBGX层中,“单独图层代码”为“1305”的图斑“标识码”字段,均需位于DTBLMFWGX表中的“标识码”字段中;否则,认定为错误图斑。"
});
}
}
catch (Exception ex)
{
RuleEntity ruleEntity = new RuleEntity()
{
CheckObject = "DTBLMFWGX",
ErrorId = this.TBBSM,
ErrorTip = "路面范围图层范围应与公路图斑和铁路图斑范围相一致规则检查失败:" + ex.Message,
ErrorType = "一类错误",
RuleCode = "LMFW101",
RuleName = "路面范围图层上图检查",
RuleContent = "通过DTBDLTBGX层中,“单独图层代码”为“1305”的图斑“标识码”字段,均需位于DTBLMFWGX表中的“标识码”字段中;否则,认定为错误图斑。"
};
rst.Add(ruleEntity);
}
return rst;
}
/// <summary>
/// 路面范围图层地类编码逻辑性检查
/// </summary>
/// <returns></returns>
public List<RuleEntity> LMFW102()
{
List<RuleEntity> rst = new List<RuleEntity>();
try
{
string sql = $"SELECT A.BSM FROM DTBDLTBGX B LEFT JOIN DTBLMFWGX A ON A.BSM=B.BSM WHERE b.TBBSM='{TBBSM}' AND B.DDTCBZ='1305' AND A.DLBM<>B.DLBM";
DataTable dt = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, sql);
if (dt == null || dt.Rows.Count <= 0)
return null;
foreach (DataRow item in dt.Rows)
{
rst.Add(new RuleEntity()
{
CheckObject = "DTBLMFWGX",
ErrorId = $"{item["BSM"].ToString()}",
BGFWBSM = $"{item["BSM"].ToString()}",
ErrorTip = "路面范围图层需与相应地类图斑地类编码保持一致",
ErrorType = "一类错误",
RuleCode = "LMFW102",
RuleName = "路面范围图层地类编码逻辑性检查",
RuleContent = "若DTBLMFWGX层地类编码与相应位置处的DTBDLTBGX层地类编码不一致,认定为错误图斑"
});
}
}
catch (Exception ex)
{
RuleEntity ruleEntity = new RuleEntity()
{
CheckObject = "DTBLMFWGX",
ErrorId = this.TBBSM,
ErrorTip = "路面范围图层需与相应地类图斑地类编码保持一致规则检查失败:" + ex.Message,
ErrorType = "一类错误",
RuleCode = "LMFW102",
RuleName = "路面范围图层地类编码逻辑性检查",
RuleContent = "若DTBLMFWGX层地类编码与相应位置处的DTBDLTBGX层地类编码不一致,认定为错误图斑"
};
rst.Add(ruleEntity);
}
return rst;
}
/// <summary>
/// 城镇村范围内地类图斑城镇村标注检查
/// </summary>
/// <returns></returns>
public List<RuleEntity> CZC101()
{
List<RuleEntity> rst = new List<RuleEntity>();
try
{
string sql = $"select BSM from DTBDLTBGX where TBBSM='{TBBSM}' AND CZCSXM<>'' AND bsm NOT IN (SELECT BSM FROM DTBCZCDYDGX)";
DataTable dt = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, sql);
if (dt == null || dt.Rows.Count <= 0) return null;
foreach (DataRow item in dt.Rows)
{
rst.Add(new RuleEntity()
{
CheckObject = "DTBCZCDYDGX",
ErrorId = $"{item["BSM"].ToString()}",
BGFWBSM = $"{item["BSM"].ToString()}",
ErrorTip = "城镇村等用地图层应与标注城镇村属性码图斑范围相一致",
ErrorType = "一类错误",
RuleCode = "CZC101",
RuleName = "城镇村等用地范围上图检查",
RuleContent = "通过DTBDLTBGX层中,“城镇村属性码”不为空的图斑“标识码”字段,均需位于DTBCZCDYDGX表中的“标识码”字段中;否则,认定为错误图斑。"
});
}
}
catch (Exception ex)
{
RuleEntity ruleEntity = new RuleEntity()
{
CheckObject = "DTBCZCDYDGX",
ErrorId = this.TBBSM,
ErrorTip = "城镇村等用地图层应与标注城镇村属性码图斑范围相一致规则检查失败:" + ex.Message,
ErrorType = "一类错误",
RuleCode = "CZC101",
RuleName = "城镇村等用地范围上图检查",
RuleContent = "通过DTBDLTBGX层中,“城镇村属性码”不为空的图斑“标识码”字段,均需位于DTBCZCDYDGX表中的“标识码”字段中;否则,认定为错误图斑。"
};
rst.Add(ruleEntity);
}
return rst;
}
public List<RuleEntity> CZC102()
{
List<RuleEntity> rst = new List<RuleEntity>();
try
{
string sql = $"SELECT BSM FROM DTBDLTBGX WHERE TBBSM='{TBBSM}' AND CZCSXM='' AND BSM IN (SELECT BSM FROM DTBCZCDYDGX)";
DataTable dt = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, sql);
if (dt == null || dt.Rows.Count <= 0) return null;
foreach (DataRow item in dt.Rows)
{
rst.Add(new RuleEntity()
{
CheckObject = "DTBCZCDYDGX",
ErrorId = $"{item["BSM"].ToString()}",
BGFWBSM = $"{item["BSM"].ToString()}",
ErrorTip = "未标注城镇村属性码的图斑不应位于城镇村等用地范围中",
ErrorType = "一类错误",
RuleCode = "CZC102",
RuleName = "城镇村范围外地类图斑城镇村标注检查",
RuleContent = "通过DLTDLTBGX层中“城镇村属性码”为空的图斑,依据其“标识码”,查看其“标识码”是否位于DTBCZCDYDGX表中的“标识码”字段中,若存在,认定为错误图斑。"
});
}
}
catch (Exception ex)
{
RuleEntity ruleEntity = new RuleEntity()
{
CheckObject = "DTBCZCDYDGX",
ErrorId = this.TBBSM,
ErrorTip = "未标注城镇村属性码的图斑不应位于城镇村等用地范围中规则检查失败:" + ex.Message,
ErrorType = "一类错误",
RuleCode = "CZC102",
RuleName = "城镇村范围外地类图斑城镇村标注检查",
RuleContent = "通过DLTDLTBGX层中“城镇村属性码”为空的图斑,依据其“标识码”,查看其“标识码”是否位于DTBCZCDYDGX表中的“标识码”字段中,若存在,认定为错误图斑。"
};
rst.Add(ruleEntity);
}
return rst;
}
public List<RuleEntity> CZC103()
{
List<RuleEntity> rst = new List<RuleEntity>();
try
{
string sql = $"SELECT A.BSM FROM DTBDLTBGX B LEFT JOIN DTBCZCDYDGX A ON A.BSM=B.BSM WHERE b.TBBSM='{TBBSM}' AND A.CZCLX<>B.CZCSXM";
DataTable dt = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, sql);
if (dt == null || dt.Rows.Count <= 0) return null;
foreach (DataRow item in dt.Rows)
{
rst.Add(new RuleEntity()
{
CheckObject = "DTBCZCDYDGX",
ErrorId = $"{item["BSM"].ToString()}",
BGFWBSM = $"{item["BSM"].ToString()}",
ErrorTip = "标注城镇村属性码的地类图斑,其城镇村属性码必须与城镇村等用地层城镇村等用地类型保持一致。",
ErrorType = "一类错误",
RuleCode = "CZC103",
RuleName = "城镇村等用地层城镇村标注逻辑性检查",
RuleContent = "若DTBCZCDYDGX层中的“标识码”字段找到相应DTBDLTBGX层中的图斑,查看DTBCZCDYDGX层中“城镇村类型”字段是否与DTBDLTBGX层中“城镇村属性码”相一致,若不相同,认定为错误图斑。"
});
}
}
catch (Exception ex)
{
RuleEntity ruleEntity = new RuleEntity()
{
CheckObject = "DTBCZCDYDGX",
ErrorId = this.TBBSM,
ErrorTip = "标注城镇村属性码的地类图斑,其城镇村属性码必须与城镇村等用地层城镇村等用地类型保持一致规则检查失败:" + ex.Message,
ErrorType = "一类错误",
RuleCode = "CZC103",
RuleName = "城镇村等用地层城镇村标注逻辑性检查",
RuleContent = "若DTBCZCDYDGX层中的“标识码”字段找到相应DTBDLTBGX层中的图斑,查看DTBCZCDYDGX层中“城镇村类型”字段是否与DTBDLTBGX层中“城镇村属性码”相一致,若不相同,认定为错误图斑。"
};
rst.Add(ruleEntity);
}
return rst;
}
public List<RuleEntity> GD103()
{
List<RuleEntity> rst = new List<RuleEntity>();
try
{
string sql = $"SELECT DISTINCT A.BSM FROM DTBDLTBGX A LEFT JOIN DTBDLTBGXGC B ON A.BSM=B.BGHTBBSM WHERE A.TBBSM='{TBBSM}' AND A.DLBM LIKE '%K' AND B.BGQDLBM<>B.BGHDLBM";
DataTable dt = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, sql);
if (dt == null || dt.Rows.Count <= 0)
return null;
foreach (DataRow item in dt.Rows)
{
rst.Add(new RuleEntity()
{
CheckObject = "DTBDLTBGX",
ErrorId = $"{item["BSM"].ToString()}",
BGFWBSM = $"{item["BSM"].ToString()}",
ErrorTip = "不得新增可调整地类图斑",
ErrorType = "一类错误",
RuleCode = "GD103",
RuleName = "新增可调整地类检查"
});
}
}
catch (Exception ex)
{
RuleEntity ruleEntity = new RuleEntity()
{
CheckObject = "DTBDLTBGX",
ErrorId = this.TBBSM,
ErrorTip = "不得新增可调整地类图斑规则检查失败:" + ex.Message,
ErrorType = "一类错误",
RuleCode = "GD103",
RuleName = "新增可调整地类检查"
};
rst.Add(ruleEntity);
}
return rst;
}
public List<RuleEntity> HDGD001()
{
List<RuleEntity> rst = new List<RuleEntity>();
try
{
string sql = $"SELECT * FROM DTBDLTBGX WHERE TBBSM='{TBBSM}' AND TBXHDM='HDGD' AND ZZSXDM='WG'";
DataTable dt = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, sql);
if (dt == null || dt.Rows.Count <= 0)
return null;
foreach (DataRow item in dt.Rows)
{
rst.Add(new RuleEntity()
{
CheckObject = "DTBDLTBGX",
ErrorId = $"{item["BSM"].ToString()}",
BGFWBSM = $"{item["BSM"].ToString()}",
ErrorTip = "河道耕地不得标注未耕种",
ErrorType = "一类错误",
RuleCode = "HDGD001",
RuleName = "河道耕地种植属性标注检查",
RuleContent = "检查单图斑地类图斑更新层中图斑细化代码为HDGD的图斑;若种植属性代码为WG,认定为错误图斑"
});
}
}
catch (Exception ex)
{
RuleEntity ruleEntity = new RuleEntity()
{
CheckObject = "DTBDLTBGX",
ErrorId = this.TBBSM,
ErrorTip = "河道耕地不得标注未耕种规则检查失败:" + ex.Message,
ErrorType = "一类错误",
RuleCode = "HDGD001",
RuleName = "河道耕地种植属性标注检查",
RuleContent = "检查单图斑地类图斑更新层中图斑细化代码为HDGD的图斑;若种植属性代码为WG,认定为错误图斑"
};
rst.Add(ruleEntity);
}
return rst;
}
public List<RuleEntity> TTQ001()
{
List<RuleEntity> rst = new List<RuleEntity>();
try
{
string sql = $"SELECT * FROM DTBDLTBGX WHERE TBBSM='{TBBSM}' AND DDTCBZ='1303' AND DLBM IN ({DLParams.gd_dlbms}) AND ZZSXDM<>'WG'";
DataTable dt = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, sql);
if (dt == null || dt.Rows.Count <= 0)
return null;
foreach (DataRow item in dt.Rows)
{
rst.Add(new RuleEntity()
{
CheckObject = "DTBDLTBGX",
ErrorId = $"{item["BSM"].ToString()}",
BGFWBSM = $"{item["BSM"].ToString()}",
ErrorTip = "推土区范围内的耕地种植属性应为“WG”",
ErrorType = "一类错误",
RuleCode = "TTQ001",
RuleName = "推土区下耕地种植属性标注检查",
RuleContent = "检查DTBDLTBGX层中标注“推土区”、且地类编码为“01类”的图斑,其种植属性代码是否为WG;若不为WG,认定为错误图斑"
});
}
}
catch (Exception ex)
{
RuleEntity ruleEntity = new RuleEntity()
{
CheckObject = "DTBDLTBGX",
ErrorId = this.TBBSM,
ErrorTip = "推土区范围内的耕地种植属性应为“WG”规则检查失败:" + ex.Message,
ErrorType = "一类错误",
RuleCode = "TTQ001",
RuleName = "推土区下耕地种植属性标注检查",
RuleContent = "检查DTBDLTBGX层中标注“推土区”、且地类编码为“01类”的图斑,其种植属性代码是否为WG;若不为WG,认定为错误图斑"
};
rst.Add(ruleEntity);
}
return rst;
}
/// <summary>
/// 推土区下耕地种植属性标注检查
/// </summary>
/// <returns></returns>
public List<RuleEntity> TTQ201()
{
List<RuleEntity> rst = new List<RuleEntity>();
return rst;
try
{
string sql = $@"select distinct a.BSM from DTBDLTBGX as a
left join DTBDLTBGXGC as b on a.bsm = b.bghtbbsm where a.TBBSM = '{this.TBBSM}' and a.DDTCBZ = '1303' and a.DLBM like '01%'
and(b.BGQDLBM <> b.BGHDLBM or replace( b.BGQTBXHDM,' ','') <> b.BGHTBXHDM or (length(b.BGQGDLX) > 0 and length(b.BGHGDLX) > 0 and b.BGQGDLX <> b.BGHGDLX)) AND B.TBBGMJ > 50";
DataTable dt = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, sql);
if (dt == null || dt.Rows.Count <= 0)
{
return rst;
}
foreach (DataRow item in dt.Rows)
{
rst.Add(new RuleEntity()
{
CheckObject = "DTBDLTBGX",
ErrorId = $"{item[0].ToString()}",
BGFWBSM = $"{item[0].ToString()}",
ErrorTip = "推土区下耕地图斑,地类编码、图斑细化代码、耕地类型必须与基础库保持一致。",
ErrorType = "一类错误",
RuleCode = "TTQ201",
RuleName = "推土区下耕地上图检查",
RuleContent = "提取单独图层代码为1303的图斑,若地类编码为01类,检查其相应DTBDLTBGXGC层,变更前与变更后地类编码、图斑细化代码、耕地类型必须一致,且单个面积大于50平;否则,否则认定为错误图斑。(所有单个不一致部分均小于50平,当作该图斑一致处理)其中,耕地类型TT PD变为空;或空变TT PD的默认耕地类型一致。"
});
}
}
catch (Exception ex)
{
RuleEntity ruleEntity = new RuleEntity()
{
CheckObject = "DTBDLTBGX",
ErrorId = this.TBBSM,
ErrorTip = "TTQ201规则执行失败:" + ex.Message,
ErrorType = "一类错误",
RuleCode = "TTQ201",
RuleName = "推土区下耕地上图检查",
RuleContent = "提取单独图层代码为1303的图斑,若地类编码为01类,检查其相应DTBDLTBGXGC层,变更前与变更后地类编码、图斑细化代码、耕地类型必须一致,且单个面积大于50平;否则,否则认定为错误图斑。(所有单个不一致部分均小于50平,当作该图斑一致处理)其中,耕地类型TT PD变为空;或空变TT PD的默认耕地类型一致。"
};
rst.Add(ruleEntity);
}
return rst;
}
/// <summary>
/// 推土区下可不变更地类上图检查
/// </summary>
/// <returns></returns>
public List<RuleEntity> TTQ202()
{
List<RuleEntity> rst = new List<RuleEntity>();
try
{
return rst;
string sql = $@"select distinct a.BSM from DTBDLTBGX as a
left join DTBDLTBGXGC as b on a.TBBSM = b.TBBSM where a.TBBSM = '{this.TBBSM}' and a.DDTCBZ = '1303' and a.DLBM ='8801'
and ((b.BGQDLBM <> b.BGHDLBM or b.BGQTBXHDM <> b.BGHTBXHDM or b.BGQGDLX <> b.BGHGDLX or b.BGQZZSXDM <> b.BGHZZSXDM)) or (bghdlbm in ('0101','0102','0103') and bghzzsxdm<>'WG') AND B.TBBGMJ > 50";
DataTable dt = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, sql);
if (dt == null || dt.Rows.Count <= 0)
{
return rst;
}
foreach (DataRow item in dt.Rows)
{
rst.Add(new RuleEntity()
{
CheckObject = "DTBDLTBGX",
ErrorId = $"{item[0].ToString()}",
BGFWBSM = $"{item[0].ToString()}",
ErrorTip = "推土区下可不变更地类图斑,地类编码、种植属性代码、图斑细化代码、耕地类型必须与基础库保持一致。",
ErrorType = "一类错误",
RuleCode = "TTQ202",
RuleName = "推土区下可不变更地类上图检查",
RuleContent = "提取单独图层代码为1303的图斑,若地类编码为8801,检查其相应DTBDLTBGXGC层,变更前与变更后地类编码、种植属性代码、图斑细化代码、耕地类型必须一致;否则,否则认定为错误图斑。(所有单个不一致部分均小于50平)"
});
}
}
catch (Exception ex)
{
RuleEntity ruleEntity = new RuleEntity()
{
CheckObject = "DTBDLTBGX",
ErrorId = this.TBBSM,
ErrorTip = "TTQ202规则执行失败:" + ex.Message,
ErrorType = "一类错误",
RuleCode = "TTQ202",
RuleName = "推土区下可不变更地类上图检查",
RuleContent = "提取单独图层代码为1303的图斑,若地类编码为8801,检查其相应DTBDLTBGXGC层,变更前与变更后地类编码、种植属性代码、图斑细化代码、耕地类型必须一致;否则,否则认定为错误图斑。(所有单个不一致部分均小于50平)"
};
rst.Add(ruleEntity);
}
return rst;
}
/// <summary>
/// 拆除未尽区下基础库地类为建设用地上图检查
/// </summary>
/// <returns></returns>
public List<RuleEntity> CCWJQ201()
{
List<RuleEntity> rst = new List<RuleEntity>();
try
{
string sql = $@"select a.BSM,b.BGQDLBM, b.BGHDLBM, b.BGQTBXHDM,b.BGHTBXHDM,b.bgqGDLX,b.BGHGDLX from DTBDLTBGX as a
left join DTBDLTBGXGC as b on a.BSM=b.BGHTBBSM where a.TBBSM='{TBBSM}' and a.DDTCBZ='1304' AND A.DLBM IN ({DLParams.jsyd_dlbms}) and (B.BGQDLBM in ({DLParams.jsyd_dlbms}) or B.BGQDLBM = '1202')
and (trim(b.BGQDLBM) <> trim(b.BGHDLBM) or trim(b.BGQTBXHDM)<> trim(b.BGHTBXHDM) or trim(b.BGQZZSXDM) <> trim(b.BGHZZSXDM)) AND B.TBBGMJ>200";
DataTable dt = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, sql);
if (dt == null || dt.Rows.Count <= 0)
{
return rst;
}
foreach (DataRow item in dt.Rows)
{
rst.Add(new RuleEntity()
{
CheckObject = "DTBDLTBGX",
ErrorId = $"{item[0].ToString()}",
BGFWBSM = $"{item[0].ToString()}",
ErrorTip = "基础库为建设用地的拆除未尽区应按建设用地上图",
ErrorType = "一类错误",
RuleCode = "CCWJQ201",
RuleName = "拆除未尽区下基础库地类为建设用地上图检查",
RuleContent = "提取单独图层代码为1304的图斑,若地类为建设用地,找到相应DTBDLTBGXGC层,若存在变更前地类编码也为建设用地或设施农用地;同时存在变更前与变更后地类编码、种植属性代码、图斑细化代码不一致的,且不一致部分面积大于200平的,认定为错误图斑。"
});
}
}
catch (Exception ex)
{
RuleEntity ruleEntity = new RuleEntity()
{
CheckObject = "DTBDLTBGX",
ErrorId = this.TBBSM,
ErrorTip = "CCWJQ201规则执行失败:" + ex.Message,
ErrorType = "一类错误",
RuleCode = "CCWJQ201",
RuleName = "拆除未尽区下基础库地类为建设用地上图检查",
RuleContent = "提取单独图层代码为1304的图斑,若地类为建设用地,找到相应DTBDLTBGXGC层,若存在变更前地类编码也为建设用地或设施农用地;同时存在变更前与变更后地类编码、种植属性代码、图斑细化代码不一致的,且不一致部分面积大于200平的,认定为错误图斑。"
};
rst.Add(ruleEntity);
}
return rst;
}
/// <summary>
/// 拆除未尽区下基础库地类为设施农用地上图检查
/// </summary>
/// <returns></returns>
public List<RuleEntity> CCWJQ202()
{
List<RuleEntity> rst = new List<RuleEntity>();
try
{
string sql = $@"select distinct b.BGHTBBSM,b.BGQDLBM, b.BGHDLBM, b.BGQTBXHDM,b.BGHTBXHDM,b.bgqGDLX,b.BGHGDLX from DTBDLTBGX as a
left join DTBDLTBGXGC as b on a.bsm=b.bghtbbsm where a.TBBSM='{TBBSM}' and a.DDTCBZ='1304' AND A.DLBM ='1202' and (B.BGQDLBM in ({DLParams.jsyd_dlbms}) or B.BGQDLBM = '1202')
and(trim(b.BGQDLBM) <> trim(b.BGHDLBM) or trim(b.BGQTBXHDM) <> trim(b.BGHTBXHDM) or trim(b.BGQZZSXDM) <> trim(b.BGHZZSXDM)) AND B.TBBGMJ > 200";
DataTable dt = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, sql);
if (dt == null || dt.Rows.Count <= 0)
{
return rst;
}
foreach (DataRow item in dt.Rows)
{
rst.Add(new RuleEntity()
{
CheckObject = "DTBDLTBGX",
ErrorId = $"{item[0].ToString()}",
BGFWBSM = $"{item[0].ToString()}",
ErrorTip = "基础库为设施农用地的拆除未尽区应按建设用地上图",
ErrorType = "一类错误",
RuleCode = "CCWJQ202",
RuleName = "拆除未尽区下基础库地类为设施农用地上图检查",
RuleContent = "提取单独图层代码为1304的图斑,若地类为设施农用地,找到相应DTBDLTBGXGC层,若存在变更前地类编码也为建设用地或设施农用地;同时存在变更前与变更后地类编码、种植属性代码、图斑细化代码不一致的,且不一致部分面积大于200平的,认定为错误图斑。"
});
}
}
catch (Exception ex)
{
RuleEntity ruleEntity = new RuleEntity()
{
CheckObject = "DTBDLTBGX",
ErrorId = this.TBBSM,
ErrorTip = "CCWJQ202规则执行失败:" + ex.Message,
ErrorType = "一类错误",
RuleCode = "CCWJQ202",
RuleName = "拆除未尽区下基础库地类为设施农用地上图检查",
RuleContent = "提取单独图层代码为1304的图斑,若地类为设施农用地,找到相应DTBDLTBGXGC层,若存在变更前地类编码也为建设用地或设施农用地;同时存在变更前与变更后地类编码、种植属性代码、图斑细化代码不一致的,且不一致部分面积大于200平的,认定为错误图斑。"
};
rst.Add(ruleEntity);
}
return rst;
}
/// <summary>
/// "LNGD001"
/// (1)提取历年耕地图斑参考图层,记为C;
/// (2)提取合法建库设用地参考图层,记为D;在C中去除C与D重叠的部分;记为E
/// (3)将地类编码为0404的,种植属性代码为空,且单独图斑代码为空的图斑,与E进行叠加,重叠部分记为F;
/// (4)E占DTBDLTBGX层的比例大于90%,且F与坡度图5级部分的单个重叠面积不存在超过50平方米的,判定为错误图斑。
///
/// LNGD002
/// (1)提取历年耕地图斑参考图层,记为C;
/// (2)提取合法建库设用地参考图层,记为D;在C中去除C与D重叠的部分;记为E
/// (3)将地类编码为0404的,种植属性代码为空,且单独图斑代码为空的图斑,与E进行叠加;
/// (4)若重叠部分(单个)大于400平时,判定为错误图斑。
///
/// LNGD003
/// (1)提取历年耕地图斑参考图层,记为C;
/// (2)提取合法建库设用地参考图层,记为D;在C中去除C与D重叠的部分;记为E
/// (3)将地类编码为01类,种植属性代码为WG,且单独图斑代码为空的图斑,与E进行叠加;
/// (4)若不重叠部分占DTBDLTBGX层的比例大于90%时,判定为错误图斑。
///
/// LNGD004
/// (1)提取历年耕地图斑参考图层,记为C;
/// (2)提取合法建库设用地参考图层,记为D;在C中去除C与D重叠的部分;记为E
/// (3)将地类编码为01类,种植属性代码为WG,且单独图斑代码为空的图斑,与E进行叠加;
/// (4)若不重叠部分(单个)大于400平时,判定为错误图斑。
///
/// LNGD005
/// (1)提取历年耕地图斑参考图层,记为C;
/// (2)提取合法建库设用地参考图层,记为D;在C中去除C与D重叠的部分;记为E
/// (3)将地类编码为0404的,种植属性代码为空,且单独图斑代码为空的图斑,与E进行叠加,重叠部分记为F;
/// (4)E占DTBDLTBGX层的比例大于90%,且F与坡度图5级部分的单个重叠面积存在超过50平方米的,判定为错误图斑。
///
/// LNGD006
/// (1)提取历年耕地图斑参考图层,记为C;
/// (2)提取合法建库设用地参考图层,记为D;在C中去除C与D重叠的部分;记为E
/// (3)将地类编码为01类,种植属性代码为WG,耕地类型为PD,且单独图斑代码为空的图斑,与坡度图中5级部分进行叠加;
/// (4)若重叠部分(单个)大于100平时,判定为错误图斑。
/// </summary>
/// <returns></returns>
public List<RuleEntity> LNGD()
{
List<RuleEntity> result = new List<RuleEntity>();
IFeatureCursor pCursor = null;
IGeometry dltbGXgeo = null;
IFeature feature = null;
IFeatureClass lngdFeatureClass = null;
IFeatureClass sjxfPDTFeatureClass = null;
IFeatureClass hfjsydfwFeatureClass = null;
IFeatureClass jc_dltbFeatureClass = null;
try
{
//var wsFactory = new ESRI.ArcGIS.DataSourcesGDB.FileGDBWorkspaceFactoryClass();
//var workspace = wsFactory.OpenFromFile(@"D:\!!!!\440781台山市\历年耕地范围\(440781)台山市\(440781)历年耕地图斑层.gdb", 0);
//WorkspaceDic["LNGDWorkspace"] = workspace;
//修改时间:2021-11-22 修改原因:此规则只有填写了地类编码(地类编码不为空)才执行
DataTable dataTable = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, $"select * from dtbdltbgx where tbbsm='{TBBSM}' and length(dlbm)>=2");
if (dataTable == null || dataTable.Rows.Count <= 0)
{
return result;
}
if (!DicFeatureClass.ContainsKey("JC_DLTB") || DicFeatureClass["JC_DLTB"] == null)
{
throw new Exception("未找到“基础_地类图斑”参考图层!");
}
if (!DicFeatureClass.ContainsKey("LNGDFW") || DicFeatureClass["LNGDFW"] == null)
{
throw new Exception("未找到“基础_历年耕地”参考图层!");
}
if (!DicFeatureClass.ContainsKey("HFJSYDFW") || DicFeatureClass["HFJSYDFW"] == null)
{
throw new Exception("未找到“基础_合法建设用地范围”参考图层!");
}
if (!DicFeatureClass.ContainsKey("SJXF_PDT") || DicFeatureClass["SJXF_PDT"] == null)
{
throw new Exception("未找到“基础_省级下发坡度图”参考图层!");
}
lngdFeatureClass = DicFeatureClass["LNGDFW"];
sjxfPDTFeatureClass = DicFeatureClass["SJXF_PDT"];
hfjsydfwFeatureClass = DicFeatureClass["HFJSYDFW"];
jc_dltbFeatureClass = DicFeatureClass["JC_DLTB"];
ISpatialFilter spatialFilter = new SpatialFilterClass
{
SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects
};
ISpatialReference spatialReference = (lngdFeatureClass as IGeoDataset).SpatialReference;
//Console.WriteLine(spatialReference.Name);
if (spatialReference == null)
{
throw new Exception("历年耕地参考数据坐标参考为空,质检失败!");
}
foreach (DataRow item in dataTable.Rows)
{
string bsm = item["BSM"] == null ? "" : item["BSM"].ToString().Trim();
string dlbm = item["DLBM"] == null ? "" : item["DLBM"].ToString().Trim();
string zzsxdm = item["ZZSXDM"] == null ? "" : item["ZZSXDM"].ToString().Trim();
string ddtcbz = item["DDTCBZ"] == DBNull.Value ? "" : item["DDTCBZ"].ToString().Trim();
string gdlx = item["GDLX"] == null ? "" : item["GDLX"].ToString().Trim();
if (!dlbm.StartsWith("01") && !"'0404','0404A'".Contains(dlbm))
{
continue;
}
//单独图斑代码为空则跳过
if (!string.IsNullOrWhiteSpace(ddtcbz) && !ddtcbz.Equals("一般地类"))
{
continue;
}
dltbGXgeo = CheckHelper.GeometryConvertHelper.ConverJsonToIGeoemtry(item["egeometry"].ToString(), esriGeometryType.esriGeometryPolygon);
dltbGXgeo.Project(spatialReference);
IArea geoArea = dltbGXgeo as IArea;
double area = geoArea.Area;
//获取图形展示
//var targetFClass = (WorkspaceDic.FirstOrDefault(X => X.Key.Equals("LNGDWorkspace")).Value as IFeatureWorkspace).OpenFeatureClass("TTQ");
//IFeatureCursor tCursor = targetFClass.Insert(true);
//IFeatureBuffer tBuffer = targetFClass.CreateFeatureBuffer();
//tBuffer.Shape = pDLTBGXgeo;
//tCursor.InsertFeature(tBuffer);
//tCursor.Flush();
//叠加历年耕地
spatialFilter.Geometry = dltbGXgeo;
spatialFilter.WhereClause = null;
pCursor = lngdFeatureClass.Search(spatialFilter, true);
ITopologicalOperator topological = null;
while ((feature = pCursor.NextFeature()) != null)
{
if (topological == null)
{
topological = feature.ShapeCopy as ITopologicalOperator;
}
else
{
topological = topological.Union(feature.ShapeCopy) as ITopologicalOperator;
}
}
//IGeometryCollection geometries = new GeometryBagClass();
//geometries.AddGeometry(feature.ShapeCopy);
//ITopologicalOperator topological = new PolygonClass();
//topological.ConstructUnion(geometries as IEnumGeometry);
//(1)提取历年耕地图斑参考图层,记为C;
IGeometry EGeometry = topological as IGeometry;
if (EGeometry != null && !EGeometry.IsEmpty)
{
if (EGeometry.SpatialReference == null)
{
EGeometry.SpatialReference = spatialReference;
}
//合法建设用地
spatialFilter.Geometry = EGeometry;
pCursor = hfjsydfwFeatureClass.Search(spatialFilter, true);
topological = null;
while ((feature = pCursor.NextFeature()) != null)
{
//获取与历年耕地重叠的部分
IGeometry geometry = CommonHelper.InterSect(feature.ShapeCopy, EGeometry);
if (geometry == null || geometry.IsEmpty)
{
continue;
}
if (topological == null)
{
topological = geometry as ITopologicalOperator;
}
else
{
topological = topological.Union(geometry) as ITopologicalOperator;
}
//geometries.AddGeometry(geometry);
}
//topological = new PolygonClass();
//topological.ConstructUnion(geometries as IEnumGeometry);
//(2)提取合法建库设用地参考图层,记为D;在C中去除C与D重叠的部分;记为E
IGeometry hfjsgdGeometry = topological as IGeometry;
if (hfjsgdGeometry != null && !hfjsgdGeometry.IsEmpty)
{
if (hfjsgdGeometry.SpatialReference == null)
{
hfjsgdGeometry.SpatialReference = spatialReference;
}
ITopologicalOperator topologicalErea = EGeometry as ITopologicalOperator;
EGeometry = topologicalErea.Difference(hfjsgdGeometry);
if (EGeometry.SpatialReference == null)
{
EGeometry.SpatialReference = spatialReference;
}
}
}
//(3)提取基础库中种植属性代码为JKHF和GCHF的图斑,记为N,将N与E合并,形成F。
spatialReference = (jc_dltbFeatureClass as IGeoDataset).SpatialReference;
dltbGXgeo.Project(spatialReference);
//spatialFilter.Geometry = dltbGXgeo;
//spatialFilter.WhereClause = "ZZSXDM='JKHF' or ZZSXDM='GCHF'";
//pCursor = jc_dltbFeatureClass.Search(spatialFilter, true);
////添加E图形
//topological = null;
//if (EGeometry != null && !EGeometry.IsEmpty)
//{
// topological = EGeometry as ITopologicalOperator;
//}
//while ((feature = pCursor.NextFeature()) != null)
//{
// //获取与基础库地类图斑图层,种植属性代码为JKHF和GCHF的图斑重叠的部分
// IGeometry geometry = CommonHelper.InterSect(feature.ShapeCopy, dltbGXgeo);
// if (geometry == null || geometry.IsEmpty)
// {
// continue;
// }
// if (topological == null)
// {
// topological = geometry as ITopologicalOperator;
// }
// else
// {
// topological =
//
// ..Union(geometry) as ITopologicalOperator;
// }
//}
//IGeometry GGeometry = null;
//double GArea = 0;
//IGeometry FGeometry = topological as IGeometry;
//if (FGeometry != null && !FGeometry.IsEmpty)
//{
// if (FGeometry.SpatialReference == null)
// {
// FGeometry.SpatialReference = spatialReference;
// }
// //(4)将单图斑,与F进行叠加,重叠部分记为G;
// //规则更改:将单图斑,与E进行叠加,重叠部分记为G
// GGeometry = CommonHelper.InterSect(dltbGXgeo, FGeometry);
// GArea = (GGeometry as IArea).Area;
//}
IGeometry GGeometry = null;
double GArea = 0;
if (EGeometry != null && !EGeometry.IsEmpty)
{
topological = EGeometry as ITopologicalOperator;
if (EGeometry.SpatialReference == null)
{
EGeometry.SpatialReference = spatialReference;
}
//(4)将单图斑,与E进行叠加,重叠部分记为G;
//规则更改:将单图斑,与E进行叠加,重叠部分记为G
GGeometry = CommonHelper.InterSect(dltbGXgeo, EGeometry);
GArea = (GGeometry as IArea).Area;
}
//LNGD001
if (dlbm.Equals("0404") && string.IsNullOrWhiteSpace(zzsxdm) && GGeometry != null && !GGeometry.IsEmpty)
{
if (GArea / area > 0.9)
{
bool interSectPDTArea50 = false;
//此处为了保持GGeometry的坐标参考和坡度图坐标参考保持一直,否者后面无法执行InterSect相交空间处理
GGeometry.Project((sjxfPDTFeatureClass as IGeoDataset).SpatialReference);
//与省级下发坡度图叠加,记录与坡度级别为5的重叠部分的面积集合
spatialFilter.Geometry = GGeometry;
spatialFilter.WhereClause = "PDJB='5'";
//bool interSectPDTArea100 = false;
pCursor = sjxfPDTFeatureClass.Search(spatialFilter, true);
while ((feature = pCursor.NextFeature()) != null)
{
//获取与历年耕地重叠的部分
IGeometry geometry = CommonHelper.InterSect(feature.ShapeCopy, GGeometry);
if (geometry == null || geometry.IsEmpty)
{
continue;
}
IArea areaI = geometry as IArea;
if (areaI.Area > 50)
{
interSectPDTArea50 = true;
break;
//if (areaI.Area > 100)
//{
// interSectPDTArea100 = true;
// break;
//}
}
System.Runtime.InteropServices.Marshal.ReleaseComObject(geometry);
}
if (!interSectPDTArea50)
{
result.Add(new RuleEntity()
{
CheckObject = "DTBDLTBGX层",
ErrorId = bsm,
BGFWBSM = bsm,
ErrorTip = "实地为荒草地图斑与存量耕地重叠比例大于90%,且不存在大于50平的坡度,整图斑应按耕地未耕种上图。",
ErrorType = "一类错误",
RuleCode = "LHGD001",
RuleName = "荒草地上图检查",
RuleContent = "实地为荒草地图斑与存量耕地重叠比例大于90%,且不存在大于50平的坡度,整图斑应按耕地未耕种上图。"
});
}
else
{
result.Add(new RuleEntity()
{
CheckObject = "DTBDLTBGX层",
ErrorId = bsm,
BGFWBSM = bsm,
ErrorTip = "实地为荒草地图斑与存量耕地重叠比例大于90%,存在达到最小上图面积的5级坡度部分,核实整图斑是否应按耕地未耕种上图。",
ErrorType = "二类错误",
RuleCode = "LHGD005",
RuleName = "荒草地上图检查",
RuleContent = "实地为荒草地图斑与存量耕地重叠比例大于90%,存在达到最小上图面积的5级坡度部分,核实整图斑是否应按耕地未耕种上图。"
});
}
}
//LNGD002
CommonHelper.IsMuiltPart(GGeometry, out List<IGeometry> listGeometry);
foreach (var geo in listGeometry)
{
IArea pArea = geo as IArea;
if (pArea.Area > 400)
{
result.Add(new RuleEntity()
{
CheckObject = "DTBDLTBGX层",
ErrorId = bsm,
BGFWBSM = bsm,
ErrorTip = "实地为荒草地图斑与存量耕地重叠大于400平,重叠部分核实是否应按耕地未耕种上图。",
ErrorType = "二类错误",
RuleCode = "LHGD002",
RuleName = "荒草地上图检查",
RuleContent = "实地为荒草地图斑与存量耕地重叠大于400平,重叠部分核实是否应按耕地未耕种上图。"
});
break;
}
}
}//LNGD003
else if (dlbm.StartsWith("01") && zzsxdm.Equals("WG", StringComparison.CurrentCultureIgnoreCase))
{
if (GArea / area < 0.1)
{
result.Add(new RuleEntity()
{
CheckObject = "DTBDLTBGX层",
ErrorId = bsm,
BGFWBSM = bsm,
ErrorTip = "实地为荒草地图斑与存量耕地不重叠比例大于90%,整图斑应按荒草地上图。",
ErrorType = "一类错误",
RuleCode = "LHGD003",
RuleName = "耕地未耕种上图检查",
RuleContent = "实地为荒草地图斑与存量耕地不重叠比例大于90%,整图斑应按荒草地上图。"
});
}
if (EGeometry != null)
{
foreach (var geo in CommonHelper.DifferenceWithSingle(dltbGXgeo, EGeometry))
{
IArea pArea = geo as IArea;
//LNGD004
if (pArea.Area > 400)
{
result.Add(new RuleEntity()
{
CheckObject = "DTBDLTBGX层",
ErrorId = bsm,
BGFWBSM = bsm,
ErrorTip = "实地为荒草地图斑与存量耕地不重叠面积大于400平,核实不重叠部分是否应按荒草地上图。",
ErrorType = "二类错误",
RuleCode = "LHGD004",
RuleName = "耕地未耕种上图检查",
RuleContent = "实地为荒草地图斑与存量耕地不重叠面积大于400平,核实不重叠部分是否应按荒草地上图。"
});
break;
}
}
}
if (gdlx.Equals("PD", StringComparison.CurrentCultureIgnoreCase))
{
//与省级下发坡度图叠加,记录与坡度级别为5的重叠部分的面积集合
dltbGXgeo.Project((sjxfPDTFeatureClass as IGeoDataset).SpatialReference);
spatialFilter.Geometry = dltbGXgeo;
spatialFilter.WhereClause = "PDJB='5'";
pCursor = sjxfPDTFeatureClass.Search(spatialFilter, true);
while ((feature = pCursor.NextFeature()) != null)
{
//获取与坡度级别为5的重叠部分
IGeometry geometry = CommonHelper.InterSect(feature.ShapeCopy, dltbGXgeo);
if (geometry == null || geometry.IsEmpty)
{
continue;
}
CommonHelper.IsMuiltPart(geometry, out List<IGeometry> listGeometry);
foreach (IGeometry partGeometry in listGeometry)
{
if (partGeometry == null || partGeometry.IsEmpty)
{
continue;
}
IArea areaI = partGeometry as IArea;
if (areaI.Area > 100)
{
result.Add(new RuleEntity()
{
CheckObject = "DTBDLTBGX层",
ErrorId = bsm,
BGFWBSM = bsm,
ErrorTip = "核实坡耕地图斑5级部分是否应按耕地未耕种上图。",
ErrorType = "二类错误",
RuleCode = "LHGD006",
RuleName = "荒草地上图检查",
RuleContent = "核实坡耕地图斑5级部分是否应按耕地未耕种上图。"
});
System.Runtime.InteropServices.Marshal.ReleaseComObject(partGeometry);
break;
}
}
System.Runtime.InteropServices.Marshal.ReleaseComObject(geometry);
}
}
}
if (feature != null)
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(feature);
feature = null;
}
if (dltbGXgeo != null)
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(dltbGXgeo);
dltbGXgeo = null;
}
}
}
catch (Exception ex)
{
RuleEntity ruleEntity = new RuleEntity()
{
CheckObject = "DTBDLTBGX层",
ErrorId = this.TBBSM,
ErrorTip = "LHGD质检规则执行失败:" + ex.Message,
ErrorType = "一类错误",
RuleCode = "LHGD001",
RuleName = "荒草地上图检查",
RuleContent = "实地为荒草地图斑与存量耕地重叠比例大于90%,整图斑应按耕地未耕种上图。"
};
result.Add(ruleEntity);
}
finally
{
if (dltbGXgeo != null)
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(dltbGXgeo);
}
if (pCursor != null)
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(pCursor);
}
}
return result;
}
public List<RuleEntity> LHGXGD()
{
List<RuleEntity> result = new List<RuleEntity>();
IFeatureCursor pCursor = null;
IFeature feature = null;
IGeometry dltbGXgeo = null;
IFeatureClass jc_dltbFeatureClass = null;
try
{
if (!DicFeatureClass.ContainsKey("JC_DLTB") || DicFeatureClass["JC_DLTB"] == null)
{
throw new Exception("未找到“基础_地类图斑”参考图层!");
}
DataTable dataTable = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, $"select t.bsm,t.dlbm,t.egeometry,t.ddtcbz,t.zzsxdm from dtbdltbgx t WHERE t.TBBSM='{TBBSM}'");
if (dataTable == null || dataTable.Rows.Count <= 0)
{
return result;
}
jc_dltbFeatureClass = DicFeatureClass["JC_DLTB"];
ISpatialReference spatialReference = (jc_dltbFeatureClass as IGeoDataset).SpatialReference;
ISpatialFilter spatialFilter = new SpatialFilterClass
{
SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects,
};
if (spatialReference == null)
{
throw new Exception("基础_地类图斑参考数据坐标参考为空,质检失败!");
}
foreach (DataRow item in dataTable.Rows)
{
string bsm = item["bsm"].ToString() == null ? "" : item["bsm"].ToString().Trim();
string dlbm = item["dlbm"].ToString() == null ? "" : item["dlbm"].ToString().Trim();
string ddtcbz = item["ddtcbz"] == DBNull.Value ? "" : item["ddtcbz"].ToString().Trim();
//string bghdlbm = item["bghdlbm"]?.ToString() == null ? "" : item["bghdlbm"]?.ToString().Trim();
if (!"1306,1307,1308".Split(',').Contains(ddtcbz))
{
continue;
}
dltbGXgeo = CheckHelper.GeometryConvertHelper.ConverJsonToIGeoemtry(item["egeometry"]?.ToString(), esriGeometryType.esriGeometryPolygon, (jc_dltbFeatureClass as IGeoDataset).SpatialReference.FactoryCode, false);
dltbGXgeo.Project(spatialReference);
spatialFilter.Geometry = dltbGXgeo;
//LHGD001
//if ((ddtcbz.Equals("1306") || ddtcbz.Equals("1307")) && !dlbm.Equals("8801"))
//{
// result.Add(new RuleEntity()
// {
// CheckObject = "DTBDLTBGX",
// ErrorId = bsm,
// BGFWBSM = bsm,
// ErrorTip = "当单独图层代码为1306、1307时,地类编码必须为8801。",
// ErrorType = "一类错误",
// RuleCode = "LHGD001",
// RuleName = "标记荒草特征图斑单独图层代码与地类编码逻辑一致性检查",
// RuleContent = "当单独图层代码为1306、1307时,地类编码必须为8801。否则,认定为错误图斑。"
// });
//}
//LHGD002
if (ddtcbz.Equals("1306"))
{
//将单独图层代码为1306的单图斑与地类编码为建设用地或农用地基础地类图斑面积进行叠加
spatialFilter.WhereClause = string.Format("DLBM IN ({0}) OR DLBM = '1202'", DLParams.jsyd_dlbms);
pCursor = jc_dltbFeatureClass.Search(spatialFilter, true);
IGeometryCollection geometries = new GeometryBagClass();
ITopologicalOperator pTopologicalOperator = new PolygonClass();
while ((feature = pCursor.NextFeature()) != null)
{
feature.ShapeCopy.Project(spatialReference);
geometries.AddGeometry(feature.ShapeCopy);
}
pTopologicalOperator.ConstructUnion(geometries as IEnumGeometry);
IGeometry pGeometry = pTopologicalOperator as IGeometry;
pGeometry.SpatialReference = spatialReference;
IGeometry geometry = CommonHelper.InterSect(pGeometry, dltbGXgeo);
IArea areaI = geometry as IArea;
if ((geometry != null || !geometry.IsEmpty) && areaI.Area > 200)
{
result.Add(new RuleEntity()
{
CheckObject = "DTBDLTBGX层",
ErrorId = bsm,
BGFWBSM = bsm,
ErrorTip = "单独图层代码为1306时,相应范围内基础库地类必须不为建设用地或设施农用地。",
ErrorType = "一类错误",
RuleCode = "LHGD002",
RuleName = "标记荒草特征图斑单独图层代码与基础库逻辑一致性检查",
RuleContent = "当单独图层代码为1306时,相应范围内的基础库地类必须不为建设用地或设施农用地。若存在为建设用地或设施农用地的部分,大于200平的情况,认定为错误图斑"
});
}
//System.Runtime.InteropServices.Marshal.ReleaseComObject(geometry);
}
//LHGD003
if (ddtcbz.Equals("1307"))
{
//将单独图层代码为1307的单图斑与地类编码不为为建设用地或农用地基础地类图斑面积进行叠加
spatialFilter.WhereClause = string.Format("DLBM NOT IN ({0}) AND DLBM <> '1202'", DLParams.jsyd_dlbms);
pCursor = jc_dltbFeatureClass.Search(spatialFilter, true);
IGeometryCollection geometries = new GeometryBagClass();
ITopologicalOperator pTopologicalOperator = new PolygonClass();
while ((feature = pCursor.NextFeature()) != null)
{
feature.ShapeCopy.Project(spatialReference);
geometries.AddGeometry(feature.ShapeCopy);
}
pTopologicalOperator.ConstructUnion(geometries as IEnumGeometry);
IGeometry pGeometry = pTopologicalOperator as IGeometry;
pGeometry.SpatialReference = spatialReference;
IGeometry geometry = CommonHelper.InterSect(pGeometry, dltbGXgeo);
IArea areaI = geometry as IArea;
if ((geometry != null || !geometry.IsEmpty) && areaI.Area > 400)
{
result.Add(new RuleEntity()
{
CheckObject = "DTBDLTBGX层",
ErrorId = bsm,
BGFWBSM = bsm,
ErrorTip = "单独图层代码为1307时,相应范围内基础库地类必须为建设用地或设施农用地。",
ErrorType = "一类错误",
RuleCode = "LHGD003",
RuleName = "标记荒草特征图斑单独图层代码与基础库逻辑一致性检查",
RuleContent = "当单独图层代码为1307时,相应范围内的基础库地类必须为建设用地或设施农用地。若存在不为建设用地或设施农用地的部分,大于400平的情况,认定为错误图斑。"
});
}
}
//LHGD004
if (ddtcbz.Equals("1308") && !dlbm.Equals("8801") && !dlbm.StartsWith("01"))
{
result.Add(new RuleEntity()
{
CheckObject = "DTBDLTBGX",
ErrorId = bsm,
BGFWBSM = bsm,
ErrorTip = "当单独图层代码为1308时,地类编码必须为8801或耕地。",
ErrorType = "一类错误",
RuleCode = "LHGD004",
RuleName = "标记荒草特征图斑单独图层代码与地类编码逻辑一致性检查",
RuleContent = "当单独图层代码为1308时,变更后地类编码必须为8801或01类。否则,认定为错误图斑。"
});
}
//LHGD005
if (ddtcbz.Equals("1308") && (dlbm.Equals("0101") || dlbm.Equals("0102") || dlbm.Equals("0103")) && !item["zzsxdm"].ToString().Equals("WG", StringComparison.CurrentCultureIgnoreCase))
{
result.Add(new RuleEntity()
{
CheckObject = "DTBDLTBGX",
ErrorId = bsm,
BGFWBSM = bsm,
ErrorTip = "当单独图层代码为1308,地类编码为01类时,种植属性代码必须为WG。",
ErrorType = "一类错误",
RuleCode = "LHGD005",
RuleName = "标记翻土特征图斑单独图层代码与耕地地类逻辑一致性检查",
RuleContent = "当单独图层代码为1308时,变更后地类编码必须为0101、0102、0103时,种植属性代码必须为WG。否则,认定为错误图斑。"
});
}
if (feature != null)
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(feature);
feature = null;
}
if (dltbGXgeo != null)
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(dltbGXgeo);
dltbGXgeo = null;
}
}
}
catch (Exception ex)
{
result.Add(new RuleEntity()
{
CheckObject = "DTBDLTBGX",
ErrorId = this.TBBSM,
ErrorTip = "LHGD规则执行失败:" + ex.Message,
ErrorType = "一类错误",
RuleCode = "LHGD001",
RuleName = "标记荒草特征图斑单独图层代码与地类编码逻辑一致性检查",
RuleContent = "当单独图层代码为1306、1307时,地类编码必须为8801。否则,认定为错误图斑。"
});
}
return result.Where((x, i) => result.FindIndex(s => s.ErrorId == x.ErrorId) == i).ToList(); ;
}
public List<RuleEntity> LHGXGCGD()
{
List<RuleEntity> result = new List<RuleEntity>();
IFeatureCursor pCursor = null;
IFeature feature = null;
IGeometry dltbGXgeo = null;
IFeatureClass lngdFeatureClass = null;
IFeatureClass sjxfPDTFeatureClass = null;
IFeatureClass hfjsydfwFeatureClass = null;
try
{
if (!DicFeatureClass.ContainsKey("LNGDFW") || DicFeatureClass["LNGDFW"] == null)
{
throw new Exception("未找到“基础_历年耕地”参考图层!");
}
if (!DicFeatureClass.ContainsKey("HFJSYDFW") || DicFeatureClass["HFJSYDFW"] == null)
{
//throw new Exception("未找到“基础_合法建设用地范围”参考图层!");
//hfjsydfwFeatureClass = DicFeatureClass["LNGDFW"];
}
if (!DicFeatureClass.ContainsKey("SJXF_PDT") || DicFeatureClass["SJXF_PDT"] == null)
{
throw new Exception("未找到“基础_省级下发坡度图”参考图层!");
}
DataTable dataTable = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, $"select t.bsm,t.dlbm,t1.egeometry,t.ddtcbz,t.zzsxdm,t1.bghdlbm from dtbdltbgx t left join DTBDLTBGXGC t1 on t.BSM=t1.BGHTBBSM WHERE t.TBBSM='{TBBSM}'");
if (dataTable == null || dataTable.Rows.Count <= 0)
{
return result;
}
lngdFeatureClass = DicFeatureClass["LNGDFW"];
sjxfPDTFeatureClass = DicFeatureClass["SJXF_PDT"];
//hfjsydfwFeatureClass = DicFeatureClass["HFJSYDFW"];
ISpatialReference spatialReference = (lngdFeatureClass as IGeoDataset).SpatialReference;
ISpatialFilter spatialFilter = new SpatialFilterClass
{
SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects
};
if (spatialReference == null)
{
throw new Exception("历年耕地参考数据坐标参考为空,质检失败!");
}
foreach (DataRow item in dataTable.Rows)
{
string bsm = item["bsm"].ToString() == null ? "" : item["bsm"].ToString().Trim();
string dlbm = item["dlbm"].ToString() == null ? "" : item["dlbm"].ToString().Trim();
string ddtcbz = item["ddtcbz"] == DBNull.Value ? "" : item["ddtcbz"].ToString().Trim();
string bghdlbm = item["bghdlbm"]?.ToString() == null ? "" : item["bghdlbm"]?.ToString().Trim();
string zzsxdm = item["zzsxdm"] == DBNull.Value ? "" : item["zzsxdm"].ToString().Trim();
if (!bghdlbm.Equals("0404") && !bghdlbm.StartsWith("01"))
{
continue;
}
dltbGXgeo = CheckHelper.GeometryConvertHelper.ConverJsonToIGeoemtryWithoutSimple(item["egeometry"].ToString(), esriGeometryType.esriGeometryPolygon, (lngdFeatureClass as IGeoDataset).SpatialReference.FactoryCode, false);
IArea geoArea = dltbGXgeo as IArea;
double area = geoArea.Area;
dltbGXgeo.Project(spatialReference);
//(1)提取历年耕地图斑参考图层,记为A;
spatialFilter.Geometry = dltbGXgeo;
spatialFilter.WhereClause = null;
pCursor = lngdFeatureClass.Search(spatialFilter, true);
ITopologicalOperator topological = null;
while ((feature = pCursor.NextFeature()) != null)
{
if (topological == null)
{
topological = feature.ShapeCopy as ITopologicalOperator;
}
else
{
topological = topological.Union(feature.ShapeCopy) as ITopologicalOperator;
}
}
IGeometry AGeometry = topological as IGeometry;
//提取合法建设用地参考图层,记为B
//dltbGXgeo.Project((hfjsydfwFeatureClass as IGeoDataset).SpatialReference);
//spatialFilter.Geometry = dltbGXgeo;
//spatialFilter.WhereClause = null;
//pCursor = hfjsydfwFeatureClass.Search(spatialFilter, true);
//topological = null;
//while ((feature = pCursor.NextFeature()) != null)
//{
// if (topological == null)
// {
// topological = feature.ShapeCopy as ITopologicalOperator;
// }
// else
// {
// topological = topological.Union(feature.ShapeCopy) as ITopologicalOperator;
// }
//}
IPolygon polygon = new PolygonClass();
IGeometry BGeometry = polygon as IGeometry;
BGeometry.SetEmpty();
//IGeometry BGeometry = topological as IGeometry;
//提取坡度图中5级坡度部分,记为C
dltbGXgeo.Project((sjxfPDTFeatureClass as IGeoDataset).SpatialReference);
spatialFilter.Geometry = dltbGXgeo;
spatialFilter.WhereClause = "PDJB='5'";
pCursor = sjxfPDTFeatureClass.Search(spatialFilter, true);
topological = null;
while ((feature = pCursor.NextFeature()) != null)
{
if (topological == null)
{
topological = feature.ShapeCopy as ITopologicalOperator;
}
else
{
topological = topological.Union(feature.ShapeCopy) as ITopologicalOperator;
}
}
IGeometry CGeometry = topological as IGeometry;
//取B与C的并集,记为D
IGeometry DGeometry = null;
if (!BGeometry.IsEmpty && (CGeometry != null && !CGeometry.IsEmpty))
{
if (BGeometry.SpatialReference == null)
{
BGeometry.SpatialReference = spatialReference;
}
if (CGeometry.SpatialReference == null)
{
CGeometry.SpatialReference = spatialReference;
}
DGeometry = CommonHelper.Union(BGeometry, CGeometry);
}
if (BGeometry == null && (CGeometry != null && !CGeometry.IsEmpty))
{
if (CGeometry.SpatialReference == null)
{
CGeometry.SpatialReference = spatialReference;
}
DGeometry = CGeometry;
}
if ((BGeometry != null && !BGeometry.IsEmpty) && CGeometry == null)
{
if (BGeometry.SpatialReference == null)
{
BGeometry.SpatialReference = spatialReference;
}
DGeometry = BGeometry;
}
//从A中,去除A与D的重叠部分,剩余部分记为E
IGeometry EGeometry = null;
if (AGeometry != null && !AGeometry.IsEmpty)
{
if (AGeometry.SpatialReference == null)
{
AGeometry.SpatialReference = spatialReference;
}
ITopologicalOperator topologicalErea = AGeometry as ITopologicalOperator;
if (DGeometry != null && !DGeometry.IsEmpty)
{
EGeometry = topologicalErea.Difference(DGeometry);
}
else
{
EGeometry = AGeometry;
}
if (EGeometry.SpatialReference == null)
{
EGeometry.SpatialReference = spatialReference;
}
}
//从DLTBDLTBGXGC层中,提取变更后地类编码为0404,且面积大于200平的图斑,记为图斑M
if (bghdlbm.Equals("0404") && area > 200 && EGeometry != null && !EGeometry.IsEmpty)
{
//M与E重叠部分
string jsonGeometry = string.Empty;
bool areaState = false;
IGeometry GGeometry = CommonHelper.InterSect(dltbGXgeo, EGeometry);
double GArea = (GGeometry as IArea).Area;
CommonHelper.IsMuiltPart(GGeometry, out List<IGeometry> listGeometry);
foreach (var geo in listGeometry)
{
IArea pArea = geo as IArea;
if (pArea.Area > 200)
{
areaState = true;
jsonGeometry = GeometryConvertHelper.GeometryToJsonString(geo);
break;
}
}
//若M与E重叠部分,占M的比例大于90%或存在单个重叠部分面积大于200平的,认定为错误图斑。
if (GArea / area > 0.9 || areaState)
{
result.Add(new RuleEntity()
{
CheckObject = "DTBDLTBGXGC层",
ErrorId = bsm,
BGFWBSM = bsm,
ErrorTip = "实地为荒草地状态,与撂荒耕地参考图层重叠比例大于90%或面积大于200平,核实是否应标注历年耕地内荒草地参考图层。",
ErrorType = "二类错误",
RuleCode = "LHGD101",
RuleName = "荒草地状态图斑检查",
RuleContent = "实地为荒草地状态,与撂荒耕地参考图层重叠比例大于90%或面积大于200平,核实是否应标注历年耕地内荒草地参考图层。",
Geometry = jsonGeometry,
GeometryType = 3
});
}
}
//从DLTBDLTBGXGC层中,提取变更后单独图层代码为1306、1307,且面积大于200平的图斑,记为图斑M
if (bghdlbm.StartsWith("01") && zzsxdm.Equals("WG", StringComparison.CurrentCultureIgnoreCase))
{
if (area > 200)
{
//M与E不重叠部分
string jsonGeometry = string.Empty;
bool areaState = false;
double GArea = 0;
if (EGeometry != null && !EGeometry.IsEmpty)
{
IGeometry GGeometry = CommonHelper.Difference(dltbGXgeo, EGeometry);
GArea = (GGeometry as IArea).Area;
CommonHelper.IsMuiltPart(GGeometry, out List<IGeometry> listGeometry);
foreach (var geo in listGeometry)
{
IArea pArea = geo as IArea;
if (pArea.Area > 200)
{
areaState = true;
jsonGeometry = GeometryConvertHelper.GeometryToJsonString(geo);
//IGeometry geoPoint = CheckHelper.GeometryConvertHelper.ConverJsonToIGeoemtryWithoutSimple(jsonGeometry, esriGeometryType.esriGeometryPolygon, (lngdFeatureClass as IGeoDataset).SpatialReference.FactoryCode, false);
//jsonGeometry = GeometryConvertHelper.GeometryToJsonString(geoPoint);
break;
}
}
}
//若M与E不重叠部分,占M的比例大于90%或存在单个不重叠部分面积大于200平的,认定为错误图斑。
if (GArea / area > 0.9 || areaState || EGeometry == null)
{
result.Add(new RuleEntity()
{
CheckObject = "DTBDLTBGXGC层",
ErrorId = bsm,
BGFWBSM = bsm,
ErrorTip = "实地为荒草地状态或翻土状态,与撂荒耕地参考图层不重叠比例大于90%或面积大于200平。",
ErrorType = "一类错误",
RuleCode = "LHGD102",
RuleName = "历年耕地范围内荒草地状态图斑检查",
RuleContent = "实地为荒草地状态或翻土状态,与撂荒耕地参考图层不重叠比例大于90%或面积大于200平。",
Geometry = jsonGeometry,
GeometryType = 3
});
}
}
}
if (feature != null)
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(feature);
feature = null;
}
if (dltbGXgeo != null)
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(dltbGXgeo);
dltbGXgeo = null;
}
}
}
catch (Exception ex)
{
result.Add(new RuleEntity()
{
CheckObject = "DTBDLTBGXGC层",
ErrorId = this.TBBSM,
ErrorTip = "LHGD规则执行失败:" + ex.Message,
ErrorType = "一类错误",
RuleCode = "LHGD101",
RuleName = "荒草地状态图斑检查",
RuleContent = "实地为荒草地状态,与撂荒耕地参考图层重叠比例大于90%或面积大于200平,核实是否应标注历年耕地内荒草地参考图层。"
});
}
return result.Where((x, i) => result.FindIndex(s => s.ErrorId == x.ErrorId) == i).ToList();
}
/// <summary>
/// "HFSX001","HFSX002","HFSX003","HFSX004","HFSX005"
/// </summary>
/// <returns></returns>
public List<RuleEntity> HFSX()
{
List<RuleEntity> result = new List<RuleEntity>();
IGeometry pDLTBGXgeo = null;
IFeatureCursor pGDHFSXCursor = null;
try
{
//var wsFactory = new ESRI.ArcGIS.DataSourcesGDB.FileGDBWorkspaceFactoryClass();
//var workspace = wsFactory.OpenFromFile(@"D:\04数据\智能调查云\7563\海珠新\耕地及恢复属性图斑层\440105.gdb", 0);
//WorkspaceDic["GDHFSXWorkspace"] = workspace;
DataTable dataTable = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, $"select * from dtbdltbgx where tbbsm='{TBBSM}'");
if (dataTable == null || dataTable.Rows.Count <= 0)
{
return result;
}
if (!DicFeatureClass.ContainsKey("GDHFSX") || DicFeatureClass["GDHFSX"] == null)
{
throw new Exception("未检测到“耕地恢复属性”图层");
}
IFeatureClass pGDHFSXFeatureClass = DicFeatureClass["GDHFSX"];
ISpatialReference spatialReference = (pGDHFSXFeatureClass as IGeoDataset).SpatialReference;
if (spatialReference == null)
{
throw new Exception("耕地恢复属性参考图层层坐标参考为空,质检失败!");
}
ISpatialFilter pGDHFSXSpatialFilter = new SpatialFilterClass
{
SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects
};
int indexGDHFSXZZSXDM = pGDHFSXFeatureClass.FindField("ZZSXDM");
List<string> lisBsms = new List<string>() { "0201", "0202", "0203", "0204", "0301", "0302", "0305", "0307", "0404A", "1104", "1104A", "0404" };//新增地类编码0404
foreach (DataRow item in dataTable.Rows)
{
string bsm = item["BSM"].ToString();
string dlbm = item["DLBM"].ToString();
string zzsxdm = item["ZZSXDM"].ToString();
if (!lisBsms.Contains(dlbm))
{
continue;
}
pDLTBGXgeo = CheckHelper.GeometryConvertHelper.ConverJsonToIGeoemtry(item["egeometry"].ToString());
pDLTBGXgeo.Project(spatialReference);
IArea area = pDLTBGXgeo as IArea;
//叠加基础库
IGeometryCollection pGDHFSXGeometries = new GeometryBagClass();
ITopologicalOperator pGDHFSXTopologicalOperator = new PolygonClass();
pGDHFSXSpatialFilter.Geometry = pDLTBGXgeo;
pGDHFSXCursor = pGDHFSXFeatureClass.Search(pGDHFSXSpatialFilter, true);
IFeature pGDHFSXfeature = null;
while ((pGDHFSXfeature = pGDHFSXCursor.NextFeature()) != null)
{
if (!CommonHelper.IsInterSect(pDLTBGXgeo, pGDHFSXfeature.ShapeCopy))
{
continue;
}
string sJCKzzsxdm = pGDHFSXfeature.Value[indexGDHFSXZZSXDM] + string.Empty;
pGDHFSXGeometries.AddGeometry(pGDHFSXfeature.ShapeCopy);
}
pGDHFSXTopologicalOperator.ConstructUnion(pGDHFSXGeometries as IEnumGeometry);
IGeometry pGDHFSXGeometry = pGDHFSXTopologicalOperator as IGeometry;
IGeometry resultGeo = CommonHelper.InterSect(pGDHFSXGeometry, pDLTBGXgeo); //叠加
IArea resultArea = resultGeo as IArea;
//HFSX001
if (zzsxdm == "JKHF" && resultArea.Area / area.Area < 0.8)
{
result.Add(new RuleEntity()
{
CheckObject = "DTBDLTBGX层",
ErrorId = bsm,
BGFWBSM = $"{item["BSM"].ToString()}",
ErrorTip = "JKHF图斑与参考图层重叠部分不够比例。",
ErrorType = "一类错误",
RuleCode = "HFSX001",
RuleName = "即可恢复图斑上图检查",
RuleContent = "JKHF图斑与参考图层重叠部分不够比例。"
});
}
//HFSX002
if (zzsxdm == "GCHF" && resultArea.Area / area.Area < 0.4)
{
result.Add(new RuleEntity()
{
CheckObject = "DTBDLTBGX层",
ErrorId = bsm,
BGFWBSM = $"{item["BSM"].ToString()}",
ErrorTip = "GCHF图斑与参考图层重叠部分不够比例。",
ErrorType = "一类错误",
RuleCode = "HFSX002",
RuleName = "工程恢复图斑上图检查",
RuleContent = "GCHF图斑与参考图层重叠部分不够比例。"
});
}
//HFSX003
if (zzsxdm == "" && resultArea.Area / area.Area > 0.5)
{
result.Add(new RuleEntity()
{
CheckObject = "DTBDLTBGX层",
ErrorId = bsm,
BGFWBSM = $"{item["BSM"].ToString()}",
ErrorTip = "图斑恢复属性应标注未标注",
ErrorType = "二类错误",
RuleCode = "HFSX003",
RuleName = "未标注恢复属性图斑上图检查",
RuleContent = "图斑恢复属性应标注未标注"
});
}
//HFSX004
if (zzsxdm == "JKHF" && resultArea.Area / area.Area >= 0.8 && resultArea.Area / area.Area <= 0.9)
{
result.Add(new RuleEntity()
{
CheckObject = "DTBDLTBGX层",
ErrorId = bsm,
BGFWBSM = $"{item["BSM"].ToString()}",
ErrorTip = "图斑与参考图层重叠部分是否可按JKHF标注,需核实",
ErrorType = "二类错误",
RuleCode = "HFSX004",
RuleName = "即可恢复图斑上图检查",
RuleContent = "图斑与参考图层重叠部分是否可按JKHF标注,需核实"
});
}
//HFSX005:依据许涛提供的“新思路质检规则20220331.xls”规则文档关闭该规则
//if (zzsxdm == "GCHF" && resultArea.Area / area.Area <= 0.5 && resultArea.Area / area.Area >= 0.4)
//{
// result.Add(new RuleEntity()
// {
// CheckObject = "DTBDLTBGX层",
// ErrorId = bsm,
// ErrorTip = "图斑与参考图层重叠部分是否可按GCHF标注,需核实",
// ErrorType = "二类错误",
// RuleCode = "HFSX005",
// RuleName = "工程恢复图斑上图检查",
// RuleContent = "图斑与参考图层重叠部分是否可按GCHF标注,需核实"
// });
//}
}
}
catch (Exception ex)
{
RuleEntity ruleEntity = new RuleEntity()
{
CheckObject = "DTBDLTBGX层",
ErrorId = this.TBBSM,
BGFWBSM = this.TBBSM,
ErrorTip = "JKHF图斑与参考图层重叠部分不够比例规则检查失败:" + ex.Message,
ErrorType = "一类错误",
RuleCode = "HFSX001",
RuleName = "荒草地上图检查",
RuleContent = "JKHF图斑与参考图层重叠部分不够比例。"
};
result.Add(ruleEntity);
}
finally
{
if (pDLTBGXgeo != null)
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(pDLTBGXgeo);
}
if (pGDHFSXCursor != null)
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(pGDHFSXCursor);
}
}
return result;
}
/// <summary>
///
/// </summary>
/// <returns></returns>
public List<RuleEntity> DDTC20X()
{
List<RuleEntity> result = new List<RuleEntity>();
IGeometry pDLTBGXgeo = null;
IFeatureCursor pJCKCursor = null;
IFeatureClass pYDGLFeatureClass = null;
try
{
DataTable dataTable = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, $"select * from dtbdltbgx where tbbsm='{TBBSM}'");
if (dataTable == null || dataTable.Rows.Count <= 0)
{
return result;
}
if (!DicFeatureClass.ContainsKey("JC_DLTB") || DicFeatureClass["JC_DLTB"] == null)
{
throw new Exception("未找到“基础库地类图斑层”!");
}
if (!DicFeatureClass.ContainsKey("NYZXMTB") || DicFeatureClass["NYZXMTB"] == null)
{
throw new Exception("未找到用“地管理信息农转用项目图斑”图层!");
}
IFeatureClass pJCKFeatureClass = DicFeatureClass["JC_DLTB"];
if (DicFeatureClass.ContainsKey("NYZXMTB"))
pYDGLFeatureClass = DicFeatureClass["NYZXMTB"];
ISpatialReference spatialReference = (pYDGLFeatureClass as IGeoDataset).SpatialReference;
if (spatialReference == null)
{
throw new Exception("基础库地类信息参考数据坐标参考为空,质检失败!");
}
//ISpatialFilter pJCKSpatialFilter = new SpatialFilterClass
//{
// SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects
//};
ISpatialFilter pYDGLSpatialFilter = new SpatialFilterClass
{
SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects
};
//int indexJCKZZSXDM = pJCKFeatureClass.FindField("ZZSXDM");
//int indexJCKTBXHDM = pJCKFeatureClass.FindField("TBXHDM");
//int indexJCKDLBM = pJCKFeatureClass.FindField("DLBM");
//int indexJCKGDLX = pJCKFeatureClass.FindField("GDLX");
foreach (DataRow item in dataTable.Rows)
{
IFeatureCursor pYDGLCursor = null;
IGeometry pYDGLGeometry = null;
List<IGeometry> listGeometryLNGDIntsect = null;
List<IGeometry> listGeometryLNGDDifference = null;
try
{
string bsm = item["BSM"].ToString();
string dlbm = item["DLBM"].ToString();
//string zzsxdm = item["ZZSXDM"] == null ? "" : item["ZZSXDM"].ToString().Trim();
//string tbxhdm = item["TBXHDM"] == null ? "" : item["TBXHDM"].ToString().Trim();
string ddtcdm = item["DDTCBZ"] == null ? "" : item["DDTCBZ"].ToString().Trim();
//string gdlx = item["GDLX"] == null ? "" : item["GDLX"].ToString().Trim();
pDLTBGXgeo = CheckHelper.GeometryConvertHelper.ConverJsonToIGeoemtry(item["egeometry"].ToString(), esriGeometryType.esriGeometryPolygon);
pDLTBGXgeo.Project(spatialReference);
IArea area = pDLTBGXgeo as IArea;
if (pYDGLFeatureClass != null)
{
//用地管理信息
//IGeometryCollection pYDGLGeometries = new GeometryBagClass();
ITopologicalOperator pYDGLTopologicalOperator = null;
pYDGLSpatialFilter.Geometry = pDLTBGXgeo;
pYDGLCursor = pYDGLFeatureClass.Search(pYDGLSpatialFilter, true);
IFeature pYDGLfeature = null;
while ((pYDGLfeature = pYDGLCursor.NextFeature()) != null)
{
if (pYDGLTopologicalOperator == null)
{
pYDGLTopologicalOperator = pYDGLfeature.ShapeCopy as ITopologicalOperator;
}
else
{
pYDGLTopologicalOperator = pYDGLTopologicalOperator.Union(pYDGLfeature.ShapeCopy) as ITopologicalOperator;
}
//if (!CommonHelper.IsInterSect(pDLTBGXgeo, pYDGLfeature.ShapeCopy))
// continue;
//pYDGLGeometries.AddGeometry(pYDGLfeature.ShapeCopy);
}
//pYDGLTopologicalOperator.ConstructUnion(pYDGLGeometries as IEnumGeometry);
pYDGLGeometry = pYDGLTopologicalOperator as IGeometry;
if (pYDGLGeometry != null && pYDGLGeometry.SpatialReference == null)
{
pYDGLGeometry.SpatialReference = (pYDGLFeatureClass as IGeoDataset).SpatialReference;
pYDGLGeometry.Project(spatialReference);
}
}
else
{
//pYDGLGeometry = new IGeometry();
IPolygon polygon = new PolygonClass();
pYDGLGeometry = polygon as IGeometry;
pYDGLGeometry.SetEmpty();
}
//重叠部分的图形面积
double intersectArea = -1;
IGeometry pGeYDGDInt = CommonHelper.InterSect(pYDGLGeometry, pDLTBGXgeo); //叠加
if (pGeYDGDInt != null && !pGeYDGDInt.IsEmpty)
{
pGeYDGDInt.Project((pYDGLFeatureClass as IGeoDataset).SpatialReference);
IArea pIntersectArea = pGeYDGDInt as IArea;
intersectArea = pIntersectArea.Area;
}
CommonHelper.IsMuiltPart(pGeYDGDInt, out listGeometryLNGDIntsect);
if (pYDGLGeometry == null)
{
IPolygon polygon = new PolygonClass();
pYDGLGeometry = polygon as IGeometry;
pYDGLGeometry.SetEmpty();
}
IGeometry pGetDifference = CommonHelper.Difference(pYDGLGeometry, pDLTBGXgeo);
if (pGetDifference != null && !pGetDifference.IsEmpty)
{
pGetDifference.Project((pYDGLFeatureClass as IGeoDataset).SpatialReference);
}
CommonHelper.IsMuiltPart(pGetDifference, out listGeometryLNGDDifference);
//记录不重叠的部分是否存在大于等于200平的部分
bool diffArea = false;
//获取单图斑与用地管理信息不重叠的部分
foreach (var geo in listGeometryLNGDDifference)
{
IArea pArea = geo as IArea;
if (pArea.Area >= 200)
{
diffArea = true;
break;
}
}
//GFBQ202
if (diffArea && ddtcdm == "1302" && !"0101、0102、0103、0204、0307、0401、0403、0404、0404A、0601、1101、1102、1103、1104、1104K、1105、1106、1107、1204、1205、1206、1207、8801、9901".Contains(dlbm))
{
result.Add(new RuleEntity()
{
CheckObject = "DTBDLTBGX层",
ErrorId = bsm,
BGFWBSM = bsm,
ErrorTip = "位于用地管理信息范围外光伏板区下地类未按地表地类上图,需核实",
ErrorType = "二类错误",
RuleCode = "GFBQ202",
RuleName = "位于用地管理信息范围外光伏板区下地类上图检查",
RuleContent = "位于用地管理信息范围外光伏板区下地类未按地表地类上图,需核实"
});
}
//TTQ203
if (ddtcdm == "1303" && DLParams.jsyd_dlbms.Contains(dlbm))
{
var geos = CommonHelper.DifferenceWithSingle(pDLTBGXgeo, pYDGLGeometry);
bool flag = false;
foreach (var geo in geos)
{
IArea pArea = geo as IArea;
if (pArea.Area >= 200)
{
flag = true;
break;
}
}
if (flag)
{
result.Add(new RuleEntity()
{
CheckObject = "DTBDLTBGX层",
ErrorId = bsm,
BGFWBSM = bsm,
ErrorTip = "推土区下按建设用地上图,应位于用地管理信息范围内。",
ErrorType = "一类错误",
RuleCode = "TTQ203",
RuleName = "推土区下用地管理信息上图检查",
RuleContent = "提取单独图层代码为1303的图斑,若地类编码为建设用地的图斑,必须与用地管理信息存在重叠;否则,认定为错误图斑。(所有单个不一致部分均小于200平)"
});
}
}
//GFBQ201
if (ddtcdm == "1302" && !"0601".Equals(dlbm))
{
foreach (var geo in listGeometryLNGDIntsect)
{
IArea pArea = geo as IArea;
if (pArea.Area > 200)
{
result.Add(new RuleEntity()
{
CheckObject = "DTBDLTBGX层",
ErrorId = bsm,
BGFWBSM = bsm,
ErrorTip = "位于用地管理信息范围内光伏板区下地类未按工业用地上图,需核实",
ErrorType = "二类错误",
RuleCode = "GFBQ201",
RuleName = "位于用地管理信息范围内光伏板区下地类上图检查",
RuleContent = "位于用地管理信息范围内光伏板区下地类未按工业用地上图,需核实"
});
break;
}
}
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
if (listGeometryLNGDDifference != null)
{
foreach (var geo in listGeometryLNGDDifference)
{
if (geo != null)
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(geo);
}
}
}
if (listGeometryLNGDIntsect != null)
{
foreach (var geo in listGeometryLNGDIntsect)
{
if (geo != null)
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(geo);
}
}
}
if (pYDGLGeometry != null)
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(pYDGLGeometry);
}
if (pYDGLCursor != null)
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(pYDGLCursor);
}
}
#region old
//if (ddtcdm == "1303")
//{
// IGeometry pGeoLNGDDiff = CommonHelper.Difference(pDLTBGXgeo, pYDGLGeometry); //擦除用地管理
// pJCKSpatialFilter.Geometry = pGeoLNGDDiff;
// pJCKCursor = pJCKFeatureClass.Search(pJCKSpatialFilter, true);
// IFeature pJCKfeature = null;
// while ((pJCKfeature = pJCKCursor.NextFeature()) != null)
// {
// string sJCKzzsxdm = pJCKfeature.Value[indexJCKZZSXDM] == null ? "" : pJCKfeature.Value[indexJCKZZSXDM].ToString().Trim();
// string sJCKtbxhdm = pJCKfeature.Value[indexJCKTBXHDM] == null ? "" : pJCKfeature.Value[indexJCKTBXHDM].ToString().Trim();
// string sJCKdlbm = pJCKfeature.Value[indexJCKDLBM] == null ? "" : pJCKfeature.Value[indexJCKDLBM].ToString().Trim();
// string sJCKgdlx = pJCKfeature.Value[indexJCKGDLX] == null ? "" : pJCKfeature.Value[indexJCKGDLX].ToString().Trim();
// IGeometry pGeoJCKInt = CommonHelper.InterSect(pGeoLNGDDiff, pJCKfeature.ShapeCopy);
// CommonHelper.IsMuiltPart(pGeoJCKInt, out List<IGeometry> listGeometryJCKInt);
// bool hasSpot = false;
// foreach (var geo in listGeometryJCKInt)
// {
// IArea pArea = geo as IArea;
// if (pArea.Area > 200)
// hasSpot = true;
// }
// if (!hasSpot)
// continue;
// //TTQ202
// if (hasSpot && !"0101,0102,0103".Contains(dlbm) && (sJCKdlbm != dlbm || sJCKtbxhdm != tbxhdm || sJCKzzsxdm != zzsxdm))
// {
// result.Add(new RuleEntity()
// {
// CheckObject = "DTBDLTBGX层",
// ErrorId = bsm,
// ErrorTip = "位于用地管理信息范围外推土区下地类(除耕地)未按原地类上图,需核实",
// ErrorType = "二类错误",
// RuleCode = "TTQ202",
// RuleName = "位于用地管理信息范围外推土区下地类上图检查",
// RuleContent = "位于用地管理信息范围外推土区下地类(除耕地)未按原地类上图,需核实"
// });
// }
// //TTQ203
// if (hasSpot && "0101,0102,0103".Contains(dlbm) && (sJCKdlbm != dlbm || sJCKtbxhdm != tbxhdm || (!string.IsNullOrWhiteSpace(sJCKgdlx) && !string.IsNullOrWhiteSpace(gdlx) && !sJCKgdlx.Equals(gdlx))))
// {
// result.Add(new RuleEntity()
// {
// CheckObject = "DTBDLTBGX层",
// ErrorId = bsm,
// ErrorTip = "位于用地管理信息范围外推土区下耕地未按原地类上图,需核实",
// ErrorType = "一类错误",
// RuleCode = "TTQ203",
// RuleName = "位于用地管理信息范围外推土区下地类上图检查",
// RuleContent = "位于用地管理信息范围外推土区下耕地未按原地类上图,需核实"
// });
// }
// }
//}
//if (ddtcdm == "1304")
//{
//string sJSYD = "'05H1','0508','0601','0602','0603','0701','0702','08H1','08H2','08H2A','0809','0810','0810A','09','1001','1002','1003','1004','1005','1007','1008','1009','1109','1001A','1002A','1003A','1004A'";
// pJCKSpatialFilter.Geometry = pDLTBGXgeo;
// pJCKCursor = pJCKFeatureClass.Search(pJCKSpatialFilter, true);
// IFeature pJCKfeature = null;
// while ((pJCKfeature = pJCKCursor.NextFeature()) != null)
// {
// string sJCKzzsxdm = pJCKfeature.Value[indexJCKZZSXDM] == null ? "" : pJCKfeature.Value[indexJCKZZSXDM].ToString().Trim();
// string sJCKtbxhdm = pJCKfeature.Value[indexJCKTBXHDM] == null ? "" : pJCKfeature.Value[indexJCKTBXHDM].ToString().Trim();
// string sJCKdlbm = pJCKfeature.Value[indexJCKDLBM] == null ? "" : pJCKfeature.Value[indexJCKDLBM].ToString().Trim();
// IGeometry pGeoJCKInt = CommonHelper.InterSect(pDLTBGXgeo, pJCKfeature.ShapeCopy);
// CommonHelper.IsMuiltPart(pGeoJCKInt, out List<IGeometry> listGeometryJCKInt);
// bool hasSpot = false;
// foreach (var geo in listGeometryJCKInt)
// {
// IArea pArea = geo as IArea;
// if (pArea.Area > 200)
// hasSpot = true;
// }
// //CCWJQ201
// if (hasSpot && sJSYD.Contains(sJCKdlbm) && (sJCKdlbm != dlbm || sJCKtbxhdm != tbxhdm))
// {
// result.Add(new RuleEntity()
// {
// CheckObject = "DTBDLTBGX层",
// ErrorId = bsm,
// ErrorTip = "基础库为建设用地的拆除未尽区应按原地类上图",
// ErrorType = "二类错误",
// RuleCode = "CCWJQ201",
// RuleName = "拆除未尽区下基础库地类为建设用地上图检查",
// RuleContent = "基础库为建设用地的拆除未尽区应按原地类上图"
// });
// }
// //CCWJQ202
// if (hasSpot && "1202".Contains(sJCKdlbm) && (sJCKdlbm != dlbm || sJCKtbxhdm != tbxhdm))
// {
// result.Add(new RuleEntity()
// {
// CheckObject = "DTBDLTBGX层",
// ErrorId = bsm,
// ErrorTip = "基础库为设施农用地的拆除未尽区应按原地类上图",
// ErrorType = "二类错误",
// RuleCode = "CCWJQ202",
// RuleName = "拆除未尽区下基础库地类为设施农用地上图检查",
// RuleContent = "基础库为设施农用地的拆除未尽区应按原地类上图"
// });
// }
// }
//}
#endregion
}
}
catch (Exception ex)
{
RuleEntity ruleEntity = new RuleEntity()
{
CheckObject = "DTBDLTBGX层",
BGFWBSM = this.TBBSM,
ErrorId = this.TBBSM,
ErrorTip = "推土区下按建设用地上图,应位于用地管理信息范围内,需核实规则检查失败:" + ex.Message,
ErrorType = "一类错误",
RuleCode = "TTQ203",
RuleName = "推土区下用地管理信息上图检查",
RuleContent = "位于用地管理信息范围内推土区下耕地未按原地类上图,需核实"
};
result.Add(ruleEntity);
}
finally
{
if (pDLTBGXgeo != null)
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(pDLTBGXgeo);
}
if (pJCKCursor != null)
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(pJCKCursor);
}
}
return result;
}
/// <summary>
/// 更新过程检查(更新过程层图斑需与地类图斑层对应)
/// </summary>
/// <returns></returns>
public List<RuleEntity> GXGC101()
{
IFeatureClass pJCKFeatureClass = null;
IGeometry pDLTBGXgeo = null;
List<RuleEntity> rst = new List<RuleEntity>();
try
{
if (DicFeatureClass.ContainsKey("JC_XZQ") && DicFeatureClass["JC_XZQ"] != null)
pJCKFeatureClass = DicFeatureClass["JC_XZQ"];
else
throw new Exception("未找到基础库行政区图层");
ISpatialReference spatialReference = (pJCKFeatureClass as IGeoDataset).SpatialReference;
if (spatialReference == null)
throw new Exception("基础库行政区图层坐标参考为空,质检失败!");
ISpatialFilter pXZQSpatialFilter = new SpatialFilterClass
{
SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects
};
string sql = $"select BSM,egeometry from DTBDLTBGX where TBBSM='{TBBSM}' and dlbm not in('9902','9903')";
DataTable dt = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, sql);
if (dt == null || dt.Rows.Count <= 0)
return null;
foreach (DataRow item in dt.Rows)
{
IFeatureCursor cursor = null;
string bsm = item["bsm"].ToString();
pDLTBGXgeo = CheckHelper.GeometryConvertHelper.ConverJsonToIGeoemtry(item["egeometry"].ToString(), esriGeometryType.esriGeometryPolygon);
pDLTBGXgeo.Project(spatialReference);
//叠加基础库行政区图层
IGeometryCollection pxzqGeometries = new GeometryBagClass();
ITopologicalOperator pxzqTopologicalOperator = new PolygonClass();
pXZQSpatialFilter.Geometry = pDLTBGXgeo;
cursor = pJCKFeatureClass.Search(pXZQSpatialFilter, true);
IFeature pXZQfeature = null;
while ((pXZQfeature = cursor.NextFeature()) != null)
{
if (!CommonHelper.IsInterSect(pDLTBGXgeo, pXZQfeature.ShapeCopy))
continue;
pxzqGeometries.AddGeometry(pXZQfeature.ShapeCopy);
}
pxzqTopologicalOperator.ConstructUnion(pxzqGeometries as IEnumGeometry);
IGeometry pXZQGeometry = pxzqTopologicalOperator as IGeometry;
bool resultState = CommonHelper.IsContains(pXZQGeometry, pDLTBGXgeo); //外业任务图斑是否在行政区范围内
if (resultState)
{
sql = $"select BGHTBBSM from DTBDLTBGXGC where BGHTBBSM='{bsm}'";
dt = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, sql);
if (dt == null || dt.Rows.Count <= 0)
{
rst.Add(new RuleEntity()
{
CheckObject = "DTBGXGC",
ErrorId = bsm,
BGFWBSM = bsm,
ErrorTip = "更新过程层图斑需与地类图斑层对应",
ErrorType = "一类错误",
RuleCode = "GXGC101",
RuleName = "更新过程层检查",
RuleContent = "通过DTBDLTBGX层中图斑“标识码”字段,其均需位于DTBDLTBGXGC表中的“变更后标识码”字段中;否则,认定为错误图斑。"
});
}
}
}
//sql = $"select BSM from DTBDLTBGX where TBBSM='{TBBSM}' and bsm NOT IN (SELECT BGHTBBSM FROM DTBDLTBGXGC) and dlbm not in('9902','9903')";
//DataTable dt = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, sql);
//if (dt == null || dt.Rows.Count <= 0)
// return null;
//foreach (DataRow item in dt.Rows)
//{
// rst.Add(new RuleEntity()
// {
// CheckObject = "DTBGXGC",
// ErrorId = $"{item["BSM"].ToString()}",
// ErrorTip = "更新过程层图斑需与地类图斑层对应",
// ErrorType = "一类错误",
// RuleCode = "GXGC101",
// RuleName = "更新过程层检查",
// RuleContent = "通过DTBDLTBGX层中图斑“标识码”字段,其均需位于DTBDLTBGXGC表中的“变更后标识码”字段中;否则,认定为错误图斑。"
// });
//}
}
catch (Exception ex)
{
RuleEntity ruleEntity = new RuleEntity()
{
CheckObject = "DTBGXGC",
ErrorId = this.TBBSM,
ErrorTip = "更新过程层图斑需与地类图斑层对应规则检查失败" + ex.Message,
ErrorType = "一类错误",
RuleCode = "GXGC101",
RuleName = "更新过程层检查",
RuleContent = "通过DTBDLTBGX层中图斑“标识码”字段,其均需位于DTBDLTBGXGC表中的“变更后标识码”字段中;否则,认定为错误图斑。"
};
rst.Add(ruleEntity);
}
return rst;
}
/// <summary>
/// 工程恢复变更为即可恢复图斑上图检查
/// </summary>
/// <returns></returns>
public List<RuleEntity> HFSX006()
{
List<RuleEntity> rst = new List<RuleEntity>();
try
{
string sql = $"select BSM from DTBDLTBGX where TBBSM='{TBBSM}' and bsm IN (SELECT bghtbbsm FROM DTBDLTBGXGC WHERE BGQDLBM=BGHDLBM and BGQZZSXDM='GCHF' and BGHZZSXDM='JKHF')";
DataTable dt = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, sql);
if (dt == null || dt.Rows.Count <= 0)
return null;
foreach (DataRow item in dt.Rows)
{
rst.Add(new RuleEntity()
{
CheckObject = "DTBGXGC",
ErrorId = $"{item["BSM"].ToString()}",
ErrorTip = "地类未发生变化的GCHF图斑,不可更改为JKHF图斑",
ErrorType = "一类错误",
RuleCode = "HFSX006",
RuleName = "工程恢复变更为即可恢复图斑上图检查",
RuleContent = "地类未发生变化的GCHF图斑,不可更改为JKHF图斑"
});
}
}
catch (Exception ex)
{
RuleEntity ruleEntity = new RuleEntity()
{
CheckObject = "DTBGXGC",
ErrorId = this.TBBSM,
ErrorTip = "地类未发生变化的GCHF图斑,不可更改为JKHF图斑规则检查失败" + ex.Message,
ErrorType = "一类错误",
RuleCode = "HFSX006",
RuleName = "工程恢复变更为即可恢复图斑上图检查",
RuleContent = "地类未发生变化的GCHF图斑,不可更改为JKHF图斑"
};
rst.Add(ruleEntity);
}
return rst;
}
/// <summary>
/// 变更范围是否在基础库行政区范围内上图检查:
/// 若任务图斑完全位于相应基础库行政区范围内作为前置条件,其相应的变更范围如果未完全在行政区范围内,判定为错误图斑。
/// </summary>
/// <returns></returns>
public List<RuleEntity> XZQ001()
{
IFeatureClass jc_xzqFeatureClass = null;
List<RuleEntity> rst = null;
IFeatureCursor pCursor = null;
IGeometry xzqGeometry = null;
IGeometry wyrwGeometry = null;
IGeometry dtbGeometry = null;
IFeature feature = null;
try
{
rst = new List<RuleEntity>();
DataTable dataTable = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, $"select tbbsm,egeometry from wyrw where tbbsm='{TBBSM}'");
if (dataTable == null || dataTable.Rows.Count <= 0)
{
return rst;
}
if (!DicFeatureClass.ContainsKey("JC_XZQ") || DicFeatureClass["JC_XZQ"] == null)
{
throw new Exception("未找到“基础_行政区”参考图层!");
}
jc_xzqFeatureClass = DicFeatureClass["JC_XZQ"];
ISpatialReference spatialReference = (jc_xzqFeatureClass as IGeoDataset).SpatialReference;
#region old 部分电脑执行topological.ConstructUnion()方法会报错:对 COM 组件的调用返回了错误 HRESULT E_FAIL。
//IQueryFilter queryFilter = new QueryFilterClass()
//{
// SubFields = "objectid,shape"
//};
//IGeometryCollection geometries = new GeometryBagClass();
//pCursor = jc_xzqFeatureClass.Search(queryFilter, true);
//while ((feature = pCursor.NextFeature()) != null)
//{
// geometries.AddGeometry(feature.ShapeCopy);
//}
//ITopologicalOperator topological = new PolygonClass();
//topological.ConstructUnion(geometries as IEnumGeometry);
//if (topological == null)
//{
// throw new Exception("“基础_行政区”图层数据为空!");
//}
////(1)提取历年耕地图斑参考图层,记为C;
//xzqGeometry = topological as IGeometry;
//if (xzqGeometry == null || xzqGeometry.IsEmpty)
//{
// throw new Exception("“基础_行政区”图层数据为空!");
//}
//if (xzqGeometry.SpatialReference == null)
//{
// xzqGeometry.SpatialReference = spatialReference;
//}
#endregion
foreach (DataRow item in dataTable.Rows)
{
DataTable dataTableDTB = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, $"select * from dtbdltbgx where tbbsm='{TBBSM}'");
if (dataTableDTB == null || dataTableDTB.Rows.Count <= 0)
{
return rst;
}
wyrwGeometry = CheckHelper.GeometryConvertHelper.ConverJsonToIGeoemtry(item["egeometry"].ToString(), esriGeometryType.esriGeometryPolygon);
wyrwGeometry.Project(spatialReference);
#region 只取与外业任务图斑相交的行政区来判断:外业任务图斑是否在行政区范围内
ISpatialFilter spatialFilter = new SpatialFilterClass()
{
SubFields = "objectid,shape",
Geometry = wyrwGeometry,
SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects
};
ITopologicalOperator topological = null;
pCursor = jc_xzqFeatureClass.Search(spatialFilter, true);
while ((feature = pCursor.NextFeature()) != null)
{
if (topological == null)
{
topological = feature.ShapeCopy as ITopologicalOperator;
}
else
{
topological = topological.Union(feature.ShapeCopy) as ITopologicalOperator;
}
}
//外业任务图斑不在行政区范围内
if (topological == null)
{
continue;
}
xzqGeometry = topological as IGeometry;
if (xzqGeometry == null || xzqGeometry.IsEmpty)
{
throw new Exception("“基础_行政区”图层数据为空!");
}
if (xzqGeometry.SpatialReference == null)
{
xzqGeometry.SpatialReference = spatialReference;
}
if (!CommonHelper.IsContains(xzqGeometry, wyrwGeometry))
{
//外业任务图斑不在行政区范围内
continue;
}
#endregion
foreach (DataRow dr in dataTableDTB.Rows)
{
//变更范围图斑
dtbGeometry = CheckHelper.GeometryConvertHelper.ConverJsonToIGeoemtry(dr["egeometry"].ToString(), esriGeometryType.esriGeometryPolygon);
dtbGeometry.Project(spatialReference);
#region 此处用变更范围再次获取行政区,而不是用上面外业任务图斑压盖到的行政区(xzqGeometry),是因为存在以下情况:外业任务图斑未跨村级行政区,但是变更范围跨了村级行政区,所以每个变更范围图斑单独获取下压盖到的行政区,用新获取的行政区判断变更范围图斑是否在行政区范围内
spatialFilter = new SpatialFilterClass()
{
SubFields = "objectid,shape",
Geometry = dtbGeometry,
SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects
};
topological = null;
pCursor = jc_xzqFeatureClass.Search(spatialFilter, true);
while ((feature = pCursor.NextFeature()) != null)
{
if (topological == null)
{
topological = feature.ShapeCopy as ITopologicalOperator;
}
else
{
topological = topological.Union(feature.ShapeCopy) as ITopologicalOperator;
}
}
xzqGeometry = topological as IGeometry;
if (xzqGeometry == null || xzqGeometry.IsEmpty)
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(dtbGeometry);
rst.Add(new RuleEntity()
{
CheckObject = "DTBDLTBGX",
ErrorId = $"{dr["BSM"].ToString()}",
ErrorTip = "任务图斑完全位于基础库行政区范围内,但变更范围不在基础库行政区范围内。",
ErrorType = "一类错误",
RuleCode = "XZQ001",
RuleName = "变更范围是否在行政区范围内上图检查",
RuleContent = "若任务图斑完全位于相应基础库行政区范围内,其相应的变更范围如果未完全在行政区范围内,判定为错误图斑。"
});
continue;
}
#endregion
if (CommonHelper.IsContains(xzqGeometry, dtbGeometry))
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(dtbGeometry);
continue;
}
System.Runtime.InteropServices.Marshal.ReleaseComObject(dtbGeometry);
rst.Add(new RuleEntity()
{
CheckObject = "DTBDLTBGX",
ErrorId = $"{dr["BSM"].ToString()}",
BGFWBSM = $"{dr["BSM"].ToString()}",
ErrorTip = "任务图斑完全位于基础库行政区范围内,但变更范围不在基础库行政区范围内。",
ErrorType = "一类错误",
RuleCode = "XZQ001",
RuleName = "变更范围是否在行政区范围内上图检查",
RuleContent = "若任务图斑完全位于相应基础库行政区范围内,其相应的变更范围如果未完全在行政区范围内,判定为错误图斑。"
});
}
}
}
catch (Exception ex)
{
RuleEntity ruleEntity = new RuleEntity()
{
CheckObject = "DTBDLTBGX",
ErrorId = this.TBBSM,
BGFWBSM = this.TBBSM,
ErrorTip = "XZQ001规则检查失败:" + ex.Message,
ErrorType = "一类错误",
RuleCode = "XZQ001",
RuleName = "变更范围是否在行政区范围内上图检查",
RuleContent = "若任务图斑完全位于相应基础库行政区范围内,其相应的变更范围如果未完全在行政区范围内,判定为错误图斑。"
};
rst.Add(ruleEntity);
}
finally
{
if (feature != null)
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(feature);
}
if (xzqGeometry != null)
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(xzqGeometry);
}
if (wyrwGeometry != null)
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(wyrwGeometry);
}
if (pCursor != null)
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(pCursor);
}
}
return rst;
}
/// <summary>
/// 界线外图斑检查
/// </summary>
/// <returns></returns>
public List<RuleEntity> XZQ002()
{
List<RuleEntity> rst = null;
IFeatureClass jc_xzqFeatureClass = null;
try
{
rst = new List<RuleEntity>();
DataTable dataTable = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, $"select tbbsm,egeometry from dtbdltbgx where tbbsm='{TBBSM}' and dlbm='9902'");
if (dataTable == null || dataTable.Rows.Count <= 0)
{
return rst;
}
if (!DicFeatureClass.ContainsKey("JC_XZQ") || DicFeatureClass["JC_XZQ"] == null)
{
throw new Exception("未找到“基础_行政区”参考图层!");
}
jc_xzqFeatureClass = DicFeatureClass["JC_XZQ"];
ISpatialReference spatialReference = (jc_xzqFeatureClass as IGeoDataset).SpatialReference;
foreach (DataRow item in dataTable.Rows)
{
IGeometry dtbGeometry = null;
IFeature feature = null;
IFeatureCursor featureCursor = null;
try
{
dtbGeometry = CheckHelper.GeometryConvertHelper.ConverJsonToIGeoemtry(item["egeometry"].ToString(), esriGeometryType.esriGeometryPolygon);
dtbGeometry.Project(spatialReference);
ISpatialFilter spatialFilter = new SpatialFilterClass()
{
SubFields = "objectid,shape",
Geometry = dtbGeometry,
SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects
};
featureCursor = jc_xzqFeatureClass.Search(spatialFilter, true);
feature = featureCursor.NextFeature();
if (feature == null)
{
continue;
}
while (feature != null)
{
IGeometry pGeoIntersect = CommonHelper.InterSect(feature.ShapeCopy, dtbGeometry);
if (pGeoIntersect == null || pGeoIntersect.IsEmpty)
{
feature = featureCursor.NextFeature();
continue;
}
IArea area = pGeoIntersect as IArea;
if (area.Area > 0)
{
RuleEntity ruleEntity = new RuleEntity()
{
CheckObject = "DTBDLTBGX",
BGFWBSM = item[0]?.ToString(),
ErrorId = item[0]?.ToString(),
ErrorTip = "县级界线范围内图斑不得标注“界线外图斑”",
ErrorType = "二类错误",
RuleCode = "XZQ002",
RuleName = "界线外图斑检查",
RuleContent = "若地类编码为9902,图斑必须与行政界线(县级)不存在重叠,容差0.0001,否则,认定为错误图斑。"
};
rst.Add(ruleEntity);
break;
}
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
if (featureCursor != null)
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(featureCursor);
}
if (feature != null)
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(feature);
}
if (dtbGeometry != null)
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(dtbGeometry);
}
}
}
}
catch (Exception ex)
{
RuleEntity ruleEntity = new RuleEntity()
{
CheckObject = "DTBDLTBGX",
ErrorId = this.TBBSM,
BGFWBSM = this.TBBSM,
ErrorTip = "XZQ002规则执行失败:" + ex.Message,
ErrorType = "二类错误",
RuleCode = "XZQ002",
RuleName = "界线外图斑检查",
RuleContent = "若地类编码为9902,图斑必须与行政界线(县级)不存在重叠,容差0.0001,否则,认定为错误图斑。"
};
rst.Add(ruleEntity);
}
return rst;
}
}
}