ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Core.Data.LinearReferencing Namespace / RouteEventSource Class / RouteEventSource Constructor
The object containing information about the route feature class.
The object containing information about the event table.
The object that specifies options for the route event source.
Example

In This Topic
    RouteEventSource Constructor
    In This Topic
    Generates a new route event source feature class using dynamic segmentation.
    Syntax

    Parameters

    routeInfo
    The object containing information about the route feature class.
    eventInfo
    The object containing information about the event table.
    routeEventSourceOptions
    The object that specifies options for the route event source.
    Exceptions
    ExceptionDescription
    routeInfo, eventInfo or routeEventSourceOptions is null.
    A geodatabase-related exception has occurred.
    Remarks
    The dynamic segmentation process calculates the location (shape) of events stored in an event table. The result of the dynamic segmentation is a dynamic feature class known as a route event source, and it can be used as the data source for further computation.
    Example
    Create a RouteEventSource via dynamic segmentation process for line events
    {
      static void CreateLineEventSource(Geodatabase geodatabase, string routeFeatureClassName = "Roads", string eventTableName = "Accidents", string routeIdFieldName = "RID", string toMeasureFieldName = "toMeasure", string fromMeasureFieldName = "fromMeasure", string offsetFieldName = "Offset")
      {
        using (FeatureClass routesFeatureClass = geodatabase.OpenDataset<FeatureClass>(routeFeatureClassName))
        using (Table eventsTable = geodatabase.OpenDataset<Table>(eventTableName))
        {
          RouteInfo routeInfo = new RouteInfo(routesFeatureClass, routeIdFieldName);
          EventInfo eventInfo = new LineEventInfo(eventsTable, routeIdFieldName, fromMeasureFieldName, toMeasureFieldName, offsetFieldName);
          RouteEventSourceOptions routeEventSourceOptions = new LineEventSourceOptions() { IsPositiveOffsetOnRight = true };
    
          using (RouteEventSource routeEventSource = new RouteEventSource(routeInfo, eventInfo, routeEventSourceOptions))
          using (RouteEventSourceDefinition routeEventSourceDefinition = routeEventSource.GetDefinition())
          {
            // Locating errors 
            IReadOnlyList<RouteEventSourceError> errors = routeEventSource.GetErrors();
    
            // Route event source fields 
            IReadOnlyList<Field> routeEventSourceFields = routeEventSourceDefinition.GetFields();
    
            // Add RouteEventSource to the ArcGIS Pro map
            FeatureLayerCreationParams layerParams = new FeatureLayerCreationParams(routeEventSource)
            {
              Name = "HighCrashAreas"
            };
    
            LayerFactory.Instance.CreateLayer<FeatureLayer>(layerParams, MapView.Active.Map);
          }
        }
      }
    }
    Locate features along routes
    {
      static void LocateLineFeaturesAlongRoutes(Geodatabase geodatabase, string routeFeatureClassName = "Roads", string eventTableName = "Accidents", string routeIdFieldName = "RID", string toMeasureFieldName = "toMeasure", string fromMeasureFieldName = "fromMeasure")
      {
        // Configure events table
        EventTableConfiguration lineEventTableConfiguration = new LineEventTableConfiguration(eventTableName, routeIdFieldName, fromMeasureFieldName, toMeasureFieldName) { KeepAllFields = true, MDirectionOffset = true };
    
        using (FeatureClass routeFeatureClass = geodatabase.OpenDataset<FeatureClass>(routeFeatureClassName))
        using (FeatureClass highCrashAreaFeatureClass = geodatabase.OpenDataset<FeatureClass>("HighCrashRegion"))
        {
          RouteInfo routeInfo = new RouteInfo(routeFeatureClass, routeIdFieldName);
    
          // Creates an event table inside the geodatabase
          routeInfo.LocateFeatures(highCrashAreaFeatureClass, 0.5, lineEventTableConfiguration);
    
          // Open newly created event table
          using (Table eventTable = geodatabase.OpenDataset<Table>(eventTableName))
          {
            EventInfo eventInfo = new LineEventInfo(eventTable, routeIdFieldName, fromMeasureFieldName, toMeasureFieldName);
    
            // Create RouteEventSource using new event table
            using (RouteEventSource routeEventSource = new RouteEventSource(routeInfo, eventInfo, new LineEventSourceOptions()))
            {
              // Process the routeEventSource as needed ...
            }
          }
        }
      }
    }
    Requirements

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

    ArcGIS Pro version: 3.4 or higher.
    See Also