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

In This Topic
    TopologyDefinition Class
    In This Topic
    Represents the schema and properties of a Topology.
    Syntax
    Public NotInheritable Class TopologyDefinition 
       Inherits ArcGIS.Core.Data.Definition
       Implements System.IDisposable 
    public sealed class TopologyDefinition : ArcGIS.Core.Data.Definition, System.IDisposable  
    Example
    Build Map Topology
    // Builds the map topology graph for the active map view and displays the number of topology nodes and edges.
    await QueuedTask.Run(() =>
    {
      //Build the map topology graph
      MapView.Active.BuildMapTopologyGraph<TopologyDefinition>(topologyGraph =>
      {
        //Getting the nodes and edges present in the graph
        var topologyGraphNodes = topologyGraph.GetNodes();
        var topologyGraphEdges = topologyGraph.GetEdges();
    
        foreach (var node in topologyGraphNodes)
        {
          // do something with the node
        }
        foreach (var edge in topologyGraphEdges)
        {
          // do something with the edge
        }
        MessageBox.Show($"Number of topo graph nodes are:  {topologyGraphNodes.Count}.\n Number of topo graph edges are {topologyGraphEdges.Count}.", "Map Topology Info");
      });
    });
    Open topology and process definition
    {
      static void OpenTopologyAndProcessDefinition()
      {
        // Open a geodatabase topology from a file geodatabase and process the topology definition.
        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"))
        {
          ProcessDefinition(geodatabase, topology);
        }
    
        // Open a feature service topology and process the topology definition.
        const string TOPOLOGY_LAYER_ID = "0";
    
        using (Geodatabase geodatabase = new Geodatabase(new ServiceConnectionProperties(new Uri("https://sdkexamples.esri.com/server/rest/services/GrandTeton/FeatureServer"))))
        using (ArcGIS.Core.Data.Topology.Topology topology = geodatabase.OpenDataset<ArcGIS.Core.Data.Topology.Topology>(TOPOLOGY_LAYER_ID))
        {
          ProcessDefinition(geodatabase, topology);
        }
    
        static void ProcessDefinition(Geodatabase geodatabase, ArcGIS.Core.Data.Topology.Topology topology)
        {
          // Similar to the rest of the Definition objects in the Core.Data API, there are two ways to open a dataset's 
          // definition -- via the Topology dataset itself or via the Geodatabase.
          using (TopologyDefinition definitionViaTopology = topology.GetDefinition())
          {
            OutputDefinition(geodatabase, definitionViaTopology);
          }
    
          using (TopologyDefinition definitionViaGeodatabase = geodatabase.GetDefinition<TopologyDefinition>("Backcountry_Topology"))
          {
            OutputDefinition(geodatabase, definitionViaGeodatabase);
          }
        }
    
        static void OutputDefinition(Geodatabase geodatabase, TopologyDefinition topologyDefinition)
        {
          Console.WriteLine($"Topology cluster tolerance => {topologyDefinition.GetClusterTolerance()}");
          Console.WriteLine($"Topology Z cluster tolerance => {topologyDefinition.GetZClusterTolerance()}");
    
          IReadOnlyList<string> featureClassNames = topologyDefinition.GetFeatureClassNames();
          Console.WriteLine($"There are {featureClassNames.Count} feature classes that are participating in the topology:");
    
          foreach (string name in featureClassNames)
          {
            // Open each feature class that participates in the topology.
            using (FeatureClass featureClass = geodatabase.OpenDataset<FeatureClass>(name))
            using (FeatureClassDefinition featureClassDefinition = featureClass.GetDefinition())
            {
              Console.WriteLine($"\t{featureClass.GetName()} ({featureClassDefinition.GetShapeType()})");
            }
          }
        }
      }
    }
    Inheritance Hierarchy

    System.Object
       ArcGIS.Core.CoreObjectsBase
          ArcGIS.Core.Data.Definition
             ArcGIS.Core.Data.Topology.TopologyDefinition

    Requirements

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

    ArcGIS Pro version: 3.0 or higher.
    See Also