ThinkGeo.com    |     Documentation    |     Premium Support

Error with QueryTools.GetFeatureById

Hi,


I am receiving the attached error (in a stack trace) when I try to use QueryTools.GetFeatureById or QueryTools.GetFeaturesByIds.


This occurs using both overloads with an explicit list of column values (I am assuming that it has something to do with the Columns) and when using ReturningColumnsType.AllColumns. The Query appears to work if I change the ReturningColumnsType to NoColumns, although this is useless for my situation as I need the attributes. I can get the correct feature if I use QueryTools.GetFeaturesByColumnValue using the same layer object that throws the aforementioned exception - but it is god awful slow...


I would attach my code but it is really trivial (1 line) and again works fine with GetFeaturesByColumnValue and appears to work when I specify not to return columns. Could this be a bug or am I totally missing something?. I am using the latest build - just downloaded it last week.


Thanks for any suggestions.


Justin



System.InvalidOperationException was unhandled

  Message="Your input index is out of bound"

  Source="MapSuiteCore"

  StackTrace:

       at ThinkGeo.MapSuite.Core.x8c51099bc2195d30.ReadFieldValue(Int32 recordIndex, Int32 fieldIndex)

       at ThinkGeo.MapSuite.Core.x8c51099bc2195d30.ReadFieldValue(Int32 recordIndex, String fieldName)

       at ThinkGeo.MapSuite.Core.ShapeFileFeatureSource.GetDataFromDbf(String id, String columnName)

       at ThinkGeo.MapSuite.Core.ShapeFileFeatureSource.GetDataFromDbf(String id, IEnumerable`1 returningColumnNames)

       at ThinkGeo.MapSuite.Core.ShapeFileFeatureSource.GetFeaturesByIdsCore(IEnumerable`1 ids, IEnumerable`1 returningColumnNames)

       at ThinkGeo.MapSuite.Core.FeatureSource.GetFeatureById(String id, IEnumerable`1 returningColumnNames)

       at ThinkGeo.MapSuite.Core.QueryTools.GetFeatureById(String id, IEnumerable`1 returningColumnNames)

       at SWAT.Mobile.frmActivity.SelectFeatureById(SWATLayer swatLayer, String id) in C:\Documents and Settings\cedpjbw\My Documents\Visual Studio 2008\Projects\MMS2\SWAT.Mobile\frmActivity.cs:line 224

       at SWAT.Mobile.frmActivity.activityControl_OnMapChangeNeeded(Object sender, MapChangeNeededArgs args) in C:\Documents and Settings\cedpjbw\My Documents\Visual Studio 2008\Projects\MMS2\SWAT.Mobile\frmActivity.cs:line 79

       at SWAT.Mobile.ucCatchBasinCleaning.LoadStructInfo(Struct structure, Boolean updateMap) in C:\Documents and Settings\cedpjbw\My Documents\Visual Studio 2008\Projects\MMS2\SWAT.Mobile\ucCatchBasinCleaning.cs:line 69

       at SWAT.Mobile.ucCatchBasinCleaning.LoadStructInfo() in C:\Documents and Settings\cedpjbw\My Documents\Visual Studio 2008\Projects\MMS2\SWAT.Mobile\ucCatchBasinCleaning.cs:line 156

       at SWAT.Mobile.ucCatchBasinCleaning.txtCatchBasin_KeyDown(Object sender, KeyEventArgs e) in C:\Documents and Settings\cedpjbw\My Documents\Visual Studio 2008\Projects\MMS2\SWAT.Mobile\ucCatchBasinCleaning.cs:line 162

       at System.Windows.Forms.Control.OnKeyDown(KeyEventArgs e)

       at System.Windows.Forms.Control.ProcessKeyEventArgs(Message& m)

       at System.Windows.Forms.Control.ProcessKeyMessage(Message& m)

       at System.Windows.Forms.Control.WmKeyChar(Message& m)

       at System.Windows.Forms.Control.WndProc(Message& m)

       at System.Windows.Forms.TextBoxBase.WndProc(Message& m)

       at System.Windows.Forms.TextBox.WndProc(Message& m)

       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)

       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)

       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)

       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)

       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)

       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)

       at System.Windows.Forms.Application.RunDialog(Form form)

       at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)

       at SWAT.Mobile.frmMain.ShowActivityForm(IActivityControl c) in C:\Documents and Settings\cedpjbw\My Documents\Visual Studio 2008\Projects\MMS2\SWAT.Mobile\frmMain.cs:line 58

       at SWAT.Mobile.frmMain.rmiNewCBC_Click(Object sender, EventArgs e) in C:\Documents and Settings\cedpjbw\My Documents\Visual Studio 2008\Projects\MMS2\SWAT.Mobile\frmMain.cs:line 41

       at Telerik.WinControls.RadItem.OnClick(EventArgs e)

       at Telerik.WinControls.UI.RadButtonItem.OnClick(EventArgs e)

       at Telerik.WinControls.UI.RadMenuItemBase.OnClick(EventArgs e)

       at Telerik.WinControls.UI.RadMenuItem.OnClick(EventArgs e)

       at Telerik.WinControls.RadItem.DoClick(EventArgs e)

       at Telerik.WinControls.RadItem.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args)

       at Telerik.WinControls.RadElement.RaiseRoutedEvent(RadElement sender, RoutedEventArgs args)

       at Telerik.WinControls.RadItem.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args)

       at Telerik.WinControls.RadElement.RaiseRoutedEvent(RadElement sender, RoutedEventArgs args)

       at Telerik.WinControls.RadElement.DoMouseUp(MouseEventArgs e)

       at Telerik.WinControls.RadElement.CallDoMouseUp(MouseEventArgs e)

       at Telerik.WinControls.ComponentInputBehavior.OnMouseUp(MouseEventArgs e)

       at Telerik.WinControls.RadControl.OnMouseUp(MouseEventArgs e)

       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)

       at System.Windows.Forms.Control.WndProc(Message& m)

       at System.Windows.Forms.ScrollableControl.WndProc(Message& m)

       at Telerik.WinControls.RadControl.WndProc(Message& m)

       at Telerik.WinControls.UI.RadPopupControl.WndProc(Message& m)

       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)

       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)

       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)

       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)

       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)

       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)

       at System.Windows.Forms.Application.Run(Form mainForm)

       at SWAT.Mobile.Program.Main() in C:\Documents and Settings\cedpjbw\My Documents\Visual Studio 2008\Projects\MMS2\SWAT.Mobile\Program.cs:line 18

  InnerException: 




The first thing I would check is to make sure the ID is valid. For all the records, the ID goes from “1” to the record count. If you entered “0” or an ID superior than the count you are going to have an “out of bound exception”. But that does not seem to be the problem because, you say, it works when using the ReturningColumnsType.NoColumns parameters. My suspicion is that your data is corrupted and we are not handling the exception in the most descriptive way. Would you mind sending us your data? If you prefer you can send it to support@thinkgeo.com if you don’t want everybody to have access to your data. Thank you.

Thanks for the quick reply Val. 
  
 I was totally missing something - I apologize. Been one of those days. 
  
 So - next question - is there any way to speed up the GetFeaturesByColumnValue query? I do have an index on the layer… 
  
 Thank you again for you help! 
  
 Justin

Justin, 
  
 Right now, GetFeaturesByColumnValue method is low performance and we don’t have better idea to speed up. 
 First, we get all features, then loop each feature and compare the column value, if they are matched the feature will be added to the collection, finally will return the collection. 
  
 If you have any better idea that can speed up, you can override GetFeaturesByColumnValueCore by using your own logic. 
  
 Thanks 
  
 James