Occasional exceptions thrown while fetching multipatch feature rows.

650
1
05-13-2020 08:24 AM
BillSmith
New Contributor III

Hello,

I'm experiencing a strange error that only happens on some of my multipatch feature.

An error occurs when cycling through a RowCursor on a couple of features, but the rest come through fine.  I have this working with legacy ArcObject code, so I don't see a problem with the features.

The exception thrown is "Value does not fall within the expected range." for 3 out of 79 features.  Any ideas?

Here are the basic code snippets.

// Reset a search cursor.

Table table = m_db_info.geodb.OpenDataset<Table>(m_class_name);
FeatureClass fc = table as FeatureClass;

if (fc != null && m_mbr != null) {
   SpatialQueryFilter spatial_filter = new SpatialQueryFilter();

   if (SetupQueryGeometry(m_mbr, fc.GetDefinition().GetSpatialReference(), out Geometry extent)) {

      // If queryFilter is an instance of ArcGIS.Core.Data.SpatialQueryFilter, either
      // both the 'FilterGeometry' and 'SpatialRelationship' properties are set or both
      // are not set. Otherwise, an ArgumentException will be raised.
      if (extent.Extent.Area > 0) {
         spatial_filter.FilterGeometry = extent;
         spatial_filter.SpatialRelationship = SpatialRelationship.Intersects;
      }

   }

   if (m_query.Length > 0) {
      spatial_filter.WhereClause = m_query;
      spatial_filter.SubFields = "*";
   }

   if (m_postfix.Length > 0) {
      spatial_filter.PostfixClause = m_postfix;
   }

   m_cursor = table.Search(spatial_filter, false); // m_cursor is a RowCursor

}

...............................

// Traverse the features in another method.

try {
   Table table = m_db_info.geodb.OpenDataset<Table>(m_class_name);
   FeatureClass fc = table as FeatureClass;

   while (m_cursor.MoveNext()) {  (THROWING AN EXCEPTION ON A FEW FEATURES HERE)
      using (Row row = m_cursor.Current) {
         // Process the feature.
         EsriFeatureRow feature = new EsriFeatureRow {
         m_feature_id = (int)row.GetObjectID()
      };

...etc...

}

Thank you in advance for any suggestions.

-Bill

1 Reply
NarelleChedzey
Esri Contributor

Bill, 

A couple of question 

- what type of attributes do you have on the feature class?  Maybe one of them is the problem.   What happens if you set the SubFields on your spatial query filter to just be ObjectId, Shape?

Do you see the same problem if you pass null to the Table.Search?  that is you're iterating through all records rather than those that match your spatial filter?

Finally, if you reorganize your code so that the cursor iteration occurs immediately after the search, do you still see the same problem?  You should also wrap your OpenDataset and Search methods in a using statement. 

for example see this snippet as a suggestion of how to iterate.  We generally don't recommend caching objects such as RowCursors. 

https://github.com/Esri/arcgis-pro-sdk/wiki/ProSnippets-Geodatabase#searching-a-table-using-queryfil... 

Let me know if these suggestions don't help to track down your issue.  If you're still having problems, maybe we can get your data for further investigation. 

Narelle