ThinkGeo.com    |     Documentation    |     Premium Support

About GetFeatureById

Hello, all


I 'd like to find ADR by follows code:


              Dim road_Layer As ShapeFileFeatureLayer = New ShapeFileFeatureLayer("...\road_64000.shp")

               cross_SQL = "select distinct ADR from road_64000 where tnode='" & nodeid & "' or fnode='" & nodeid & "'"

                road_Layer.Open()


                road_DT = road_Layer.QueryTools.ExecuteQuery(cross_SQL)

                road_Layer.Close()


Now, I want to use another method to get the same result. But it seems has some error. Could anyone help me?


 Dim road_Layer As ShapeFileFeatureLayer = New ShapeFileFeatureLayer("D:\GIS\TWD97\v3_shp\small\road_10001.shp")

                road_Layer.Open()

                Dim dbfColumns As Collection(Of DbfColumn) = DirectCast(road_Layer.FeatureSource, ShapeFileFeatureSource).GetDbfColumns()

                Dim columnNames As New Collection(Of String)()


                For Each dbfColumn As DbfColumn In dbfColumns

                    If (dbfColumn.ColumnName.Trim() = "TNODE " Or dbfColumn.ColumnName.Trim() = "FNODE" Or dbfColumn.ColumnName.Trim() = "ADR") Then

                        columnNames.Add(dbfColumn.ColumnName)

                    End If

                Next

                featuresT = road_Layer.FeatureSource.GetFeaturesByColumnValue("TNODE ", nodeid, columnNames)

                featuresF = road_Layer.FeatureSource.GetFeaturesByColumnValue("FNODE", nodeid, columnNames)

                Dim ADRfeature As Collection(Of Feature) = Nothing

                ADRfeature = road_Layer.QueryTools.GetFeatureById(featuresT(0).Id, New String() {"ADR"})

                Dim ADR As String = ""

                ADR = ADRfeature(0).ColumnValues("ADR")


 



sorry, I think I know where has wrong.  
 ADRfeature can’t set as collection (of feature) 
  
   Dim ADRfeature As Feature = Nothing 
     For i As Integer = 0 To (featuresT.Count - 1) 
      ADRfeature = road_Layer.QueryTools.GetFeatureById(featuresT(i).Id, New String() {“ADR”}) 
      Next 
     ADR = ADRfeature.ColumnValues(“ADR”) 
  


Carol, 
  
 Thanks for your post! 
  
 It’s awesome that you fix the problem by yourself.