ArcEngine拓扑检查总结

更新时间:2023-05-16 16:53:48 阅读: 评论:0

ArcEngine 拓扑检查总结
本⽂⼤部分内容参考AO帮助⽂档和ArcMap帮助⽂档,⼤家实际使⽤中遇到的问题也可以在本帖下⽅留⾔交流,谢谢!欢迎浏览,拒绝转载!
拓扑基础知识
1.
拓扑检查常⽤的⽅法
调⽤GP ⼯具(CheckGeometry)检查数据的⼏何CheckGeometry的相关说明
CheckGeometry质检项 CheckGeometry调⽤⽰例代码
建议使⽤范围 有效的输⼊格式包括 shapefile 以及存储在个⼈地理数据库或⽂件地理数据库中的要素类。⽽ SDE 地理数据库则会在上传⼏何时⾃动检查每个⼏何的有效性;因此,检查⼏何和修复⼏何⼯具⽆需⽤于 SDE。
缺点:使⽤该GP⼯具会⽣成检查结果图层,检查的⼏何错误种类相对固定,对于复杂的拓扑错误不⽀持。
优点:代码相对简单,适合对拓扑检查规则不是很复杂的⼊库级别的检查。
调⽤ITopologicalOperator5接⼝进⾏拓扑检查
ESRI .ArcGIS.Geoprocessor.Geoprocessor  geoProcessor = new ESRI .ArcGIS.Geoprocessor.Geoprocessor ();
ESRI .ArcGIS.DataManagementTools.CheckGeometry  checkGeometryTool = new ESRI .ArcGIS.DataManagementTools.CheckGeometry ();checkGeometryTool .in _features = otherPara[0];
checkGeometryTool .out _table = otherPara[1];
IGeoProcessorResult gpResult = geoProcessor .Execute (checkGeometryTool, null) as IGeoProcessorResult ;
ITopologicalOperator5接⼝相关说明
Provides access to members for constructing new geometries bad upon topological relationships between existing
geometries.
ITopologicalOperator5常⽤⽅法 ITopologicalOperator5⽰例代码参考资料
建议使⽤范围
这个接⼝类似ArcMap中编辑⼯具条中的验证功能,只能针对要素进⾏逐个检查,个⼈觉得如果图层中要素不多的话 可以使⽤此接⼝进⾏拓扑检查,如果图层中要素⽐较多,数据量⽐较⼤,建议使⽤GP⼯具或者创建拓扑进⾏检查,个⼈建议仅供参考,如果异议请留⾔!通过接⼝创建拓扑进⾏拓扑检查
IPointCollection polygonVertices = new  PolygonClass();
IPointCollection lineVertices = pGeometry as  IPointCollection;
polygonVertices.AddPointCollection(lineVertices);
ITopologicalOperator3 pTopology = polygonVertices as  ITopologicalOperator3;
esriNonSimpleReasonEnum reason = esriNonSimpleReasonEnum.esriNonSimpleSelfInterctions;    //⾃相交
中国传统节日有哪些
pTopology.IsKnownSimple_2 = fal ;
小学成语接龙if  (!_IsSimpleEx(out  reason))
{
if  (reason == esriNonSimpleReasonEnum.esriNonSimpleSelfInterctions)
{
//记录拓扑错误
}
拓扑基础知识
⼀个拓扑可以添加多个拓扑图层,⼀个要素数据集可以拥有多个拓扑,但是⼀个要素类(图层)只能在⼀个拓扑中并且只有简单的要素类才能添加到拓扑中进⾏拓扑检查。
常⽤接⼝
ITopologyContainer2接⼝:
创建拓扑
⽤到的⽅法:
1.ITopologyContainer.CreateTopology
2.ITopologyContainer2.CreateTopologyEx
这两个⽅法的返回类型都是ITopology 对象
⽰例代码1:⽰例代码2:
// featureDatat is an IFeatureDatat where the topology will be located.
// specifyZClusterTolerance is a System.Boolean whether a ZClusterTolerance has been specified.
// topologyName is a string with the topology's name.
// Cast the feature datat to the ITopologyContainer2 interface to create a topology.
//下⾯代码⼤概意思是如果需要z 容差⽤CreateTopologyEx ⽅法,不需要z 容差⽤CreateTopology ⽅法
ITopologyContainer2 topologyContainer = (ITopologyContainer2)featureDatat;
ITopology topology = null ;
if  (specifyZClusterTolerance)
{
topology = topologyContainer.CreateTopologyEx(topologyName,
topologyContainer.DefaultClusterTolerance,
topologyContainer.DefaultZClusterTolerance,  - 1, "");
}
el
{
英文名大全女topology = topologyContainer.CreateTopology(topologyName,
topologyContainer.DefaultClusterTolerance,  - 1, "");
}
IFeatureDatat featureDatat = featureClass.FeatureDatat;
ITopologyContainer2 topologyContainer = (ITopologyContainer2)featureDatat;
if (topologyContainer == null)
{
return true;
}
//判断当前命名的拓扑是否存在,如果存在,删除
bool bTopExists = (featureDatat.Workspace as IWorkspace2).get_NameExists(esriDatatType.esriDTTopology, sTopologyName);
if (bTopExists)
{
ITopology topologyTemp = _TopologyByName(sTopologyName);
//删除拓扑
IDatat pDatatTemp = (IDatat)topologyTemp;
pDatatTemp.Delete();
Marshal.ReleaComObject(pDatatTemp);
}
//创建⼀个新的拓扑
if (dTolerance == -1)
{
dTolerance = topologyContainer.DefaultClusterTolerance;
}
//ITopology topology = topologyContainer.CreateTopology(sTopologyName, topologyContainer.DefaultClusterTolerance, -1, "");
ITopology topology = topologyContainer.CreateTopology(TopologyName, dTolerance, -1, "");
添加图层和拓扑规则
⽤到的⽅法:
1.ITopology.AddClass
2.ITopologyRuleContainer.AddRule
⽰例代码1:
//添加拓扑图层
topology.AddClass(featureClass, weight, xyRank, zRank, fal);
//添加拓扑规则
public void AddRuleToTopology(ITopology topology, esriTopologyRuleType ruleType,
String ruleName, IFeatureClass featureClass)
{
凉皮调料水的做法
// 创建拓扑规则
ITopologyRule topologyRule = new TopologyRuleClass();
topologyRule.TopologyRuleType = ruleType;
topologyRule.Name = ruleName;
topologyRule.OriginClassID = featureClass.FeatureClassID;
topologyRule.AllOriginSubtypes = true;
//把topology对象强制转换到ITopologyRuleContainer对象,然后添加拓扑规则
ITopologyRuleContainer topologyRuleContainer = (ITopologyRuleContainer)topology;
if (_CanAddRule(topologyRule))
{
topologyRuleContainer.AddRule(topologyRule);
}
el
{
throw new ArgumentException("Could not add specified rule to the topology.");
}
}
⽰例代码2:The following code example demonstrates how to create a topology rule between two feature class, specify it at the subtype level for the destination, and add it to the topology:
public void AddRuleToTopology(ITopology topology, esriTopologyRuleType ruleType,
String ruleName, IFeatureClass originClass, int originSubtype, IFeatureClass
destinationClass, int destinationSubtype)
{
// Create a topology rule.
ITopologyRule topologyRule = new TopologyRuleClass();
topologyRule.TopologyRuleType = ruleType;
topologyRule.Name = ruleName;
topologyRule.OriginClassID = originClass.FeatureClassID;
topologyRule.AllOriginSubtypes = fal;
空调怎么选topologyRule.OriginSubtype = originSubtype;
topologyRule.DestinationClassID = destinationClass.FeatureClassID;
topologyRule.AllDestinationSubtypes = fal;
topologyRule.DestinationSubtype = destinationSubtype;
// Cast the topology to the ITopologyRuleContainer interface and add the rule.
小白菜怎么炒好吃ITopologyRuleContainer topologyRuleContainer = (ITopologyRuleContainer)topology;
if (_CanAddRule(topologyRule))
{
topologyRuleContainer.AddRule(topologyRule);
}
el
{
throw new ArgumentException("Could not add specified rule to the topology.");
}
}
验证拓扑
⽤到的⽅法:
1.ITopology.ValidateTopology
⽰例代码1:
public void ValidateTopology(ITopology topology, IEnvelope envelope)
{
// Get the dirty area within the provided envelope.
IPolygon locationPolygon = new PolygonClass();
ISegmentCollection gmentCollection = (ISegmentCollection)locationPolygon;
gmentCollection.SetRectangle(envelope);
IPolygon polygon = _DirtyArea(locationPolygon);
// If a dirty area exists, validate the topology.
if (!polygon.IsEmpty)
{
良药苦口利于病忠言逆耳利于行的意思// Define the area to validate and validate the topology.
IEnvelope areaToValidate = polygon.Envelope;
IEnvelope areaValidated = topology.ValidateTopology(areaToValidate);
}
辞职原因怎么写最合适
}
⽰例代码2:完整的创建拓扑函数

本文发布于:2023-05-16 16:53:48,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/82/656460.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:拓扑   检查   要素   图层   添加   规则   代码   欢迎
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图