You are here: > ESRI Forums > arcgis desktop discussion forums > Thread Replies

ArcGIS Desktop Discussion Forums

ArcGIS Desktop - ArcObjects Visual Basic for Application (VBA) forum

Select by Attributes on IMS image service l...   Rob Ellis Mar 02, 2004
Re: Select by Attributes on IMS image servi...   G. Venkata Vijay Kumar Mar 02, 2004
Re: Select by Attributes on IMS image servi...   Rob Ellis Mar 03, 2004
Re: Select by Attributes on IMS image servi...   G. Venkata Vijay Kumar Mar 04, 2004
Re: Select by Attributes on IMS image servi...   Kirk Kuykendall Mar 04, 2004
Re: Select by Attributes on IMS image servi...   Rob Ellis Mar 08, 2004
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Select by Attributes on IMS image service layer 
Author Rob Ellis 
Date Mar 02, 2004 
Message I have a polygon layer served from an IMS image service that I can bring into ArcMap and carry out manual 'Select By Attribute' functions. However I am unable to repeat the process in a macro. Is it possible for me to do this or can I only use QueryFilters and FeatureSelections on data sources other than image services? I am working from the ArcObjects sample related to "Selecting Features Using An Attribute Query", the code of which is included with one minor change to get past the 'Not A Feature Layer' catch. I have tried defining the 'pFeatureLayer' object as both ILayer and IIMSMapLayer, but I still get 'type mismatch' errors associated with the Set pFeatureLayer and Set pFeatureSelection commands, yet i can't find equivalent commands for IIMSMapLayers. Your suggestions are appreciated.

regards

Rob 
 
Public Sub SelectMapFeatures()
  Dim pMxDoc As IMxDocument
  Dim pMap As IMap
  Dim pActiveView As IActiveView
  Dim pFeatureLayer As IFeatureLayer
  Dim pFeatureSelection As IFeatureSelection
  Dim pQueryFilter As IQueryFilter
  
  Set pMxDoc = Application.Document
  Set pMap = pMxDoc.FocusMap
  Set pActiveView = pMap
  
  'For simplicity sake let's use the first layer in the map
  'If Not TypeOf pMap.Layer(0) Is IFeatureLayer Then Exit Sub
  Set pFeatureLayer = pMap.Layer(0)
  Set pFeatureSelection = pFeatureLayer 'QI
  
  'Create the query filter
  Set pQueryFilter = New QueryFilter
  pQueryFilter.WhereClause = "NAME = 'Nova Scotia'"
  
  'Invalidate only the selection cache
  'Flag the original selection
  pActiveView.PartialRefresh esriViewGeoSelection, Nothing, Nothing
  'Perform the selection
  pFeatureSelection.SelectFeatures pQueryFilter, esriSelectionResultNew, False
  'Flag the new selection
  pActiveView.PartialRefresh esriViewGeoSelection, Nothing, Nothing
  
End Sub
 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Select by Attributes on IMS image service layer 
Author G. Venkata Vijay Kumar 
Date Mar 02, 2004 
Message Hi, didnt something like this help. Hope it does. 
 
Dim pLayer as ILayer
Dim pIMSLayer as IIMSMapLayer
set pLayer = pMap.Layer(0)

If TypeOf pLayer is IIMSMapLayer then
    Set pIMSLayer = pLayer
End If
 
  Vijay Kumar
Software Developer
 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Select by Attributes on IMS image service layer 
Author Rob Ellis 
Date Mar 03, 2004 
Message Hi Vijay

Thanks for your suggestion but I am still unable to make this IIMSMapLayer a 'FeatureLayer'. I get a 'type mismatch' error when I try:

Dim pFeatureLayer As IFeatureLayer
Dim pLayer As ILayer
Dim pIMSLayer As IIMSMapLayer
Set pLayer = pMap.Layer(0)

If TypeOf pLayer Is IIMSMapLayer Then
Set pIMSLayer = pLayer
End If

Set pFeatureLayer = pIMSLayer

It seems that an IFeatureLayer can not utilise an IIMSMapLayer - any other thoughts?

Thanks again for your assistance

Rob
 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Select by Attributes on IMS image service layer 
Author G. Venkata Vijay Kumar 
Date Mar 04, 2004 
Message Hi, i am not much help with IIMSMapLayer. Sorry for that. Hope the following helps you out.
Here is a link to the IIMSMapLayer interface
---------------------------------------------
http://arcobjectsonline.esri.com/default.asp?URL=/arcobjectsonline/componenthelp/esricore/iimsmaplayer.htm

and this is what it says...

