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

2497 lines
133 KiB

6 months ago
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.Geometry;
using Kingo.RuleCheck.CheckHelper;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
namespace Kingo.RuleCheck.XJRuleCheck
{
/// <summary>
/// 城镇村属性上图检查
/// </summary>
public class CZCSXCheck_DTB : RuleCheckBase_DTB
{
public CZCSXCheck_DTB()
{
var list = GetConfigList("CZCSXCheck_DTB");
if (list.Count > 0)
ruleMethodNames = list;
}
/// <summary>
/// 下发城镇村等用地字典值
/// </summary>
private string key_czcdyd = "CZCDYDI";
private List<string> ruleMethodNames = new List<string>()
{
//"CZC201","CZC203","CZC211","CZC212","CZC213","CZC214","CZC221","CZC222",
//"CZC001","CZC002","CZC101","CZC301","CZC302","CZC303","CZC304","CZC305","CZC306","CZC401","CZC402","CZC403","CZC404","CZC501","CZC502","CZC503","CZC504","CZC505","CZC506","CZC20X"
"CZC001","CZC002","CZC101","CZC_507","CZC_508"
//,"CZC20X"
};
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> workspace)
{
return this.StartCheck(tbbsm, sourePath, workspace, ruleMethodNames);
}
public List<RuleEntity> CZC001()
{
List<RuleEntity> rst = new List<RuleEntity>();
RuleEntity ruleEntity = new RuleEntity()
{
CheckObject = "DTBDLTBGX",
ErrorId = this.TBBSM,
ErrorTip = "地类编码为1001、1002、1003、1007、1008、1009、1109的图斑,城镇村属性码字段必须为空。",
ErrorType = "一类错误",
RuleCode = "CZC001",
RuleName = "线状地物城镇村属性赋值情况检查"
};
try
{
string sql = $"select BSM from DTBDLTBGX where tbbsm='{TBBSM}' and dlbm in ('1001','1001A','1002','1002A','1003','1003A','1004A','1007','1008','1009','1109') and CZCSXM is not null and 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 = ruleEntity.CheckObject,
ErrorId = item[0].ToString(),
BGFWBSM = item[0].ToString(),
ErrorTip = ruleEntity.ErrorTip,
ErrorType = ruleEntity.ErrorType,
RuleCode = ruleEntity.RuleCode,
RuleName = ruleEntity.RuleName,
RuleContent = ruleEntity.RuleContent,
});
}
}
catch (Exception ex)
{
ruleEntity.ErrorTip = $"{ruleEntity.RuleName}失败:{ex.Message}";
rst.Add(ruleEntity);
}
return rst;
}
public List<RuleEntity> CZC002()
{
List<RuleEntity> rst = new List<RuleEntity>();
RuleEntity ruleEntity = new RuleEntity()
{
CheckObject = "DTBDLTBGX",
ErrorId = this.TBBSM,
ErrorTip = "地类编码为88类、99类的图斑,城镇村属性码字段必须为空。",
ErrorType = "一类错误",
RuleCode = "CZC002",
RuleName = "特殊地类城镇村属性赋值情况检查"
};
try
{
string sql = $"select BSM from DTBDLTBGX where tbbsm='{TBBSM}' and dlbm in ('8801','9902','9903','9905') and CZCSXM is not null and 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 = ruleEntity.CheckObject,
ErrorId = item[0].ToString(),
BGFWBSM = item[0].ToString(),
ErrorTip = ruleEntity.ErrorTip,
ErrorType = ruleEntity.ErrorType,
RuleCode = ruleEntity.RuleCode,
RuleName = ruleEntity.RuleName,
RuleContent = ruleEntity.RuleContent,
});
}
}
catch (Exception ex)
{
ruleEntity.ErrorTip = $"{ruleEntity.RuleName}失败:{ex.Message}";
rst.Add(ruleEntity);
}
return rst;
}
public List<RuleEntity> CZC101()
{
List<RuleEntity> rst = new List<RuleEntity>();
RuleEntity ruleEntity = new RuleEntity()
{
CheckObject = "DTBDLTBGX",
ErrorId = this.TBBSM,
ErrorTip = "非建设用地,单图斑阶段不得标注201A、202A、204、205。",
ErrorType = "一类错误",
RuleCode = "CZC101",
RuleName = "非建设用地标注城镇村属性情况检查"
};
try
{
string sql = $"select BSM from DTBDLTBGX where tbbsm='{TBBSM}' and dlbm not in ('05H1','0508','0601','0602','0603','0701','0702','08H1','08H2','08H2A','0809','0810','0810A','09','1004','1005','1201','1001','1002','1003','1007','1008','1009','1109') and CZCSXM in ('201A','202A','204','205')";
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 = ruleEntity.CheckObject,
ErrorId = item[0].ToString(),
BGFWBSM = item[0].ToString(),
ErrorTip = ruleEntity.ErrorTip,
ErrorType = ruleEntity.ErrorType,
RuleCode = ruleEntity.RuleCode,
RuleName = ruleEntity.RuleName,
RuleContent = ruleEntity.RuleContent,
});
}
//0602和0603城镇村属性只能是204,如果填其他,报错
string sql1 = $"select BSM from DTBDLTBGX where tbbsm='{TBBSM}' and dlbm in ('0602','0603') and CZCSXM not in ('204')";
DataTable dt1 = 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 = ruleEntity.CheckObject,
ErrorId = item[0].ToString(),
BGFWBSM = item[0].ToString(),
ErrorTip = "0602和0603城镇村属性只能是204",
ErrorType = ruleEntity.ErrorType,
RuleCode = ruleEntity.RuleCode,
RuleName = ruleEntity.RuleName,
RuleContent = "0602和0603城镇村属性只能是204",
});
}
}
catch (Exception ex)
{
ruleEntity.ErrorTip = $"{ruleEntity.RuleName}失败:{ex.Message}";
rst.Add(ruleEntity);
}
return rst;
}
public List<RuleEntity> CZC20X()
{
List<RuleEntity> result = new List<RuleEntity>();
try
{
List<string> Sljslist = new List<string> { "05H1", "0508", "0601", "0602", "0603", "0701", "0702", "08H1", "08H2", "08H2A", "0809", "0810", "0810A", "09", "1004", "1005", "1201" };
List<string> Slfjslist = new List<string> { "05H1", "0508", "0601", "0602", "0603", "0701", "0702", "08H1", "08H2", "08H2A", "0809", "0810", "0810A", "09", "1004", "1005", "1201", "1001", "1002", "1003", "1007", "1008", "1009", "1109" };
List<string> Blfjslist = new List<string> { "05H1", "0508", "0601", "0602", "0603", "0701", "0702", "08H1", "08H2", "08H2A", "0809", "0810", "0810A", "09", "1004", "1005", "1201", "1001", "1001A", "1002", "1002A", "1003", "1003A", "1004A", "1007", "1008", "1009", "1109" };
DataTable dataTable = SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, $"select d.bsm,w.gjdlbm,d.dlbm,d.bz from DTBDLTBGX d left join wyrw w on d.tbbsm=w.tbbsm where d.tbbsm='{this.TBBSM}'");
if (dataTable == null || dataTable.Rows.Count <= 0)
return result;
foreach (DataRow item in dataTable.Rows)
{
string slType = string.Empty;
string BLType = string.Empty;
string bsm = item["bsm"].ToString();
string gjdlbm = item["gjdlbm"].ToString();
string dlbm = item["dlbm"].ToString();
if (Sljslist.Contains(gjdlbm))
slType = "SL_JS";
if (!Slfjslist.Contains(gjdlbm))
slType = "SL_FJS";
if (Sljslist.Contains(dlbm))
BLType = "BL_JS";
if (!Blfjslist.Contains(dlbm))
BLType = "BL_FJS";
if (dlbm != gjdlbm && BLType == "BL_JS" && slType == "SL_JS")
{
RuleEntity ruleEntity = new RuleEntity()
{
CheckObject = "DTBDLTBGX",
ErrorId = bsm,
BGFWBSM = bsm,
ErrorTip = "原则上地类相对上轮数据库发生变化,但均属于建设用地的图斑,城镇村属性码应与上轮保持一致。",
ErrorType = "二类错误",
RuleCode = "CZC201",
RuleName = "相对于上轮发生建设用地内部变化城镇村属性标注检查",
RuleContent = "原则上地类相对上轮数据库发生变化,但均属于建设用地的图斑,城镇村属性码应与上轮保持一致"
};
result.Add(ruleEntity);
}
if (dlbm != gjdlbm && BLType == "BL_FJS" && slType == "SL_FJS")
{
RuleEntity ruleEntity = new RuleEntity()
{
CheckObject = "DTBDLTBGX",
ErrorId = bsm,
BGFWBSM = bsm,
ErrorTip = "原则上地类相对上轮数据库发生变化,但均属于非建设用地的图斑,城镇村属性码应与上轮保持一致。",
ErrorType = "二类错误",
RuleCode = "CZC202",
RuleName = "相对于上轮发生建设用地内部变化城镇村属性标注检查",
RuleContent = "原则上地类相对上轮数据库发生变化,但均属于非建设用地的图斑,城镇村属性码应与上轮保持一致。"
};
result.Add(ruleEntity);
}
if (dlbm != gjdlbm && BLType == "BL_FJS" && slType == "SL_JS")
{
RuleEntity ruleEntity = new RuleEntity()
{
CheckObject = "DTBDLTBGX",
ErrorId = bsm,
BGFWBSM = bsm,
ErrorTip = "原则上地类相对上轮数据库发生建设用地更新为非建设用地的情况,城镇村属性应参照CZCDYDI层进行标注。",
ErrorType = "二类错误",
RuleCode = "CZC203",
RuleName = "相对于上轮发生建设用地内部变化城镇村属性标注检查",
RuleContent = "原则上地类相对上轮数据库发生建设用地更新为非建设用地的情况,城镇村属性应参照CZCDYDI层进行标注。"
};
result.Add(ruleEntity);
}
if (dlbm == gjdlbm && (item["bz"].ToString() == "9904" || item["bz"].ToString() == "9905" || item["bz"].ToString() == "8801"))
{
RuleEntity ruleEntity = new RuleEntity()
{
CheckObject = "DTBDLTBGX",
BGFWBSM = bsm,
ErrorTip = "地类保持一致的国家意见图斑,城镇村属性待核查。",
ErrorType = "二类错误",
RuleCode = "CZC204",
RuleName = "相对于上轮发生建设用地内部变化城镇村属性标注检查",
RuleContent = "地类保持一致的国家意见图斑,城镇村属性待核查。"
};
result.Add(ruleEntity);
}
}
}
catch (Exception ex)
{
RuleEntity ruleEntity = new RuleEntity()
{
CheckObject = "DTBDLTBGX",
ErrorId = this.TBBSM,
ErrorTip = "原则上地类相对上轮数据库发生变化,但均属于建设用地的图斑,城镇村属性码应与上轮保持一致。规则检查失败:" + ex.Message,
ErrorType = "二类错误",
RuleCode = "CZC20X",
RuleName = "相对于上轮发生建设用地内部变化城镇村属性标注检查",
RuleContent = "原则上地类相对上轮数据库发生变化,但均属于建设用地的图斑,城镇村属性码应与上轮保持一致"
};
result.Add(ruleEntity);
}
return result;
}
//public List<RuleEntity> CZC201()
//{
// List<RuleEntity> rst = new List<RuleEntity>();
// RuleEntity ruleEntity = new RuleEntity()
// {
// CheckObject = "DTBDLTBGX",
// ErrorId = this.TBBSM,
// ErrorTip = "位于三调203范围内的图斑,若实地现状为非建设用地,不得保留203属性。",
// ErrorType = "一类错误",
// RuleCode = "CZC201",
// RuleName = "非建设用地保留203情况检查"
// };
// RuleEntity ruleEntity202 = new RuleEntity()
// {
// CheckObject = "DTBDLTBGX",
// ErrorId = this.TBBSM,
// ErrorTip = "10平方米以下三调203属性保留合理性检查",
// ErrorType = "二类错误",
// RuleCode = "CZC202",
// RuleName = "10平方米以下三调203属性保留合理性检查"
// };
// IFeatureClass sdczc_dltbFeatureClass = null;
// IGeometry dltbGXgeo = null;
// IFeatureCursor pCursor = null;
// IFeature feature = null;
// try
// {
// if (!DicFeatureClass.ContainsKey(key_czcdyd) || DicFeatureClass[key_czcdyd] == null)
// {
// throw new Exception("未找到“下发城镇村等用地”参考图层!");
// }
// sdczc_dltbFeatureClass = DicFeatureClass[key_czcdyd];
// ISpatialReference spatialReference = (sdczc_dltbFeatureClass as IGeoDataset).SpatialReference;
// if (spatialReference == null)
// {
// throw new Exception("下发城镇村等用地数据坐标参考为空,质检失败!");
// }
// if (sdczc_dltbFeatureClass.Fields.FindField("CZSX") == -1)
// throw new Exception("“下发城镇村等用地”参考图层 未包含CZSX字段");
// ISpatialFilter spatialFilter = new SpatialFilterClass
// {
// SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects,
// WhereClause = "CZCLX ='203' and CZSX = '三调村庄范围'"
// };
// string sql = $"select bghtbbsm,egeometry from dtbdltbgxgc where tbbsm = '{TBBSM}' and bghdlbm not in ('05H1','0508','0601','0602','0603','0701','0702','08H1','08H2','08H2A','0809','0810','0810A','09','1004','1005','1201','1001','1002','1003','1007','1008','1009','1109') and bgqczcsxm='203' and bghczcsxm='203'";
// DataTable dt = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, sql);
// if (dt == null || dt.Rows.Count <= 0)
// return rst;
// List<string> lisCZC201 = new List<string>();
// List<string> lisCZC202 = new List<string>();
// foreach (DataRow item in dt.Rows)
// {
// dltbGXgeo = CheckHelper.GeometryConvertHelper.ConverJsonToIGeoemtry(item["egeometry"].ToString(), esriGeometryType.esriGeometryPolygon, spatialReference.FactoryCode, false);
// spatialFilter.Geometry = dltbGXgeo;
// pCursor = sdczc_dltbFeatureClass.Search(spatialFilter, true);
// while ((feature = pCursor.NextFeature()) != null)
// {
// IGeometry geoInter = CheckHelper.CommonHelper.InterSect(feature.ShapeCopy, dltbGXgeo);
// IArea area = geoInter as IArea;
// if (area != null)
// {
// if (area.Area > 10)
// {
// lisCZC201.Add(item[0].ToString());
// }
// else
// {
// lisCZC202.Add(item[0].ToString());
// }
// }
// }
// }
// lisCZC201 = lisCZC201.Distinct().ToList();
// lisCZC202 = lisCZC202.Distinct().ToList();
// foreach (var item in lisCZC201)
// {
// rst.Add(new RuleEntity()
// {
// CheckObject = ruleEntity.CheckObject,
// ErrorId = item,
// BGFWBSM = item,
// ErrorTip = ruleEntity.ErrorTip,
// ErrorType = ruleEntity.ErrorType,
// RuleCode = ruleEntity.RuleCode,
// RuleName = ruleEntity.RuleName,
// RuleContent = ruleEntity.RuleContent,
// });
// }
// foreach (var item in lisCZC202)
// {
// rst.Add(new RuleEntity()
// {
// CheckObject = ruleEntity202.CheckObject,
// ErrorId = item,
// BGFWBSM = item,
// ErrorTip = ruleEntity202.ErrorTip,
// ErrorType = ruleEntity202.ErrorType,
// RuleCode = ruleEntity202.RuleCode,
// RuleName = ruleEntity202.RuleName,
// RuleContent = ruleEntity202.RuleContent,
// });
// }
// }
// catch (Exception ex)
// {
// ruleEntity.ErrorTip = $"{ruleEntity.RuleName}失败:{ex.Message}";
// rst.Add(ruleEntity);
// }
// return rst;
//}
//public List<RuleEntity> CZC203()
//{
// List<RuleEntity> rst = new List<RuleEntity>();
// RuleEntity ruleEntity = new RuleEntity()
// {
// CheckObject = "DTBDLTBGX",
// ErrorId = this.TBBSM,
// ErrorTip = "疑似203边缘建设用地拆除图斑保留203属性合理性检查",
// ErrorType = "二类错误",
// RuleCode = "CZC203",
// RuleName = "疑似203边缘建设用地拆除图斑保留203属性合理性检查"
// };
// IFeatureClass sdczc_dltbFeatureClass = null; //三调203
// IFeatureClass edczc_dltbFeatureClass = null; //二调203
// IGeometry dltbGXgeo = null;
// IFeatureCursor pCursor = null;
// IFeature feature = null;
// try
// {
// var wsFactory = new ESRI.ArcGIS.DataSourcesGDB.FileGDBWorkspaceFactory();
// var workspace = wsFactory.OpenFromFile(@"D:\2022变更修改\单图斑建库软件\城镇村等用地参考图层\441204高要区.gdb", 0);
// DicFeatureClass = new Dictionary<string, IFeatureClass>();
// DicFeatureClass["CZCDYD"] = (workspace as IFeatureWorkspace).OpenFeatureClass("CZCDYDI");
// string sql1 = $"select * from dtbdltbgxgc where tbbsm = '{TBBSM}'";
// DataTable dtt = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, sql1);
// InsertTB(dtt);
// if (!DicFeatureClass.ContainsKey(key_czcdyd) || DicFeatureClass[key_czcdyd] == null)
// {
// throw new Exception("未找到“下发城镇村等用地”参考图层!");
// }
// sdczc_dltbFeatureClass = DicFeatureClass[key_czcdyd];
// edczc_dltbFeatureClass = DicFeatureClass[key_czcdyd];
// ISpatialReference spatialReference = (sdczc_dltbFeatureClass as IGeoDataset).SpatialReference;
// if (spatialReference == null)
// {
// throw new Exception("下发城镇村等用地数据坐标参考为空,质检失败!");
// }
// if (sdczc_dltbFeatureClass.Fields.FindField("CZSX") == -1)
// throw new Exception("“下发城镇村等用地”参考图层 未包含CZSX字段");
// ISpatialFilter spatialFilter = new SpatialFilterClass
// {
// SpatialRel = esriSpatialRelEnum.esriSpatialRelOverlaps, //覆盖
// WhereClause = "CZCLX ='203' and CZSX = '三调村庄范围'"
// };
// string sql = $"select bghtbbsm,egeometry from dtbdltbgxgc where tbbsm = '{TBBSM}' and bghdlbm not in ('05H1','0508','0601','0602','0603','0701','0702','08H1','08H2','08H2A','0809','0810','0810A','09','1004','1005','1201','1001','1002','1003','1007','1008','1009','1109') and bgqczcsxm='203' and bghczcsxm='203'";
// DataTable dt = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, sql);
// if (dt == null || dt.Rows.Count <= 0)
// return rst;
// //DTBDLTBGXGC层图斑,变更前地类编码为05H1、0508、0601、0602、0603、0701、0702、08H1、08H2、08H2A、0809、0810、0810A、09、1004、1005、1201其中之一
// string sql2 = $"select bghtbbsm,egeometry from dtbdltbgxgc where tbbsm = '{TBBSM}' and bgqdlbm in ('05H1','0508','0601','0602','0603','0701','0702','08H1','08H2','08H2A','0809','0810','0810A','09','1004','1005','1201')";
// DataTable dt2 = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, sql2);
// if (dt2 == null || dt2.Rows.Count <= 0)
// return rst;
// Dictionary<string, IGeometry> dic = new Dictionary<string, IGeometry>();
// IEnumerable<IGrouping<string, DataRow>> result2 = dt2.Rows.Cast<DataRow>().GroupBy(dr => dr["bghtbbsm"].ToString());
// foreach (IGrouping<string, DataRow> ig in result2)
// {
// IGeometryCollection geometries = new GeometryBagClass();
// ITopologicalOperator gxgcTopological = new PolygonClass();
// foreach (DataRow dr in ig)
// {
// dltbGXgeo = CheckHelper.GeometryConvertHelper.ConverJsonToIGeoemtry(dr["egeometry"].ToString(), esriGeometryType.esriGeometryPolygon, spatialReference.FactoryCode, false);
// geometries.AddGeometry(dltbGXgeo);
// }
// //融合
// gxgcTopological.ConstructUnion(geometries as IEnumGeometry);
// IGeometry pGeoC = gxgcTopological as IGeometry;
// dic[ig.Key] = pGeoC;
// }
// List<string> lisCZC203 = new List<string>();
// IEnumerable<IGrouping<string, DataRow>> result = dt.Rows.Cast<DataRow>().GroupBy(dr => dr["bghtbbsm"].ToString());
// foreach (IGrouping<string, DataRow> ig in result)
// {
// IGeometryCollection geometries = new GeometryBagClass();
// ITopologicalOperator gxgcTopological = new PolygonClass();
// foreach (DataRow dr in ig)
// {
// dltbGXgeo = CheckHelper.GeometryConvertHelper.ConverJsonToIGeoemtry(dr["egeometry"].ToString(), esriGeometryType.esriGeometryPolygon, spatialReference.FactoryCode, false);
// //在B中,若该类型图斑均与三调203范围均不重叠,
// spatialFilter.Geometry = dltbGXgeo;
// pCursor = sdczc_dltbFeatureClass.Search(spatialFilter, true);
// feature = pCursor.NextFeature();
// if (feature == null)
// {
// geometries.AddGeometry(dltbGXgeo);
// }
// }
// //将B进行融合,形成C
// gxgcTopological.ConstructUnion(geometries as IEnumGeometry);
// IGeometry pGeoC = gxgcTopological as IGeometry;
// //若C存在图斑与二调203范围共边的情况
// ISpatialFilter sped = new SpatialFilterClass
// {
// //SpatialRel = esriSpatialRelEnum.esriSpatialRelWithin, //共边
// WhereClause = "CZCLX ='203' and CZSX = '二调村庄范围'",
// SpatialRel = esriSpatialRelEnum.esriSpatialRelRelation
// };
// sped.SpatialRelDescription = "TF**T****";
// sped.Geometry = pGeoC;
// var aa= (pGeoC as IArea).Area;
// IFeatureCursor cursorEdczc = edczc_dltbFeatureClass.Search(sped, true);
// IFeature featureEdczc = null;
// while ((featureEdczc = cursorEdczc.NextFeature()) != null)
// {
// //提取与其共边的DTBDLTBGXGC层图斑,若变更前地类编码为05H1、0508、0601、0602、0603、0701、0702、08H1、08H2、08H2A、0809、0810、0810A、09、1004、1005、1201其中之一,相应C中图斑纳入人工核查。
// var cc = featureEdczc.OID;
// if (dic.ContainsKey(ig.Key)&&CommonHelper.IsInterSect(featureEdczc.ShapeCopy,dic[ig.Key])) //
// {
// lisCZC203.Add(ig.Key);
// }
// }
// }
// lisCZC203 = lisCZC203.Distinct().ToList();
// foreach (var item in lisCZC203)
// {
// rst.Add(new RuleEntity()
// {
// CheckObject = ruleEntity.CheckObject,
// ErrorId = item,
// BGFWBSM = item,
// ErrorTip = ruleEntity.ErrorTip,
// ErrorType = ruleEntity.ErrorType,
// RuleCode = ruleEntity.RuleCode,
// RuleName = ruleEntity.RuleName,
// RuleContent = ruleEntity.RuleContent,
// });
// }
// }
// catch (Exception ex)
// {
// ruleEntity.ErrorTip = $"{ruleEntity.RuleName}失败:{ex.Message}";
// rst.Add(ruleEntity);
// }
// return rst;
//}
//public List<RuleEntity> CZC211()
//{
// List<RuleEntity> rst = new List<RuleEntity>();
// RuleEntity ruleEntity = new RuleEntity()
// {
// CheckObject = "DTBDLTBGX",
// ErrorId = this.TBBSM,
// ErrorTip = "二调203范围内非边缘拆除图斑,不得去除203属性",
// ErrorType = "一类错误",
// RuleCode = "CZC211",
// RuleName = "二调203范围内非边界拆除图斑去除203属性情况检查"
// };
// IFeatureClass edczc_dltbFeatureClass = null; //二调203
// IGeometry dltbGXgeo = null;
// IFeatureCursor pCursor = null;
// IFeature feature = null;
// try
// {
// if (!DicFeatureClass.ContainsKey(key_czcdyd) || DicFeatureClass[key_czcdyd] == null)
// {
// throw new Exception("未找到“下发城镇村等用地”参考图层!");
// }
// edczc_dltbFeatureClass = DicFeatureClass[key_czcdyd];
// ISpatialReference spatialReference = (edczc_dltbFeatureClass as IGeoDataset).SpatialReference;
// if (spatialReference == null)
// {
// throw new Exception("下发城镇村等用地数据坐标参考为空,质检失败!");
// }
// if (edczc_dltbFeatureClass.Fields.FindField("CZSX") == -1)
// throw new Exception("“下发城镇村等用地”参考图层 未包含CZSX字段");
// ISpatialFilter spatialFilter = new SpatialFilterClass
// {
// SpatialRel = esriSpatialRelEnum.esriSpatialRelOverlaps, //覆盖
// WhereClause = "CZCLX ='203' and CZSX = '二调村庄范围'"
// };
// //对于任务图斑下DTBDLTBGXGC层中变更后地类编码不为05H1、0508、0601、0602、0603、0701、0702、08H1、08H2、08H2A、0809、0810、0810A、09、1004、1005、1201以及1001、1002、1003、1007、1008、1009、1109的图斑,且变更后城镇村属性码为空的部分,该部分记为A。在A中,提取变更前城镇村属性码为203的部分,该部分记为B。
// string sql = $"select bghtbbsm,egeometry from dtbdltbgxgc where tbbsm = '{TBBSM}' and bghdlbm not in ('05H1','0508','0601','0602','0603','0701','0702','08H1','08H2','08H2A','0809','0810','0810A','09','1004','1005','1201','1001','1002','1003','1007','1008','1009','1109') and bgqczcsxm='203' and (bghczcsxm='' or bghczcsxm is null)";
// DataTable dt = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, sql);
// if (dt == null || dt.Rows.Count <= 0)
// return rst;
// List<string> lisCZC211 = new List<string>();
// IEnumerable<IGrouping<string, DataRow>> result = dt.Rows.Cast<DataRow>().GroupBy(dr => dr["bghtbbsm"].ToString());
// foreach (IGrouping<string, DataRow> ig in result)
// {
// bool isOverLaps = false;
// bool isTouch = false;
// foreach (DataRow dr in ig)
// {
// dltbGXgeo = CheckHelper.GeometryConvertHelper.ConverJsonToIGeoemtry(dr["egeometry"].ToString(), esriGeometryType.esriGeometryPolygon, spatialReference.FactoryCode, false);
// //与二调203范围存在重叠
// spatialFilter.Geometry = dltbGXgeo;
// pCursor = edczc_dltbFeatureClass.Search(spatialFilter, true);
// feature = pCursor.NextFeature();
// if (feature != null)
// isOverLaps = true;
// //与二调203范围存在共边的情况
// ISpatialFilter sped = new SpatialFilterClass
// {
// SpatialRel = esriSpatialRelEnum.esriSpatialRelTouches, //共边
// WhereClause = "CZCSXM='203'"
// };
// if (edczc_dltbFeatureClass.Search(sped, true).NextFeature() != null)
// isTouch = true;
// }
// if (isOverLaps && !isTouch)
// lisCZC211.Add(ig.Key);
// }
// lisCZC211 = lisCZC211.Distinct().ToList();
// foreach (var item in lisCZC211)
// {
// rst.Add(new RuleEntity()
// {
// CheckObject = ruleEntity.CheckObject,
// ErrorId = item,
// BGFWBSM = item,
// ErrorTip = ruleEntity.ErrorTip,
// ErrorType = ruleEntity.ErrorType,
// RuleCode = ruleEntity.RuleCode,
// RuleName = ruleEntity.RuleName,
// RuleContent = ruleEntity.RuleContent,
// });
// }
// }
// catch (Exception ex)
// {
// ruleEntity.ErrorTip = $"{ruleEntity.RuleName}失败:{ex.Message}";
// rst.Add(ruleEntity);
// }
// return rst;
//}
//public List<RuleEntity> CZC212()
//{
// List<RuleEntity> rst = new List<RuleEntity>();
// RuleEntity ruleEntity = new RuleEntity()
// {
// CheckObject = "DTBDLTBGX",
// ErrorId = this.TBBSM,
// ErrorTip = "二调203范围内非拆除图斑,不得去除203属性。",
// ErrorType = "一类错误",
// RuleCode = "CZC212",
// RuleName = "二调203范围内非拆除图斑去除203情况检查"
// };
// IFeatureClass edczc_dltbFeatureClass = null; //二调203
// IGeometry dltbGXgeo = null;
// IFeatureCursor pCursor = null;
// IFeature feature = null;
// try
// {
// if (!DicFeatureClass.ContainsKey(key_czcdyd) || DicFeatureClass[key_czcdyd] == null)
// {
// throw new Exception("未找到“下发城镇村等用地”参考图层!");
// }
// edczc_dltbFeatureClass = DicFeatureClass[key_czcdyd];
// ISpatialReference spatialReference = (edczc_dltbFeatureClass as IGeoDataset).SpatialReference;
// if (spatialReference == null)
// {
// throw new Exception("下发城镇村等用地数据坐标参考为空,质检失败!");
// }
// if (edczc_dltbFeatureClass.Fields.FindField("CZSX") == -1)
// throw new Exception("“下发城镇村等用地”参考图层 未包含CZSX字段");
// ISpatialFilter spatialFilter = new SpatialFilterClass
// {
// SpatialRel = esriSpatialRelEnum.esriSpatialRelOverlaps, //覆盖
// WhereClause = "CZCLX ='203' and CZSX = '二调村庄范围'"
// };
// //对于任务图斑下DTBDLTBGXGC层中变更后地类编码不为05H1、0508、0601、0602、0603、0701、0702、08H1、08H2、08H2A、0809、0810、0810A、09、1004、1005、1201以及1001、1002、1003、1007、1008、1009、1109的图斑,且变更后城镇村属性码为空的部分,该部分记为A。在A中,提取变更前城镇村属性码为203的部分,该部分记为B。 且变更前地类不为05类、06类(含0603)、07、08、09、1004、1005、1201,且面积大于10平方米。
// string sql = $"select bghtbbsm,egeometry from dtbdltbgxgc where tbbsm = '{TBBSM}' and bghdlbm not in ('05H1','0508','0601','0602','0603','0701','0702','08H1','08H2','08H2A','0809','0810','0810A','09','1004','1005','1201','1001','1002','1003','1007','1008','1009','1109') and bgqdlbm not in ('05H1','0508','0601','0602','0603','0701','0702','08H1','08H2','08H2A','0809','0810','0810A','09','1004','1005','1201') and bgqczcsxm='203' and (bghczcsxm='' or bghczcsxm is null) and bghtbdlmj>10";
// DataTable dt = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, sql);
// if (dt == null || dt.Rows.Count <= 0)
// return rst;
// List<string> lisCZC211 = new List<string>();
// IEnumerable<IGrouping<string, DataRow>> result = dt.Rows.Cast<DataRow>().GroupBy(dr => dr["bghtbbsm"].ToString());
// foreach (IGrouping<string, DataRow> ig in result)
// {
// foreach (DataRow dr in ig)
// {
// dltbGXgeo = CheckHelper.GeometryConvertHelper.ConverJsonToIGeoemtry(dr["egeometry"].ToString(), esriGeometryType.esriGeometryPolygon, spatialReference.FactoryCode, false);
// //与二调203范围存在重叠
// spatialFilter.Geometry = dltbGXgeo;
// pCursor = edczc_dltbFeatureClass.Search(spatialFilter, true);
// feature = pCursor.NextFeature();
// if (feature != null)
// {
// lisCZC211.Add(ig.Key);
// }
// }
// }
// lisCZC211 = lisCZC211.Distinct().ToList();
// foreach (var item in lisCZC211)
// {
// rst.Add(new RuleEntity()
// {
// CheckObject = ruleEntity.CheckObject,
// ErrorId = item,
// BGFWBSM = item,
// ErrorTip = ruleEntity.ErrorTip,
// ErrorType = ruleEntity.ErrorType,
// RuleCode = ruleEntity.RuleCode,
// RuleName = ruleEntity.RuleName,
// RuleContent = ruleEntity.RuleContent,
// });
// }
// }
// catch (Exception ex)
// {
// ruleEntity.ErrorTip = $"{ruleEntity.RuleName}失败:{ex.Message}";
// rst.Add(ruleEntity);
// }
// return rst;
//}
//public List<RuleEntity> CZC213()
//{
// List<RuleEntity> rst = new List<RuleEntity>();
// RuleEntity ruleEntity = new RuleEntity()
// {
// CheckObject = "DTBDLTBGX",
// ErrorId = this.TBBSM,
// ErrorTip = "二调203范围内疑似迭代图斑,去除203属性合理性检",
// ErrorType = "二类错误",
// RuleCode = "CZC213",
// RuleName = "二调203范围内疑似迭代图斑,去除203属性合理性检查"
// };
// IFeatureClass edczc_dltbFeatureClass = null; //二调203
// IGeometry dltbGXgeo = null;
// IFeatureCursor pCursor = null;
// IFeature feature = null;
// try
// {
// if (!DicFeatureClass.ContainsKey(key_czcdyd) || DicFeatureClass[key_czcdyd] == null)
// {
// throw new Exception("未找到“下发城镇村等用地”参考图层!");
// }
// edczc_dltbFeatureClass = DicFeatureClass[key_czcdyd];
// ISpatialReference spatialReference = (edczc_dltbFeatureClass as IGeoDataset).SpatialReference;
// if (spatialReference == null)
// {
// throw new Exception("下发城镇村等用地数据坐标参考为空,质检失败!");
// }
// if (edczc_dltbFeatureClass.Fields.FindField("CZSX") == -1)
// throw new Exception("“下发城镇村等用地”参考图层 未包含CZSX字段");
// ISpatialFilter spatialFilter = new SpatialFilterClass
// {
// SpatialRel = esriSpatialRelEnum.esriSpatialRelOverlaps, //覆盖
// WhereClause = "CZCLX ='203' and CZSX = '二调村庄范围'"
// };
// //对于任务图斑下DTBDLTBGXGC层中变更后地类编码不为05H1、0508、0601、0602、0603、0701、0702、08H1、08H2、08H2A、0809、0810、0810A、09、1004、1005、1201以及1001、1002、1003、1007、1008、1009、1109的图斑,且变更后城镇村属性码为空的部分,该部分记为A。在A中,提取变更前城镇村属性码为203的部分,该部分记为B。 且变更前地类不为05类、06类(含0603)、07、08、09、1004、1005、1201,且面积未达到10平方米。
// string sql = $"select bghtbbsm,egeometry from dtbdltbgxgc where tbbsm = '{TBBSM}' and bghdlbm not in ('05H1','0508','0601','0602','0603','0701','0702','08H1','08H2','08H2A','0809','0810','0810A','09','1004','1005','1201','1001','1002','1003','1007','1008','1009','1109') and bgqdlbm not in ('05H1','0508','0601','0602','0603','0701','0702','08H1','08H2','08H2A','0809','0810','0810A','09','1004','1005','1201') and bgqczcsxm='203' and (bghczcsxm='' or bghczcsxm is null) and bghtbdlmj<=10";
// DataTable dt = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, sql);
// if (dt == null || dt.Rows.Count <= 0)
// return rst;
// List<string> lisCZC213 = new List<string>();
// IEnumerable<IGrouping<string, DataRow>> result = dt.Rows.Cast<DataRow>().GroupBy(dr => dr["bghtbbsm"].ToString());
// foreach (IGrouping<string, DataRow> ig in result)
// {
// foreach (DataRow dr in ig)
// {
// dltbGXgeo = CheckHelper.GeometryConvertHelper.ConverJsonToIGeoemtry(dr["egeometry"].ToString(), esriGeometryType.esriGeometryPolygon, spatialReference.FactoryCode, false);
// //与二调203范围存在重叠
// spatialFilter.Geometry = dltbGXgeo;
// pCursor = edczc_dltbFeatureClass.Search(spatialFilter, true);
// feature = pCursor.NextFeature();
// if (feature != null)
// {
// lisCZC213.Add(ig.Key);
// }
// }
// }
// lisCZC213 = lisCZC213.Distinct().ToList();
// foreach (var item in lisCZC213)
// {
// rst.Add(new RuleEntity()
// {
// CheckObject = ruleEntity.CheckObject,
// ErrorId = item,
// BGFWBSM = item,
// ErrorTip = ruleEntity.ErrorTip,
// ErrorType = ruleEntity.ErrorType,
// RuleCode = ruleEntity.RuleCode,
// RuleName = ruleEntity.RuleName,
// RuleContent = ruleEntity.RuleContent,
// });
// }
// }
// catch (Exception ex)
// {
// ruleEntity.ErrorTip = $"{ruleEntity.RuleName}失败:{ex.Message}";
// rst.Add(ruleEntity);
// }
// return rst;
//}
//public List<RuleEntity> CZC214()
//{
// List<RuleEntity> rst = new List<RuleEntity>();
// RuleEntity ruleEntity = new RuleEntity()
// {
// CheckObject = "DTBDLTBGX",
// ErrorId = this.TBBSM,
// ErrorTip = "二调203范围内疑似拆除图斑,不得去除203属性",
// ErrorType = "二类错误",
// RuleCode = "CZC214",
// RuleName = "二调203范围内疑似拆除图斑,不得去除203属性情况检查"
// };
// IFeatureClass edczc_dltbFeatureClass = null; //二调203
// IGeometry dltbGXgeo = null;
// IFeatureCursor pCursor = null;
// IFeature feature = null;
// try
// {
// if (!DicFeatureClass.ContainsKey(key_czcdyd) || DicFeatureClass[key_czcdyd] == null)
// {
// throw new Exception("未找到“下发城镇村等用地”参考图层!");
// }
// edczc_dltbFeatureClass = DicFeatureClass[key_czcdyd];
// ISpatialReference spatialReference = (edczc_dltbFeatureClass as IGeoDataset).SpatialReference;
// if (spatialReference == null)
// {
// throw new Exception("下发城镇村等用地数据坐标参考为空,质检失败!");
// }
// if (edczc_dltbFeatureClass.Fields.FindField("CZSX") == -1)
// throw new Exception("“下发城镇村等用地”参考图层 未包含CZSX字段");
// ISpatialFilter spatialFilter = new SpatialFilterClass
// {
// SpatialRel = esriSpatialRelEnum.esriSpatialRelOverlaps, //覆盖
// WhereClause = "CZCLX ='203' and CZSX = '二调村庄范围'"
// };
// //对于任务图斑下DTBDLTBGXGC层中变更后地类编码不为05H1、0508、0601、0602、0603、0701、0702、08H1、08H2、08H2A、0809、0810、0810A、09、1004、1005、1201以及1001、1002、1003、1007、1008、1009、1109的图斑,且变更后城镇村属性码为空的部分,该部分记为A。在A中,提取变更前城镇村属性码为203的部分,该部分记为B。 且变更前地类均为05类、06类(含0603)、07、08、09、1004、1005、1201
// string sql = $"select bghtbbsm,egeometry from dtbdltbgxgc where tbbsm = '{TBBSM}' and bghdlbm not in ('05H1','0508','0601','0602','0603','0701','0702','08H1','08H2','08H2A','0809','0810','0810A','09','1004','1005','1201','1001','1002','1003','1007','1008','1009','1109') and bgqdlbm in ('05H1','0508','0601','0602','0603','0701','0702','08H1','08H2','08H2A','0809','0810','0810A','09','1004','1005','1201') and bgqczcsxm='203' and (bghczcsxm='' or bghczcsxm is null)";
// DataTable dt = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, sql);
// if (dt == null || dt.Rows.Count <= 0)
// return rst;
// string sql2 = $"select bghtbbsm,count(1) from dtbdltbgxgc where tbbsm = '{TBBSM}' group by bghtbbsm";
// DataTable dt2 = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, sql2);
// if (dt == null || dt.Rows.Count <= 0)
// return rst;
// Dictionary<string, int> dic = new Dictionary<string, int>();
// foreach (DataRow dr in dt2.Rows)
// {
// dic[dr[0].ToString()] = Convert.ToInt32(dr[1].ToString());
// }
// List<string> lisCZC214 = new List<string>();
// IEnumerable<IGrouping<string, DataRow>> result = dt.Rows.Cast<DataRow>().GroupBy(dr => dr["bghtbbsm"].ToString());
// foreach (IGrouping<string, DataRow> ig in result)
// {
// if (ig.Count() != dic[ig.Key])
// continue;
// foreach (DataRow dr in ig)
// {
// dltbGXgeo = CheckHelper.GeometryConvertHelper.ConverJsonToIGeoemtry(dr["egeometry"].ToString(), esriGeometryType.esriGeometryPolygon, spatialReference.FactoryCode, false);
// //与二调203范围存在重叠
// spatialFilter.Geometry = dltbGXgeo;
// pCursor = edczc_dltbFeatureClass.Search(spatialFilter, true);
// feature = pCursor.NextFeature();
// if (feature != null)
// {
// lisCZC214.Add(ig.Key);
// }
// }
// }
// lisCZC214 = lisCZC214.Distinct().ToList();
// foreach (var item in lisCZC214)
// {
// rst.Add(new RuleEntity()
// {
// CheckObject = ruleEntity.CheckObject,
// ErrorId = item,
// BGFWBSM = item,
// ErrorTip = ruleEntity.ErrorTip,
// ErrorType = ruleEntity.ErrorType,
// RuleCode = ruleEntity.RuleCode,
// RuleName = ruleEntity.RuleName,
// RuleContent = ruleEntity.RuleContent,
// });
// }
// }
// catch (Exception ex)
// {
// ruleEntity.ErrorTip = $"{ruleEntity.RuleName}失败:{ex.Message}";
// rst.Add(ruleEntity);
// }
// return rst;
//}
//public List<RuleEntity> CZC221()
//{
// List<RuleEntity> rst = new List<RuleEntity>();
// RuleEntity ruleEntity = new RuleEntity()
// {
// CheckObject = "DTBDLTBGX",
// ErrorId = this.TBBSM,
// ErrorTip = "新增非建设用地203属性图斑面积不得大于10平方米",
// ErrorType = "一类错误",
// RuleCode = "CZC221",
// RuleName = "新增非建设用地203属性图斑面积检查"
// };
// IFeatureClass edczc_dltbFeatureClass = null; //二调203
// IGeometry dltbGXgeo = null;
// try
// {
// if (!DicFeatureClass.ContainsKey("JC_DLTB") || DicFeatureClass["JC_DLTB"] == null)
// {
// throw new Exception("未找到“基础_地类图斑”参考图层!");
// }
// edczc_dltbFeatureClass = DicFeatureClass["JC_DLTB"];
// ISpatialReference spatialReference = (edczc_dltbFeatureClass as IGeoDataset).SpatialReference;
// if (spatialReference == null)
// {
// throw new Exception("基础_地类图斑数据坐标参考为空,质检失败!");
// }
// //对于任务图斑下DTBDLTBGXGC层中变更后地类编码不为05H1、0508、0601、0602、0603、0701、0702、08H1、08H2、08H2A、0809、0810、0810A、09、1004、1005、1201以及1001、1002、1003、1007、1008、1009、1109的图斑,且变更后城镇村属性码为203的部分,该部分记为A。在A中,提取变更前城镇村属性码为空的部分,该部分记为B。
// string sql = $"select bghtbbsm,egeometry from dtbdltbgxgc where tbbsm = '{TBBSM}' and bghdlbm not in ('05H1','0508','0601','0602','0603','0701','0702','08H1','08H2','08H2A','0809','0810','0810A','09','1004','1005','1201','1001','1002','1003','1007','1008','1009','1109') and bghczcsxm='203' and (bgqczcsxm='' or bgqczcsxm is null)";
// DataTable dt = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, sql);
// if (dt == null || dt.Rows.Count <= 0)
// return rst;
// List<string> lisCZC221 = new List<string>();
// IEnumerable<IGrouping<string, DataRow>> result = dt.Rows.Cast<DataRow>().GroupBy(dr => dr["bghtbbsm"].ToString());
// foreach (IGrouping<string, DataRow> ig in result)
// {
// IGeometryCollection geometries = new GeometryBagClass();
// ITopologicalOperator gxgcTopological = new PolygonClass();
// foreach (DataRow dr in ig)
// {
// dltbGXgeo = CheckHelper.GeometryConvertHelper.ConverJsonToIGeoemtry(dr["egeometry"].ToString(), esriGeometryType.esriGeometryPolygon, spatialReference.FactoryCode, false);
// geometries.AddGeometry(dltbGXgeo);
// }
// //融合
// gxgcTopological.ConstructUnion(geometries as IEnumGeometry);
// IGeometry pGeoC = gxgcTopological as IGeometry;
// IArea area = pGeoC as IArea;
// if (area != null && area.Area >= 10)
// lisCZC221.Add(ig.Key);
// }
// lisCZC221 = lisCZC221.Distinct().ToList();
// foreach (var item in lisCZC221)
// {
// rst.Add(new RuleEntity()
// {
// CheckObject = ruleEntity.CheckObject,
// ErrorId = item,
// BGFWBSM = item,
// ErrorTip = ruleEntity.ErrorTip,
// ErrorType = ruleEntity.ErrorType,
// RuleCode = ruleEntity.RuleCode,
// RuleName = ruleEntity.RuleName,
// RuleContent = ruleEntity.RuleContent,
// });
// }
// }
// catch (Exception ex)
// {
// ruleEntity.ErrorTip = $"{ruleEntity.RuleName}失败:{ex.Message}";
// rst.Add(ruleEntity);
// }
// return rst;
//}
//public List<RuleEntity> CZC222()
//{
// List<RuleEntity> rst = new List<RuleEntity>();
// RuleEntity ruleEntity = new RuleEntity()
// {
// CheckObject = "DTBDLTBGX",
// ErrorId = this.TBBSM,
// ErrorTip = "新增非建设用地203属性图斑必须与203保留图斑共边",
// ErrorType = "一类错误",
// RuleCode = "CZC222",
// RuleName = "新增非建设用地203属性图斑检查"
// };
// IFeatureClass sdczc_dltbFeatureClass = null; //三调203
// IGeometry dltbGXgeo = null;
// try
// {
// if (!DicFeatureClass.ContainsKey("JC_DLTB") || DicFeatureClass["JC_DLTB"] == null)
// {
// throw new Exception("未找到“基础_地类图斑”参考图层!");
// }
// sdczc_dltbFeatureClass = DicFeatureClass["JC_DLTB"]; ;
// ISpatialReference spatialReference = (sdczc_dltbFeatureClass as IGeoDataset).SpatialReference;
// if (spatialReference == null)
// {
// throw new Exception("基础_地类图斑数据坐标参考为空,质检失败!");
// }
// ISpatialFilter spatialFilter = new SpatialFilterClass
// {
// SpatialRel = esriSpatialRelEnum.esriSpatialRelOverlaps, //覆盖
// WhereClause = "CZCSXM='203'"
// };
// //对于任务图斑下DTBDLTBGXGC层中变更后地类编码不为05H1、0508、0601、0602、0603、0701、0702、08H1、08H2、08H2A、0809、0810、0810A、09、1004、1005、1201以及1001、1002、1003、1007、1008、1009、1109的图斑,且变更后城镇村属性码为203的部分,该部分记为A。在A中,提取变更前城镇村属性码为空的部分,该部分记为B。
// string sql = $"select bghtbbsm,egeometry,bghdlbm from dtbdltbgxgc where tbbsm = '{TBBSM}' and bghdlbm not in ('05H1','0508','0601','0602','0603','0701','0702','08H1','08H2','08H2A','0809','0810','0810A','09','1004','1005','1201','1001','1002','1003','1007','1008','1009','1109') and (bgqczcsxm='' or bgqczcsxm is null) and bghczcsxm='203'";
// DataTable dt = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, sql);
// if (dt == null || dt.Rows.Count <= 0)
// return rst;
// //对于任务图斑下DTBDLTBGXGC层进行提取,提取其中变更前城镇村属性码与变更后城镇村属性码均为203的部分,记为C
// string sql2 = $"select bghtbbsm,egeometry,bghdlbm from dtbdltbgxgc where tbbsm = '{TBBSM}' and bgqczcsxm='203' and bghczcsxm='203'";
// DataTable dt2 = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, sql2);
// if (dt2 == null || dt2.Rows.Count <= 0)
// return rst;
// List<Tuple<string, string, IGeometry>> tups = new List<Tuple<string, string, IGeometry>>();
// foreach (DataRow dataRow in dt2.Rows)
// {
// dltbGXgeo = CheckHelper.GeometryConvertHelper.ConverJsonToIGeoemtry(dataRow["egeometry"].ToString(), esriGeometryType.esriGeometryPolygon, spatialReference.FactoryCode, false);
// tups.Add(new Tuple<string, string, IGeometry>
// (
// dataRow[0].ToString(),
// dataRow[2].ToString(),
// dltbGXgeo
// ));
// }
// List<string> lisCZC222 = new List<string>();
// IEnumerable<IGrouping<string, DataRow>> result = dt.Rows.Cast<DataRow>().GroupBy(dr => dr["bghtbbsm"].ToString());
// foreach (IGrouping<string, DataRow> ig in result)
// {
// IGeometryCollection geometries = new GeometryBagClass();
// ITopologicalOperator gxgcTopological = new PolygonClass();
// bool hasTouch = false;
// foreach (DataRow dr in ig)
// {
// dltbGXgeo = CheckHelper.GeometryConvertHelper.ConverJsonToIGeoemtry(dr["egeometry"].ToString(), esriGeometryType.esriGeometryPolygon, spatialReference.FactoryCode, false);
// // 将B与C共边,且共边两侧变更后地类编码相同时,通过检查。否则,认定为错误图斑。
// foreach (var it in tups.Where(x => x.Item2 == dr["bghdlbm"].ToString()))
// {
// if (CommonHelper.IsAdjacent(dltbGXgeo, it.Item3))
// hasTouch = true;
// }
// }
// if (!hasTouch)
// lisCZC222.Add(ig.Key);
// }
// lisCZC222 = lisCZC222.Distinct().ToList();
// foreach (var item in lisCZC222)
// {
// rst.Add(new RuleEntity()
// {
// CheckObject = ruleEntity.CheckObject,
// ErrorId = item,
// BGFWBSM = item,
// ErrorTip = ruleEntity.ErrorTip,
// ErrorType = ruleEntity.ErrorType,
// RuleCode = ruleEntity.RuleCode,
// RuleName = ruleEntity.RuleName,
// RuleContent = ruleEntity.RuleContent,
// });
// }
// }
// catch (Exception ex)
// {
// ruleEntity.ErrorTip = $"{ruleEntity.RuleName}失败:{ex.Message}";
// rst.Add(ruleEntity);
// }
// return rst;
//}
public List<RuleEntity> CZC301()
{
List<RuleEntity> rst = new List<RuleEntity>();
RuleEntity ruleEntity = new RuleEntity()
{
CheckObject = "DTBDLTBGX",
ErrorId = this.TBBSM,
ErrorTip = "201变更为202情况检查",
ErrorType = "二类错误",
RuleCode = "CZC301",
RuleName = "201变更为202情况检查"
};
try
{
//提取DTBDLTBGXGC层中,变更前城镇村属性码为201,变更后城镇村属性码为202的图斑,纳入人工核查。
string sql = $"select bghtbbsm from dtbdltbgxgc where tbbsm = '{TBBSM}' and bghczcsxm='202' and bgqczcsxm='201'";
DataTable dt = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, sql);
if (dt == null || dt.Rows.Count <= 0)
return rst;
List<string> lisCZC301 = dt.AsEnumerable().Select(x => x[0].ToString()).ToList();
lisCZC301 = lisCZC301.Distinct().ToList();
foreach (var item in lisCZC301)
{
rst.Add(new RuleEntity()
{
CheckObject = ruleEntity.CheckObject,
ErrorId = item,
BGFWBSM = item,
ErrorTip = ruleEntity.ErrorTip,
ErrorType = ruleEntity.ErrorType,
RuleCode = ruleEntity.RuleCode,
RuleName = ruleEntity.RuleName,
RuleContent = ruleEntity.RuleContent,
});
}
}
catch (Exception ex)
{
ruleEntity.ErrorTip = $"{ruleEntity.RuleName}失败:{ex.Message}";
rst.Add(ruleEntity);
}
return rst;
}
public List<RuleEntity> CZC302()
{
List<RuleEntity> rst = new List<RuleEntity>();
RuleEntity ruleEntity = new RuleEntity()
{
CheckObject = "DTBDLTBGX",
ErrorId = this.TBBSM,
ErrorTip = "201变更为203情况检查",
ErrorType = "二类错误",
RuleCode = "CZC302",
RuleName = "201变更为203情况检查"
};
try
{
//提取DTBDLTBGXGC层中,变更前城镇村属性码为201,变更后城镇村属性码为203的图斑,纳入人工核查。
string sql = $"select bghtbbsm from dtbdltbgxgc where tbbsm = '{TBBSM}' and bghczcsxm='203' and bgqczcsxm='201'";
DataTable dt = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, sql);
if (dt == null || dt.Rows.Count <= 0)
return rst;
List<string> lisCZC302 = dt.AsEnumerable().Select(x => x[0].ToString()).ToList();
lisCZC302 = lisCZC302.Distinct().ToList();
foreach (var item in lisCZC302)
{
rst.Add(new RuleEntity()
{
CheckObject = ruleEntity.CheckObject,
ErrorId = item,
BGFWBSM = item,
ErrorTip = ruleEntity.ErrorTip,
ErrorType = ruleEntity.ErrorType,
RuleCode = ruleEntity.RuleCode,
RuleName = ruleEntity.RuleName,
RuleContent = ruleEntity.RuleContent,
});
}
}
catch (Exception ex)
{
ruleEntity.ErrorTip = $"{ruleEntity.RuleName}失败:{ex.Message}";
rst.Add(ruleEntity);
}
return rst;
}
public List<RuleEntity> CZC303()
{
List<RuleEntity> rst = new List<RuleEntity>();
RuleEntity ruleEntity = new RuleEntity()
{
CheckObject = "DTBDLTBGX",
ErrorId = this.TBBSM,
ErrorTip = "202变更为201情况检查",
ErrorType = "二类错误",
RuleCode = "CZC303",
RuleName = "202变更为201情况检查"
};
try
{
//提取DTBDLTBGXGC层中,变更前城镇村属性码为202,变更后城镇村属性码为201的图斑,纳入人工核查。
string sql = $"select bghtbbsm from dtbdltbgxgc where tbbsm = '{TBBSM}'and bghczcsxm='201' and bgqczcsxm='202'";
DataTable dt = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, sql);
if (dt == null || dt.Rows.Count <= 0)
return rst;
List<string> lisCZC302 = dt.AsEnumerable().Select(x => x[0].ToString()).ToList();
lisCZC302 = lisCZC302.Distinct().ToList();
foreach (var item in lisCZC302)
{
rst.Add(new RuleEntity()
{
CheckObject = ruleEntity.CheckObject,
ErrorId = item,
BGFWBSM = item,
ErrorTip = ruleEntity.ErrorTip,
ErrorType = ruleEntity.ErrorType,
RuleCode = ruleEntity.RuleCode,
RuleName = ruleEntity.RuleName,
RuleContent = ruleEntity.RuleContent,
});
}
}
catch (Exception ex)
{
ruleEntity.ErrorTip = $"{ruleEntity.RuleName}失败:{ex.Message}";
rst.Add(ruleEntity);
}
return rst;
}
public List<RuleEntity> CZC304()
{
List<RuleEntity> rst = new List<RuleEntity>();
RuleEntity ruleEntity = new RuleEntity()
{
CheckObject = "DTBDLTBGX",
ErrorId = this.TBBSM,
ErrorTip = "202变更为203情况检查",
ErrorType = "二类错误",
RuleCode = "CZC304",
RuleName = "202变更为203情况检查"
};
try
{
//提取DTBDLTBGXGC层中,变更前城镇村属性码为202,变更后城镇村属性码为203的图斑,纳入人工核查。
string sql = $"select bghtbbsm from dtbdltbgxgc where tbbsm = '{TBBSM}' and bghczcsxm='203' and bgqczcsxm='202'";
DataTable dt = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, sql);
if (dt == null || dt.Rows.Count <= 0)
return rst;
List<string> lisCZC302 = dt.AsEnumerable().Select(x => x[0].ToString()).ToList();
lisCZC302 = lisCZC302.Distinct().ToList();
foreach (var item in lisCZC302)
{
rst.Add(new RuleEntity()
{
CheckObject = ruleEntity.CheckObject,
ErrorId = item,
BGFWBSM = item,
ErrorTip = ruleEntity.ErrorTip,
ErrorType = ruleEntity.ErrorType,
RuleCode = ruleEntity.RuleCode,
RuleName = ruleEntity.RuleName,
RuleContent = ruleEntity.RuleContent,
});
}
}
catch (Exception ex)
{
ruleEntity.ErrorTip = $"{ruleEntity.RuleName}失败:{ex.Message}";
rst.Add(ruleEntity);
}
return rst;
}
public List<RuleEntity> CZC305()
{
List<RuleEntity> rst = new List<RuleEntity>();
RuleEntity ruleEntity = new RuleEntity()
{
CheckObject = "DTBDLTBGX",
ErrorId = this.TBBSM,
ErrorTip = "203变更为201情况检查",
ErrorType = "二类错误",
RuleCode = "CZC305",
RuleName = "203变更为201情况检查"
};
try
{
//提取DTBDLTBGXGC层中,变更前城镇村属性码为203,变更后城镇村属性码为201的图斑,纳入人工核查。
string sql = $"select bghtbbsm from dtbdltbgxgc where tbbsm = '{TBBSM}'and bghczcsxm='201' and bgqczcsxm='203'";
DataTable dt = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, sql);
if (dt == null || dt.Rows.Count <= 0)
return rst;
List<string> lisCZC302 = dt.AsEnumerable().Select(x => x[0].ToString()).ToList();
lisCZC302 = lisCZC302.Distinct().ToList();
foreach (var item in lisCZC302)
{
rst.Add(new RuleEntity()
{
CheckObject = ruleEntity.CheckObject,
ErrorId = item,
BGFWBSM = item,
ErrorTip = ruleEntity.ErrorTip,
ErrorType = ruleEntity.ErrorType,
RuleCode = ruleEntity.RuleCode,
RuleName = ruleEntity.RuleName,
RuleContent = ruleEntity.RuleContent,
});
}
}
catch (Exception ex)
{
ruleEntity.ErrorTip = $"{ruleEntity.RuleName}失败:{ex.Message}";
rst.Add(ruleEntity);
}
return rst;
}
public List<RuleEntity> CZC306()
{
List<RuleEntity> rst = new List<RuleEntity>();
RuleEntity ruleEntity = new RuleEntity()
{
CheckObject = "DTBDLTBGX",
ErrorId = this.TBBSM,
ErrorTip = "203变更为202情况检查",
ErrorType = "二类错误",
RuleCode = "CZC306",
RuleName = "203变更为202情况检查"
};
try
{
//提取DTBDLTBGXGC层中,变更前城镇村属性码为203,变更后城镇村属性码为202的图斑,纳入人工核查
string sql = $"select bghtbbsm from dtbdltbgxgc where tbbsm = '{TBBSM}' and bghczcsxm='202' and bgqczcsxm='203'";
DataTable dt = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, sql);
if (dt == null || dt.Rows.Count <= 0)
return rst;
List<string> lisCZC302 = dt.AsEnumerable().Select(x => x[0].ToString()).ToList();
lisCZC302 = lisCZC302.Distinct().ToList();
foreach (var item in lisCZC302)
{
rst.Add(new RuleEntity()
{
CheckObject = ruleEntity.CheckObject,
ErrorId = item,
BGFWBSM = item,
ErrorTip = ruleEntity.ErrorTip,
ErrorType = ruleEntity.ErrorType,
RuleCode = ruleEntity.RuleCode,
RuleName = ruleEntity.RuleName,
RuleContent = ruleEntity.RuleContent,
});
}
}
catch (Exception ex)
{
ruleEntity.ErrorTip = $"{ruleEntity.RuleName}失败:{ex.Message}";
rst.Add(ruleEntity);
}
return rst;
}
public List<RuleEntity> CZC401()
{
List<RuleEntity> rst = new List<RuleEntity>();
RuleEntity ruleEntity = new RuleEntity()
{
CheckObject = "DTBDLTBGX",
ErrorId = this.TBBSM,
ErrorTip = "因203属性分割的图斑,必须均标记“城镇村图斑编号”",
ErrorType = "一类错误",
RuleCode = "CZC401",
RuleName = "城镇村图斑编号标记情况检查"
};
IFeatureClass edczc_dltbFeatureClass = null; //二调203
try
{
if (!DicFeatureClass.ContainsKey("JC_DLTB") || DicFeatureClass["JC_DLTB"] == null)
{
throw new Exception("未找到“基础_地类图斑”参考图层!");
}
edczc_dltbFeatureClass = DicFeatureClass["JC_DLTB"];
ISpatialReference spatialReference = (edczc_dltbFeatureClass as IGeoDataset).SpatialReference;
if (spatialReference == null)
{
throw new Exception("基础_地类图斑数据坐标参考为空,质检失败!");
}
//对于任务图斑下,提取城镇村属性码标注203和空的图斑,
string sql = $"select bsm,egeometry,dlbm,zzsxdm,tbxhdm,ddtcbz,gdlx,CZCTBBH from dtbdltbgx where tbbsm = '{TBBSM}' and (czcsxm='203' or czcsxm='' or czcsxm is null)";
DataTable dt = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, sql);
if (dt == null || dt.Rows.Count <= 0)
return rst;
List<Tuple<string, IGeometry, string, string>> tuples = new List<Tuple<string, IGeometry, string, string>>();
foreach (DataRow dr in dt.Rows)
{
IGeometry dltbGXgeo = CheckHelper.GeometryConvertHelper.ConverJsonToIGeoemtry(dr["egeometry"].ToString(), esriGeometryType.esriGeometryPolygon, spatialReference.FactoryCode, false);
tuples.Add(new Tuple<string, IGeometry, string, string>($"{dr["bsm"]}", dltbGXgeo, $"{dr["dlbm"]}{dr["zzsxdm"]}{dr["tbxhdm"]}{dr["ddtcbz"]}{dr["gdlx"]}", $"{dr["CZCTBBH"]}"));
}
//若其中存在地类编码、种植属性代码、图斑细化代码、单独图层代码、耕地类型均一致,且共边的图斑,检查其城镇村编号情况是否一致,且不可为空。否则,判定为错误图斑。
List<string> lisCZC302 = new List<string>();
var groups = tuples.GroupBy(x => x.Item3);
foreach (var item in groups)
{
foreach (var gp in item)
{
string czctbbh = gp.Item4;
foreach (var gp2 in item)
{
if (gp2.Item1 == gp.Item1)
continue;
if (CommonHelper.IsAdjacent(gp.Item2, gp2.Item2))
{
if (gp2.Item4 != gp.Item4 || string.IsNullOrEmpty(gp2.Item4))
lisCZC302.Add(gp2.Item1);
}
}
}
}
lisCZC302 = lisCZC302.Distinct().ToList();
foreach (var item in lisCZC302)
{
rst.Add(new RuleEntity()
{
CheckObject = ruleEntity.CheckObject,
ErrorId = item,
BGFWBSM = item,
ErrorTip = ruleEntity.ErrorTip,
ErrorType = ruleEntity.ErrorType,
RuleCode = ruleEntity.RuleCode,
RuleName = ruleEntity.RuleName,
RuleContent = ruleEntity.RuleContent,
});
}
}
catch (Exception ex)
{
ruleEntity.ErrorTip = $"{ruleEntity.RuleName}失败:{ex.Message}";
rst.Add(ruleEntity);
}
return rst;
}
public List<RuleEntity> CZC402()
{
List<RuleEntity> rst = new List<RuleEntity>();
RuleEntity ruleEntity = new RuleEntity()
{
CheckObject = "DTBDLTBGX",
ErrorId = this.TBBSM,
ErrorTip = "标记“城镇村图斑编号”的图斑,城镇村属性码应为203或空。",
ErrorType = "一类错误",
RuleCode = "CZC402",
RuleName = "城镇村图斑编号标记正确性检查"
};
try
{
//对于任务图斑下,对于“城镇村图斑编号”不为空、且标记内容相同的图斑,检查其城镇村属性码值域是否在203、空之间。若不位于其中,判定为错误图斑。
string sql = $"select bsm from dtbdltbgx where tbbsm = '{TBBSM}' and CZCTBBH<>'' and CZCTBBH is not null and (czcsxm not in('203','') and czcsxm is not null)";
DataTable dt = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, sql);
if (dt == null || dt.Rows.Count <= 0)
return rst;
List<string> lisCZC302 = dt.AsEnumerable().Select(x => x[0].ToString()).ToList();
lisCZC302 = lisCZC302.Distinct().ToList();
foreach (var item in lisCZC302)
{
rst.Add(new RuleEntity()
{
CheckObject = ruleEntity.CheckObject,
ErrorId = item,
BGFWBSM = item,
ErrorTip = ruleEntity.ErrorTip,
ErrorType = ruleEntity.ErrorType,
RuleCode = ruleEntity.RuleCode,
RuleName = ruleEntity.RuleName,
RuleContent = ruleEntity.RuleContent,
});
}
}
catch (Exception ex)
{
ruleEntity.ErrorTip = $"{ruleEntity.RuleName}失败:{ex.Message}";
rst.Add(ruleEntity);
}
return rst;
}
public List<RuleEntity> CZC403()
{
List<RuleEntity> rst = new List<RuleEntity>();
RuleEntity ruleEntity = new RuleEntity()
{
CheckObject = "DTBDLTBGX",
ErrorId = this.TBBSM,
ErrorTip = "标记“城镇村图斑编号”的图斑,应共边且地类编码、种植属性代码、图斑细化代码、单独图层代码、耕地类型保持一致",
ErrorType = "一类错误",
RuleCode = "CZC403",
RuleName = "城镇村图斑编号标记正确性与地类逻辑检查"
};
IFeatureClass edczc_dltbFeatureClass = null; //二调203
try
{
if (!DicFeatureClass.ContainsKey("JC_DLTB") || DicFeatureClass["JC_DLTB"] == null)
{
throw new Exception("未找到“基础_地类图斑”参考图层!");
}
edczc_dltbFeatureClass = DicFeatureClass["JC_DLTB"];
ISpatialReference spatialReference = (edczc_dltbFeatureClass as IGeoDataset).SpatialReference;
if (spatialReference == null)
{
throw new Exception("基础_地类图斑数据坐标参考为空,质检失败!");
}
//对于任务图斑下,对于“城镇村图斑编号”不为空、且标记内容相同的图斑
string sql = $"select bsm,egeometry,dlbm,zzsxdm,tbxhdm,ddtcbz,gdlx,CZCTBBH from dtbdltbgx where tbbsm = '{TBBSM}' and CZCTBBH <>'' and CZCTBBH is not null";
DataTable dt = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, sql);
if (dt == null || dt.Rows.Count <= 0)
return rst;
List<Tuple<string, IGeometry, string, string>> tuples = new List<Tuple<string, IGeometry, string, string>>();
foreach (DataRow dr in dt.Rows)
{
IGeometry dltbGXgeo = CheckHelper.GeometryConvertHelper.ConverJsonToIGeoemtry(dr["egeometry"].ToString(), esriGeometryType.esriGeometryPolygon, spatialReference.FactoryCode, false);
tuples.Add(new Tuple<string, IGeometry, string, string>($"{dr["bsm"]}", dltbGXgeo, $"{dr["dlbm"]}{dr["zzsxdm"]}{dr["tbxhdm"]}{dr["ddtcbz"]}{dr["gdlx"]}", $"{dr["CZCTBBH"]}"));
}
//检查其是否共边,且地类编码、种植属性代码、图斑细化代码、单独图层代码、耕地类型均一致。若不共边、或不一致,认定为错误图斑。
List<string> lisCZC302 = new List<string>();
var groups = tuples.GroupBy(x => x.Item4);
List<IGeometry> listGeometry;
foreach (var item in groups)
{
int countsx = item.GroupBy(x => x.Item3).Count(); //比较属性是否都一致
if (countsx > 1)
{
foreach (var gp in item)
lisCZC302.Add(gp.Item1);
}
//融合相同城镇村图斑编号的
IGeometryCollection geometries = new GeometryBagClass();
ITopologicalOperator gxgcTopological = new PolygonClass();
foreach (var gp in item)
{
geometries.AddGeometry(gp.Item2);
}
gxgcTopological.ConstructUnion(geometries as IEnumGeometry);
IGeometry pGeoC = gxgcTopological as IGeometry;
if (CommonHelper.IsMuiltPart(pGeoC, out listGeometry))
foreach (var gp in item)
lisCZC302.Add(gp.Item1);
}
lisCZC302 = lisCZC302.Distinct().ToList();
foreach (var item in lisCZC302)
{
rst.Add(new RuleEntity()
{
CheckObject = ruleEntity.CheckObject,
ErrorId = item,
BGFWBSM = item,
ErrorTip = ruleEntity.ErrorTip,
ErrorType = ruleEntity.ErrorType,
RuleCode = ruleEntity.RuleCode,
RuleName = ruleEntity.RuleName,
RuleContent = ruleEntity.RuleContent,
});
}
}
catch (Exception ex)
{
ruleEntity.ErrorTip = $"{ruleEntity.RuleName}失败:{ex.Message}";
rst.Add(ruleEntity);
}
return rst;
}
public List<RuleEntity> CZC404()
{
List<RuleEntity> rst = new List<RuleEntity>();
RuleEntity ruleEntity = new RuleEntity()
{
CheckObject = "DTBDLTBGX",
ErrorId = this.TBBSM,
ErrorTip = "特殊地类不需填写种植属性代码、图斑细化代码、单独图层代码、耕地类型、城镇村属性码、城镇村图斑编号字段",
ErrorType = "一类错误",
RuleCode = "CZC404",
RuleName = "特殊地类标注城镇村图斑编号检查"
};
try
{
//对于地类编码为88类、99类的图斑,种植属性代码、图斑细化代码、耕地类型、城镇村属性码、城镇村图斑编号字段必须为空。否则,认定为错误图斑。
string sql = $"select bsm,zzsxdm,tbxhdm,gdlx,CZCTBBH from dtbdltbgx where tbbsm = '{TBBSM}' and (dlbm like '%88%' or dlbm like '%99%')";
DataTable dt = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, sql);
if (dt == null || dt.Rows.Count <= 0)
return rst;
List<string> lisCZC302 = new List<string>();
foreach (DataRow dr in dt.Rows)
{
if (!string.IsNullOrEmpty(dr["zzsxdm"].ToString()) || !string.IsNullOrEmpty(dr["tbxhdm"].ToString()) || !string.IsNullOrEmpty(dr["gdlx"].ToString()) || !string.IsNullOrEmpty(dr["CZCTBBH"].ToString()))
{
lisCZC302.Add(dr["bsm"].ToString());
}
}
lisCZC302 = lisCZC302.Distinct().ToList();
foreach (var item in lisCZC302)
{
rst.Add(new RuleEntity()
{
CheckObject = ruleEntity.CheckObject,
ErrorId = item,
BGFWBSM = item,
ErrorTip = ruleEntity.ErrorTip,
ErrorType = ruleEntity.ErrorType,
RuleCode = ruleEntity.RuleCode,
RuleName = ruleEntity.RuleName,
RuleContent = ruleEntity.RuleContent,
});
}
}
catch (Exception ex)
{
ruleEntity.ErrorTip = $"{ruleEntity.RuleName}失败:{ex.Message}";
rst.Add(ruleEntity);
}
return rst;
}
public List<RuleEntity> CZC501()
{
List<RuleEntity> rst = new List<RuleEntity>();
RuleEntity ruleEntity = new RuleEntity()
{
CheckObject = "DTBDLTBGX",
ErrorId = this.TBBSM,
ErrorTip = "标注村庄属性的非建设用地与三调村庄范围重叠面积大于10平方米时,应切割图斑、并去除重叠部分村庄属性标注。",
ErrorType = "一类错误",
RuleCode = "CZC501",
RuleName = "标注203非建设用地疑似位于三调203范围内检查"
};
IFeatureClass czc_FeatureClass = null; //三调203
IGeometry dltbGXgeo = null;
IFeatureCursor pCursor = null;
IFeature feature = null;
List<IGeometry> listGeometryIntsect = null;
try
{
if (!DicFeatureClass.ContainsKey(key_czcdyd) || DicFeatureClass[key_czcdyd] == null)
{
throw new Exception("未找到“下发城镇村等用地”参考图层!");
}
czc_FeatureClass = DicFeatureClass[key_czcdyd];
ISpatialReference spatialReference = (czc_FeatureClass as IGeoDataset).SpatialReference;
if (spatialReference == null)
{
throw new Exception("下发城镇村等用地数据坐标参考为空,质检失败!");
}
if (czc_FeatureClass.Fields.FindField("CZSX") == -1)
throw new Exception("“下发城镇村等用地”参考图层 未包含CZSX字段");
//1、对于地类编码不为05H1、0508、0601、0602、0603、0701、0702、08H1、08H2、08H2A、0809、0810、0810A、09、1004、1005、1201以及1001、1002、1003、1007、1008、1009、1109的图斑,且变更后城镇村属性码为203的部分,该部分记为A。
string sql = $"select bsm,egeometry from dtbdltbgx where tbbsm = '{TBBSM}' and dlbm not in ('05H1','0508','0601','0602','0603','0701','0702','08H1','08H2','08H2A','0809','0810','0810A','09','1004','1005','1201','1001','1002','1003','1007','1008','1009','1109','1001A','1002A','1003A') and dlbm not like '88%' and dlbm not like '99%' and czcsxm='203'";
DataTable dt = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, sql);
if (dt == null || dt.Rows.Count <= 0)
return rst;
//2、提取下发城镇村等用地参考图层中的“三调村庄属性”部分,改部分记为B。
List<string> lisCZC501 = new List<string>();
foreach (DataRow dr in dt.Rows)
{
dltbGXgeo = CheckHelper.GeometryConvertHelper.ConverJsonToIGeoemtry(dr["egeometry"].ToString(), esriGeometryType.esriGeometryPolygon, spatialReference.FactoryCode, false);
ISpatialFilter spatialFilter = new SpatialFilterClass
{
SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects,
WhereClause = "CZCLX like '203%' and CZSX = '三调村庄范围'"
};
IGeometryCollection geometries = new GeometryBagClass();
ITopologicalOperator gxgcTopological = new PolygonClass();
spatialFilter.Geometry = dltbGXgeo;
pCursor = czc_FeatureClass.Search(spatialFilter, false);
feature = null;
while ((feature = pCursor.NextFeature()) != null)
{
//3、将A与B进行叠加,若存在单个重叠部分大于10平方米,认定为错误图斑。
//IGeometry pGeoInt = CommonHelper.InterSect(feature.ShapeCopy, dltbGXgeo); //叠加
//CommonHelper.IsMuiltPart(pGeoInt, out listGeometryIntsect);
//foreach (var geo in listGeometryIntsect)
//{
// IArea pArea = geo as IArea;
// if (pArea.Area > 10)
// {
// lisCZC501.Add(dr[0].ToString());
// }
//}
geometries.AddGeometry(feature.ShapeCopy);
}
gxgcTopological.ConstructUnion(geometries as IEnumGeometry);
IGeometry pGeoC = gxgcTopological as IGeometry;
//3、将A与B进行叠加,若存在单个不重叠部分大于10平方米,认定为错误图斑。
IGeometry pGeoInt = CommonHelper.InterSect(pGeoC, dltbGXgeo);
CommonHelper.IsMuiltPart(pGeoInt, out listGeometryIntsect);
foreach (var geo in listGeometryIntsect)
{
IArea pArea = geo as IArea;
if (pArea.Area > 10)
{
lisCZC501.Add(dr[0].ToString());
}
}
}
lisCZC501 = lisCZC501.Distinct().ToList();
foreach (var item in lisCZC501)
{
rst.Add(new RuleEntity()
{
CheckObject = ruleEntity.CheckObject,
ErrorId = item,
BGFWBSM = item,
ErrorTip = ruleEntity.ErrorTip,
ErrorType = ruleEntity.ErrorType,
RuleCode = ruleEntity.RuleCode,
RuleName = ruleEntity.RuleName,
RuleContent = ruleEntity.RuleContent,
});
}
}
catch (Exception ex)
{
ruleEntity.ErrorTip = $"{ruleEntity.RuleName}失败:{ex.Message}";
rst.Add(ruleEntity);
}
return rst;
}
public List<RuleEntity> CZC502()
{
List<RuleEntity> rst = new List<RuleEntity>();
RuleEntity ruleEntity = new RuleEntity()
{
CheckObject = "DTBDLTBGX",
ErrorId = this.TBBSM,
ErrorTip = "标注村庄属性的非建设用地与三调村庄范围重叠面积小于10平方米时,核实未重叠部分与二调村庄范围的重叠情况。",
ErrorType = "二类错误",
RuleCode = "CZC502",
RuleName = "标注203非建设用地存在与三调203部分重叠检查"
};
IFeatureClass czc_FeatureClass = null; //三调203
IGeometry dltbGXgeo = null;
IFeatureCursor pCursor = null;
IFeature feature = null;
List<IGeometry> listGeometryIntsect = null;
try
{
if (!DicFeatureClass.ContainsKey(key_czcdyd) || DicFeatureClass[key_czcdyd] == null)
{
throw new Exception("未找到“下发城镇村等用地”参考图层!");
}
czc_FeatureClass = DicFeatureClass[key_czcdyd];
ISpatialReference spatialReference = (czc_FeatureClass as IGeoDataset).SpatialReference;
if (spatialReference == null)
{
throw new Exception("下发城镇村等用地数据坐标参考为空,质检失败!");
}
if (czc_FeatureClass.Fields.FindField("CZSX") == -1)
throw new Exception("“下发城镇村等用地”参考图层 未包含CZSX字段");
//1、对于地类编码不为05H1、0508、0601、0602、0603、0701、0702、08H1、08H2、08H2A、0809、0810、0810A、09、1004、1005、1201以及1001、1002、1003、1007、1008、1009、1109的图斑,且变更后城镇村属性码为203的部分,该部分记为A。
string sql = $"select bsm,egeometry from dtbdltbgx where tbbsm = '{TBBSM}' and dlbm not in ('05H1','0508','0601','0602','0603','0701','0702','08H1','08H2','08H2A','0809','0810','0810A','09','1004','1005','1201','1001','1002','1003','1007','1008','1009','1109','1001A','1002A','1003A') and dlbm not like '88%' and dlbm not like '99%' and czcsxm='203'";
DataTable dt = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, sql);
if (dt == null || dt.Rows.Count <= 0)
return rst;
//2、提取下发城镇村等用地参考图层中的“三调村庄属性”部分,改部分记为B。
List<string> lisCZC502 = new List<string>();
foreach (DataRow dr in dt.Rows)
{
dltbGXgeo = CheckHelper.GeometryConvertHelper.ConverJsonToIGeoemtry(dr["egeometry"].ToString(), esriGeometryType.esriGeometryPolygon, spatialReference.FactoryCode, false);
ISpatialFilter spatialFilter = new SpatialFilterClass
{
SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects,
WhereClause = "CZCLX like '203%' and CZSX = '三调村庄范围'"
};
spatialFilter.Geometry = dltbGXgeo;
if (czc_FeatureClass.FeatureCount(spatialFilter) == 0)
{
if ((dltbGXgeo as IArea).Area < 10)
lisCZC502.Add(dr[0].ToString());
}
else
{
IGeometryCollection geometries = new GeometryBagClass();
ITopologicalOperator gxgcTopological = new PolygonClass();
pCursor = czc_FeatureClass.Search(spatialFilter, true);
feature = null;
bool flag = false;
while ((feature = pCursor.NextFeature()) != null)
{
////3、将A与B进行叠加,若存在重叠部分面积均小于10平方米,纳入人工核查。
//IGeometry pGeoInt = CommonHelper.InterSect(feature.ShapeCopy, dltbGXgeo); //叠加
//IArea pArea = pGeoInt as IArea;
//if (pArea.Area >= 10)
//{
// flag = true;
//}
geometries.AddGeometry(feature.ShapeCopy);
}
gxgcTopological.ConstructUnion(geometries as IEnumGeometry);
IGeometry pGeoC = gxgcTopological as IGeometry;
//3、将A与B进行叠加,若存在单个不重叠部分大于10平方米,认定为错误图斑。
IGeometry pGeoInt = CommonHelper.InterSect(pGeoC, dltbGXgeo);
CommonHelper.IsMuiltPart(pGeoInt, out listGeometryIntsect);
foreach (var geo in listGeometryIntsect)
{
IArea pArea = geo as IArea;
if (pArea.Area >= 10)
{
flag = true;
}
}
if (!flag)
lisCZC502.Add(dr[0].ToString());
}
}
lisCZC502 = lisCZC502.Distinct().ToList();
foreach (var item in lisCZC502)
{
rst.Add(new RuleEntity()
{
CheckObject = ruleEntity.CheckObject,
ErrorId = item,
BGFWBSM = item,
ErrorTip = ruleEntity.ErrorTip,
ErrorType = ruleEntity.ErrorType,
RuleCode = ruleEntity.RuleCode,
RuleName = ruleEntity.RuleName,
RuleContent = ruleEntity.RuleContent,
});
}
}
catch (Exception ex)
{
ruleEntity.ErrorTip = $"{ruleEntity.RuleName}失败:{ex.Message}";
rst.Add(ruleEntity);
}
return rst;
}
public List<RuleEntity> CZC503()
{
List<RuleEntity> rst = new List<RuleEntity>();
RuleEntity ruleEntity = new RuleEntity()
{
CheckObject = "DTBDLTBGX",
ErrorId = this.TBBSM,
ErrorTip = "标注村庄属性的非建设用地与二调村庄范围不重叠面积大于10平方米时,应切割图斑、并去除不重叠部分村庄属性标注。",
ErrorType = "一类错误",
RuleCode = "CZC503",
RuleName = "标注203非建设用地疑似落在二调203范围外检查"
};
IFeatureClass czc_FeatureClass = null; //三调203
IGeometry dltbGXgeo = null;
IFeatureCursor pCursor = null;
IFeature feature = null;
List<IGeometry> listGeometryIntsect = null;
try
{
if (!DicFeatureClass.ContainsKey(key_czcdyd) || DicFeatureClass[key_czcdyd] == null)
{
throw new Exception("未找到“下发城镇村等用地”参考图层!");
}
czc_FeatureClass = DicFeatureClass[key_czcdyd];
ISpatialReference spatialReference = (czc_FeatureClass as IGeoDataset).SpatialReference;
if (spatialReference == null)
{
throw new Exception("下发城镇村等用地数据坐标参考为空,质检失败!");
}
if (czc_FeatureClass.Fields.FindField("CZSX") == -1)
throw new Exception("“下发城镇村等用地”参考图层 未包含CZSX字段");
//1、对于地类编码不为05H1、0508、0601、0602、0603、0701、0702、08H1、08H2、08H2A、0809、0810、0810A、09、1004、1005、1201以及1001、1002、1003、1007、1008、1009、1109的图斑,且变更后城镇村属性码为203的部分,该部分记为A。
string sql = $"select bsm,egeometry from dtbdltbgx where tbbsm = '{TBBSM}' and dlbm not in ('05H1','0508','0601','0602','0603','0701','0702','08H1','08H2','08H2A','0809','0810','0810A','09','1004','1005','1201','1001','1002','1003','1007','1008','1009','1109','1001A','1002A','1003A') and dlbm not like '88%' and dlbm not like '99%' and czcsxm='203'";
DataTable dt = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, sql);
if (dt == null || dt.Rows.Count <= 0)
return rst;
//2、提取下发城镇村等用地参考图层中的“二调村庄属性”部分,改部分记为B。
List<string> lisCZC503 = new List<string>();
foreach (DataRow dr in dt.Rows)
{
dltbGXgeo = CheckHelper.GeometryConvertHelper.ConverJsonToIGeoemtry(dr["egeometry"].ToString(), esriGeometryType.esriGeometryPolygon, spatialReference.FactoryCode, false);
ISpatialFilter spatialFilter = new SpatialFilterClass
{
SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects,
WhereClause = "CZCLX like '203%' and CZSX = '二调村庄范围'"
};
spatialFilter.Geometry = dltbGXgeo;
if (czc_FeatureClass.FeatureCount(spatialFilter) == 0)
{
if ((dltbGXgeo as IArea).Area > 10)
lisCZC503.Add(dr[0].ToString());
}
else
{
//融合相同城镇村图斑编号的
IGeometryCollection geometries = new GeometryBagClass();
ITopologicalOperator gxgcTopological = new PolygonClass();
pCursor = czc_FeatureClass.Search(spatialFilter, false);
feature = null;
while ((feature = pCursor.NextFeature()) != null)
{
//3、将A与B进行叠加,若存在单个不重叠部分大于10平方米,认定为错误图斑。
//listGeometryIntsect = CommonHelper.DifferenceWithSingle(dltbGXgeo, feature.ShapeCopy);
//foreach (var geo in listGeometryIntsect)
//{
// IArea pArea = geo as IArea;
// if (pArea.Area > 10)
// {
// lisCZC503.Add(dr[0].ToString());
// }
//}
geometries.AddGeometry(feature.ShapeCopy);
}
gxgcTopological.ConstructUnion(geometries as IEnumGeometry);
IGeometry pGeoC = gxgcTopological as IGeometry;
//3、将A与B进行叠加,若存在单个不重叠部分大于10平方米,认定为错误图斑。
listGeometryIntsect = CommonHelper.DifferenceWithSingle(dltbGXgeo, pGeoC);
foreach (var geo in listGeometryIntsect)
{
IArea pArea = geo as IArea;
if (pArea.Area > 10)
{
lisCZC503.Add(dr[0].ToString());
}
}
}
}
lisCZC503 = lisCZC503.Distinct().ToList();
foreach (var item in lisCZC503)
{
rst.Add(new RuleEntity()
{
CheckObject = ruleEntity.CheckObject,
ErrorId = item,
BGFWBSM = item,
ErrorTip = ruleEntity.ErrorTip,
ErrorType = ruleEntity.ErrorType,
RuleCode = ruleEntity.RuleCode,
RuleName = ruleEntity.RuleName,
RuleContent = ruleEntity.RuleContent,
});
}
}
catch (Exception ex)
{
ruleEntity.ErrorTip = $"{ruleEntity.RuleName}失败:{ex.Message}";
rst.Add(ruleEntity);
}
return rst;
}
public List<RuleEntity> CZC504()
{
List<RuleEntity> rst = new List<RuleEntity>();
RuleEntity ruleEntity = new RuleEntity()
{
CheckObject = "DTBDLTBGX",
ErrorId = this.TBBSM,
ErrorTip = "标注村庄属性的非建设用地与二调村庄范围不重叠面积小于10平方米时,核实重叠部分与203范围重叠情况。",
ErrorType = "二类错误",
RuleCode = "CZC504",
RuleName = "标注203非建设用地存在新增203情况检查"
};
IFeatureClass czc_FeatureClass = null; //三调203
IGeometry dltbGXgeo = null;
IFeatureCursor pCursor = null;
IFeature feature = null;
List<IGeometry> listGeometryIntsect = null;
try
{
if (!DicFeatureClass.ContainsKey(key_czcdyd) || DicFeatureClass[key_czcdyd] == null)
{
throw new Exception("未找到“下发城镇村等用地”参考图层!");
}
czc_FeatureClass = DicFeatureClass[key_czcdyd];
ISpatialReference spatialReference = (czc_FeatureClass as IGeoDataset).SpatialReference;
if (spatialReference == null)
{
throw new Exception("下发城镇村等用地数据坐标参考为空,质检失败!");
}
if (czc_FeatureClass.Fields.FindField("CZSX") == -1)
throw new Exception("“下发城镇村等用地”参考图层 未包含CZSX字段");
//1、对于地类编码不为05H1、0508、0601、0602、0603、0701、0702、08H1、08H2、08H2A、0809、0810、0810A、09、1004、1005、1201以及1001、1002、1003、1007、1008、1009、1109的图斑,且变更后城镇村属性码为203的部分,该部分记为A。
string sql = $"select bsm,egeometry from dtbdltbgx where tbbsm = '{TBBSM}' and dlbm not in ('05H1','0508','0601','0602','0603','0701','0702','08H1','08H2','08H2A','0809','0810','0810A','09','1004','1005','1201','1001','1002','1003','1007','1008','1009','1109','1001A','1002A','1003A') and dlbm not like '88%' and dlbm not like '99%' and czcsxm='203'";
DataTable dt = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, sql);
if (dt == null || dt.Rows.Count <= 0)
return rst;
//2、提取下发城镇村等用地参考图层中的“二调村庄属性”部分,改部分记为B。
List<string> lisCZC503 = new List<string>();
foreach (DataRow dr in dt.Rows)
{
dltbGXgeo = CheckHelper.GeometryConvertHelper.ConverJsonToIGeoemtry(dr["egeometry"].ToString(), esriGeometryType.esriGeometryPolygon, spatialReference.FactoryCode, false);
ISpatialFilter spatialFilter = new SpatialFilterClass
{
SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects,
WhereClause = "CZCLX like '203%' and CZSX = '二调村庄范围'"
};
spatialFilter.Geometry = dltbGXgeo;
if (czc_FeatureClass.FeatureCount(spatialFilter) == 0)
{
if ((dltbGXgeo as IArea).Area <= 10)
lisCZC503.Add(dr[0].ToString());
}
else
{
//融合相同城镇村图斑编号的
IGeometryCollection geometries = new GeometryBagClass();
ITopologicalOperator gxgcTopological = new PolygonClass();
pCursor = czc_FeatureClass.Search(spatialFilter, true);
feature = null;
bool flag = false;
while ((feature = pCursor.NextFeature()) != null)
{
//3、将A与B进行叠加,若存在单个不重叠部分均小于10平米,纳入人工核查。
//listGeometryIntsect = CommonHelper.DifferenceWithSingle(dltbGXgeo, feature.ShapeCopy);
//foreach (var geo in listGeometryIntsect)
//{
// IArea pArea = geo as IArea;
// if (pArea.Area == 0 || pArea.Area >= 10)
// {
// flag = true;
// }
//}
geometries.AddGeometry(feature.ShapeCopy);
}
gxgcTopological.ConstructUnion(geometries as IEnumGeometry);
IGeometry pGeoC = gxgcTopological as IGeometry;
//3、将A与B进行叠加,若存在单个不重叠部分大于10平方米,认定为错误图斑。
listGeometryIntsect = CommonHelper.DifferenceWithSingle(dltbGXgeo, pGeoC);
foreach (var geo in listGeometryIntsect)
{
IArea pArea = geo as IArea;
if (pArea.Area == 0 || pArea.Area >= 10)
{
flag = true;
}
}
if (!flag)
lisCZC503.Add(dr[0].ToString());
}
}
lisCZC503 = lisCZC503.Distinct().ToList();
foreach (var item in lisCZC503)
{
rst.Add(new RuleEntity()
{
CheckObject = ruleEntity.CheckObject,
ErrorId = item,
BGFWBSM = item,
ErrorTip = ruleEntity.ErrorTip,
ErrorType = ruleEntity.ErrorType,
RuleCode = ruleEntity.RuleCode,
RuleName = ruleEntity.RuleName,
RuleContent = ruleEntity.RuleContent,
});
}
}
catch (Exception ex)
{
ruleEntity.ErrorTip = $"{ruleEntity.RuleName}失败:{ex.Message}";
rst.Add(ruleEntity);
}
return rst;
}
public List<RuleEntity> CZC505()
{
List<RuleEntity> rst = new List<RuleEntity>();
RuleEntity ruleEntity = new RuleEntity()
{
CheckObject = "DTBDLTBGX",
ErrorId = this.TBBSM,
ErrorTip = "未标注村庄属性的非建设用地与二调村庄范围重叠面积大于30平方米时,应切割图斑、并将重叠部分标注村庄属性。",
ErrorType = "一类错误",
RuleCode = "CZC505",
RuleName = "未标注城镇村属性的非建设用地疑似位于二调203范围内检查"
};
IFeatureClass czc_FeatureClass = null; //三调203
IGeometry dltbGXgeo = null;
IFeatureCursor pCursor = null;
IFeature feature = null;
List<IGeometry> listGeometryIntsect = null;
try
{
if (!DicFeatureClass.ContainsKey(key_czcdyd) || DicFeatureClass[key_czcdyd] == null)
{
throw new Exception("未找到“下发城镇村等用地”参考图层!");
}
czc_FeatureClass = DicFeatureClass[key_czcdyd];
ISpatialReference spatialReference = (czc_FeatureClass as IGeoDataset).SpatialReference;
if (spatialReference == null)
{
throw new Exception("下发城镇村等用地数据坐标参考为空,质检失败!");
}
if (czc_FeatureClass.Fields.FindField("CZSX") == -1)
throw new Exception("“下发城镇村等用地”参考图层 未包含CZSX字段");
//1、对于地类编码不为05H1、0508、0601、0602、0603、0701、0702、08H1、08H2、08H2A、0809、0810、0810A、09、1004、1005、1201以及1001、1002、1003、1007、1008、1009、1109的图斑,且变更后城镇村属性码为203的部分,该部分记为A。
string sql = $"select bsm,egeometry from dtbdltbgx where tbbsm = '{TBBSM}' and dlbm not in ('05H1','0508','0601','0602','0603','0701','0702','08H1','08H2','08H2A','0809','0810','0810A','09','1004','1005','1201','1001','1002','1003','1007','1008','1009','1109','1001A','1002A','1003A') and dlbm not like '88%' and dlbm not like '99%' and (czcsxm='' or czcsxm is null)";
DataTable dt = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, sql);
if (dt == null || dt.Rows.Count <= 0)
return rst;
//2、提取下发城镇村等用地参考图层中的“二调村庄属性”部分,改部分记为B。
List<string> lisCZC505 = new List<string>();
foreach (DataRow dr in dt.Rows)
{
dltbGXgeo = CheckHelper.GeometryConvertHelper.ConverJsonToIGeoemtry(dr["egeometry"].ToString(), esriGeometryType.esriGeometryPolygon, spatialReference.FactoryCode, false);
ISpatialFilter spatialFilter = new SpatialFilterClass
{
SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects,
WhereClause = "CZCLX like '203%' and CZSX = '二调村庄范围'"
};
//融合相同城镇村图斑编号的
IGeometryCollection geometries = new GeometryBagClass();
ITopologicalOperator gxgcTopological = new PolygonClass();
spatialFilter.Geometry = dltbGXgeo;
pCursor = czc_FeatureClass.Search(spatialFilter, true);
feature = null;
while ((feature = pCursor.NextFeature()) != null)
{
////3、将A与B进行叠加,若存在单个重叠部分大于30平方米,认定为错误图斑。
//IGeometry pGeoInt = CommonHelper.InterSect(feature.ShapeCopy, dltbGXgeo); //叠加
//CommonHelper.IsMuiltPart(pGeoInt, out listGeometryIntsect);
//foreach (var geo in listGeometryIntsect)
//{
// IArea pArea = geo as IArea;
// if (pArea.Area > 30)
// {
// lisCZC505.Add(dr[0].ToString());
// }
//}
geometries.AddGeometry(feature.ShapeCopy);
}
gxgcTopological.ConstructUnion(geometries as IEnumGeometry);
IGeometry pGeoC = gxgcTopological as IGeometry;
//3、将A与B进行叠加,若存在单个不重叠部分大于10平方米,认定为错误图斑。
IGeometry pGeoInt = CommonHelper.InterSect(pGeoC, dltbGXgeo); //叠加
CommonHelper.IsMuiltPart(pGeoInt, out listGeometryIntsect);
foreach (var geo in listGeometryIntsect)
{
IArea pArea = geo as IArea;
if (pArea.Area > 30)
{
lisCZC505.Add(dr[0].ToString());
}
}
}
lisCZC505 = lisCZC505.Distinct().ToList();
foreach (var item in lisCZC505)
{
rst.Add(new RuleEntity()
{
CheckObject = ruleEntity.CheckObject,
ErrorId = item,
BGFWBSM = item,
ErrorTip = ruleEntity.ErrorTip,
ErrorType = ruleEntity.ErrorType,
RuleCode = ruleEntity.RuleCode,
RuleName = ruleEntity.RuleName,
RuleContent = ruleEntity.RuleContent,
});
}
}
catch (Exception ex)
{
ruleEntity.ErrorTip = $"{ruleEntity.RuleName}失败:{ex.Message}";
rst.Add(ruleEntity);
}
return rst;
}
public List<RuleEntity> CZC506()
{
List<RuleEntity> rst = new List<RuleEntity>();
RuleEntity ruleEntity = new RuleEntity()
{
CheckObject = "DTBDLTBGX",
ErrorId = this.TBBSM,
ErrorTip = "未标注村庄属性的非建设用地与二调村庄范围重叠面积小于30平方米时,核实未重叠部分与203范围重叠情况。",
ErrorType = "二类错误",
RuleCode = "CZC506",
RuleName = "未标注城镇村属性的非建设用地存在灭失203情况检查"
};
IFeatureClass czc_FeatureClass = null; //三调203
IGeometry dltbGXgeo = null;
IFeatureCursor pCursor = null;
IFeature feature = null;
List<IGeometry> listGeometryIntsect = null;
try
{
if (!DicFeatureClass.ContainsKey(key_czcdyd) || DicFeatureClass[key_czcdyd] == null)
{
throw new Exception("未找到“下发城镇村等用地”参考图层!");
}
czc_FeatureClass = DicFeatureClass[key_czcdyd];
ISpatialReference spatialReference = (czc_FeatureClass as IGeoDataset).SpatialReference;
if (spatialReference == null)
{
throw new Exception("下发城镇村等用地数据坐标参考为空,质检失败!");
}
if (czc_FeatureClass.Fields.FindField("CZSX") == -1)
throw new Exception("“下发城镇村等用地”参考图层 未包含CZSX字段");
//1、对于地类编码不为05H1、0508、0601、0602、0603、0701、0702、08H1、08H2、08H2A、0809、0810、0810A、09、1004、1005、1201以及1001、1002、1003、1007、1008、1009、1109的图斑,且变更后城镇村属性码为203的部分,该部分记为A。
string sql = $"select bsm,egeometry from dtbdltbgx where tbbsm = '{TBBSM}' and dlbm not in ('05H1','0508','0601','0602','0603','0701','0702','08H1','08H2','08H2A','0809','0810','0810A','09','1004','1005','1201','1001','1001A','1002','1002A','1003','1003A','1007','1008','1009','1109') and dlbm not like '88%' and dlbm not like '99%' and czcsxm='203'";
DataTable dt = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, sql);
if (dt == null || dt.Rows.Count <= 0)
return rst;
//2、提取下发城镇村等用地参考图层中的“三调村庄属性”部分,改部分记为B。
List<string> lisCZC506 = new List<string>();
foreach (DataRow dr in dt.Rows)
{
dltbGXgeo = CheckHelper.GeometryConvertHelper.ConverJsonToIGeoemtry(dr["egeometry"].ToString(), esriGeometryType.esriGeometryPolygon, spatialReference.FactoryCode, false);
ISpatialFilter spatialFilter = new SpatialFilterClass
{
SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects,
WhereClause = "CZCLX like '203%' and CZSX = '二调村庄范围'"
};
spatialFilter.Geometry = dltbGXgeo;
if (czc_FeatureClass.FeatureCount(spatialFilter) == 0)
{
if ((dltbGXgeo as IArea).Area < 30)
lisCZC506.Add(dr[0].ToString());
}
else
{
//融合相同城镇村图斑编号的
IGeometryCollection geometries = new GeometryBagClass();
ITopologicalOperator gxgcTopological = new PolygonClass();
pCursor = czc_FeatureClass.Search(spatialFilter, true);
feature = null;
bool flag = false;
while ((feature = pCursor.NextFeature()) != null)
{
////3、将A与B进行叠加,若存在重叠部分面积均小于30平方米,纳入人工核查。
//IGeometry pGeoInt = CommonHelper.InterSect(feature.ShapeCopy, dltbGXgeo); //叠加
//IArea pArea = pGeoInt as IArea;
//if (pArea.Area >= 30)
//{
// flag = true;
//}
geometries.AddGeometry(feature.ShapeCopy);
}
gxgcTopological.ConstructUnion(geometries as IEnumGeometry);
IGeometry pGeoC = gxgcTopological as IGeometry;
IGeometry pGeoInt = CommonHelper.InterSect(pGeoC, dltbGXgeo);
CommonHelper.IsMuiltPart(pGeoInt, out listGeometryIntsect);
foreach (var geo in listGeometryIntsect)
{
IArea pArea = geo as IArea;
if (pArea.Area >= 30)
{
flag = true;
}
}
if (!flag)
{
lisCZC506.Add(dr[0].ToString());
}
}
}
lisCZC506 = lisCZC506.Distinct().ToList();
foreach (var item in lisCZC506)
{
rst.Add(new RuleEntity()
{
CheckObject = ruleEntity.CheckObject,
ErrorId = item,
BGFWBSM = item,
ErrorTip = ruleEntity.ErrorTip,
ErrorType = ruleEntity.ErrorType,
RuleCode = ruleEntity.RuleCode,
RuleName = ruleEntity.RuleName,
RuleContent = ruleEntity.RuleContent,
});
}
}
catch (Exception ex)
{
ruleEntity.ErrorTip = $"{ruleEntity.RuleName}失败:{ex.Message}";
rst.Add(ruleEntity);
}
return rst;
}
public List<RuleEntity> CZC_507()
{
List<RuleEntity> rst = new List<RuleEntity>();
IFeatureClass czc_FeatureClass = null;
IGeometry dltbGXgeo = null;
IFeatureCursor pCursor = null;
IFeature feature = null;
try
{
if (!DicFeatureClass.ContainsKey(key_czcdyd) || DicFeatureClass[key_czcdyd] == null)
throw new Exception("未找到“城镇村等用地”图层!");
czc_FeatureClass = DicFeatureClass[key_czcdyd];
ISpatialReference spatialReference = (czc_FeatureClass as IGeoDataset).SpatialReference;
if (spatialReference == null)
throw new Exception("下发城镇村等用地数据坐标参考为空,质检失败!");
DataTable dt = SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, $"select * from dtbdltbgx where tbbsm='{TBBSM}'");
if (dt == null || dt.Rows.Count <= 0)
return rst;
foreach (DataRow dr in dt.Rows)
{
dltbGXgeo = CheckHelper.GeometryConvertHelper.ConverJsonToIGeoemtryWithoutSimple(dr["egeometry"].ToString());
dltbGXgeo.Project(spatialReference);
ISpatialFilter spatialFilter = new SpatialFilterClass
{
SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects,
};
spatialFilter.Geometry = dltbGXgeo;
if (czc_FeatureClass.FeatureCount(spatialFilter) > 0)
{
pCursor = czc_FeatureClass.Search(spatialFilter, true);
feature = null;
while ((feature = pCursor.NextFeature()) != null)
{
if (feature.ShapeCopy.IsEmpty) continue;
var geo = CommonHelper.InterSect(dltbGXgeo, feature.ShapeCopy);
if (geo.IsEmpty) continue;
string minAnglejsonGeometry = string.Empty;
ESRI.ArcGIS.esriSystem.IClone clone = geo as ESRI.ArcGIS.esriSystem.IClone;
double minAngle = CommonHelper.GetMinAngle(clone.Clone() as IGeometry, out minAnglejsonGeometry);
if (!string.IsNullOrWhiteSpace(minAnglejsonGeometry))
{
IGeometry geoPoint = GeometryConvertHelper.ConverJsonToIGeoemtry(minAnglejsonGeometry, esriGeometryType.esriGeometryPoint);
minAnglejsonGeometry = GeometryConvertHelper.GeometryToJsonString(geoPoint);
}
if (minAngle < 10 && minAngle >= 0)
{
rst.Add(new RuleEntity()
{
CheckObject = "DTBDLTBGX",
ErrorId = this.TBBSM,
BGFWBSM = this.TBBSM,
ErrorTip = "变更图斑与基础城镇村等用地相交存在尖锐角或局部狭长错误图斑",
ErrorType = "二类错误",
RuleCode = "CZC_507",
RuleName = "尖锐角及局部狭长检查",
RuleContent = "相交结果图层内若存在一个角度小于10度,或局部狭长的图斑,认定为错误图斑。",
Geometry = minAnglejsonGeometry,
GeometryType = 1
});
}
}
}
}
}
catch (Exception ex)
{
rst.Add(new RuleEntity()
{
CheckObject = "DTBDLTBGX",
ErrorId = this.TBBSM,
BGFWBSM = this.TBBSM,
ErrorTip = $"变更图斑与基础城镇村等用地相交存在尖锐角或局部狭长错误图斑,异常:{ex.Message}",
ErrorType = "二类错误",
RuleCode = "CZC_507",
RuleName = "尖锐角及局部狭长检查",
RuleContent = "相交结果图层内若存在一个角度小于10度,或局部狭长的图斑,认定为错误图斑。",
});
}
return rst;
}
public List<RuleEntity> CZC_508()
{
List<RuleEntity> rst = new List<RuleEntity>();
IFeatureClass czc_FeatureClass = null;
IGeometry dltbGXgeo = null;
IGeometry adjoinDltbGeo = null;
IFeatureCursor pCursor = null;
IFeature feature = null;
try
{
if (!DicFeatureClass.ContainsKey(key_czcdyd) || DicFeatureClass[key_czcdyd] == null)
throw new Exception("未找到“城镇村等用地”图层!");
czc_FeatureClass = DicFeatureClass[key_czcdyd];
ISpatialReference spatialReference = (czc_FeatureClass as IGeoDataset).SpatialReference;
if (spatialReference == null)
throw new Exception("下发城镇村等用地数据坐标参考为空,质检失败!");
DataTable dt = SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, $"select egeometry,bsm from dtbdltbgx where tbbsm='{TBBSM}'");
if (dt == null || dt.Rows.Count <= 0)
return rst;
for (int i = 0; i < dt.Rows.Count; i++)
{
dltbGXgeo = GeometryConvertHelper.ConverJsonToIGeoemtry(dt.Rows[i][0] as string);
DataTable tempDt = SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, $"select egeometry,bsm from dtbdltbgx where bsm <> '{dt.Rows[i][1] as string}'");
for (int j = 0; j < tempDt.Rows.Count; j++)
{
adjoinDltbGeo = GeometryConvertHelper.ConverJsonToIGeoemtry(tempDt.Rows[j][0] as string);
if (!CommonHelper.IsAdjacent(dltbGXgeo, adjoinDltbGeo)) continue;
adjoinDltbGeo.Project(spatialReference);
ISpatialFilter spatialFilter = new SpatialFilterClass
{
SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects,
};
spatialFilter.Geometry = adjoinDltbGeo;
if (czc_FeatureClass.FeatureCount(spatialFilter) > 0)
{
pCursor = czc_FeatureClass.Search(spatialFilter, true);
feature = null;
while ((feature = pCursor.NextFeature()) != null)
{
if (feature.ShapeCopy.IsEmpty) continue;
var geo = CommonHelper.InterSect(adjoinDltbGeo, feature.ShapeCopy);
if (geo.IsEmpty) continue;
string minAnglejsonGeometry = string.Empty;
ESRI.ArcGIS.esriSystem.IClone clone = geo as ESRI.ArcGIS.esriSystem.IClone;
double minAngle = CommonHelper.GetMinAngle(clone.Clone() as IGeometry, out minAnglejsonGeometry);
if (!string.IsNullOrWhiteSpace(minAnglejsonGeometry))
{
IGeometry geoPoint = GeometryConvertHelper.ConverJsonToIGeoemtry(minAnglejsonGeometry, esriGeometryType.esriGeometryPoint);
minAnglejsonGeometry = GeometryConvertHelper.GeometryToJsonString(geoPoint);
}
if (minAngle < 10 && minAngle >= 0)
{
rst.Add(new RuleEntity()
{
CheckObject = "DTBDLTBGX",
ErrorId = this.TBBSM,
BGFWBSM = this.TBBSM,
ErrorTip = "当前的变更范围相邻的图斑与基础城镇村等用地相交存在尖锐角或局部狭长错误图斑",
ErrorType = "二类错误",
RuleCode = "CZC_508",
RuleName = "尖锐角及局部狭长检查",
RuleContent = "相交结果图层内若存在一个角度小于10度,或局部狭长的图斑,认定为错误图斑。",
Geometry = minAnglejsonGeometry,
GeometryType = 1
});
}
}
}
}
}
}
catch (Exception ex)
{
rst.Add(new RuleEntity()
{
CheckObject = "DTBDLTBGX",
ErrorId = this.TBBSM,
BGFWBSM = this.TBBSM,
ErrorTip = $"当前的变更范围相邻的图斑与基础城镇村等用地相交存在尖锐角或局部狭长错误图斑,异常:{ex.Message}",
ErrorType = "二类错误",
RuleCode = "CZC_508",
RuleName = "尖锐角及局部狭长检查",
RuleContent = "相交结果图层内若存在一个角度小于10度,或局部狭长的图斑,认定为错误图斑。",
});
}
finally
{
if (dltbGXgeo != null)
System.Runtime.InteropServices.Marshal.ReleaseComObject(dltbGXgeo);
if (adjoinDltbGeo != null)
System.Runtime.InteropServices.Marshal.ReleaseComObject(adjoinDltbGeo);
}
return rst;
}
}
}