ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Core.Data.Topology Namespace / TopologyError Class
Members Example

In This Topic
    TopologyError Class
    In This Topic
    Represents an error associated with a Topology.
    Object Model
    TopologyError ClassGeometry Class
    Syntax
    Public NotInheritable Class TopologyError 
    public sealed class TopologyError 
    Example
    Process topology errors
    {
      static void ProcessTopologyErrors()
      {
        using (Geodatabase geodatabase = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri(@"C:\TestData\GrandTeton.gdb"))))
        using (ArcGIS.Core.Data.Topology.Topology topology = geodatabase.OpenDataset<ArcGIS.Core.Data.Topology.Topology>("Backcountry_Topology"))
        {
          // Get all the errors and exceptions currently associated with the topology.
          IReadOnlyList<TopologyError> allErrorsAndExceptions = topology.GetErrors(new ErrorDescription(topology.GetExtent()));
    
          Console.WriteLine($"errors and exceptions count => {allErrorsAndExceptions.Count}");
          Console.WriteLine("OriginClassName \t OriginObjectID \t DestinationClassName \t DestinationObjectID \t RuleType \t IsException \t Shape type \t Shape width & height \t  Rule ID \t");
    
          foreach (TopologyError error in allErrorsAndExceptions)
          {
            Console.WriteLine(
              $"'{error.OriginClassName}' \t {error.OriginObjectID} \t '{error.DestinationClassName}' \t " +
              $"{error.DestinationObjectID} \t {error.RuleType} \t {error.IsException} \t {error.Shape.GeometryType} \t " +
              $"{error.Shape.Extent.Width},{error.Shape.Extent.Height} \t {error.RuleID}");
          }
        }
      }
    }
    Mark and unmark errors or exceptions
    {
      static void MarkAndUnmarkAsErrors(ArcGIS.Core.Data.Topology.Topology topology)
      {
        // Get all the errors due to features violating the "PointProperlyInsideArea" topology rule.
        using (TopologyDefinition topologyDefinition = topology.GetDefinition())
        {
          TopologyRule pointProperlyInsideAreaRule = topologyDefinition.GetRules().First(rule => rule.RuleType == TopologyRuleType.PointProperlyInsideArea);
    
          ErrorDescription errorDescription = new ErrorDescription(topology.GetExtent())
          {
            TopologyRule = pointProperlyInsideAreaRule
          };
    
          IReadOnlyList<TopologyError> errorsDueToViolatingPointProperlyInsideAreaRule = topology.GetErrors(errorDescription);
          Console.WriteLine($"There are {errorsDueToViolatingPointProperlyInsideAreaRule.Count} feature violating the 'PointProperlyInsideArea' topology rule.");
    
          // Mark all errors from features violating the 'PointProperlyInsideArea' topology rule as exceptions.
          foreach (TopologyError error in errorsDueToViolatingPointProperlyInsideAreaRule)
          {
            topology.MarkAsException(error);
          }
    
          // Now verify all the errors from features violating the 'PointProperlyInsideArea' topology rule have indeed been
          // marked as exceptions.
          //
          // By default, ErrorDescription is initialized to ErrorType.ErrorAndException.  Here we want ErrorType.ErrorOnly.
          errorDescription = new ErrorDescription(topology.GetExtent())
          {
            ErrorType = ErrorType.ErrorOnly,
            TopologyRule = pointProperlyInsideAreaRule
          };
    
          IReadOnlyList<TopologyError> errorsAfterMarkedAsExceptions = topology.GetErrors(errorDescription);
          Console.WriteLine($"There are {errorsAfterMarkedAsExceptions.Count} feature violating the 'PointProperlyInsideArea' topology rule after all the errors have been marked as exceptions.");
    
          // Finally, reset all the exceptions as errors by unmarking them as exceptions.
    
          foreach (TopologyError error in errorsDueToViolatingPointProperlyInsideAreaRule)
          {
            topology.UnmarkAsException(error);
          }
    
          IReadOnlyList<TopologyError> errorsAfterUnmarkedAsExceptions = topology.GetErrors(errorDescription);
          Console.WriteLine($"There are {errorsAfterUnmarkedAsExceptions.Count} feature violating the 'PointProperlyInsideArea' topology rule after all the exceptions have been reset as errors.");
        }
      }
    }
    Inheritance Hierarchy

    System.Object
       ArcGIS.Core.Data.Topology.TopologyError

    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also