本文主要是介绍关于AllOriginSubtypes和AllDestinationSubtypes拓扑检查官方文档有误导,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
目录
1.问题描述:
2.有问题的代码:
3.修改能正确执行的代码 :
1.问题描述:
当两个要素类参与拓扑时,官方有一段代码,将拓扑规则加到拓扑中
ITopologyRule.AllOriginSubtypes Property
Indicates if all origin subtypes are specified for the topology rule.
ITopologyRule.AllDestinationSubtypes Property
Indicates if all destination subtypes are specified for the topology rule.
默认为false,但是这样是得不到拓扑结果的。
2.有问题的代码:
public void AddRuleToTopology(ITopology topology, esriTopologyRuleType ruleType,String ruleName, IFeatureClass originClass, int originSubtype, IFeatureClassdestinationClass, int destinationSubtype)
{// Create a topology rule.ITopologyRule topologyRule = new TopologyRuleClass();topologyRule.TopologyRuleType = ruleType;topologyRule.Name = ruleName;topologyRule.OriginClassID = originClass.FeatureClassID;topologyRule.AllOriginSubtypes = false;topologyRule.OriginSubtype = originSubtype;topologyRule.DestinationClassID = destinationClass.FeatureClassID;topologyRule.AllDestinationSubtypes = false;topologyRule.DestinationSubtype = destinationSubtype;// Cast the topology to the ITopologyRuleContainer interface and add the rule.ITopologyRuleContainer topologyRuleContainer = (ITopologyRuleContainer)topology;if (topologyRuleContainer.get_CanAddRule(topologyRule)){topologyRuleContainer.AddRule(topologyRule);}else{throw new ArgumentException("Could not add specified rule to the topology.");}
3.修改能正确执行的代码 :
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 = true;// topologyRule.OriginSubtype = originSubtype;topologyRule.DestinationClassID = destinationClass.FeatureClassID;topologyRule.AllDestinationSubtypes = true;//topologyRule.DestinationSubtype = destinationSubtype;// Cast the topology to the ITopologyRuleContainer interface and add the rule.ITopologyRuleContainer topologyRuleContainer = (ITopologyRuleContainer)topology;if (topologyRuleContainer.get_CanAddRule(topologyRule)){topologyRuleContainer.AddRule(topologyRule);}else{throw new ArgumentException("无法将指定的规则添加到拓扑中 .");}}
这篇关于关于AllOriginSubtypes和AllDestinationSubtypes拓扑检查官方文档有误导的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!