Sorry if I'm missing something, anytime I grab the value of a given feature.ColumnValue (when the value is of type Integer in the shape file), I get the following example result type: 4.15000000000e+ It works fine on string values. What am I doing wrong?
For i As Integer = 0 To feature.ColumnValues.Count - 1
I emailed support@thinkgeo.com with a sample project as well as some sample data, note that I copied the code to a Winforms application which seemed easier to send back and forth.
I'm gonna check it as soon as i get the email from support@thinkgeo.com. Do you mention forwarding it to me? Anyway, i will ask for that from supports.
If I am not making any mistake, this problem mentioned here is exactly the same with the first issue in Ticket 2998. If so, I think let us keep the ticket thread alive because it is more convenient to attach files.
For anyone experiencing similar situation, I ended up passing in the column collection that contains the columntype, I can then evaluate this and do the proper type conversion. Here is a simple routine to process the values from the feature columns (note that I’m populating a ListBox control with the id of ‘lstResults’):
Private Sub GetColumnContents(ByVal feature As Feature, ByVal columns As Collection(Of FeatureSourceColumn)) For i As Integer = 0 To columns.Count - 1 Select Case columns(i).TypeName Case “String” Me.lstResults.Items.Add(feature.ColumnValues.ElementAt(i).Key & ": " & feature.ColumnValues.ElementAt(i).Value) Case “Double” Me.lstResults.Items.Add(feature.ColumnValues.ElementAt(i).Key & ": " & CDbl(feature.ColumnValues.ElementAt(i).Value).ToString) Case “Integer” Me.lstResults.Items.Add(feature.ColumnValues.ElementAt(i).Key & ": " & CInt(feature.ColumnValues.ElementAt(i).Value).ToString) Case Else Me.lstResults.Items.Add(feature.ColumnValues.ElementAt(i).Key & ": " & feature.ColumnValues.ElementAt(i).Value) End Select Next End Sub
Thanks for sharing your idea. Do you means there is any better idea about it or something else? I’m sorry that i didn’t get you. Can you detail the purpose?
Hi Johnny, the purpose of the procedure I came up with is that if you simply grab the value using: feature.ColumnValues.ElementAt(i).Value and the type is of Double then the display or conversion to string will not work correctly, you must first convert to Double in Visual Basic using something like CDbl and then convert to string. Hope this makes sense?
Hi Jason, Sorry that I was unable to recreate it. I’m not sure whether you get the specified columns values when requesting features, please have a check that the input columns collection has the same sequence to the parameter “columns” of GetColumnContents method. Here is the screenshot I got: