欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

AE拓扑规则创建

程序员文章站 2022-06-12 16:48:11
...
  • 拓扑规则创建方法
IFeatureDataset FeatureDataset; 要创建拓扑规则的要素集
ITopologyContainer2 pTopoCont = FeatureDataset as ITopologyContainer2;
ITopology pTopology = pTopoCont.CreateTopology("拓扑名称", 容差(double, -1, string.Empty);
pTopology.AddClass(pFeaCls1, 10, 5, 5, false);
pTopology.AddClass(pFeaCls2, 10, 5, 5, false);

ITopologyRule pTopoRule = new TopologyRuleClass();
pTopoRule.TopologyRuleType=(规则赋值)
pTopoRule.OriginClassID = pFeaCls1.ObjectClassID;
pTopoRule.AllOriginSubtypes = true;
pTopoRule.DestinationClassID = pFeaCls2.ObjectClassID;
pTopoRule.AllDestinationSubtypes = true;

 添加规则
ITopologyRuleContainer pTopRuleCon = pTopology as ITopologyRuleContainer;
bool bCanAddRule = pTopRuleCon.get_CanAddRule(pTopoRule);
  • 执行拓扑
 IGeoDataset pGeoDS = pTopology as IGeoDataset;
 IEnvelope pEnv = pGeoDS.Extent;  
 IEnvelope pEnvOut = pTopology.ValidateTopology(pEnv);
  • 拓扑图层展示
 ITopologyLayer pTopologyLyr = new TopologyLayerClass();
 pTopologyLyr.Topology = pTopology;
(pTopologyLyr as ILayer).Name = "图层名称";
 pMap.AddLayer(pTopologyLyr as ILayer);
  • 获取拓扑错误信息
//获取要素类容器
IFeatureDataset pFeaDs = pTopology.FeatureDataset;
IFeatureClassContainer pFeaClsContainer = pFeaDs as IFeatureClassContainer;

//获取拓扑规则容器
ITopologyRuleContainer pRuleCont = pTopology as ITopologyRuleContainer;
IEnumRule pEnumRule = pRuleCont.Rules;
if (pEnumRule == null)
{
    return;
}

 //获取错误要素容器
IErrorFeatureContainer pErrFeaContainer = pTopology as IErrorFeatureContainer;
IRule pRule = pEnumRule.Next();
ITopologyRule pTopRule = pRule as ITopologyRule;
 while (pRule != null)
 {
    int OrgCID = pTopRule.OriginClassID;
    int DesCID = pTopRule.DestinationClassID;
    IFeatureClass pOrgFeaCls = pFeaClsContainer.get_ClassByID(OrgCID);
     获取拓扑错误要素集合
    IEnumTopologyErrorFeature pEnumTopoErrFea = pErrFeaContainer.get_ErrorFeatures(pSpr, pTopRule, pEnv, true, true);
     ITopologyErrorFeature pTopologyErrFea = pEnumTopoErrFea.Next();
     while (pTopologyErrFea != null)
     {
      获取拓扑错误图形的objectid
      int ErrID = pTopologyErrFea.ErrorID;
      int OrgOID = pTopologyErrFea.OriginOID;
      int DesOID = pTopologyErrFea.DestinationOID;
     }
 }
  • 拓扑相关规则
    esriTopologyRuleType pTopoRuleType=null;
    1.必须在其它图层线的端点:esriTopologyRuleType.esriTRTPointCoveredByLineEndpoint;
    2.点必须在其他线上:esriTopologyRuleType.esriTRTPointCoveredByLine;
    3.点必须在其它面的内部:esriTopologyRuleType.esriTRTPointProperlyInsideArea;
    4.图层内部线不可以重叠: esriTopologyRuleType.esriTRTLineNoOverlap;
    5.图层内部线和线之间必须不相交:esriTopologyRuleType.esriTRTLineNoIntersection;
    6.必须在其它图层面的边缘上: esriTopologyRuleType.esriTRTLineCoveredByAreaBoundary;
    7.不能自身重叠: esriTopologyRuleType.esriTRTLineNoSelfOverlap;
    8.不能自身相交: esriTopologyRuleType.esriTRTLineNoSelfIntersect;
    9.必须是单线: esriTopologyRuleType.esriTRTLineNoMultipart;
    10.线的端点必须在其它线上:esriTopologyRuleType.esriTRTLineNoIntersectOrInteriorTouch;
    11.线的节点必须被其他点覆盖: esriTopologyRuleType.esriTRTLineEndpointCoveredByPoint;
    12.图层内部面和面之间必须不重叠:esriTopologyRuleType.esriTRTAreaNoOverlap;
    13.图层内部面和面之间必须没有缝隙:esriTopologyRuleType.esriTRTAreaNoGaps;
    14.必须不和其它图层的面重叠:esriTopologyRuleType.esriTRTAreaNoOverlapArea;
    15.必须被其它图层的面覆盖:esriTopologyRuleType.esriTRTAreaCoveredByAreaClass;
    16.必须在其它图层面的内部:esriTopologyRuleType.esriTRTAreaCoveredByArea;
    17.边缘必须被其它图层的线覆盖:esriTopologyRuleType.esriTRTAreaBoundaryCoveredByLine;
    18.线必须不被其他图层覆盖:esriTopologyRuleType.esriTRTLineNoOverlapLine;
    19.点必须被其他面的边界覆盖: esriTopologyRuleType.esriTRTPointCoveredByAreaBoundary;
    20.面的边界必须被其它图层面边界覆盖: esriTopologyRuleType.esriTRTAreaBoundaryCoveredByAreaBoundary;
    21.面与面重叠: esriTopologyRuleType.esriTRTAreaAreaCoverEachOther;
    22.线必须无摇摆:esriTopologyRuleType.esriTRTLineNoDangles;
    23.线不存在伪节点: esriTopologyRuleType.esriTRTLineNoPseudos;
    24.线必须被其他图层覆盖:esriTopologyRuleType.esriTRTLineCoveredByLineClass;
    25.面必须包含点: esriTopologyRuleType.esriTRTAreaContainPoint;