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.
2209 lines
120 KiB
2209 lines
120 KiB
using System; |
|
using System.Collections.Generic; |
|
using System.Data; |
|
using System.Linq; |
|
using System.Runtime.InteropServices; |
|
using System.Text; |
|
using System.Threading.Tasks; |
|
using ESRI.ArcGIS.Carto; |
|
using ESRI.ArcGIS.Geodatabase; |
|
using ESRI.ArcGIS.Geometry; |
|
using Kingo.RuleCheck.CheckHelper; |
|
namespace Kingo.RuleCheck.XJRuleCheck |
|
{ |
|
/// <summary> |
|
/// 图形、属性规范性检查 |
|
/// </summary> |
|
public class TXSXCheck_DTB : RuleCheckBase_DTB |
|
{ |
|
public TXSXCheck_DTB() |
|
{ |
|
var list = GetConfigList("TXSXCheck_DTB"); |
|
if (list.Count > 0) |
|
ruleMethodNames = list; |
|
} |
|
|
|
private List<string> ruleMethodNames = new List<string>() |
|
{ "TX001", "TX002", "TX003", "TX005", "TX005A", "TX105", "TX006", "TX007", "TX008", "TX009", "TX010", "TX101", "TX011", "TX102", "TX012", "TX022", "TX022A", "TX023", "TX024", "TX025", "TX026", "TX027", "TX028", "TX029", "BSM001", "SX002", "TXSXJC" |
|
}; |
|
|
|
private string dataSetName = "TDBZSJJ"; |
|
|
|
public override List<RuleEntity> ExcuteCheck(string sourePath, IWorkspace workspace) |
|
{ |
|
return this.StartCheck(sourePath, workspace, ruleMethodNames); |
|
} |
|
|
|
public override List<RuleEntity> ExcuteCheck(string sourePath, Dictionary<string, IFeatureClass> 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 tbbsm, string sourePath, Dictionary<string, IFeatureClass> dicFeatureClass) |
|
{ |
|
return this.StartCheck(tbbsm, sourePath, dicFeatureClass, ruleMethodNames); |
|
} |
|
|
|
/// <summary> |
|
/// 图形属性合并检查 |
|
/// </summary> |
|
/// <returns></returns> |
|
public List<RuleEntity> TXSXJC() |
|
{ |
|
List<RuleEntity> result = new List<RuleEntity>(); |
|
IGeometry geometry = null; |
|
try |
|
{ |
|
DataTable dataTable = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, $"select * from dtbdltbgx where tbbsm='{TBBSM}' and (IsDelete <> '1' or IsDelete ISNULL or IsDelete = '' or IsDelete = ' ' )"); |
|
if (dataTable == null || dataTable.Rows.Count <= 0) |
|
{ |
|
return result; |
|
} |
|
GaussCalculateLibrary.CoordinateReferenceMapping coordinateReference = null; |
|
ISpatialReference featureClassSpatialReference = new SpatialReferenceEnvironmentClass().CreateSpatialReference(4490); |
|
foreach (DataRow item in dataTable.Rows) |
|
{ |
|
string bsm = item["BSM"] == null ? "" : item["BSM"].ToString(); |
|
string dlbm = item["DLBM"] == null ? "" : item["DLBM"].ToString(); |
|
string ddtcdm = item["DDTCBZ"] == null ? "" : item["DDTCBZ"].ToString(); |
|
string czctbbh = item["CZCTBBH"] == null ? "" : item["CZCTBBH"].ToString(); |
|
IArea area = null; |
|
if (coordinateReference == null) |
|
{ |
|
geometry = CheckHelper.GeometryConvertHelper.ConverJsonToIGeoemtry(item["egeometry"].ToString()); |
|
area = geometry as IArea; |
|
coordinateReference = GaussCalculateLibrary.CoordinateHelper.ListCoordinateReference.FirstOrDefault(x => area.Centroid.X > x.MinX && area.Centroid.X < x.MaxX); |
|
geometry.Project(GeometryConvertHelper.CreateProjectedCoordinateSystem(coordinateReference.WKID)); |
|
} |
|
else |
|
{ |
|
geometry = CheckHelper.GeometryConvertHelper.ConverJsonToIGeoemtry(item["egeometry"].ToString(), esriGeometryType.esriGeometryPolygon, coordinateReference.WKID, false); |
|
} |
|
CheckHelper.GeometryConvertHelper.SimplifyGeometry(geometry); |
|
area = geometry as IArea; |
|
#region TX003 规则合并一起检查 |
|
double length = (geometry as IPolygon).Length; |
|
try |
|
{ |
|
if (!dlbm.StartsWith("99") && !dlbm.StartsWith("88")) |
|
{ |
|
double data = length / ((geometry as IPointCollection).PointCount - 1); |
|
if (data < 1 || data > 70) |
|
{ |
|
result.Add(new RuleEntity() |
|
{ |
|
CheckObject = "单图斑建库成果", |
|
ErrorId = bsm, |
|
BGFWBSM = bsm, |
|
ErrorTip = "【DTBDLTBGX】存在节点密度不符合要求图斑", |
|
ErrorType = "一类错误", |
|
RuleCode = "TX003", |
|
RuleName = "图形节点密度检查", |
|
RuleContent = "若图斑存在节点密度过于稀疏、稠密(平均节点密度<1米,或大于70米)的情况,认定为错误图斑。" |
|
}); |
|
} |
|
} |
|
|
|
} |
|
catch (Exception ex) |
|
{ |
|
result.Add(new RuleEntity() |
|
{ |
|
CheckObject = "单图斑建库成果", |
|
ErrorId = this.TBBSM, |
|
ErrorTip = "【DTBDLTBGX】存在节点密度不符合要求图斑规则检查失败:" + ex.Message, |
|
ErrorType = "一类错误", |
|
RuleCode = "TX003", |
|
RuleName = "图形节点密度检查", |
|
RuleContent = "若图斑存在节点密度过于稀疏、稠密(平均节点密度<1米,或大于70米)的情况,认定为错误图斑。" |
|
}); |
|
} |
|
#endregion |
|
|
|
string jsonGeometry = string.Empty; |
|
ESRI.ArcGIS.esriSystem.IClone clone = geometry as ESRI.ArcGIS.esriSystem.IClone; |
|
double minAngle = CommonHelper.GetMinAngle(clone.Clone() as IGeometry, out jsonGeometry); |
|
if (!string.IsNullOrWhiteSpace(jsonGeometry)) |
|
{ |
|
IGeometry geoPoint = GeometryConvertHelper.ConverJsonToIGeoemtry(jsonGeometry, esriGeometryType.esriGeometryPoint); |
|
(geoPoint as IGeometry2).Project(featureClassSpatialReference); |
|
jsonGeometry = GeometryConvertHelper.GeometryToJsonString(geoPoint); |
|
} |
|
#region TX010 规则合并一起检查 |
|
//try |
|
//{ |
|
// if (!dlbm.StartsWith("99") && !dlbm.StartsWith("88") && string.IsNullOrEmpty(czctbbh)) |
|
// { |
|
// if (minAngle < 10 && minAngle >= 0) |
|
// { |
|
// result.Add(new RuleEntity() |
|
// { |
|
// CheckObject = "单图斑建库成果", |
|
// ErrorId = bsm, |
|
// BGFWBSM = bsm, |
|
// ErrorTip = "【DTBDLTBGX】存在尖锐角或局部狭长错误图斑", |
|
// ErrorType = "二类错误", |
|
// RuleCode = "TX010", |
|
// RuleName = "尖锐角及局部狭长检查", |
|
// RuleContent = "图层内若存在一个角度小于10度,或局部狭长的图斑,认定为错误图斑。", |
|
// Geometry = jsonGeometry, |
|
// GeometryType = 1 |
|
// }); |
|
// } |
|
// } |
|
|
|
//} |
|
//catch (Exception ex) |
|
//{ |
|
// result.Add(new RuleEntity() |
|
// { |
|
// CheckObject = "单图斑建库成果", |
|
// ErrorId = this.TBBSM, |
|
// ErrorTip = "【DTBDLTBGX】存在尖锐角或局部狭长错误图斑规则检查失败:" + ex.Message, |
|
// ErrorType = "二类错误", |
|
// RuleCode = "TX010", |
|
// RuleName = "尖锐角及局部狭长检查", |
|
// RuleContent = "图层内若存在一个角度小于10度,或局部狭长的图斑,认定为错误图斑。" |
|
// }); |
|
//} |
|
#endregion |
|
#region TX004 规则合并一起检查 |
|
//try |
|
//{ |
|
// List<string> list = new List<string>() { "1001", "1002", "1003", "1004", "1006", "1009", "1107", "1107A", "1109", "9902", "9903" }; |
|
// if (!list.Contains(dlbm) && area.Area / length < 0.2 && minAngle < 20 && minAngle >= 0) |
|
// { |
|
// result.Add(new RuleEntity() |
|
// { |
|
// CheckObject = "单图斑建库成果", |
|
// ErrorId = bsm, |
|
// BGFWBSM = bsm, |
|
// ErrorTip = "【DTBDLTBGX】存在碎小或狭长图斑", |
|
// ErrorType = "一类错误", |
|
// RuleCode = "TX004", |
|
// RuleName = "碎小、狭长图斑检查", |
|
// RuleContent = "除地类编码为1001、1002、1003、1004、1006、1009、1107、1107A、1109外的其余图斑,若满足面积/周长<0.2,且有一个角度小于20的条件,认定为错误图斑。" |
|
// }); |
|
// } |
|
//} |
|
//catch (Exception ex) |
|
//{ |
|
// result.Add(new RuleEntity() |
|
// { |
|
// CheckObject = "单图斑建库成果", |
|
// ErrorId = this.TBBSM, |
|
// ErrorTip = "【矢量图层】存在碎小或狭长图斑规则检查失败:" + ex.Message, |
|
// ErrorType = "一类错误", |
|
// RuleCode = "TX004", |
|
// RuleName = "碎小、狭长图斑检查", |
|
// RuleContent = "除地类编码为1001、1002、1003、1004、1006、1009、1107、1107A、1109外的其余图斑,若满足面积/周长<0.2,且有一个角度小于20的条件,认定为错误图斑。" |
|
// }); |
|
//} |
|
#endregion |
|
#region TX005、关闭TX005A 规则合并一起检查 |
|
try |
|
{ |
|
if (!dlbm.StartsWith("88") && !dlbm.StartsWith("99")) |
|
{ |
|
List<string> list = new List<string>() { "1001", "1002", "1003", "1004", "1006", "1009", "1101", "1107", "1107A", "1203" }; |
|
if (!list.Contains(dlbm) && area.Area < 30) |
|
{ |
|
list = new List<string>() { "1303", "1304" }; |
|
if (list.Contains(ddtcdm)) |
|
{ |
|
result.Add(new RuleEntity() |
|
{ |
|
CheckObject = "单图斑建库成果", |
|
ErrorId = bsm, |
|
BGFWBSM = bsm, |
|
ErrorTip = "【DTBDLTBGX】存在不够上图面积的图斑", |
|
ErrorType = "二类错误", |
|
RuleCode = "TX105", |
|
RuleName = "碎面多边形检查", |
|
RuleContent = "DTBDLTBGX层中,除地类编码为1001、1002、1003、1004、1006、1009、1101、1107、1107A、1203外的其它图斑,若单独图层代码为1303、1304,存在面积小于30平方米的图斑,认定为错误图斑" |
|
}); |
|
} |
|
else |
|
{ |
|
result.Add(new RuleEntity() |
|
{ |
|
CheckObject = "单图斑建库成果", |
|
ErrorId = bsm, |
|
BGFWBSM = bsm, |
|
ErrorTip = "【DTBDLTBGX】存在不够上图面积的图斑", |
|
ErrorType = "二类错误", |
|
RuleCode = "TX005", |
|
RuleName = "碎面多边形检查", |
|
RuleContent = "DTBDLTBGX层中,除地类编码为1001、1002、1003、1004、1006、1009、1101、1107、1107A、1203外的其它图斑,若单独图层代码不为1303、1304,存在面积小于30平方米的图斑,认定为错误图斑" |
|
}); |
|
} |
|
} |
|
if (!list.Contains(dlbm) && area.Area < 10) |
|
{ |
|
list = new List<string>() { "1303", "1304" }; |
|
if (!list.Contains(ddtcdm)) |
|
{ |
|
result.Add(new RuleEntity() |
|
{ |
|
CheckObject = "单图斑建库成果", |
|
ErrorId = bsm, |
|
BGFWBSM = bsm, |
|
ErrorTip = "【DTBDLTBGX】存在不够上图面积的图斑", |
|
ErrorType = "一类错误", |
|
RuleCode = "TX005A", |
|
RuleName = "碎面多边形检查", |
|
RuleContent = "DTBDLTBGX层中,除地类编码为1001、1002、1003、1004、1006、1009、1101、1107、1107A、1203外的其它图斑,若单独图层代码不为1303、1304,存在面积小于10平方米的图斑,认定为错误图斑" |
|
}); |
|
} |
|
} |
|
} |
|
|
|
} |
|
catch (Exception ex) |
|
{ |
|
result.Add(new RuleEntity() |
|
{ |
|
CheckObject = "单图斑建库成果", |
|
ErrorId = this.TBBSM, |
|
ErrorTip = "【DTBDLTBGX】存在不够上图面积的图斑规则检查失败:" + ex.Message, |
|
ErrorType = "一类错误", |
|
RuleCode = "TX005", |
|
RuleName = "碎面多边形检查", |
|
RuleContent = "DTBDLTBGX层中,除地类编码为1001、1002、1003、1004、1006、1009、1101、1107、1107A、1203外的其它图斑,若存在面积小于10平方米的图斑,认定为错误图斑" |
|
}); |
|
} |
|
#endregion |
|
#region TX006 规则合并一起检查 |
|
try |
|
{ |
|
if (!dlbm.StartsWith("99") && !dlbm.StartsWith("88")) |
|
{ |
|
//防止存在多部件图形,但另一部分又是空的图形 |
|
IGeometryCollection geometryCollection = geometry as IGeometryCollection; |
|
if (geometryCollection.GeometryCount > 1) |
|
{ |
|
for (int i = 0; i < geometryCollection.GeometryCount; i++) |
|
{ |
|
IGeometry geometrySub = geometryCollection.Geometry[i]; |
|
IArea areaSub = geometrySub as IArea; |
|
if (areaSub == null || Math.Abs(areaSub.Area) == 0) |
|
{ |
|
result.Add(new RuleEntity() |
|
{ |
|
ErrorTip = "【DTBDLTBGX】图形为多部件图形,且存在为空的部件!", |
|
ErrorId = bsm, |
|
BGFWBSM = bsm, |
|
CheckObject = "单图斑建库成果", |
|
ErrorType = "一类错误", |
|
RuleCode = "TX006", |
|
RuleName = "图形内拓扑检查", |
|
RuleContent = "面层内要素若存在图形错误,认定为错误图斑", |
|
}); |
|
break; |
|
} |
|
} |
|
} |
|
//IPointCollection polygonVertices = new PolygonClass(); |
|
//IPointCollection lineVertices = geometry as IPointCollection; |
|
//polygonVertices.AddPointCollection(lineVertices); |
|
ITopologicalOperator3 pTopology = geometry as ITopologicalOperator3; |
|
esriNonSimpleReasonEnum reason = esriNonSimpleReasonEnum.esriNonSimpleOK;//自相交 |
|
pTopology.IsKnownSimple_2 = false; |
|
if (!pTopology.get_IsSimpleEx(out reason)) |
|
{ |
|
string message = string.Empty; |
|
switch (reason) |
|
{ |
|
case esriNonSimpleReasonEnum.esriNonSimpleOK: |
|
break; |
|
case esriNonSimpleReasonEnum.esriNonSimpleRingOrientation: |
|
message = "环可能方向不正确(外环 - 顺时针,内环 - 逆时针)"; |
|
break; |
|
case esriNonSimpleReasonEnum.esriNonSimpleSegmentOrientation: |
|
message = "各个细分市场的方向不一致"; |
|
break; |
|
case esriNonSimpleReasonEnum.esriNonSimpleShortSegments: |
|
message = "某些线段比与几何相关的空间参考的系统单位所允许的短"; |
|
break; |
|
case esriNonSimpleReasonEnum.esriNonSimpleSelfIntersections: |
|
message = "存在自相交"; |
|
break; |
|
case esriNonSimpleReasonEnum.esriNonSimpleUnclosedRing: |
|
message = "存在未关闭的环"; |
|
break; |
|
case esriNonSimpleReasonEnum.esriNonSimpleEmptyPart: |
|
message = "存在空部件"; |
|
break; |
|
case esriNonSimpleReasonEnum.esriNonSimpleMismatchedAttributes: |
|
message = "几何图形具有不匹配的属性"; |
|
break; |
|
case esriNonSimpleReasonEnum.esriNonSimpleDiscontinuousParts: |
|
message = "几何图形包含不连续的部分"; |
|
break; |
|
case esriNonSimpleReasonEnum.esriNonSimpleEmptyZValues: |
|
message = "几何图形Z值为空"; |
|
break; |
|
case esriNonSimpleReasonEnum.esriNonSimpleDuplicateVertex: |
|
message = "几何图形有重复的顶点"; |
|
break; |
|
default: |
|
message = reason.ToString(); |
|
break; |
|
} |
|
if (!string.IsNullOrWhiteSpace(message)) |
|
{ |
|
result.Add(new RuleEntity() |
|
{ |
|
ErrorTip = "【DTBDLTBGX】图形错误:" + message, |
|
ErrorId = bsm, |
|
BGFWBSM = bsm, |
|
CheckObject = "单图斑建库成果", |
|
ErrorType = "一类错误", |
|
RuleCode = "TX006", |
|
RuleName = "图形内拓扑检查", |
|
RuleContent = "面层内要素若存在图形错误,认定为错误图斑", |
|
}); |
|
} |
|
} |
|
} |
|
|
|
} |
|
catch (Exception ex) |
|
{ |
|
result.Add(new RuleEntity() |
|
{ |
|
ErrorTip = "【DTBDLTBGX】存在自相交图斑规则检查失败:" + ex.Message, |
|
ErrorId = this.TBBSM, |
|
CheckObject = "单图斑建库成果", |
|
ErrorType = "一类错误", |
|
RuleCode = "TX006", |
|
RuleContent = "面层内要素若存在图形错误,认定为错误图斑", |
|
RuleName = "图形内拓扑检查" |
|
}); |
|
} |
|
#endregion |
|
#region TX007 规则合并一起检查 |
|
try |
|
{ |
|
if (!dlbm.StartsWith("99") && !dlbm.StartsWith("88")) |
|
{ |
|
//此处排除内外环的要素,判断当前要素图形是否存在多个外环 |
|
GeometryBag ExterGeometryBag = (geometry as ESRI.ArcGIS.Geometry.IPolygon4).ExteriorRingBag as GeometryBag; |
|
IGeometryCollection ExterRingGeometryCollection = ExterGeometryBag as IGeometryCollection; |
|
if (ExterRingGeometryCollection.GeometryCount > 1) |
|
{ |
|
result.Add(new RuleEntity() |
|
{ |
|
ErrorId = bsm, |
|
BGFWBSM = bsm, |
|
ErrorTip = $"【DTBDLTBGX】存在组合图斑", |
|
CheckObject = "单图斑建库成果", |
|
ErrorType = "一类错误", |
|
RuleCode = "TX007", |
|
RuleContent = "面层内要素若存在组合图斑,认定为错误图斑", |
|
RuleName = "组合图斑检查", |
|
}); |
|
} |
|
} |
|
|
|
} |
|
catch (Exception ex) |
|
{ |
|
result.Add(new RuleEntity() |
|
{ |
|
ErrorId = this.TBBSM, |
|
ErrorTip = $"【DTBDLTBGX】存在组合图斑规则检查失败:" + ex.Message, |
|
CheckObject = "单图斑建库成果", |
|
ErrorType = "一类错误", |
|
RuleCode = "TX007", |
|
RuleContent = "面层内要素若存在组合图斑,认定为错误图斑", |
|
RuleName = "组合图斑检查" |
|
}); |
|
} |
|
#endregion |
|
#region TX011 规则合并一起检查 |
|
try |
|
{ |
|
if (!dlbm.StartsWith("99") && !dlbm.StartsWith("88") && string.IsNullOrEmpty(czctbbh)) |
|
{ |
|
|
|
List<string> list = new List<string>() { "1001", "1001A", "1002", "1002A", "1003", "1003A", "1004", "1004A", "1006", "1009", "1101", "1107", "1107A" }; |
|
if (area.Area / length < 0.2 && !list.Contains(string.IsNullOrWhiteSpace(dlbm) ? "" : dlbm.ToString())) |
|
{ |
|
result.Add(new RuleEntity() |
|
{ |
|
CheckObject = "单图斑建库成果", |
|
ErrorId = bsm, |
|
BGFWBSM = bsm, |
|
ErrorTip = "【DTBDLTBGX】存在图形不规则的错误图斑", |
|
ErrorType = "二类错误", |
|
RuleCode = "TX011", |
|
RuleName = "不规则图形检查", |
|
RuleContent = "除地类编码为1001、1001A、1002、1002A、1003、1003A、1004、1004A、1006、1009、1101、1107、1107A的图斑外,图层内若存在面积/周长<0.2的图斑,认定为错误图斑" |
|
}); |
|
} |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
result.Add(new RuleEntity() |
|
{ |
|
CheckObject = "单图斑建库成果", |
|
ErrorId = this.TBBSM, |
|
ErrorTip = "【DTBDLTBGX】存在图形不规则的错误图斑规则检查失败:" + ex.Message, |
|
ErrorType = "二类错误", |
|
RuleCode = "TX011", |
|
RuleName = "不规则图形检查", |
|
RuleContent = "除地类编码为1001、1001A、1002、1002A、1003、1003A、1004、1004A、1006、1009、1101、1107、1107A的图斑外,图层内若存在面积/周长<0.2的图斑,认定为错误图斑" |
|
}); |
|
} |
|
#endregion |
|
#region TX101 |
|
//try |
|
//{ |
|
// if (!dlbm.StartsWith("99") && !dlbm.StartsWith("88") && string.IsNullOrEmpty(czctbbh)) |
|
// { |
|
// if (minAngle < 20 && minAngle >= 10) |
|
// { |
|
// result.Add(new RuleEntity() |
|
// { |
|
// CheckObject = "单图斑建库成果", |
|
// ErrorId = bsm, |
|
// BGFWBSM = bsm, |
|
// ErrorTip = "【DTBDLTBGX】存在尖锐角或局部狭长错误图斑,需核实", |
|
// ErrorType = "二类错误", |
|
// RuleCode = "TX101", |
|
// RuleName = "尖锐角及局部狭长检查", |
|
// RuleContent = "图层内若存在一个角度大于等于10度且小于20度,或局部狭长的图斑,认定为错误图斑", |
|
// Geometry = jsonGeometry, |
|
// GeometryType = 1 |
|
// }); |
|
// } |
|
// } |
|
//} |
|
//catch (Exception ex) |
|
//{ |
|
// result.Add(new RuleEntity() |
|
// { |
|
// CheckObject = "单图斑建库成果", |
|
// ErrorId = this.TBBSM, |
|
// ErrorTip = "【DTBDLTBGX】存在尖锐角或局部狭长错误图斑,需核实规则检查失败:" + ex.Message, |
|
// ErrorType = "二类错误", |
|
// RuleCode = "TX101", |
|
// RuleName = "尖锐角及局部狭长检查", |
|
// RuleContent = "图层内若存在一个角度大于等于10度且小于20度,或局部狭长的图斑,认定为错误图斑" |
|
// }); |
|
//} |
|
#endregion |
|
#region TX102 |
|
//try |
|
//{ |
|
// if (!dlbm.StartsWith("99") && !dlbm.StartsWith("88") && string.IsNullOrEmpty(czctbbh)) |
|
// { |
|
// List<string> list = new List<string>() { "1001", "1001A", "1002", "1002A", "1003", "1003A", "1004", "1004A", "1006", "1009", "1101", "1107", "1107A" }; |
|
// if (0.2 <= area.Area / length && area.Area / length < 1.2 && !list.Contains(dlbm == null ? "" : dlbm.ToString())) |
|
// { |
|
// result.Add(new RuleEntity() |
|
// { |
|
// CheckObject = "单图斑建库成果", |
|
// ErrorId = bsm, |
|
// BGFWBSM = bsm, |
|
// ErrorTip = "【DTBDLTBGX】存在图形不规则的错误图斑", |
|
// ErrorType = "二类错误", |
|
// RuleCode = "TX102", |
|
// RuleName = "不规则图形检查", |
|
// RuleContent = "除地类编码为1001、1001A、1002、1002A、1003、1003A、1004、1004A、1006、1009、1101、1107、1107A的图斑外,图层内若存在0.2≤面积/周长<1.2的图斑,认定为错误图斑" |
|
// }); |
|
// } |
|
// } |
|
//} |
|
//catch (Exception ex) |
|
//{ |
|
// result.Add(new RuleEntity() |
|
// { |
|
// CheckObject = "单图斑建库成果", |
|
// ErrorId = this.TBBSM, |
|
// ErrorTip = "【DTBDLTBGX】存在图形不规则的错误图斑规则检查失败:" + ex.Message, |
|
// ErrorType = "二类错误", |
|
// RuleCode = "TX102", |
|
// RuleName = "不规则图形检查", |
|
// RuleContent = "除地类编码为1001、1001A、1002、1002A、1003、1003A、1004、1004A、1006、1009、1101、1107、1107A的图斑外,图层内若存在0.2≤面积/周长<1.2的图斑,认定为错误图斑" |
|
// }); |
|
//} |
|
#endregion |
|
if (geometry != null) |
|
{ |
|
System.Runtime.InteropServices.Marshal.ReleaseComObject(geometry); |
|
geometry = null; |
|
} |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
RuleEntity ruleEntity = new RuleEntity() |
|
{ |
|
CheckObject = "单图斑建库成果", |
|
ErrorId = this.TBBSM, |
|
ErrorTip = "【DTBDLTBGX】图形属性检查异常:" + ex.Message, |
|
ErrorType = "一类错误", |
|
RuleCode = "TXSXJC", |
|
RuleName = "图形属性检查", |
|
RuleContent = "图形属性检查。" |
|
}; |
|
result.Add(ruleEntity); |
|
} |
|
finally |
|
{ |
|
if (geometry != null) |
|
{ |
|
System.Runtime.InteropServices.Marshal.ReleaseComObject(geometry); |
|
} |
|
//if (cursor != null) |
|
//{ |
|
// System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor); |
|
//} |
|
//if (featureClass != null) |
|
//{ |
|
// System.Runtime.InteropServices.Marshal.ReleaseComObject(featureClass); |
|
//} |
|
} |
|
return result; |
|
} |
|
|
|
public List<RuleEntity> TX001() |
|
{ |
|
List<RuleEntity> result = new List<RuleEntity>(); |
|
IGeometry geometry1 = null; |
|
IGeometry geometry2 = null; |
|
try |
|
{ |
|
//标记删除后的任务包图斑不做叠加 只检查0或者空值 |
|
DataTable dataTable = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, $"select * from dtbdltbgx where tbbsm='{TBBSM}' and (IsDelete <> '1' or IsDelete ISNULL or IsDelete = '' or IsDelete = ' ' )"); |
|
if (dataTable == null || dataTable.Rows.Count <= 0) |
|
{ |
|
return result; |
|
} |
|
ISpatialReference featureClassSpatialReference = new SpatialReferenceEnvironmentClass().CreateSpatialReference(4490); |
|
DataTable dataTable2 = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, $"select egeometry,bsm from dtbdltbgx where IsDelete <> '1' or IsDelete ISNULL or IsDelete = '' or IsDelete = ' ' "); |
|
for (int i = 0; i < dataTable.Rows.Count; i++) |
|
{ |
|
string strdlbm = dataTable.Rows[i]["DLBM"] as string; |
|
if (strdlbm == null || string.IsNullOrEmpty(strdlbm)) continue; |
|
if (strdlbm.StartsWith("99") || strdlbm.StartsWith("88")) |
|
continue; |
|
geometry1 = GeometryConvertHelper.ConverJsonToIGeoemtry(dataTable.Rows[i]["EGeometry"] as string); |
|
for (int j = 0; j < dataTable2.Rows.Count; j++) |
|
{ |
|
if (dataTable2.Rows[j][1].Equals(dataTable.Rows[i]["BSM"])) |
|
{ |
|
continue; |
|
} |
|
geometry2 = GeometryConvertHelper.ConverJsonToIGeoemtry(dataTable2.Rows[j][0] as string); |
|
|
|
var geo = CommonHelper.InterSect(geometry1, geometry2); |
|
if (geo.IsEmpty) |
|
{ |
|
System.Runtime.InteropServices.Marshal.ReleaseComObject(geometry2); |
|
continue; |
|
} |
|
var line = CommonHelper.GeometryToPolyline(geo); |
|
(line as IGeometry2).Project(featureClassSpatialReference); //转为球面后在插入要素图层是会自动转为要素图层坐标系 |
|
string jsonGeometry = GeometryConvertHelper.GeometryToJsonString(line); |
|
|
|
result.Add(new RuleEntity() |
|
{ |
|
ErrorTip = "【DTBDLTBGX】图层内存在相互重叠要素", |
|
ErrorId = TBBSM, |
|
CheckObject = "单图斑建库成果", |
|
ErrorType = "一类错误", |
|
RuleCode = "TX001", |
|
RuleContent = "若同一图层内存在面与面重叠(包括完全重叠与部分重叠,容差超过0.0001米)的图斑,认定为错误图斑", |
|
RuleName = "图斑重叠检查", |
|
GeometryType = 2, |
|
Geometry = jsonGeometry |
|
}); |
|
return result; |
|
} |
|
System.Runtime.InteropServices.Marshal.ReleaseComObject(geometry1); |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
RuleEntity ruleEntity = new RuleEntity() |
|
{ |
|
ErrorTip = "【DTBDLTBGX】图层内存在相互重叠要素规则检查失败:" + ex.Message, |
|
ErrorId = this.TBBSM, |
|
CheckObject = "单图斑建库成果", |
|
ErrorType = "一类错误", |
|
RuleCode = "TX001", |
|
RuleContent = "若同一图层内存在面与面重叠(包括完全重叠与部分重叠,容差超过0.0001米)的图斑,认定为错误图斑", |
|
RuleName = "图斑重叠检查", |
|
}; |
|
result.Add(ruleEntity); |
|
} |
|
return result; |
|
} |
|
|
|
public List<RuleEntity> TX002() |
|
{ |
|
List<RuleEntity> result = new List<RuleEntity>(); |
|
IGeometry geometry1 = null; |
|
IGeometry geometry2 = null; |
|
try |
|
{ |
|
//2021.11.9修改原因:省级审核不允许道路分叉 |
|
DataTable dataTable = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, $"select group_concat(bsm) as bsmstr,dlbm from dtbdltbgx where tbbsm='{TBBSM}' group by dlbm,zzsxdm,tbxhdm,gdlx,ddtcbz,czcsxm,xzdwkd,ljlx,kcxs,qsxz,ZLDWDM,qsdwdm,gdpdjb having count(1)>1"); |
|
if (dataTable == null || dataTable.Rows.Count <= 0) |
|
{ |
|
return result; |
|
} |
|
HashSet<string> lisTX002 = new HashSet<string>(); |
|
HashSet<string> lisTX027 = new HashSet<string>(); |
|
|
|
foreach (DataRow item in dataTable.Rows) |
|
{ |
|
if (item[1] == null || item[1] as string == null || (item[1] as string).StartsWith("99") || (item[1] as string).StartsWith("88")) |
|
{ |
|
continue; |
|
} |
|
List<string> listBSM = (item[0] as string).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(); |
|
DataTable dataTable1 = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, $"select egeometry,bz,bsm,dlbm from dtbdltbgx where BSM in ('{string.Join("','", listBSM)}') "); |
|
for (int i = 0; i < dataTable1.Rows.Count; i++) |
|
{ |
|
geometry1 = GeometryConvertHelper.ConverJsonToIGeoemtry(dataTable1.Rows[i][0] as string); |
|
string sBsm = dataTable1.Rows[i][2] + string.Empty; |
|
string sXJBZ = dataTable1.Rows[i][1] + string.Empty; |
|
string strDLBM = dataTable1.Rows[i][3] + string.Empty; |
|
for (int j = i + 1; j < dataTable1.Rows.Count; j++) |
|
{ |
|
geometry2 = GeometryConvertHelper.ConverJsonToIGeoemtry(dataTable1.Rows[j][0] as string); |
|
if (!CommonHelper.IsAdjacent(geometry1, geometry2)) |
|
{ |
|
System.Runtime.InteropServices.Marshal.ReleaseComObject(geometry2); |
|
continue; |
|
} |
|
string sXJBZ2 = dataTable1.Rows[j][1] + string.Empty; |
|
string strDLBM2 = dataTable1.Rows[j][3] + string.Empty; |
|
if (string.IsNullOrEmpty(sXJBZ) && sXJBZ == sXJBZ2) |
|
{ |
|
//2323.11.28 山西需求 |
|
//TX002 道路不提示合并 |
|
//权属性质,权属单位代码,坐落单位代码,现状地物宽度,耕地坡度级别不一致,相同地类属性不能提示合并 |
|
if (!DLParams.dl_dlbms.Contains(strDLBM) && !DLParams.dl_dlbms.Contains(strDLBM2)) |
|
lisTX002.Add(sBsm); |
|
} |
|
else |
|
lisTX027.Add(sBsm); |
|
} |
|
System.Runtime.InteropServices.Marshal.ReleaseComObject(geometry1); |
|
} |
|
} |
|
|
|
foreach (var tbbsm in lisTX002) |
|
{ |
|
result.Add(new RuleEntity() |
|
{ |
|
CheckObject = "DTBDLTBGX", |
|
ErrorId = tbbsm, |
|
BGFWBSM = tbbsm, |
|
ErrorTip = "同一任务图斑下的单图斑成果,若为相邻相同属性图斑,应合并上图", |
|
ErrorType = "一类错误", |
|
RuleCode = "TX002", |
|
RuleContent = "对于DTBDLTBGX层中的图斑,若其地类编码、种植属性代码、图斑细化代码、耕地类型、单独图层代码、城镇村属性码与同一任务包下相邻的其他单图斑均相同的图斑进行提取,若相应图斑的“县级备注”字段均为空,判定为错误图斑", |
|
RuleName = "相同属性相邻图斑合并情况检查", |
|
}); |
|
} |
|
foreach (var tbbsm in lisTX027) |
|
{ |
|
result.Add(new RuleEntity() |
|
{ |
|
CheckObject = "DTBDLTBGX", |
|
ErrorId = tbbsm, |
|
BGFWBSM = tbbsm, |
|
ErrorTip = "同一任务图斑下的单图斑成果,若为相邻相同属性图斑,依据“县级备注”字段核实是否需要合并上图", |
|
ErrorType = "二类错误", |
|
RuleCode = "TX027", |
|
RuleContent = "对于DTBDLTBGX层中的图斑,若其地类编码、种植属性代码、图斑细化代码、耕地类型、单独图层代码、城镇村属性码与同一任务包下相邻的其他单图斑均相同的图斑进行提取,若相应图斑的“县级备注”字段不为空,判定为错误图斑", |
|
RuleName = "相同属性相邻图斑合并情况检查", |
|
}); |
|
} |
|
return result; |
|
} |
|
catch (Exception ex) |
|
{ |
|
RuleEntity ruleEntity = new RuleEntity() |
|
{ |
|
ErrorTip = "TX002规则检查失败:" + ex.Message, |
|
ErrorId = this.TBBSM, |
|
CheckObject = "DTBDLTBGX", |
|
ErrorType = "一类错误", |
|
RuleCode = "TX002", |
|
RuleContent = "对于DTBDLTBGX层中的图斑,若其地类编码、种植属性代码、图斑细化代码、耕地类型、单独图层代码、城镇村属性码与同一任务包下相邻的其他单图斑均相同,认定为错误图斑。", |
|
RuleName = "相同属性相邻图斑合并情况检查" |
|
}; |
|
result.Add(ruleEntity); |
|
} |
|
finally |
|
{ |
|
if (geometry1 != null) |
|
{ |
|
System.Runtime.InteropServices.Marshal.ReleaseComObject(geometry1); |
|
} |
|
if (geometry2 != null) |
|
{ |
|
System.Runtime.InteropServices.Marshal.ReleaseComObject(geometry2); |
|
} |
|
} |
|
return result; |
|
} |
|
|
|
public List<RuleEntity> BSM001() |
|
{ |
|
List<RuleEntity> result = new List<RuleEntity>(); |
|
try |
|
{ |
|
System.Data.DataTable dataTable = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, $"SELECT BSM FROM DTBDLTBGX WHERE TBBSM ='{TBBSM}' AND dlbm<>'9904' GROUP BY BSM having count(1)>1"); |
|
if (dataTable != null && dataTable.Rows.Count > 0) |
|
{ |
|
foreach (DataRow item in dataTable.Rows) |
|
{ |
|
result.Add(new RuleEntity() |
|
{ |
|
CheckObject = "单图斑建库成果", |
|
ErrorId = item[0].ToString(), |
|
BGFWBSM = item[0].ToString(), |
|
ErrorTip = "【DTBDLTBGX】内图斑标识码不唯一", |
|
ErrorType = "一类错误", |
|
RuleCode = "BSM001", |
|
RuleName = "标识码唯一性检查", |
|
RuleContent = "图层内图斑标识码若不唯一,认定为错误图斑。" |
|
}); |
|
} |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
RuleEntity ruleEntity = new RuleEntity() |
|
{ |
|
CheckObject = "单图斑建库成果", |
|
ErrorId = this.TBBSM, |
|
ErrorTip = "【DTBDLTBGX】内图斑标识码不唯一规则检查失败:" + ex.Message, |
|
ErrorType = "一类错误", |
|
RuleCode = "BSM001", |
|
RuleName = "标识码唯一性检查", |
|
RuleContent = "图层内图斑标识码若不唯一,认定为错误图斑。" |
|
}; |
|
result.Add(ruleEntity); |
|
} |
|
return result; |
|
} |
|
|
|
public List<RuleEntity> TX012() |
|
{ |
|
List<RuleEntity> result = new List<RuleEntity>(); |
|
HashSet<string> tbbsms = new HashSet<string>(); |
|
List<IGeometry> lstDifferenceGeo = null; |
|
try |
|
{ |
|
string sql = $"select C.TBBSM,B.MJ,C.jcmj from (SELECT TBBSM,sum(abs(A.tbmj)) as MJ FROM DTBDLTBGX A where TBBSM='{TBBSM}' AND substr(TBBSM,7,4)<>'ZZBG') as b left join WYRW c on c.TBBSM=b.TBBSM WHERE abs(B.MJ*0.0015/C.tbmj)<0.8"; |
|
System.Data.DataTable dataTable = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, sql); |
|
if (dataTable != null && dataTable.Rows.Count > 0) |
|
{ |
|
result.Add(new RuleEntity() |
|
{ |
|
CheckObject = "单图斑建库成果", |
|
ErrorId = TBBSM, |
|
BGFWBSM = TBBSM, |
|
ErrorTip = "下发任务图斑未完全响应", |
|
ErrorType = "二类错误", |
|
RuleCode = "TX012", |
|
RuleName = "单图斑待上报范围规范性检查", |
|
RuleContent = "(1)将同一任务图斑下所有单图斑成果的面积和记为A;任务图斑面积记为B;当A/B的比例小于90%时,认定为错误图斑。或(2)将任务图斑擦除同一任务图斑下所有单图斑成果,剩余部分进行打散为各个小图斑,若存在某一小图斑的面积≥50平方米,认定为错误图斑。" |
|
}); |
|
return result; |
|
} |
|
else |
|
{ |
|
dataTable = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, $"select egeometry from WYRW WHERE TBBSM ='{TBBSM}'"); |
|
if (dataTable == null || dataTable.Rows.Count != 1) |
|
{ |
|
throw new Exception($"WYRW表未找到TBBSM={TBBSM}的外业任务图斑!"); |
|
} |
|
IGeometry wyrwGeometry = CheckHelper.GeometryConvertHelper.ConverJsonToIGeoemtry(dataTable.Rows[0][0].ToString()); |
|
dataTable = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, $"select egeometry from DTBDLTBGX WHERE TBBSM ='{TBBSM}' AND substr(TBBSM,7,4)<>'ZZBG'"); |
|
if (dataTable == null || dataTable.Rows.Count <= 0) |
|
{ |
|
//throw new Exception($"外业任务图斑下未找到变更范围图斑!"); |
|
return result; |
|
} |
|
//IGeometryCollection geometries = new GeometryBagClass(); |
|
ITopologicalOperator topological = null; |
|
foreach (DataRow item in dataTable.Rows) |
|
{ |
|
IGeometry geometry = CheckHelper.GeometryConvertHelper.ConverJsonToIGeoemtry(item[0].ToString()); |
|
if (topological == null) |
|
{ |
|
topological = geometry as ITopologicalOperator; |
|
} |
|
else |
|
{ |
|
topological = topological.Union(geometry) as ITopologicalOperator; |
|
} |
|
|
|
//geometries.AddGeometry(geometry); |
|
} |
|
|
|
|
|
//topological.ConstructUnion(geometries as IEnumGeometry); |
|
if (topological == null) |
|
{ |
|
result.Add(new RuleEntity() |
|
{ |
|
CheckObject = "单图斑建库成果", |
|
ErrorId = TBBSM, |
|
BGFWBSM = TBBSM, |
|
ErrorTip = "下发任务图斑未完全响应", |
|
ErrorType = "二类错误", |
|
RuleCode = "TX012", |
|
RuleName = "单图斑待上报范围规范性检查", |
|
RuleContent = "(1)将同一任务图斑下所有单图斑成果的面积和记为A;任务图斑面积记为B;当A/B的比例小于90%时,认定为错误图斑。" |
|
}); |
|
return result; |
|
} |
|
IGeometry bgfwGeometry = topological as IGeometry; |
|
lstDifferenceGeo = CommonHelper.DifferenceWithSingle(wyrwGeometry, bgfwGeometry); |
|
foreach (var item in lstDifferenceGeo) |
|
{ |
|
if (item == null || item.IsEmpty) |
|
{ |
|
continue; |
|
} |
|
IArea area = item as IArea; |
|
if (area.Area >= 200) |
|
{ |
|
result.Add(new RuleEntity() |
|
{ |
|
CheckObject = "单图斑建库成果", |
|
ErrorId = TBBSM, |
|
BGFWBSM = TBBSM, |
|
ErrorTip = "下发任务图斑未完全响应", |
|
ErrorType = "二类错误", |
|
RuleCode = "TX012", |
|
RuleName = "单图斑待上报范围规范性检查", |
|
RuleContent = "(2)将同一任务图斑下所有单图斑成果擦除任务图斑,剩余部分进行打散为各个小图斑,若存在某一小图斑的面积≥200平方米,认定为错误图斑。" |
|
}); |
|
break; |
|
} |
|
} |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
RuleEntity ruleEntity = new RuleEntity() |
|
{ |
|
CheckObject = "单图斑建库成果", |
|
ErrorId = this.TBBSM, |
|
ErrorTip = "下发任务图斑未完全响应规则检查失败:" + ex.Message, |
|
ErrorType = "一类错误", |
|
RuleCode = "TX012", |
|
RuleName = "单图斑待上报范围规范性检查", |
|
RuleContent = "(1)将同一任务图斑下所有单图斑成果的面积和记为A;任务图斑面积记为B;当A/B的比例小于90%时,认定为错误图斑;(2)将同一任务图斑下所有单图斑成果擦除任务图斑,剩余部分进行打散为各个小图斑,若存在某一小图斑的面积≥200平方米,认定为错误图斑。" |
|
}; |
|
result.Add(ruleEntity); |
|
} |
|
return result; |
|
} |
|
|
|
public List<RuleEntity> SX002() |
|
{ |
|
List<RuleEntity> result = new List<RuleEntity>(); |
|
try |
|
{ |
|
string sql = $"SELECT * from DTBDLTBGX where TBBSM='{TBBSM}' and KCDLBM not in ('','1203','1207')"; |
|
System.Data.DataTable dataTable = SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, sql); |
|
if (dataTable != null && dataTable.Rows.Count > 0) |
|
{ |
|
foreach (DataRow item in dataTable.Rows) |
|
{ |
|
result.Add(new RuleEntity() |
|
{ |
|
CheckObject = "DTBDLTBGX层", |
|
ErrorId = item[0].ToString(), |
|
ErrorTip = "扣除地类编码只能为1203、1207或空。", |
|
ErrorType = "一类错误", |
|
RuleCode = "SX002", |
|
RuleName = "扣除地类编码规范性检查", |
|
RuleContent = "当扣除地类编码值域须为1203、1207、空,其中之一,若不是,认定为错误图斑。" |
|
}); |
|
} |
|
} |
|
} |
|
|
|
catch (Exception ex) |
|
{ |
|
RuleEntity ruleEntity = new RuleEntity() |
|
{ |
|
CheckObject = "DTBDLTBGX层", |
|
ErrorId = this.TBBSM, |
|
ErrorTip = "扣除地类编码只能为1203、1207或空规则检查失败:" + ex.Message, |
|
ErrorType = "一类错误", |
|
RuleCode = "SX002", |
|
RuleName = "扣除地类编码规范性检查", |
|
RuleContent = "当扣除地类编码值域须为1203、1207、空,其中之一,若不是,认定为错误图斑。" |
|
}; |
|
result.Add(ruleEntity); |
|
} |
|
return result; |
|
} |
|
|
|
public List<RuleEntity> TX02X() |
|
{ |
|
List<RuleEntity> result = new List<RuleEntity>(); |
|
IFeatureCursor cursor = null; |
|
IFeatureCursor pInsertCursor = null; |
|
IFeatureClass pJCKFeatureClass = null; |
|
try |
|
{ |
|
bool isSj = true; |
|
//var wsFactory = new ESRI.ArcGIS.DataSourcesGDB.FileGDBWorkspaceFactory(); |
|
//var workspace = wsFactory.OpenFromFile(@"D:\!!!!\440105海珠区\基础数据库\440105\440105海珠区.gdb", 0); |
|
//WorkspaceDic["JCKWorkspace"] = workspace; |
|
//WorkspaceDic["NWorkspace"] = workspace; |
|
if (DicFeatureClass.ContainsKey("JC_BGFWCG") && DicFeatureClass["JC_BGFWCG"] != null) |
|
{ |
|
pJCKFeatureClass = DicFeatureClass["JC_BGFWCG"]; |
|
} |
|
else if (DicFeatureClass.ContainsKey("DLTB_NMK") && DicFeatureClass["DLTB_NMK"] != null) |
|
{ |
|
pJCKFeatureClass = DicFeatureClass["DLTB_NMK"]; |
|
} |
|
else if (DicFeatureClass.ContainsKey("JC_DLTB") && DicFeatureClass["JC_DLTB"] != null) |
|
{ |
|
pJCKFeatureClass = DicFeatureClass["JC_DLTB"]; |
|
} |
|
else |
|
{ |
|
throw new Exception("未找到基础库地类图斑层"); |
|
} |
|
//省级规则不使用N图层 |
|
IWorkspace pJCKworkspace = (pJCKFeatureClass as FeatureClass).Workspace; |
|
if (!DicFeatureClass.ContainsKey("NON") && pJCKworkspace.Type != esriWorkspaceType.esriRemoteDatabaseWorkspace) //SDE中图层默认已设置正确坐标系 |
|
isSj = false; |
|
|
|
if (!isSj && (!DicFeatureClass.ContainsKey("N") || DicFeatureClass["N"] == null)) |
|
{ |
|
throw new Exception("未找到质检结果图层N"); |
|
} |
|
IFeatureClass pNFeatureClass = DicFeatureClass.ContainsKey("N") ? DicFeatureClass["N"] : null; |
|
|
|
if (!isSj) |
|
{ |
|
if (pNFeatureClass.Fields.FindField("WYRWTBBSM") < -1) |
|
{ |
|
IField wyrwField = new FieldClass(); |
|
IFieldEdit nameFieldEdit = (IFieldEdit)wyrwField; |
|
nameFieldEdit.Name_2 = "WYRWTBBSM"; |
|
nameFieldEdit.AliasName_2 = "外业任务图斑标识码"; |
|
nameFieldEdit.Length_2 = 20; |
|
nameFieldEdit.Type_2 = esriFieldType.esriFieldTypeString; |
|
//fieldsEdit.AddField(wyrwField); |
|
pNFeatureClass.AddField(wyrwField); |
|
} |
|
if (pNFeatureClass.Fields.FindField("ZBXX") < -1) |
|
{ |
|
IField zbxxField = new FieldClass(); |
|
IFieldEdit zbxxFieldEdit = (IFieldEdit)zbxxField; |
|
zbxxFieldEdit.Name_2 = "ZBXX"; |
|
zbxxFieldEdit.AliasName_2 = "占原图斑比例"; |
|
zbxxFieldEdit.Length_2 = 20; |
|
zbxxFieldEdit.Type_2 = esriFieldType.esriFieldTypeString; |
|
//fieldsEdit.AddField(zbxxField); |
|
pNFeatureClass.AddField(zbxxFieldEdit); |
|
} |
|
IWorkspace workspace = (pNFeatureClass as FeatureClass).Workspace; |
|
CommonHelper.SetGeoDatasetSpatialReference(workspace, (pJCKFeatureClass as IGeoDataset).SpatialReference, 0.0001); |
|
|
|
IQueryFilter queryFilter = new QueryFilterClass() |
|
{ |
|
WhereClause = $"WYRWTBBSM='{TBBSM}'" |
|
}; |
|
//若之前存在记录则删除,根据WYRWTBBSM |
|
(pNFeatureClass as ITable).DeleteSearchedRows(queryFilter); |
|
} |
|
|
|
|
|
//将该外业任务图斑下所有变更范围融合 |
|
Dictionary<string, IGeometry> dicBgfws = new Dictionary<string, IGeometry>(); //变更范围与图形字典 |
|
|
|
DataTable dataTable = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, $"select * from dtbdltbgx where tbbsm='{TBBSM}'AND dlbm not like '99%' AND dlbm not like '88%' AND (CZCTBBH='' OR CZCTBBH IS NULL) "); |
|
if (dataTable == null || dataTable.Rows.Count <= 0) |
|
{ |
|
return result; |
|
} |
|
ISpatialReference spatialReference = (pJCKFeatureClass as IGeoDataset).SpatialReference; |
|
if (spatialReference == null) |
|
{ |
|
throw new Exception("基础库地类图斑层坐标参考为空,质检失败!"); |
|
} |
|
IGeometry geometry = null; |
|
IGeometryCollection geometries = new GeometryBagClass(); |
|
ITopologicalOperator pTopologicalOperator = new PolygonClass(); |
|
foreach (DataRow item in dataTable.Rows) |
|
{ |
|
geometry = CheckHelper.GeometryConvertHelper.ConverJsonToIGeoemtry(item["egeometry"].ToString()); |
|
geometry.Project(spatialReference); |
|
if (geometry.IsEmpty) |
|
{ |
|
throw new Exception(item["BSM"] + "图形为空!"); |
|
} |
|
string bgfwbsm = item["BSM"].ToString(); |
|
dicBgfws[bgfwbsm] = geometry; |
|
geometries.AddGeometry(geometry); |
|
} |
|
pTopologicalOperator.ConstructUnion(geometries as IEnumGeometry); |
|
IGeometry pGeometry = pTopologicalOperator as IGeometry; |
|
pGeometry.SpatialReference = spatialReference; |
|
|
|
//获取N图层字段集合 |
|
Dictionary<int, string> dicFields = new Dictionary<int, string>(); |
|
int iWYRWTbbsm = -1, iZBXX = -1; |
|
if (!isSj) |
|
{ |
|
for (int i = 0; i < pNFeatureClass.Fields.FieldCount; i++) |
|
{ |
|
if (!pNFeatureClass.Fields.Field[i].Required) //过滤必要字段 Geometry字段为必要字段但可编辑 |
|
dicFields[i] = pNFeatureClass.Fields.Field[i].Name; |
|
} |
|
iWYRWTbbsm = pNFeatureClass.Fields.FindField("WYRWTBBSM"); |
|
iZBXX = pNFeatureClass.Fields.FindField("ZBXX"); //占比信息字段 |
|
} |
|
|
|
|
|
|
|
//取相交的基础库DLTB并用DTBDLTBGX擦除,并将结果存入N图层 |
|
//pInsertCursor = pNFeatureClass.Insert(true); |
|
//IFeatureBuffer tBuffer = pNFeatureClass.CreateFeatureBuffer(); |
|
|
|
ISpatialReference featureClassSpatialReference = new SpatialReferenceEnvironmentClass().CreateSpatialReference(4490); |
|
|
|
ISpatialFilter spatialFilter = new SpatialFilterClass |
|
{ |
|
Geometry = pGeometry, |
|
SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects |
|
}; |
|
cursor = pJCKFeatureClass.Search(spatialFilter, true); |
|
int indexDLBM = pJCKFeatureClass.FindField("DLBM"); |
|
IFeature feature; |
|
while ((feature = cursor.NextFeature()) != null) |
|
{ |
|
if (feature.ShapeCopy.IsEmpty) |
|
{ |
|
continue; |
|
} |
|
if (!CommonHelper.IsInterSect(pGeometry, feature.ShapeCopy)) |
|
{ |
|
continue; |
|
} |
|
|
|
string dlbm = feature.Value[indexDLBM] + string.Empty; |
|
foreach (var geo in CommonHelper.DifferenceWithSingle(feature.ShapeCopy, pGeometry)) |
|
{ |
|
if (geo.IsEmpty) |
|
{ |
|
continue; |
|
} |
|
double length = (geo as IPolygon).Length; |
|
IArea area = geo as IArea; |
|
double dArea = area.Area; |
|
|
|
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); |
|
(geoPoint as IGeometry2).Project(featureClassSpatialReference); |
|
minAnglejsonGeometry = GeometryConvertHelper.GeometryToJsonString(geoPoint); |
|
} |
|
var line = CommonHelper.GeometryToPolyline(geo); |
|
(line as IGeometry2).Project(featureClassSpatialReference); //转为球面后在插入要素图层是会自动转为要素图层坐标系 |
|
string jsonGeometry = GeometryConvertHelper.GeometryToJsonString(line); |
|
bool hasError = false; |
|
IFeature tBuffer = isSj ? null : pNFeatureClass.CreateFeature(); |
|
foreach (var item in dicBgfws) |
|
{ |
|
string bgfwBsm = item.Key; |
|
if (!CommonHelper.IsInterSect(item.Value, feature.ShapeCopy)) |
|
{ |
|
continue; |
|
} |
|
//TX022 规则合并一起检查 |
|
//if (dArea < 50) |
|
//{ |
|
// hasError = true; |
|
// result.Add(new RuleEntity() |
|
// { |
|
// CheckObject = "单图斑建库N图层", |
|
// ErrorId = tBuffer?.OID + string.Empty, |
|
// BGFWBSM = bgfwBsm, |
|
// ErrorTip = "被动变化图斑存在不够上图面积的图斑", |
|
// ErrorType = "一类错误", |
|
// RuleCode = "TX022", |
|
// RuleName = "碎面多边形检查", |
|
// RuleContent = "DTBDLTBGX层中,若存在面积小于50平方米的图斑,认定为错误图斑", |
|
// Geometry = jsonGeometry, |
|
// GeometryType = 2 |
|
// }); |
|
//} |
|
//TX023 规则合并一起检查 |
|
//if (minAngle < 10 && dArea >= 50) |
|
//{ |
|
// hasError = true; |
|
// result.Add(new RuleEntity() |
|
// { |
|
// CheckObject = "单图斑建库N图层", |
|
// ErrorId = tBuffer?.OID + string.Empty, |
|
// BGFWBSM = bgfwBsm, |
|
// ErrorTip = "被动变化图斑存在尖锐角或局部狭长错误图斑", |
|
// ErrorType = "二类错误", |
|
// RuleCode = "TX023", |
|
// RuleName = "尖锐角及局部狭长检查", |
|
// RuleContent = "图层内若存在一个角度小于10度,或局部狭长的图斑,认定为错误图斑。", |
|
// Geometry = minAnglejsonGeometry, |
|
// GeometryType = 1 |
|
// }); |
|
//} |
|
//TX024 规则合并一起检查 |
|
if (indexDLBM > -1) |
|
{ |
|
List<string> list = new List<string>() { "1001", "1002", "1003", "1004", "1006", "1009", "1101", "1107", "1107A" }; |
|
if (dArea / length < 0.2 && !list.Contains(dlbm == null ? "" : dlbm.ToString()) && dArea >= 50 && minAngle > 10) |
|
{ |
|
hasError = true; |
|
result.Add(new RuleEntity() |
|
{ |
|
CheckObject = "单图斑建库N图层", |
|
ErrorId = tBuffer?.OID + string.Empty, |
|
BGFWBSM = bgfwBsm, |
|
ErrorTip = "被动变化图斑存在图形不规则的错误图斑", |
|
ErrorType = "二类错误", |
|
RuleCode = "TX024", |
|
RuleName = "不规则图形检查", |
|
RuleContent = "除地类编码为1001、1002、1003、1004、1006、1009、1101、1107、1107A的图斑外,图层内若存在面积/周长<0.2的图斑,认定为错误图斑", |
|
Geometry = jsonGeometry, |
|
GeometryType = 2 |
|
}); |
|
} |
|
} |
|
//TX025 规则合并一起检查 |
|
//if (minAngle >= 10 && minAngle < 20) |
|
//{ |
|
// hasError = true; |
|
// result.Add(new RuleEntity() |
|
// { |
|
// CheckObject = "单图斑建库N图层", |
|
// ErrorId = tBuffer?.OID + string.Empty, |
|
// BGFWBSM = bgfwBsm, |
|
// ErrorTip = "被动变化图斑存在尖锐角或局部狭长错误图斑,需核实", |
|
// ErrorType = "二类错误", |
|
// RuleCode = "TX025", |
|
// RuleName = "尖锐角及局部狭长检查", |
|
// RuleContent = "被动变化图斑存在尖锐角或局部狭长错误图斑,需核实", |
|
// Geometry = minAnglejsonGeometry, |
|
// GeometryType = 1 |
|
// }); |
|
//} |
|
//TX026 规则合并一起检查 |
|
//if (indexDLBM > -1) |
|
//{ |
|
// List<string> list = new List<string>() { "1001", "1002", "1003", "1004", "1006", "1009", "1101", "1107", "1107A" }; |
|
// if (dArea / length >= 0.2 && dArea / length < 1.2 && !list.Contains(dlbm == null ? "" : dlbm.ToString())) |
|
// { |
|
// hasError = true; |
|
// result.Add(new RuleEntity() |
|
// { |
|
// CheckObject = "单图斑建库N图层", |
|
// ErrorId = tBuffer?.OID + string.Empty, |
|
// BGFWBSM = bgfwBsm, |
|
// ErrorTip = "存在图形不规则的错误图斑,需核实", |
|
// ErrorType = "二类错误", |
|
// RuleCode = "TX026", |
|
// RuleName = "不规则图形检查", |
|
// RuleContent = "存在图形不规则的错误图斑,需核实", |
|
// Geometry = jsonGeometry, |
|
// GeometryType = 2 |
|
// }); |
|
// } |
|
//} |
|
} |
|
if (!hasError) |
|
continue; |
|
foreach (KeyValuePair<int, string> keyValue in dicFields) |
|
{ |
|
if (keyValue.Value.ToUpper() == "OBJECTID" || keyValue.Key == iZBXX || keyValue.Value.Equals("ZZSXMC", StringComparison.CurrentCultureIgnoreCase)) |
|
continue; |
|
if (keyValue.Key == iWYRWTbbsm) |
|
tBuffer.Value[keyValue.Key] = TBBSM; |
|
else |
|
tBuffer.Value[keyValue.Key] = feature.Value[feature.Fields.FindField(keyValue.Value)]; |
|
} |
|
if (!isSj) |
|
{ |
|
tBuffer.Shape = geo; |
|
if (iZBXX > -1) |
|
{ |
|
var zb = (dArea / (feature.ShapeCopy as IArea).Area).ToString("P"); //图斑占基础库比例 |
|
tBuffer.Value[iZBXX] = zb; |
|
} |
|
tBuffer.Store(); |
|
} |
|
} |
|
} |
|
//pInsertCursor.Flush(); |
|
//System.Runtime.InteropServices.Marshal.ReleaseComObject(tBuffer); |
|
|
|
//IFeature tBuffer1 = pNFeatureClass.CreateFeature(); |
|
//tBuffer1.Shape = pGeometry; |
|
//tBuffer1.Store(); |
|
} |
|
catch (Exception ex) |
|
{ |
|
RuleEntity ruleEntity = new RuleEntity() |
|
{ |
|
CheckObject = "单图斑建库N图层", |
|
ErrorId = this.TBBSM, |
|
ErrorTip = "被动变化图斑存在碎小或狭长图斑规则检查失败:" + ex.Message, |
|
ErrorType = "二类错误", |
|
RuleCode = "TX021", |
|
RuleName = "碎小、狭长图斑检查", |
|
RuleContent = "除地类编码为1001、1002、1003、1004、1006、1009、1107、1107A、1109外的其余图斑,若满足面积/周长<0.2,且有一个角度小于20的条件,认定为错误图斑。" |
|
}; |
|
result.Add(ruleEntity); |
|
} |
|
finally |
|
{ |
|
if (cursor != null) |
|
{ |
|
System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor); |
|
} |
|
if (pInsertCursor != null) |
|
{ |
|
System.Runtime.InteropServices.Marshal.ReleaseComObject(pInsertCursor); |
|
} |
|
} |
|
return result.Where((x, i) => result.FindIndex(z => z.ErrorId == x.ErrorId) == i).ToList(); |
|
} |
|
|
|
public List<RuleEntity> TX022() |
|
{ |
|
List<RuleEntity> result = new List<RuleEntity>(); |
|
IFeatureCursor cursor = null; |
|
IFeatureClass pJCKFeatureClass = null; |
|
bool isZhixin = true; |
|
try |
|
{ |
|
bool isSj = true; |
|
if (DicFeatureClass.ContainsKey("DLTB_NMK") && DicFeatureClass["DLTB_NMK"] != null) |
|
{ |
|
pJCKFeatureClass = DicFeatureClass["DLTB_NMK"]; |
|
} |
|
else if (DicFeatureClass.ContainsKey("JC_DLTB") && DicFeatureClass["JC_DLTB"] != null) |
|
{ |
|
pJCKFeatureClass = DicFeatureClass["JC_DLTB"]; |
|
} |
|
else |
|
{ |
|
throw new Exception("未找到基础库地类图斑层"); |
|
} |
|
//省级规则不使用N图层 |
|
IWorkspace pJCKworkspace = (pJCKFeatureClass as FeatureClass).Workspace; |
|
if (!DicFeatureClass.ContainsKey("NON") && pJCKworkspace.Type != esriWorkspaceType.esriRemoteDatabaseWorkspace) //SDE中图层默认已设置正确坐标系 |
|
isSj = false; |
|
|
|
if (!isSj && (!DicFeatureClass.ContainsKey("N") || DicFeatureClass["N"] == null)) |
|
{ |
|
throw new Exception("未找到质检结果图层N"); |
|
} |
|
IFeatureClass pNFeatureClass = DicFeatureClass.ContainsKey("N") ? DicFeatureClass["N"] : null; |
|
if (!isSj) |
|
{ |
|
if (pNFeatureClass.Fields.FindField("WYRWTBBSM") < -1) |
|
{ |
|
IField wyrwField = new FieldClass(); |
|
IFieldEdit nameFieldEdit = (IFieldEdit)wyrwField; |
|
nameFieldEdit.Name_2 = "WYRWTBBSM"; |
|
nameFieldEdit.AliasName_2 = "外业任务图斑标识码"; |
|
nameFieldEdit.Length_2 = 20; |
|
nameFieldEdit.Type_2 = esriFieldType.esriFieldTypeString; |
|
//fieldsEdit.AddField(wyrwField); |
|
pNFeatureClass.AddField(wyrwField); |
|
} |
|
if (pNFeatureClass.Fields.FindField("ZBXX") < -1) |
|
{ |
|
IField zbxxField = new FieldClass(); |
|
IFieldEdit zbxxFieldEdit = (IFieldEdit)zbxxField; |
|
zbxxFieldEdit.Name_2 = "ZBXX"; |
|
zbxxFieldEdit.AliasName_2 = "占原图斑比例"; |
|
zbxxFieldEdit.Length_2 = 20; |
|
zbxxFieldEdit.Type_2 = esriFieldType.esriFieldTypeString; |
|
//fieldsEdit.AddField(zbxxField); |
|
pNFeatureClass.AddField(zbxxFieldEdit); |
|
} |
|
IWorkspace workspace = (pNFeatureClass as FeatureClass).Workspace; |
|
CommonHelper.SetGeoDatasetSpatialReference(workspace, (pJCKFeatureClass as IGeoDataset).SpatialReference, 0.0001); |
|
|
|
IQueryFilter queryFilter = new QueryFilterClass() |
|
{ |
|
WhereClause = $"WYRWTBBSM='{TBBSM}'" |
|
}; |
|
//若之前存在记录则删除,根据WYRWTBBSM |
|
(pNFeatureClass as ITable).DeleteSearchedRows(queryFilter); |
|
} |
|
|
|
Dictionary<string, IGeometry> dicBgfws = new Dictionary<string, IGeometry>(); //变更范围与图形字典 |
|
DataTable dataTable = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, $"select * from dtbdltbgx where tbbsm='{TBBSM}'AND dlbm<>'9904' and dlbm<>'9902' and dlbm<>'9903' and dlbm<>'9905'"); |
|
if (dataTable == null || dataTable.Rows.Count <= 0) |
|
{ |
|
return result; |
|
} |
|
ISpatialReference spatialReference = (pJCKFeatureClass as IGeoDataset).SpatialReference; |
|
if (spatialReference == null) |
|
{ |
|
throw new Exception("基础库地类图斑层坐标参考为空,质检失败!"); |
|
} |
|
; |
|
IGeometryCollection geometries = new GeometryBagClass(); |
|
ITopologicalOperator pTopologicalOperator = new PolygonClass(); |
|
foreach (DataRow item in dataTable.Rows) |
|
{ |
|
if (item["dlbm"].ToString().StartsWith("88")) |
|
{ |
|
isZhixin = true; |
|
break; |
|
|
|
} |
|
IGeometry geometry = CheckHelper.GeometryConvertHelper.ConverJsonToIGeoemtryWithoutSimple(item["egeometry"].ToString()); |
|
geometry.Project(spatialReference); |
|
if (geometry.IsEmpty) |
|
{ |
|
throw new Exception(item["BSM"] + "图形为空!"); |
|
} |
|
string bgfwbsm = item["BSM"].ToString(); |
|
dicBgfws[bgfwbsm] = geometry; |
|
geometries.AddGeometry(geometry); |
|
} |
|
if (isZhixin) |
|
return result; |
|
pTopologicalOperator.ConstructUnion(geometries as IEnumGeometry); |
|
IGeometry pGeometry = pTopologicalOperator as IGeometry; |
|
pGeometry.SpatialReference = spatialReference; |
|
ISpatialReference featureClassSpatialReference = new SpatialReferenceEnvironmentClass().CreateSpatialReference(4490); |
|
//获取N图层字段集合 |
|
Dictionary<int, string> dicFields = new Dictionary<int, string>(); |
|
int iWYRWTbbsm = -1, iZBXX = -1; |
|
if (!isSj) |
|
{ |
|
for (int i = 0; i < pNFeatureClass.Fields.FieldCount; i++) |
|
{ |
|
if (!pNFeatureClass.Fields.Field[i].Required) //过滤必要字段 Geometry字段为必要字段但可编辑 |
|
dicFields[i] = pNFeatureClass.Fields.Field[i].Name; |
|
} |
|
iWYRWTbbsm = pNFeatureClass.Fields.FindField("WYRWTBBSM"); |
|
iZBXX = pNFeatureClass.Fields.FindField("ZBXX"); //占比信息字段 |
|
} |
|
ISpatialFilter spatialFilter = new SpatialFilterClass |
|
{ |
|
Geometry = pGeometry, |
|
SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects |
|
}; |
|
cursor = pJCKFeatureClass.Search(spatialFilter, true); |
|
IFeature feature; |
|
while ((feature = cursor.NextFeature()) != null) |
|
{ |
|
if (feature.ShapeCopy.IsEmpty) |
|
{ |
|
continue; |
|
} |
|
if (!CommonHelper.IsInterSect(pGeometry, feature.ShapeCopy)) |
|
{ |
|
continue; |
|
} |
|
foreach (var geo in CommonHelper.DifferenceWithSingle(feature.ShapeCopy, pGeometry)) |
|
{ |
|
if (geo.IsEmpty) |
|
{ |
|
continue; |
|
} |
|
double length = (geo as IPolygon).Length; |
|
IArea area = geo as IArea; |
|
double dArea = area.Area; |
|
var line = CommonHelper.GeometryToPolyline(geo); |
|
(line as IGeometry2).Project(featureClassSpatialReference); //转为球面后在插入要素图层是会自动转为要素图层坐标系 |
|
string jsonGeometry = GeometryConvertHelper.GeometryToJsonString(line); |
|
IFeature tBuffer = isSj ? null : pNFeatureClass.CreateFeature(); |
|
bool hasError = false; |
|
foreach (var item in dicBgfws) |
|
{ |
|
if (!CommonHelper.IsInterSect(item.Value, feature.ShapeCopy)) |
|
{ |
|
continue; |
|
} |
|
if (dArea >= 10 && dArea < 50) |
|
{ |
|
hasError = true; |
|
result.Add(new RuleEntity() |
|
{ |
|
CheckObject = "单图斑建库N图层", |
|
ErrorId = tBuffer?.OID + string.Empty, |
|
BGFWBSM = item.Key, |
|
ErrorTip = "被动变化图斑存在不够上图面积的图斑", |
|
ErrorType = "二类错误", |
|
RuleCode = "TX022", |
|
RuleName = "碎面多边形检查", |
|
RuleContent = "DTBDLTBGX层中,若存在面积大于等于10且小于50平方米的图斑,认定为错误图斑", |
|
Geometry = jsonGeometry, |
|
GeometryType = 2 |
|
}); |
|
|
|
} |
|
if (dArea < 10) |
|
{ |
|
hasError = true; |
|
result.Add(new RuleEntity() |
|
{ |
|
CheckObject = "单图斑建库N图层", |
|
ErrorId = tBuffer?.OID + string.Empty, |
|
BGFWBSM = item.Key, |
|
ErrorTip = "被动变化图斑存在不够上图面积的图斑", |
|
ErrorType = "二类错误", |
|
RuleCode = "TX022A", |
|
RuleName = "碎面多边形检查", |
|
RuleContent = "DTBDLTBGX层中,若存在面积小于10平方米的图斑,认定为错误图斑", |
|
Geometry = jsonGeometry, |
|
GeometryType = 2 |
|
}); |
|
|
|
} |
|
} |
|
if (!hasError) |
|
continue; |
|
foreach (KeyValuePair<int, string> keyValue in dicFields) |
|
{ |
|
if (keyValue.Value.ToUpper() == "OBJECTID" || keyValue.Key == iZBXX || keyValue.Value.Equals("ZZSXMC", StringComparison.CurrentCultureIgnoreCase)) |
|
continue; |
|
if (keyValue.Key == iWYRWTbbsm) |
|
tBuffer.Value[keyValue.Key] = TBBSM; |
|
else |
|
tBuffer.Value[keyValue.Key] = feature.Value[feature.Fields.FindField(keyValue.Value)]; |
|
} |
|
if (!isSj) |
|
{ |
|
tBuffer.Shape = geo; |
|
if (iZBXX > -1) |
|
{ |
|
var zb = (dArea / (feature.ShapeCopy as IArea).Area).ToString("P"); //图斑占基础库比例 |
|
tBuffer.Value[iZBXX] = zb; |
|
} |
|
tBuffer.Store(); |
|
} |
|
} |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
|
|
RuleEntity ruleEntity = new RuleEntity() |
|
{ |
|
CheckObject = "单图斑建库N图层", |
|
ErrorId = this.TBBSM, |
|
ErrorTip = "被动变化图斑存在不够上图面积的图斑:" + ex.Message, |
|
ErrorType = "二类错误", |
|
RuleCode = "TX022", |
|
RuleName = "碎面多边形检查 ", |
|
RuleContent = "DTBDLTBGX层中,若存在面积小于50平方米的图斑,认定为错误图斑。" |
|
}; |
|
result.Add(ruleEntity); |
|
} |
|
finally |
|
{ |
|
if (cursor != null) |
|
{ |
|
System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor); |
|
} |
|
} |
|
return result; |
|
} |
|
|
|
public List<RuleEntity> TX028() |
|
{ |
|
List<RuleEntity> result = new List<RuleEntity>(); |
|
try |
|
{ |
|
DataTable dataTable = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, $"select dlbm,egeometry,bsm from dtbdltbgx where tbbsm='{TBBSM}'"); |
|
if (dataTable == null || dataTable.Rows.Count <= 0) |
|
{ |
|
return result; |
|
} |
|
List<string> lstDLBM = new List<string>() { "9903", "9904", "9905" }; |
|
if (dataTable.Rows.Count == 1) |
|
{ |
|
string dlbm = dataTable.Rows[0]?.ToString(); |
|
string bsm = dataTable.Rows[0][2]?.ToString(); |
|
if (lstDLBM.Contains(dlbm)) |
|
{ |
|
DataTable dataTable1 = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, $"select egeometry from wyrw where tbbsm='{TBBSM}'"); |
|
if (dataTable1 == null || dataTable1.Rows.Count <= 0) |
|
{ |
|
throw new Exception("WYRW表中未找到TBBSM为:" + TBBSM + "的图斑"); |
|
} |
|
if (!dataTable.Rows[0][1].Equals(dataTable1.Rows[0][0])) |
|
{ |
|
RuleEntity ruleEntity = new RuleEntity() |
|
{ |
|
CheckObject = "DTBDLTBGX层", |
|
ErrorId = this.TBBSM, |
|
BGFWBSM = bsm, |
|
ErrorTip = "界线外图斑及申请灭失图斑范围必须与任务图斑范围相同", |
|
ErrorType = "一类错误", |
|
RuleCode = "TX028", |
|
RuleName = "界线外图斑及申请灭失图斑范围检查", |
|
RuleContent = "当地类编码为9903、9904或9905时,相应任务图斑范围下仅可存在一个单图斑建库成果,且图形与任务图斑范围相同。" |
|
}; |
|
result.Add(ruleEntity); |
|
} |
|
} |
|
} |
|
else |
|
{ |
|
foreach (DataRow dr in dataTable.Rows) |
|
{ |
|
if (!lstDLBM.Contains(dr[0]?.ToString())) |
|
{ |
|
continue; |
|
} |
|
string bsm = dr[2]?.ToString(); |
|
RuleEntity ruleEntity = new RuleEntity() |
|
{ |
|
CheckObject = "DTBDLTBGX层", |
|
ErrorId = this.TBBSM, |
|
BGFWBSM = bsm, |
|
ErrorTip = "界线外图斑及申请灭失图斑范围必须与任务图斑范围相同", |
|
ErrorType = "一类错误", |
|
RuleCode = "TX028", |
|
RuleName = "界线外图斑及申请灭失图斑范围检查", |
|
RuleContent = "当地类编码为9903、9904或9905时,相应任务图斑范围下仅可存在一个单图斑建库成果,且图形与任务图斑范围相同。" |
|
}; |
|
result.Add(ruleEntity); |
|
break; |
|
} |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
RuleEntity ruleEntity = new RuleEntity() |
|
{ |
|
CheckObject = "DTBDLTBGX层", |
|
ErrorId = this.TBBSM, |
|
ErrorTip = "TX028规则执行失败:" + ex.Message, |
|
ErrorType = "一类错误", |
|
RuleCode = "TX028", |
|
RuleName = "界线外图斑及申请灭失图斑范围检查", |
|
RuleContent = "当地类编码为9903时,相应任务图斑范围下仅可存在一个单图斑建库成果,且图形于任务图斑范围相同。" |
|
}; |
|
result.Add(ruleEntity); |
|
} |
|
return result; |
|
} |
|
public List<RuleEntity> TX029() |
|
{ |
|
List<RuleEntity> result = new List<RuleEntity>(); |
|
IFeatureCursor cursor = null; |
|
IFeatureClass pJCKFeatureClass = null; |
|
IGeometry pDLTBGXgeo = null; |
|
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 |
|
}; |
|
DataTable dataTable = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, $"select egeometry,bsm from dtbdltbgx where tbbsm='{TBBSM}'"); |
|
if (dataTable == null || dataTable.Rows.Count <= 0) |
|
{ |
|
return result; |
|
} |
|
foreach (DataRow item in dataTable.Rows) |
|
{ |
|
string bsm = item["bsm"].ToString(); |
|
pDLTBGXgeo = CheckHelper.GeometryConvertHelper.ConverJsonToIGeoemtry(item["egeometry"].ToString()); |
|
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.IsInterSect(pXZQGeometry, pDLTBGXgeo); //叠加 |
|
if (!resultState) |
|
{ |
|
RuleEntity ruleEntity = new RuleEntity() |
|
{ |
|
CheckObject = "DTBDLTBGX层", |
|
ErrorId = bsm, |
|
BGFWBSM = bsm, |
|
ErrorTip = "单图斑成果存在部分位于县级行政区界线外情况,请核实是否为零米线调整图斑", |
|
ErrorType = "二类错误", |
|
RuleCode = "TX029", |
|
RuleName = "跨越界线图斑检查", |
|
RuleContent = "提取基础库XZQ层,按最外围图形形成新的的图层A。若DTBDLTBGX层图斑未完全位于图层A范围内,提示为错误图斑。" |
|
}; |
|
result.Add(ruleEntity); |
|
} |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
RuleEntity ruleEntity = new RuleEntity() |
|
{ |
|
CheckObject = "DTBDLTBGX层", |
|
ErrorId = this.TBBSM, |
|
ErrorTip = "TX029规则执行失败:" + ex.Message, |
|
ErrorType = "二类错误", |
|
RuleCode = "TX029", |
|
RuleName = "跨越界线图斑检查", |
|
RuleContent = "提取基础库XZQ层,按最外围图形形成新的的图层A。若DTBDLTBGX层图斑未完全位于图层A范围内,提示为错误图斑。" |
|
}; |
|
result.Add(ruleEntity); |
|
} |
|
return result; |
|
} |
|
public List<RuleEntity> TX990() |
|
{ |
|
List<RuleEntity> result = new List<RuleEntity>(); |
|
IFeatureClass pJCKFeatureClass = null; |
|
try |
|
{ |
|
DataTable dataTable = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, $"select dlbm,egeometry,bsm from dtbdltbgx where tbbsm='{TBBSM}'"); |
|
if (dataTable == null || dataTable.Rows.Count <= 0) |
|
{ |
|
return result; |
|
} |
|
List<string> lstDLBM = new List<string>() { "9902", "9903", "9904", "9905" }; |
|
if (dataTable.Rows.Count == 1) |
|
{ |
|
string dlbm = dataTable.Rows[0][0]?.ToString(); |
|
string bsm = dataTable.Rows[0][2]?.ToString(); |
|
DataTable data = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, $"select egeometry from wyrw where tbbsm='{TBBSM}'"); |
|
if (data == null || data.Rows.Count <= 0) |
|
{ |
|
throw new Exception("WYRW表中未找到TBBSM为:" + TBBSM + "的图斑"); |
|
} |
|
if (!lstDLBM.Contains(dlbm)) |
|
{ |
|
return result; |
|
} |
|
if (DicFeatureClass.ContainsKey("JC_DLTB") && DicFeatureClass["JC_DLTB"] != null) |
|
{ |
|
pJCKFeatureClass = DicFeatureClass["JC_DLTB"]; |
|
} |
|
string dataGeometry = dataTable.Rows[0][1]?.ToString(); |
|
IGeometry convertGeometryData = GeometryConvertHelper.ConverJsonToIGeoemtry(dataGeometry, esriGeometryType.esriGeometryPolygon, (pJCKFeatureClass as IGeoDataset).SpatialReference.FactoryCode, false); //通过平面坐标参考数据获取单图斑图形数据 |
|
IArea areaData = convertGeometryData as IArea; |
|
double b = areaData.Area;//获取单图斑面积 |
|
IGeometry convertGeometry = GeometryConvertHelper.ConverJsonToIGeoemtry(data.Rows[0][0]?.ToString(), esriGeometryType.esriGeometryPolygon, (pJCKFeatureClass as IGeoDataset).SpatialReference.FactoryCode, false);//通过平面坐标参考数据获取任务图斑图形数据 |
|
IArea area = convertGeometry as IArea; |
|
double a = area.Area;//获取任务图斑面积 |
|
string JsonEgeomerty = GeometryConvertHelper.GeometryToJsonString(convertGeometry); |
|
if (!dataGeometry.Equals(JsonEgeomerty) && Math.Abs(a - b) > 0.05) |
|
{ |
|
RuleEntity ruleEntity = new RuleEntity() |
|
{ |
|
CheckObject = "DTBDLTBGX层", |
|
ErrorId = this.TBBSM, |
|
BGFWBSM = bsm, |
|
ErrorTip = "地类为9902、9903、9904、9905的,单图斑的范围边界必须与任务图斑范围相一致", |
|
ErrorType = "一类错误", |
|
RuleCode = "TX990", |
|
RuleName = "99类图形检查", |
|
RuleContent = "地类为9902、9903、9904、9905的,单图斑的范围边界必须与任务图斑范围相一致。" |
|
}; |
|
result.Add(ruleEntity); |
|
} |
|
} |
|
else |
|
{ |
|
foreach (DataRow item in dataTable.Rows) |
|
{ |
|
|
|
if (!lstDLBM.Contains(item[0]?.ToString())) |
|
{ |
|
continue; |
|
} |
|
RuleEntity ruleEntity = new RuleEntity() |
|
{ |
|
CheckObject = "DTBDLTBGX层", |
|
ErrorId = this.TBBSM, |
|
BGFWBSM = item[2]?.ToString(), |
|
ErrorTip = "地类为9902、9903、9904、9905的,单图斑的范围边界必须与任务图斑范围相一致", |
|
ErrorType = "一类错误", |
|
RuleCode = "TX990", |
|
RuleName = "99类图形检查", |
|
RuleContent = "地类为9902、9903、9904、9905的,单图斑的范围边界必须与任务图斑范围相一致。" |
|
}; |
|
result.Add(ruleEntity); |
|
break; |
|
|
|
} |
|
} |
|
} |
|
catch (Exception e) |
|
{ |
|
|
|
RuleEntity ruleEntity = new RuleEntity() |
|
{ |
|
CheckObject = "DTBDLTBGX层", |
|
ErrorId = this.TBBSM, |
|
ErrorTip = "TX990规则执行失败:" + e.Message, |
|
ErrorType = "一类错误", |
|
RuleCode = "TX990", |
|
RuleName = "99类图形检查", |
|
RuleContent = "地类为9902、9903、9904、9905的,单图斑的范围边界必须与任务图斑范围相一致。" |
|
}; |
|
result.Add(ruleEntity); |
|
} |
|
return result; |
|
} |
|
|
|
#region |
|
//public List<RuleEntity> TX02X() |
|
//{ |
|
// List<RuleEntity> result = new List<RuleEntity>(); |
|
// IFeatureCursor cursor = null; |
|
// IFeatureCursor pInsertCursor = null; |
|
// try |
|
// { |
|
// //var wsFactory = new ESRI.ArcGIS.DataSourcesGDB.FileGDBWorkspaceFactory(); |
|
// //var workspace = wsFactory.OpenFromFile(@"D:\Code\441523陆河县基础库.gdb", 0); |
|
// //WorkspaceDic["NWorkspace"] = workspace; |
|
// //WorkspaceDic["JCKWorkspace"] = workspace; |
|
|
|
// if (!WorkspaceDic.ContainsKey("JCKWorkspace")) |
|
// { |
|
// return result; |
|
// } |
|
// if (!WorkspaceDic.ContainsKey("NWorkspace")) |
|
// { |
|
// return result; |
|
// } |
|
// IFeatureClass pJCKFeatureClass = (WorkspaceDic.FirstOrDefault(X => X.Key.Equals("JCKWorkspace")).Value as IFeatureWorkspace).OpenFeatureClass("DLTB"); |
|
|
|
// IWorkspace pNWorkspace = WorkspaceDic.FirstOrDefault(X => X.Key.Equals("NWorkspace")).Value; |
|
// IFeatureClass pNFeatureClass = null; |
|
// if ((pNWorkspace as IWorkspace2).NameExists[esriDatasetType.esriDTFeatureClass, "N"]) |
|
// { |
|
// pNFeatureClass = (pNWorkspace as IFeatureWorkspace).OpenFeatureClass("N"); |
|
// } |
|
// else |
|
// { |
|
// //根据基础库地类图斑创建图层 |
|
// IFields tarfields = CommonHelper.GetFieldsBySource(pJCKFeatureClass); |
|
// // 在字段集合中添加一个WYRWTBBSM. |
|
// IFieldsEdit fieldsEdit = (IFieldsEdit)tarfields; |
|
// IField wyrwField = new FieldClass(); |
|
// IFieldEdit nameFieldEdit = (IFieldEdit)wyrwField; |
|
// nameFieldEdit.Name_2 = "WYRWTBBSM"; |
|
// nameFieldEdit.AliasName_2 = "外业任务图斑标识码"; |
|
// nameFieldEdit.Length_2 = 20; |
|
// nameFieldEdit.Type_2 = esriFieldType.esriFieldTypeString; |
|
// fieldsEdit.AddField(wyrwField); |
|
|
|
// IField zbxxField = new FieldClass(); |
|
// IFieldEdit zbxxFieldEdit = (IFieldEdit)zbxxField; |
|
// zbxxFieldEdit.Name_2 = "ZBXX"; |
|
// zbxxFieldEdit.AliasName_2 = "占原图斑比例"; |
|
// zbxxFieldEdit.Length_2 = 20; |
|
// zbxxFieldEdit.Type_2 = esriFieldType.esriFieldTypeString; |
|
// fieldsEdit.AddField(zbxxField); |
|
|
|
// string sConfigKeyword = pNWorkspace.Type != esriWorkspaceType.esriRemoteDatabaseWorkspace ? "" : "PG_GEOMETRY"; |
|
// pNFeatureClass = (pNWorkspace as IFeatureWorkspace).CreateFeatureClass("N", tarfields, null, null, esriFeatureType.esriFTSimple, pJCKFeatureClass.ShapeFieldName, sConfigKeyword); |
|
// } |
|
// bool isSj = true; |
|
// if (pNWorkspace.Type != esriWorkspaceType.esriRemoteDatabaseWorkspace) //SDE中图层默认已设置正确坐标系 |
|
// { |
|
// CommonHelper.SetGeoDatasetSpatialReference(pNWorkspace, (pJCKFeatureClass as IGeoDataset).SpatialReference, 0.0001); |
|
// isSj = false; |
|
// } |
|
|
|
// IQueryFilter queryFilter = new QueryFilterClass() |
|
// { |
|
// WhereClause = $"WYRWTBBSM='{TBBSM}'" |
|
// }; |
|
// //若之前存在记录则删除,根据WYRWTBBSM |
|
// (pNFeatureClass as ITable).DeleteSearchedRows(queryFilter); |
|
|
|
// //将该外业任务图斑下所有变更范围融合 |
|
// DataTable dataTable = CheckHelper.SQLiteDBOperate.Instance.ExceDataTable(this.SourcePath, $"select * from dtbdltbgx where tbbsm='{TBBSM}'"); |
|
// if (dataTable == null || dataTable.Rows.Count <= 0) |
|
// { |
|
// return result; |
|
// } |
|
// GaussCalculateLibrary.CoordinateReferenceMapping coordinateReference = null; |
|
// IGeometry geometry = null; |
|
// IGeometryCollection geometries = new GeometryBagClass(); |
|
// ITopologicalOperator pTopologicalOperator = new PolygonClass(); |
|
// foreach (DataRow item in dataTable.Rows) |
|
// { |
|
// if (coordinateReference == null) |
|
// { |
|
// geometry = CheckHelper.GeometryConvertHelper.ConverJsonToIGeoemtry(item["egeometry"].ToString()); |
|
// IArea area = geometry as IArea; |
|
// coordinateReference = GaussCalculateLibrary.CoordinateHelper.ListCoordinateReference.FirstOrDefault(x => area.Centroid.X > x.MinX && area.Centroid.X < x.MaxX); |
|
// geometry.Project(GeometryConvertHelper.CreateProjectedCoordinateSystem(coordinateReference.WKID)); |
|
// } |
|
// else |
|
// { |
|
// geometry = CheckHelper.GeometryConvertHelper.ConverJsonToIGeoemtry(item["egeometry"].ToString(), esriGeometryType.esriGeometryPolygon, coordinateReference.WKID, false); |
|
// } |
|
// if (geometry.IsEmpty) |
|
// { |
|
// continue; |
|
// } |
|
// geometries.AddGeometry(geometry); |
|
// } |
|
// pTopologicalOperator.ConstructUnion(geometries as IEnumGeometry); |
|
// IGeometry pGeometry = pTopologicalOperator as IGeometry; |
|
|
|
// //获取N图层字段集合 |
|
// IFields flds = new FieldsClass(); |
|
// IFieldsEdit fldsEdit = flds as IFieldsEdit; |
|
// Dictionary<int, string> dicFields = new Dictionary<int, string>(); |
|
// for (int i = 0; i < pNFeatureClass.Fields.FieldCount; i++) |
|
// { |
|
// if (!pNFeatureClass.Fields.Field[i].Required) //过滤必要字段 Geometry字段为必要字段但可编辑 |
|
// dicFields[i] = pNFeatureClass.Fields.Field[i].Name; |
|
// } |
|
// int iWYRWTbbsm = pNFeatureClass.Fields.FindField("WYRWTBBSM"); |
|
// int iZBXX = pNFeatureClass.Fields.FindField("ZBXX"); //占比信息字段 |
|
|
|
// //取相交的基础库DLTB并用DTBDLTBGX擦除,并将结果存入N图层 |
|
// pInsertCursor = pNFeatureClass.Insert(true); |
|
// IFeatureBuffer tBuffer = pNFeatureClass.CreateFeatureBuffer(); |
|
|
|
// ISpatialFilter spatialFilter = new SpatialFilterClass |
|
// { |
|
// Geometry = pGeometry, |
|
// SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects |
|
// }; |
|
// cursor = pJCKFeatureClass.Search(spatialFilter, true); |
|
// IFeature feature; |
|
// while ((feature = cursor.NextFeature()) != null) |
|
// { |
|
// if (feature.ShapeCopy.IsEmpty) |
|
// { |
|
// continue; |
|
// } |
|
// if (!CommonHelper.IsInterSect(pGeometry, feature.ShapeCopy)) |
|
// { |
|
// continue; |
|
// } |
|
// foreach (KeyValuePair<int, string> keyValue in dicFields) |
|
// { |
|
// if (keyValue.Value.ToUpper() == "OBJECTID" || keyValue.Key == iZBXX) |
|
// continue; |
|
// if (keyValue.Key == iWYRWTbbsm) |
|
// tBuffer.Value[keyValue.Key] = TBBSM; |
|
// else |
|
// tBuffer.Value[keyValue.Key] = feature.Value[feature.Fields.FindField(keyValue.Value)]; |
|
// } |
|
// foreach (var geo in CommonHelper.DifferenceWithSingle(feature.ShapeCopy, pGeometry)) |
|
// { |
|
// if (geo.IsEmpty) |
|
// { |
|
// continue; |
|
// } |
|
// tBuffer.Shape = geo; |
|
// if (iZBXX > -1) |
|
// { |
|
// IArea pArea = geo as IArea; |
|
// var zb = (pArea.Area / (feature.ShapeCopy as IArea).Area).ToString("P"); |
|
// tBuffer.Value[iZBXX] = zb; |
|
// } |
|
// pInsertCursor.InsertFeature(tBuffer); |
|
// } |
|
// } |
|
// pInsertCursor.Flush(); |
|
// System.Runtime.InteropServices.Marshal.ReleaseComObject(tBuffer); |
|
|
|
// //检查错误 |
|
// int indexDLBM = pNFeatureClass.FindField("DLBM"); |
|
// queryFilter.WhereClause = $"WYRWTBBSM='{TBBSM}'"; |
|
// cursor = pNFeatureClass.Search(queryFilter, true); |
|
// while ((feature = cursor.NextFeature()) != null) |
|
// { |
|
// if (feature.Shape.IsEmpty) |
|
// { |
|
// continue; |
|
// } |
|
// string dlbm = feature.Value[indexDLBM] + string.Empty; |
|
// double length = (feature.ShapeCopy as IPolygon).Length; |
|
// IArea area = feature.ShapeCopy as IArea; |
|
// string jsonGeometry = string.Empty; |
|
// double minAngle = CommonHelper.GetMinAngle(feature.ShapeCopy, out jsonGeometry); |
|
// //TX022 规则合并一起检查 |
|
// if (area.Area < 50) |
|
// { |
|
// result.Add(new RuleEntity() |
|
// { |
|
// CheckObject = "单图斑建库N图层", |
|
// ErrorId = feature.OID + string.Empty, |
|
// ErrorTip = "被动变化图斑存在不够上图面积的图斑", |
|
// ErrorType = isSj ? "一类错误" : "二类错误", |
|
// RuleCode = "TX022", |
|
// RuleName = "碎面多边形检查", |
|
// RuleContent = "DTBDLTBGX层中,若存在面积小于50平方米的图斑,认定为错误图斑" |
|
// }); |
|
// } |
|
// //TX023 规则合并一起检查 |
|
// if (minAngle < 10 && area.Area >= 50) |
|
// { |
|
// result.Add(new RuleEntity() |
|
// { |
|
// CheckObject = "单图斑建库N图层", |
|
// ErrorId = feature.OID + string.Empty, |
|
// ErrorTip = "被动变化图斑存在尖锐角或局部狭长错误图斑", |
|
// ErrorType = "一类错误", |
|
// RuleCode = "TX023", |
|
// RuleName = "尖锐角及局部狭长检查", |
|
// RuleContent = "图层内若存在一个角度小于10度,或局部狭长的图斑,认定为错误图斑。" |
|
// }); |
|
// } |
|
// //TX024 规则合并一起检查 |
|
// if (indexDLBM > -1) |
|
// { |
|
// List<string> list = new List<string>() { "1001", "1002", "1003", "1004", "1006", "1009", "1101", "1107", "1107A" }; |
|
// if (area.Area / length < 0.2 && !list.Contains(dlbm == null ? "" : dlbm.ToString()) && area.Area >= 50 && minAngle > 10) |
|
// { |
|
// result.Add(new RuleEntity() |
|
// { |
|
// CheckObject = "单图斑建库N图层", |
|
// ErrorId = feature.OID + string.Empty, |
|
// ErrorTip = "被动变化图斑存在图形不规则的错误图斑", |
|
// ErrorType = "一类错误", |
|
// RuleCode = "TX024", |
|
// RuleName = "不规则图形检查", |
|
// RuleContent = "除地类编码为1001、1002、1003、1004、1006、1009、1101、1107、1107A的图斑外,图层内若存在面积/周长<0.2的图斑,认定为错误图斑。" |
|
// }); |
|
// } |
|
// } |
|
// //TX025 规则合并一起检查 |
|
// if (minAngle >= 10 && minAngle < 20) |
|
// { |
|
// result.Add(new RuleEntity() |
|
// { |
|
// CheckObject = "单图斑建库N图层", |
|
// ErrorId = feature.OID + string.Empty, |
|
// ErrorTip = "被动变化图斑存在尖锐角或局部狭长错误图斑,需核实", |
|
// ErrorType = "二类错误", |
|
// RuleCode = "TX025", |
|
// RuleName = "尖锐角及局部狭长检查", |
|
// RuleContent = "被动变化图斑存在尖锐角或局部狭长错误图斑,需核实" |
|
// }); |
|
// } |
|
// //TX026 规则合并一起检查 |
|
// if (indexDLBM > -1) |
|
// { |
|
// List<string> list = new List<string>() { "1001", "1002", "1003", "1004", "1006", "1009", "1101", "1107", "1107A" }; |
|
// if (area.Area / length >= 0.2 && area.Area / length < 1.2 && !list.Contains(dlbm == null ? "" : dlbm.ToString())) |
|
// { |
|
// result.Add(new RuleEntity() |
|
// { |
|
// CheckObject = "单图斑建库N图层", |
|
// ErrorId = feature.OID + string.Empty, |
|
// ErrorTip = "存在图形不规则的错误图斑,需核实", |
|
// ErrorType = "二类错误", |
|
// RuleCode = "TX026", |
|
// RuleName = "不规则图形检查", |
|
// RuleContent = "存在图形不规则的错误图斑,需核实" |
|
// }); |
|
// } |
|
// } |
|
// } |
|
|
|
// //删除N图层中未报错图斑 |
|
// string lisOids = string.Join(",", result.Select(x => x.ErrorId).ToList()); |
|
// queryFilter.WhereClause = string.IsNullOrEmpty(lisOids) ? $"WYRWTBBSM='{TBBSM}'" : $"WYRWTBBSM='{TBBSM}' and objectid not in ({lisOids})"; |
|
// (pNFeatureClass as ITable).DeleteSearchedRows(queryFilter); |
|
// } |
|
// catch (Exception ex) |
|
// { |
|
// RuleEntity ruleEntity = new RuleEntity() |
|
// { |
|
// CheckObject = "单图斑建库N图层", |
|
// ErrorId = this.TBBSM, |
|
// ErrorTip = "被动变化图斑存在碎小或狭长图斑规则检查失败:" + ex.Message, |
|
// ErrorType = "一类错误", |
|
// RuleCode = "TX021", |
|
// RuleName = "碎小、狭长图斑检查", |
|
// RuleContent = "除地类编码为1001、1002、1003、1004、1006、1009、1107、1107A、1109外的其余图斑,若满足面积/周长<0.2,且有一个角度小于20的条件,认定为错误图斑。" |
|
// }; |
|
// result.Add(ruleEntity); |
|
// } |
|
// finally |
|
// { |
|
// if (cursor != null) |
|
// { |
|
// System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor); |
|
// } |
|
// if (pInsertCursor != null) |
|
// { |
|
// System.Runtime.InteropServices.Marshal.ReleaseComObject(pInsertCursor); |
|
// } |
|
// } |
|
// return result; |
|
//} |
|
#endregion |
|
|
|
private List<RuleEntity> CheckRule(string tableName, esriTopologyRuleType topologyRuleType, string topologyRuleName) |
|
{ |
|
IWorkspace workspace = null; |
|
IWorkspaceFactory2 wsFactory = null; |
|
List<RuleEntity> result = new List<RuleEntity>(); |
|
try |
|
{ |
|
if (sourceWorkSpace == null || string.IsNullOrWhiteSpace(sourceWorkSpace.PathName) || !System.IO.File.Exists(sourceWorkSpace.PathName)) |
|
{ |
|
return result; |
|
} |
|
string topoMDBPath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(sourceWorkSpace.PathName), System.IO.Path.GetFileNameWithoutExtension(sourceWorkSpace.PathName) + "_Topo.mdb"); |
|
System.IO.File.Copy(sourceWorkSpace.PathName, topoMDBPath, true); |
|
wsFactory = new ESRI.ArcGIS.DataSourcesGDB.AccessWorkspaceFactoryClass(); |
|
workspace = wsFactory.OpenFromFile(topoMDBPath, 0); |
|
//判断图层是否存在 |
|
bool isExist = (workspace as IWorkspace2).get_NameExists(esriDatasetType.esriDTFeatureClass, tableName); |
|
if (!isExist) |
|
{ |
|
return null; |
|
} |
|
IDatabaseCompact databaseCompact = (IDatabaseCompact)workspace; |
|
databaseCompact.Compact(); |
|
IFeatureClass pFeatureClass = (workspace as IFeatureWorkspace).OpenFeatureClass(tableName); |
|
//判断如果图层没有数据则跳过 |
|
if (pFeatureClass.FeatureCount(null) <= 0) |
|
{ |
|
return null; |
|
} |
|
// 创建拓扑规则 |
|
ITopologyRule topologyRule = new TopologyRuleClass(); |
|
topologyRule.TopologyRuleType = topologyRuleType;//面要素之间无空隙 |
|
topologyRule.Name = topologyRuleName;//"MustNoIntersection"; |
|
topologyRule.OriginClassID = pFeatureClass.FeatureClassID; |
|
topologyRule.AllOriginSubtypes = true; |
|
result = CheckHelper.DataCheckTopologyHelper.CreateTopology(new List<ITopologyRule> { topologyRule }, workspace, new List<string>() { tableName }, this.dataSetName); |
|
} |
|
catch (Exception ex) |
|
{ |
|
throw ex; |
|
} |
|
finally |
|
{ |
|
if (workspace != null) |
|
{ |
|
System.Runtime.InteropServices.Marshal.ReleaseComObject(workspace); |
|
} |
|
if (wsFactory != null) |
|
{ |
|
System.Runtime.InteropServices.Marshal.ReleaseComObject(wsFactory); |
|
} |
|
} |
|
return result; |
|
} |
|
|
|
private List<RuleEntity> CheckRule(string tableName) |
|
{ |
|
IWorkspace workspace = null; |
|
IWorkspaceFactory2 wsFactory = null; |
|
List<RuleEntity> result = new List<RuleEntity>(); |
|
try |
|
{ |
|
if (sourceWorkSpace == null || string.IsNullOrWhiteSpace(sourceWorkSpace.PathName) || !System.IO.File.Exists(sourceWorkSpace.PathName)) |
|
{ |
|
return result; |
|
} |
|
string topoMDBPath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(sourceWorkSpace.PathName), System.IO.Path.GetFileNameWithoutExtension(sourceWorkSpace.PathName) + "_Diss.mdb"); |
|
System.IO.File.Copy(sourceWorkSpace.PathName, topoMDBPath, true); |
|
wsFactory = new ESRI.ArcGIS.DataSourcesGDB.AccessWorkspaceFactoryClass(); |
|
workspace = wsFactory.OpenFromFile(topoMDBPath, 0); |
|
//判断图层是否存在 |
|
bool isExist = (workspace as IWorkspace2).get_NameExists(esriDatasetType.esriDTFeatureClass, tableName); |
|
if (!isExist) |
|
{ |
|
return null; |
|
} |
|
IDatabaseCompact databaseCompact = (IDatabaseCompact)workspace; |
|
databaseCompact.Compact(); |
|
IFeatureClass pFeatureClass = (workspace as IFeatureWorkspace).OpenFeatureClass(tableName); |
|
//判断如果图层没有数据则跳过 |
|
if (pFeatureClass.FeatureCount(null) <= 0) |
|
{ |
|
return null; |
|
} |
|
|
|
CheckHelper.GeoprocessorHelper.PolygonNeighbors(pFeatureClass, $"{topoMDBPath}//result", "BSM;DLBM;TBXHDM;ZZSXDM;GDLX;DDTCBZ;CZCSXM"); |
|
|
|
var tmdbHelper = new CheckHelper.MDBHelper(topoMDBPath); |
|
tmdbHelper.connOpen(); |
|
DataTable dt = tmdbHelper.ExecuteDataTable("SELECT src_BSM from result where LENGTH >0 AND src_DLBM = nbr_DLBM AND src_TBXHDM = nbr_TBXHDM AND src_ZZSXDM = nbr_ZZSXDM AND src_GDLX = nbr_GDLX AND src_DDTCBZ = nbr_DDTCBZ AND src_CZCSXM = nbr_CZCSXM"); |
|
if (dt != null) |
|
{ |
|
foreach (DataRow dr in dt.Rows) |
|
{ |
|
RuleEntity ruleEntity = new RuleEntity(); |
|
ruleEntity.ErrorId = dr[0] + string.Empty; |
|
result.Add(ruleEntity); |
|
} |
|
} |
|
tmdbHelper.DisConn(); |
|
|
|
} |
|
catch (Exception ex) |
|
{ |
|
throw ex; |
|
} |
|
finally |
|
{ |
|
if (workspace != null) |
|
{ |
|
System.Runtime.InteropServices.Marshal.ReleaseComObject(workspace); |
|
} |
|
if (wsFactory != null) |
|
{ |
|
System.Runtime.InteropServices.Marshal.ReleaseComObject(wsFactory); |
|
} |
|
} |
|
return result; |
|
} |
|
} |
|
}
|
|
|