Vishful thinking…

ESRI bug on performing a spatial query with a GeometryBag containing multiple shapes against SDE

Posted in ArcGIS, ESRI by viswaug on August 20, 2007

This is an bug that I came up on when building some productivity tools for ArcMAP. It is interesting to note that this bug was introduced in ArcGIS 9.2 while ArcGIS 9.1 works fine. The bug took me by surprise since the bug happens in the core geometry functions of the ArcObjects library.

The feature I was building was performing a pretty simple spatial query operation using a SpatialFilter object on a featureclass. The featureclass against which the query was being performed was in a SDE database. Much to my chagrin, I came to find out that this bug occurs only when the featureclass is a SDE featureclass and not when it is from a file geodatabase. That doesn’t help too much cause our customers expect the application to work everywhere. Getting back to the SpatialFilter, the geometry being used in the filter was a GeometryBag containing more than one feature. On running the query, the results weren’t as expected. Even though, the GeometryBag contained more than one geometry in it, the results returned corresponded only to the first geometry in the GeometryBag. After, spending quite a bit of time figuring out all the cases when the error occurred I was able to contact ESRI support and confirm this as an issue and obtain an incident number.

#NIM010450 – SelectFeatures with a spatial query does not work when using a query geometry which is a GeometryBag with more than one feature in it.

Now, we just have to sit on our hands and wait patiently for ESRI to get around to fixing it. I was actually excited when ESRI had announced that they were making the effort to publish the list of known software defects online by August 2007. But this latest blog entry from the ESRI support center doesn’t sound too promising.

3 Responses

Subscribe to comments with RSS.

  1. Anoop said, on August 27, 2007 at 11:14 am

    We have a function which create a buffer in one layer, to query another layer. This code worked fine in 9.1, but in 9.2 the return datatable is always null. Do you think this is the same problem?

    Thanks in advance.

    public DataTable drGetDAList(WebMap webMap, ArrayList arrPoints, int nBufferLayerId, int nFindLayerId, string sUnits, double dDistance, bool bDrawBuffers)
    {
    try
    {
    System.Data.DataTable dataGridTable=null;

    // Get Feature IDS (FIDs) from selected features in the buffer layer
    // ArrayList has been populated by the Selection class, which has been called by the Selection Tool in the Toolbar

    IMapServer mapServer = webMap.MapServer;

    IServerContext serverContext = webMap.ServerContext;
    if (webMap.IsPooled)
    webMap.ManageLifetime(serverContext);

    // Create and fill a FIDSet2 using FIDs retrieved above (selected features from buffer layer)
    IFIDSet2 fidSet2 = serverContext.CreateObject("esriGeodatabase.FIDSet") as IFIDSet2;
    webMap.ManageLifetime(fidSet2);
    for (int i = 0; i -1)
    {
    // Clear features selection in previos Find Layer
    ILayerDescription prevFindLayerDescription = mapDescription.LayerDescriptions.get_Element(prevFindLayerID);
    webMap.ManageLifetime(prevFindLayerDescription);
    prevFindLayerDescription.SelectionFeatures = null;
    }
    #endregion

    #region Get OBJECTID and DisplayField fields INDEX in "Find" Layer
    // These fields are going to be used to display in the features found DataGrid

    if (prevFindLayerID != findLayerID)
    {
    webMap.AGSWebControl.Page.Session["OIDField"] = null;
    webMap.AGSWebControl.Page.Session["DisplayField"] = null;
    webMap.AGSWebControl.Page.Session["SHAPEField"] = null;

    IMapServerInfo mapServerInfo = mapServer.GetServerInfo(mapDescriptionName);
    IMapLayerInfo mapLayerInfo = mapServerInfo.MapLayerInfos.get_Element(findLayerID);
    IFields fields = mapLayerInfo.Fields;
    webMap.ManageLifetime(mapServerInfo);
    webMap.ManageLifetime(mapLayerInfo);
    webMap.ManageLifetime(fields);

    // Find Display Field
    string displayField = mapLayerInfo.DisplayField;
    string subFields = "";
    string fieldName = "";
    string objectIDName = "";
    IField field = null;
    webMap.ManageLifetime(field);
    int objectID = -1;
    for (int i = 0; i LayerDescription in order to draw FOUND features
    ILayerDescription layerDescription = mapDescription.LayerDescriptions.get_Element(findLayerID);
    webMap.ManageLifetime(layerDescription);
    // To draw FOUND features use cons color

    layerDescription.SelectionColor = null;
    layerDescription.SelectionFeatures = fidSet;

    if (webMap.AGSWebControl.Page.Session["OIDField"] != null)
    {
    // Retrieve FOUND features RECORDSET to populate DataGrid
    IRecordSet recordSet = mapServer.QueryFeatureData(mapDescriptionName, findLayerID, findQueryFilter);
    webMap.ManageLifetime(recordSet);

    // Convert the recordset to a System.Data.DataSet from where
    // the OBJECTID and Display Field are going to be extracted as a table
    // that it is going to bind to the DataGrid
    System.Data.DataSet selectedDataSet = webMap.ConvertRecordSetToDataSet(recordSet, true, false);

    #region Bound/unbound subset table to the DataGrid
    if (selectedDataSet != null)
    {
    // Change returned table columns name to match datagrid column names
    // Change OBJECTID field name to FeatureID column name
    dataGridTable = selectedDataSet.Tables[0];

    if (dataGridTable.Rows.Count > 0)
    {
    string oidField = webMap.AGSWebControl.Page.Session["OIDField"] as string;
    DataColumn OIDDataColumn = dataGridTable.Columns[oidField];

    string displayField = webMap.AGSWebControl.Page.Session["DisplayField"] as string;
    DataColumn displayFieldDataColumn = dataGridTable.Columns[displayField];

    // Change table's OBJECTID column name to match dataGrid column's name
    if (OIDDataColumn != null)
    OIDDataColumn.ColumnName = DATAGRID_OBJECTID;

    }

    webMap.AGSWebControl.Page.Session["selectedDataSet"] = dataGridTable;

    }
    else
    {
    return null;
    }
    #endregion
    }
    }
    else
    {
    return null;
    }
    #endregion

    // Refresh WebMap to redraw FIND selection and buffers
    if (bDrawBuffers==true) webMap.Refresh();
    webMap.AGSWebControl.Page.Session["findLayerID"] = findLayerID;
    return dataGridTable;

    // Change UI
    }
    catch (Exception error)
    {
    throw error;
    }

    }

  2. viswaug said, on August 27, 2007 at 1:10 pm

    Hi Anoop,

    That depends on if you are using the GeometryBag to hold the buffered features and using it as the query geometry in your query filer.

    Vish

  3. SOLAP said, on May 11, 2008 at 12:06 am

    I have better experience with 9.3.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: