标签:解决办法 FileGDBAPI attrQueryRows2 空间数据 attrQueryRows int env table
问题: 坑爹得filegdb数据,只能查询一次, 第二次查询只返回2条数据
分析: 在QGIS, ArcMap中重新查看, 数据正常,
使用FileGDB_API_1_5_1-VS2015\samples\Querying 这个库里面用例直接查也是正常.
但是我使用得时候先统计了个数, 再执行查询, 于是出问题得代码出现了,:
int Searchtest(Table &table)
{
fgdbError hr;
wstring errorText;
EnumRows attrQueryRows, attrQueryRows2;
FileGDBAPI::Row pRow2, pRow;
int nCount = 0;
int oid = 0;
FileGDBAPI::Envelope env;
table.GetExtent(env);
if ((hr = table.Search(L"OBJECTID", L"", env, true, attrQueryRows)) != S_OK)
{
wcout << "An error occurred while performing the attribute query." << endl;
ErrorInfo::GetErrorDescription(hr, errorText);
wcout << errorText << "(" << hr << ")." << endl;
return -1;
}
//FileGDBAPI::Row pRow;
while ((hr = attrQueryRows.Next(pRow)) == S_OK)
{
++nCount;
hr = pRow2.GetOID(oid);
}
attrQueryRows.Close();
table.GetExtent(env);
if ((hr = table.Search(L"*", L"", env, true, attrQueryRows2)) != S_OK)
{
wcout << "An error occurred while performing the attribute query." << endl;
ErrorInfo::GetErrorDescription(hr, errorText);
wcout << errorText << "(" << hr << ")." << endl;
return -1;
}
while ((hr = attrQueryRows2.Next(pRow2)) == S_OK)
{
++nCount;
hr = pRow2.GetOID(oid);
}
}
attrQueryRows2和attrQueryRows遍历结果应该一样, 但是结果就是完全attrQueryRows2 只有2条,attrQueryRows有537条[正确结果],
结合测试说得, 他的机器上这个数据在ArcGIS中缩放会消失(我机器不消失), 猜测空间索引有问题, 那么只需要找到重建空间索引得API即可, 但是FileGDBAPI 里面没得, 然后有两个这样得方法
没错这个方法设置为false会重新整理空间索引, 如果不放心就先设置为true,在设置为false, 这可能需要一些时间, 但是对于我这里得数据做完这个后就一切正常了, 再次吐槽一下坑爹得filegdb
标签:解决办法,FileGDBAPI,attrQueryRows2,空间数据,attrQueryRows,int,env,table 来源: https://blog.csdn.net/chijingjing/article/details/121221056
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。