Obtain the route feature class from a route event layers

317
2
07-22-2021 11:50 PM
Zoggo
by
New Contributor II

I'm using route event layers in ArcGIS Pro 2.8. I have to catch the underlying route feature class polygon of a route event. But I can't get the route feature class. My code looks like this:

public async void  Test(Geometry  Point)
        {
            FeatureClass RouteFeatureClass;
            SpatialQueryFilter spatialFilter;
            Polyline RouteFeaturePolyline;

            foreach (Layer Layer in MapView.Active.Map.GetLayersAsFlattenedList())
            {
                if (await EditEventsToolModule.IsRouteEventLayer(Layer))
                {
                    //Get the underlying RouteFeatureClass (not the event table)
                    RouteFeatureClass = ???;

                    spatialFilter = new SpatialQueryFilter
                    {
                        FilterGeometry = Point,
                        SpatialRelationship = SpatialRelationship.Intersects,
                    };

                    using (RowCursor rowCursor = RouteFeatureClass.Search(spatialFilter, false))
                    {
                        while (rowCursor.MoveNext())
                        {
                            using (Feature feature = rowCursor.Current as Feature)
                            {
                                RouteFeaturePolyline = feature.GetShape() as Polyline;
                                //do something with the polyline
                            }
                        }
                    }
                }
            }
        }

        public static async Task<Boolean> IsRouteEventLayer(Layer Layer)
        {
            return await QueuedTask.Run(() =>
            {
                Boolean IsRouteEventLayer = false;
                CIMDataConnection CIMDatacionnection = Layer.GetDataConnection();
                if (CIMDatacionnection != null)
                {
                    if (CIMDatacionnection.GetType().Equals(typeof(CIMRouteEventDataConnection)))
                    {
                        IsRouteEventLayer = true;
                    }
                }
                return IsRouteEventLayer;
            });
        }
0 Kudos
2 Replies
JeremyWiles
New Contributor III

I am not sure about a route feature class polygon.  Did you mean polyline?

0 Kudos
Zoggo
by
New Contributor II

Yes, of course. I mean polyline not polygon. 

0 Kudos