Equivalent of IRouteLocator in ArcGIS Pro SDK?

568
2
01-23-2022 10:52 AM
PamTurner
New Contributor III

Hi All - I'm hoping to convert an existing ArcMap Add-in to an ArcGIS Pro Add-in but the tool does quite a bit of Linear Referencing and I can't seem to find an equivalent of the below code, or any other tasks from the linear referencing portion of the tool.  The ArcMap tool allows the user to trace an LRS to define a "project segment" then that segment is located on the LRS and the measures stored in an event table for future use.

Any ideas would be great as I haven't been able to find anything dealing with LRS methods. Maybe they're just not available yet? 

public static void LRSLocateLine(IFeatureClass InputFC)
        { 
            try
            {
                IRouteLocator rtLocator = LRSSetupLocator();

                //create new table name for output to scratch workspace

                IDataset ds = (IDataset)createWSandFC.fWorkspace;
                IWorkspaceName wsn = (IWorkspaceName)ds.FullName;
                ITableName tblname = new TableNameClass();
                IDatasetName dsn = (IDatasetName)tblname;
                dsn.WorkspaceName = wsn;
                dsn.Name = "events_temp";

                try
                {

                   IDataset tempDS;
                   tempDS = (IDataset)createWSandFC.fWorkspace.OpenTable("events_temp");
                   tempDS.Delete();
                }
                catch
                {
                }

                

                //Create RouteLocatorOperations object
                IRouteLocatorOperations2 routeop = new RouteLocatorOperationsClass();
                routeop.RouteLocator = rtLocator;
                routeop.InputFeatureClass = InputFC;

                //output event properties
                IRouteEventProperties2 LMeasProps = new RouteMeasureLinePropertiesClass(); //RouteMeasurePointPropertiesClass();
                LMeasProps.AddErrorField = true;
                LMeasProps.EventRouteIDFieldName = "RTE_NM";

                IRouteMeasureLineProperties MPLineProps = (IRouteMeasureLineProperties)LMeasProps;
                MPLineProps.FromMeasureFieldName = "FromMeas";
                MPLineProps.ToMeasureFieldName = "ToMeas";

                //Locate the points along the routes
                double radius = 1;
              

                routeop.LocateLineFeatures(radius, LMeasProps, true, dsn, "DEFAULT", null);
            
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message);

            }
        }

 

 

0 Kudos
2 Replies
by Anonymous User
Not applicable

Hi Pam,
We currently do not have a Linear Referencing API, although it is being considered in the long-term roadmap. With this said, some methods of IMSegmentation2 have been included with the GeometryEngine.

The Pro SDK allows you to call geoprocessing tools, and you may be able to accomplish some of your add-in needs calling GP tools from the Linear Referencing and Location Referencing toolboxes.

Also, many Pro users with LRS needs use the Roads and Highways extension with related REST customization options.

Please feel free to expand further on any specific LRS needs.

0 Kudos
PamTurner
New Contributor III

Thank you for the reply. I will look into the Geometry Engine. I'm not sure the GP engine will work in this case as it may not be a quick enough response time for the users and it needs to write back to a single table. I don't think Roads and Highways is an option for this particular user base either, but something else to look into.

Thank you!