Select to view content in your preferred language

Query layer using another layer (VB.NET)

819
2
03-23-2011 12:05 PM
BrianLeroux
Frequent Contributor
I am looking to build off of the Query Features sample. Instead of drawing a polygon so select, I am looking to use the polygons inside a shape file. The issue I am having is I am not sure how to identify the contents of a shape file as a point, line, or polygon. I can identify the layer type with the following but not the shape types.

For Each item As MapItem In fold.ChildItems
            If TypeOf item Is Layers Then

Any help is appreciated.
0 Kudos
2 Replies
AndreiIvanov
Deactivated User
Brian,

to identify the shape type of the layer you need to do it via Table class. Table class has GeometryType property that from the help "Gets the type of geometry that this Table is capable of storing". If you need further help, let me know!
0 Kudos
BrianLeroux
Frequent Contributor
I can't get this layer by query code working. Any help is appreciated.

Dim points As Table = tvwMapItems.SelectedNode.Tag

        Dim poly As Table = tvwMapItems2.SelectedNode.Tag


        'Create a List to store ObjectID's
        Dim objectIDList As List(Of Integer) = New List(Of Integer)()

        'Loop over each  area and perform a spatial query to find points
        For Each polyArea As Row In poly.GetRows()

            Dim polyAreaShape As Geometry = polyArea.Geometry
            Dim foundPoints As RowCollection = points.Search(New Filter(polyAreaShape, FilterSearchOptions.Intersects))
            For Each rw As Row In foundPoints
                objectIDList.Add(rw.ObjectID)
            Next
        Next

        ' create the table binding adapter and fill it
        Dim tableBindingAdapter As TableBindingAdapter = New TableBindingAdapter(points)
        tableBindingAdapter.UseColumnAliasNames = True
        tableBindingAdapter.UseCodedValueDomains = True
        tableBindingAdapter.Fill(objectIDList.ToArray())

        ' display the results
        Dim resultsForm As QueryResultsForm = New QueryResultsForm(tableBindingAdapter)
        resultsForm.ShowDialog()
0 Kudos