Select from NALayer

273
4
Jump to solution
12-28-2013 03:49 AM
Highlighted
Occasional Contributor
Hello.

I want to select a feature from Network Analysis layer. I have the result (naLayer), which is solution of some Network Analysis problem. But when I cast   naLayer as IfeatureLayer   I get NULL.

Can anyone help me to solve this problem?

 SelectByAttributeQuery(naLayer as IfeatureLayer, "myQuery", true);   public void SelectByAttributeQuery(IFeatureLayer featureLayer,String whereClause,bool justOne) {     IMap m_map = axMapControl.Map;     if (m_map.SelectionCount > 0) m_map.ClearSelection();     IFeatureSelection featureSelection = featureLayer as IFeatureSelection;     IQueryFilter queryFilter = new QueryFilterClass();     queryFilter.WhereClause = whereClause;     featureSelection.SelectFeatures(queryFilter,esriSelectionResultEnum.esriSelectionResultNew,justOne);      axMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null); }
Reply
0 Kudos
1 Solution

Accepted Solutions
Highlighted
Occasional Contributor
Sanjay, many thanks for your reply.
I can get ILayer from INALayer, but when I try get IFeatureLayer from that ILayer I get NULL.

But I solved this problem using following way:

     IFeatureClass routesFeatureClass = m_NAContext.NAClasses.get_ItemByName("Routes") as IFeatureClass;      IFeatureLayer routesFeatureLayer = new FeatureLayerClass();      routesFeatureLayer.FeatureClass = routesFeatureClass;      axMapControl.AddLayer(routesFeatureLayer as ILayer, 0);      SelectByAttributeQuery(routesFeatureLayer, "myWhereClause", true);  

View solution in original post

Reply
0 Kudos
4 Replies
Highlighted
Occasional Contributor II
So, do you get false when you execute following line?


if ( naLayer is IFeatureLayer)
{

}
Reply
0 Kudos
Highlighted
Occasional Contributor II
INALayer is implemented by NALayerClass class. This class also implements ILayer and other interfaces but not IFeatureLayer. This could be the reason.

Can you try to get ILayer from INALayer and then IFeatureLayer from ILayer?

HTH.
Reply
0 Kudos
Highlighted
Occasional Contributor
Sanjay, many thanks for your reply.
I can get ILayer from INALayer, but when I try get IFeatureLayer from that ILayer I get NULL.

But I solved this problem using following way:

     IFeatureClass routesFeatureClass = m_NAContext.NAClasses.get_ItemByName("Routes") as IFeatureClass;      IFeatureLayer routesFeatureLayer = new FeatureLayerClass();      routesFeatureLayer.FeatureClass = routesFeatureClass;      axMapControl.AddLayer(routesFeatureLayer as ILayer, 0);      SelectByAttributeQuery(routesFeatureLayer, "myWhereClause", true);  

View solution in original post

Reply
0 Kudos
Highlighted
Occasional Contributor II
Glad your issue is fixed and thanks for posting the solution.
Reply
0 Kudos