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;
});
}
I am not sure about a route feature class polygon. Did you mean polyline?
Yes, of course. I mean polyline not polygon.