/// <summary> /// 建立拓扑 /// </summary> /// <param name="featureDataset">目标数据集</param> /// <param name="topologyName">拓扑名称</param> 
public void CreateTopology(IFeatureDataset featureDataset, string topologyName) 
{ // 建立一个空拓扑(拓扑名称、获得数据集的XY容差作为拓扑容差) 
ITopologyContainer topologyContainer = (ITopologyContainer)featureDataset; 
ITopology topology = topologyContainer.CreateTopology(topologyName,
topologyContainer.DefaultClusterTolerance, -1, ""); 
// 获得“Roads”线状要素类加入到拓扑当中,拓扑等级为1 
IFeatureClassContainer featureclassContainer = (IFeatureClassContainer)featureDataset;
 IFeatureClass featureClass = featureclassContainer.get_ClassByName("Roads");
 topology.AddClass(featureClass, 5, 1, 1, false); // 建立一个拓扑规则(线丌重合) 
ItopologyRuleContainer topologyRuleContainer = (ITopologyRuleContainer)topology; 
ITopologyRule topologyRule = new TopologyRuleClass();
 topologyRule.TopologyRuleType = esriTopologyRuleType.esriTRTLineNoOverlap;
 topologyRule.OriginClassID = featureClass.ObjectClassID; 
topologyRule.AllOriginSubtypes = true; topologyRule.Name = "Roads No Overlap"; // 把建立好的拓扑规则添加到拓扑中 
if (topologyRuleContainer.get_CanAddRule(topologyRule)) 
{ topologyRuleContainer.AddRule(topologyRule); } 
// 验证拓扑 IGeoDataset geoDataset = (IGeoDataset)topology; 
//根据拓扑对象获得范围 IPolygon searchArea = new PolygonClass(); 
ISegmentCollection segmentCollection = (ISegmentCollection)searchArea; 
segmentCollection.SetRectangle(geoDataset.Extent); // 获得整个拓扑中的“脏区” 
IPolygon dirtyArea = topology.get_DirtyArea(searchArea); // 验证“脏区” 
IEnvelope dirtyAreaEnvelope = dirtyArea.Envelope; topology.ValidateTopology(dirtyAreaEnvelope);

相关文章:

  • 2021-11-17
  • 2021-11-17
  • 2021-05-24
  • 2022-12-23
  • 2021-12-19
  • 2021-04-03
  • 2022-12-23
猜你喜欢
  • 2021-04-11
  • 2022-02-16
  • 2022-12-23
  • 2021-11-17
  • 2021-06-14
  • 2022-12-23
  • 2021-12-02
相关资源
相似解决方案