"An IMSMapLayer is a composite layer consisting of IMS sublayers. You can use the ICompositeLayer::Layer property to get a reference to an IMS sublayer; the sublayer is of type IIMSSubLayer. From that, you can get a reference to the ACLayer (Arc Connection layer) on which the sublayer is based. An ACLayer does not implement ILayer; rather, it is an XML representation of the layer from the Internet service. ACLayers use the symbology defined on the Internet service for display in ArcMap."

Here is a sample which changes the renderer of the 'SubLayer'
-----------------------------------------------------------------
http://arcobjectsonline.esri.com/default.asp?URL=/arcobjectsonline/samples/ims/change%20sub-layer%20simplerenderer/change%20sublayer%20simplerenderer.htm 
  Vijay Kumar
Software Developer
 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Select by Attributes on IMS image service layer 
Author Kirk Kuykendall 
Date Mar 04, 2004 
Message code below works for me with ESRI's census diversity image service and tiger highways selected in the TOC.

Note that the sublayers of an IIMSMapLayer can implement IFeatureSelection.

kkeywords iimsfeatureclass 
 
Option Explicit
Sub Test()
    Dim pMxDoc As IMxDocument
    Set pMxDoc = ThisDocument
    If TypeOf pMxDoc.SelectedItem Is IFeatureLayer Then
        Dim pFLayer As IFeatureLayer
        Set pFLayer = pMxDoc.SelectedItem
        If TypeOf pFLayer.FeatureClass Is IIMSFeatureClass Then
            Dim pIMSFC As IIMSFeatureClass
            Set pIMSFC = pFLayer.FeatureClass
            Debug.Print pIMSFC.Axl
        End If
        Dim pQF As IQueryFilter
        Set pQF = New QueryFilter
        pQF.WhereClause = "TGR.TGR_HIGHWAYS.TLID = 101501692"
        
        Dim pFSel As IFeatureSelection
        Set pFSel = pFLayer
        Dim pMouseCursor As IMouseCursor
        Set pMouseCursor = New MouseCursor
        pMouseCursor.SetCursor 2
        Application.StatusBar.Message(0) = "selecting ..."
        pFSel.SelectFeatures pQF, esriSelectionResultNew, False
        DrawSelect pMxDoc.FocusMap
        Application.StatusBar.Message(0) = ""
    End If
End Sub

Sub DrawSelect(pAV As IActiveView)
    Dim lCacheID As Long
    lCacheID = pAV.ScreenCacheID(esriViewGeoSelection, Nothing)
    pAV.ScreenDisplay.Invalidate Nothing, True, lCacheID
End Sub
 
  Kirk Kuykendall
AmberGIS Programming Services & Sales
http://www.ambergis.com
Now Answering questions at:
http://gis.stackexchange.com/


 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Select by Attributes on IMS image service layer 
Author Rob Ellis 
Date Mar 08, 2004 
Message Thanks Vijay and Kirk, a combination of your tips has enabled me to apply the IFeatureSelection and QueryFilter functions to an IMSSubLayer. My code is included for anyone else trying to do the same, it's probably not the most efficient, but it works for now. An obvious improvment would be to select the appropriate sublayer by name or by user input, I'll get arounf to that another time.

Thanks again

Rob 
 
Dim pMxDoc As IMxDocument
  Dim pMap As IMap
  Dim pActiveView As IActiveView
  Dim pContentsView As IContentsView
  Dim pFeatureLayer As IFeatureLayer
  Dim pFeatureSelection As IFeatureSelection
  Dim pQueryFilter As IQueryFilter

  Dim pCompLayer As ICompositeLayer
  Dim pTheSubLayer As IIMSSubLayer

  Set pMxDoc = Application.Document
  Set pMap = pMxDoc.FocusMap
  Set pActiveView = pMap
 
  Set pCompLayer = pMap.Layer(0)
  
  Set pTheSubLayer = pCompLayer.Layer(9)' Manually select the appropriate sublayer
  Set pFeatureLayer = pTheSubLayer
  Set pFeatureSelection = pFeatureLayer 'QI
 
  'Create the query filter
  Set pQueryFilter = New QueryFilter
  pQueryFilter.WhereClause = "THEATTRIBUTE = 'THEVALUE'"
  'Invalidate only the selection cache
  'Flag the original selection
  pActiveView.PartialRefresh esriViewGeoSelection, Nothing, Nothing
  'Perform the selection
  pFeatureSelection.SelectFeatures pQueryFilter, esriSelectionResultNew, False
  'Flag the new selection
  pActiveView.PartialRefresh esriViewGeoSelection, Nothing, Nothing