Provides access to members that return and set topology rules.
Members
Name | Description | |
---|---|---|
AddRule | Adds a topology rule. | |
CanAddRule | Indicates if the topology rule can be added to the topology. | |
DeleteRule | Deletes a topology rule. | |
DemoteFromRuleException | Demotes a topology error from an exception to an error. | |
PromoteToRuleException | Promotes a topology error to an exception. | |
Rule | The topology rule with the corresponding ID. | |
RuleByGUID | The rule with the globally unique ID. | |
Rules | An enumeration of all the topology rules. | |
RulesByClass | An enumeration of all the rules for a given class. | |
RulesByClassAndSubtype | An enumeration of all the rules for a given class and subtype. |
ITopologyRuleContainer.AddRule Method
Adds a topology rule.
Public Sub AddRule ( _
ByVal Rule As ITopologyRule _
)
public void AddRule (
ITopologyRule Rule
);
Errors Returned
FDO_E_INVALID_TOPOLOGY_RULE_TYPE
The ITopologyRule::TopologyRuleType property has been specified as a non-existent rule type. See esriTopologyRuleType for a listing of the supported Topology rules.
FDO_E_INVALID_GEOMETRY_TYPE_FOR_TOPOLOGY_RULE
The geometry type of the origin and/or destination feature class is invalid for the topology rule.
FDO_E_INVALID_TOPOLOGY_RULE
The topology rule is invalid. This error can be raised if an invalid OriginSubtype or DestinationSubtype has been specified.
FDO_E_INVALID_TOPOLOGY_RULE_CLASS_ASSIGNMENT
The origin and destination feature classes for the topology rule have been specified as the same class. This error can also be raised when the origin and destination feature classes are the same, but one has been established at the feature class level and the other at the subtype level.
FDO_E_INCONSISTENT_TOPOLOGY_RULE
The topology rule is inconsistent and cannot be added to the Topology, and it conflicts with an existing rule. Examples include: adding a rule specified at the feature class level to a Topology that already contains a rule of the same type for the same feature class but specified at the subtype level.
For example, for feature class FC1 with subtypes SubT1 and SubT2 and a Topology with the rule, FC1 Must Not Overlap, the following rules, specified at the subtype level, are invalid and would result in a value of false from CanAddRule:
FC1: SubT1 Must Not Overlap
FC1: SubT2 Must Not Overlap
Remarks
Adds the specified rule to the topology. Before adding the topology rule, use ITopologyRuleContainer::CanAddRule to determine if the rule is inconsistent with any existing topology rules. Topology rules of the same type cannot be specified at the class level and subtype level for the same feature class.
Using the AddRule method on a topology that has already been validated, in whole or in part, will result in a dirty area created for the extent of the feature classes participating in the rule and a change to the state of the topology to esriTSUnanalyzed.
ITopologyRuleContainer.CanAddRule Property
Indicates if the topology rule can be added to the topology.
Public Function get_CanAddRule ( _
ByVal Rule As ITopologyRule _
) As Boolean
public bool get_CanAddRule (
ITopologyRule Rule
);
Remarks
The CanAddRule property returns a boolean value indicating if the topology rule is valid and consistent with the existing rules. This property will return false if:
- An identical rule is already present in the topology. A rule is determined to be identical with an existing rule if:
- For a given rule type, the origin class and subtype and if applicable, destination class and subtype are equal to an existing rule.
- For single feature class rules, such as esriTRTAreaNoGaps in the origin feature class is defined at the class and subtype level.
- The destination feature class is specified at both the class and subtype level if the origin is specified at the class level.
- the origin subtype is defined twice, except for rules esriTRTAreaNoOverlapArea and esriTRTLineNoOverlapLine.
- A topology rule of the same rule type with the same origin and destination feature class is already present in the Topology, but the rule being added is defined at the subtype level.
- The rule is defined on both the subtype and class levels for a given class-rule combination.
- The Object Class ID and Subtype value are invalid. For example, if the topology rule has been specified to use subtypes however no subtypes are defined for the relevant feature class, CanAddRule would return false.
For example, for feature class FC1 with subtypes; SubT1 and SubT2, and a Topology with the rule; FC1 AreaNoOverlap, the following rules, specified at the subtype level, are invalid and CanAddRule would return False:
FC1: SubT1 AreNoOverlap
FC1: SubT2 AreNoOverlap
After calling CanAddRule, it is not guaranteed that the topology rule will be added to the Topology. ITopologyRuleContainer::AddRule may still fail if the geometry types of the Origin and Destination feature classes are incorrect. In this case, an FDO_E_INVALID_GEOMETRY_TYPE_FOR_TOPOLOGY_RULE error would be raised.
ITopologyRuleContainer.DeleteRule Method
Deletes a topology rule.
Public Sub DeleteRule ( _
ByVal Rule As ITopologyRule _
)
public void DeleteRule (
ITopologyRule Rule
);
Remarks
Removes the specified rule from the topology. DeleteRule will remove any associated topology errors and will not result in the creation of a dirty area, nor will the state of the topology change.
ITopologyRuleContainer.DemoteFromRuleException Method
Demotes a topology error from an exception to an error.
Public Sub DemoteFromRuleException ( _
ByVal errorException As ITopologyErrorFeature _
)
public void DemoteFromRuleException (
ITopologyErrorFeature errorException
);
Remarks
The DemoteFromRuleException method will demote an exception feature from an exception to an error. On a topology in an ArcSDEgeodatabase, DemoteFromRuleException must be called from within an edit session and edit operation. Topology Exceptions arise when a topology rule is purposefully violated. Marking purposeful topology errors as exceptions allows other clients of the topology to handle them in an appropriate or specific manner, e.g., in reporting or symbolization.
Note that it is also possible to promote an error or mark the error as an exception with the ITopologyRuleContainer::PromoteToRuleException method.
ITopologyRuleContainer.PromoteToRuleException Method
Promotes a topology error to an exception.
Public Sub PromoteToRuleException ( _
ByVal errorException As ITopologyErrorFeature _
)
public void PromoteToRuleException (
ITopologyErrorFeature errorException
);
Remarks
The PromoteToRuleException method will promote the specified error to an exception feature. On a topology in an ArcSDEgeodatabase, PromoteToRuleException must be called from within an edit session and edit operation. Topologyexceptions arise when a topology rule is purposefully violated. Marking purposeful topology errors as exceptions allows other clients of the topology to handle them in an appropriate or specific manner, e.g., in reporting or symbolization.
Note: It is possible to demote an exception or mark the exception as an error with the ITopologyRuleContainer::DemoteFromRuleException method.
ITopologyRuleContainer.Rule Property
The topology rule with the corresponding ID.
Public Function get_Rule ( _
ByVal RuleID As Integer _
) As IRule
public IRule get_Rule (
int RuleID
);
Remarks
The Rule property returns the rule corresponding to the supplied ID. The RuleID is the internal ID of the topology rule as stored in the geodatabase system tables and is unique within the geodatabase.
To get the ID of the topology rule, QI to the IRule interface and use the IRule::ID property.
ITopologyRuleContainer.RuleByGUID Property
The rule with the globally unique ID.
Public Function get_RuleByGUID ( _
ByVal GUID As String _
) As IRule
public IRule get_RuleByGUID (
string GUID
);
Errors Returned
If a nonexistent or incorrect GUID is supplied, RuleByGUID will return an error.
Remarks
Returns the rule identified by the specified GUID. The GUID is generated after the topology is added to the topology using ITopologyRuleContainer::AddRule. The GUID can be returned from the ITopologyRule::GUID property
ITopologyRuleContainer.Rules Property
An enumeration of all the topology rules.
Public ReadOnly Property Rules As IEnumRule
public IEnumRule Rules {get;}
Remarks
Returns an enumerator of the topology rules associated with the topology. The enumerator will contain all rules defined for the topology but not the one rule inherent to each topology, the esriTRTFeatureLargerThanClusterTolerance rule.
ITopologyRuleContainer.RulesByClass Property
An enumeration of all the rules for a given class.
Public Function get_RulesByClass ( _
ByVal ClassID As Integer _
) As IEnumRule
public IEnumRule get_RulesByClass (
int ClassID
);
Remarks
The RulesByClass property returns an enumerator of the rules associated with a particular class in the topology using the feature class� IObjectClass::ObjectClassID. An empty enumerator is returned if an IObjectClass::ObjectClassID corresponding to a feature class is not found in the topology.
ITopologyRuleContainer.RulesByClassAndSubtype Property
An enumeration of all the rules for a given class and subtype.
Public Function get_RulesByClassAndSubtype ( _
ByVal ClassID As Integer, _
ByVal SubType As Integer _
) As IEnumRule
public IEnumRule get_RulesByClassAndSubtype (
int ClassID,
int SubType
);
Remarks
The RulesByClassAndSubtype property returns an enumerator of the rules associated with a particular class/subtype pair in the topology. If the ObjectClassID corresponds to a feature class or the Subtype value does not exist, an empty enumerator is returned.
Classes that implement ITopologyRuleContainer
Classes | Description |
---|
Remarks
The ITopologyRuleContainer interface provides access to members for adding, removing, and returning topology rules from a topology. This interface also provides access to members that control the promotion and demotion of topology errors and exceptions.
void AddRuleOnTopologyRuleContainer(ITopology topology)
{
// Get the topology rule container
ITopologyRuleContainer topologyRuleContainer = (ITopologyRuleContainer)topology;
// Create a rule having area with no gaps
ITopologyRule newTopologyRule = new TopologyRuleClass()
{
AllOriginSubtypes = true,
TopologyRuleType = esriTopologyRuleType.esriTRTAreaNoGaps,
Name = "Area with no gaps"
};
// Add a rule to the container
bool canAddRule = topologyRuleContainer.get_CanAddRule(newTopologyRule);
if (canAddRule)
{
topologyRuleContainer.AddRule(newTopologyRule);
}
}