FileGDB API for linux学习系列之三,检索目录树
分享
使用FileGDB API提供的函数GetChildDatasets可以像ArcCatalog一样,访问FileGDB的目录结构,包括FileGDB所包括的FeatureDataset,FeatureClass,RasterDatast,RasterCatalog,MosaicDataset等等,在FileGDB API中一共包含以下几种类型:
Feature Class
Item
Range Domain
Extension Dataset
Parcel Fabric
Workspace Extension
Domain
Relationship Class
Raster Catalog
Folder
Tin
Dataset
Survey Dataset
AbstractTable
Mosaic Dataset
Feature Dataset
Schematic Dataset
Terrain
Replica Dataset
Network Dataset
Historical Marker
Catalog Dataset
Resource
Table
Raster Dataset
Geometric Network
Topology
Toolbox
Coded Value Domain
Replica
Representation Class
Workspace
以下的步骤是访问FileGDB中根目录中所有的FeatureDataset以及各个FeatureDataset下所包括的FeatureClass的代码以及实现结果。
1. 使用ArcCatalog创建一个FileGDB,名称为TestFileGDB,向其中录入一些FeatureDataset以及FeatureClass和普通表,结果如下图:
2. 自己写个例子程序运行结果如下,(此程序纯c++实现的console例子程序,没有使用任何的linux的界面库)
3. 实现代码如下:
整个工程会在整个系列完成后上传。
文章来源:http://blog.csdn.net/liufeng1980423/article/details/6218437
Feature Class
Item
Range Domain
Extension Dataset
Parcel Fabric
Workspace Extension
Domain
Relationship Class
Raster Catalog
Folder
Tin
Dataset
Survey Dataset
AbstractTable
Mosaic Dataset
Feature Dataset
Schematic Dataset
Terrain
Replica Dataset
Network Dataset
Historical Marker
Catalog Dataset
Resource
Table
Raster Dataset
Geometric Network
Topology
Toolbox
Coded Value Domain
Replica
Representation Class
Workspace
以下的步骤是访问FileGDB中根目录中所有的FeatureDataset以及各个FeatureDataset下所包括的FeatureClass的代码以及实现结果。
1. 使用ArcCatalog创建一个FileGDB,名称为TestFileGDB,向其中录入一些FeatureDataset以及FeatureClass和普通表,结果如下图:
2. 自己写个例子程序运行结果如下,(此程序纯c++实现的console例子程序,没有使用任何的linux的界面库)
3. 实现代码如下:
#include
#include
#include <string>
#include
#include
#include
#include
#define EXT_FILEGDB_API _declspec(dllimport)
#pragma warning (disable : 4251)
#include "Geodatabase.h"
#include "GeodatabaseManagement.h"
using namespace std;
using namespace FileGDBAPI;
Geodatabase geodatabase;
long getchilddataset(std::wstring parentDataset, std::wstring DatasetType,std::vector& childDatasets);
int main()
{
// Create a new geodatabase in the current directory.
long hr;
// Re-open the geodatabase.
if ((hr = OpenGeodatabase(L"../data/TestFileGDB.gdb", geodatabase)) != S_OK)
{
wcout << "An error occurred while opening the geodatabase." << endl;
wcout << "Error code: " << hr << endl;
return -1;
}
wcout << "The geodatabase has been opened." << endl;
std::vector childDatasets;
std::vector childFeatureClass;
hr = getchilddataset(L"//",L"Feature Dataset",childDatasets);
if(S_OK != hr)
{
wprintf(L"%s/n",L"An error occurred whild getchilddata from root");
wprintf(L"Error code: %d/n",hr);
return -1;
}
int index = 0;
int FeatureClassIndex = 0;
int FeatureDataCount = (int)childDatasets.size();
int FeatureClassCount = 0;
wprintf(L"TestFileGDB/n");
//wcout << "--";
for(index = 0; index < FeatureDataCount; index++)
{
std::wstring DatasetName = (std::wstring)childDatasets.at(index);
wcout << " " << DatasetName << endl;
childFeatureClass.clear();
hr = getchilddataset(DatasetName,L"Feature Class",childFeatureClass);
if(S_OK == hr)
{
FeatureClassCount = (int)childFeatureClass.size();
for(FeatureClassIndex = 0; FeatureClassIndex " << FeatureClassName <//",L"Feature Class",childFeatureClass);
FeatureClassCount = (int)childFeatureClass.size();
if(S_OK == hr)
{
for(FeatureClassIndex = 0; FeatureClassIndex < FeatureClassCount; FeatureClassIndex++)
{
std:wstring FeatureClassName = childFeatureClass.at(FeatureClassIndex);
wcout << " " << FeatureClassName < tablelist;
int tablecount = 0;
int tableindex = 0;
std::wstring tablename;
hr = getchilddataset(L"//",L"Table",tablelist);
if(S_OK == hr)
{
tablecount = (int)tablelist.size();
for(tableindex = 0; tableindex < tablecount; tableindex++)
{
tablename = tablelist.at(tableindex);
wcout << " " << tablename << endl;
}
}
// Close the geodatabase before the delete.
if ((hr = CloseGeodatabase(geodatabase)) != S_OK)
{
wcout << "An error occurred while closing the geodatabase." << endl;
wcout << "Error code: " << hr << endl;
return -1;
}
return 0;
}
long getchilddataset(std::wstring parentDataset, std::wstring DatasetType,std::vector& childDatasets)
{
long result = geodatabase.GetChildDatasets(parentDataset,DatasetType,childDatasets);
return result;
}
整个工程会在整个系列完成后上传。
文章来源:http://blog.csdn.net/liufeng1980423/article/details/6218437
0 个评论
推荐内容
相关问题
- 请问大家学习AE开发都参考了哪些资料?
- Arcgis runtime for android初学者该如何系统的学习?
- Linux下如何将ArcGIS Server的服务端口改为80
- 如何对linux上的 ArcGIS Server 的许可进行更新?
- Engine中如何删除mdb或者FileGDB?
- arcgis pro2.8发布使用深度学习分类像素GP报错?
- arcgis pro2.8深度学习,检测变化dlpk现成模型获取?
- Linux上安装ArcGIS Server或者Portal提示缺少gettext包
- ArcGIS Pro2.8使用深度学习分类像素中环境使用GPU报错?
- 请问有没有ArcGIS Engine 10系列视频的清晰版,网上下载的都是很模糊的版本,如果有的话能否发我一份?
- 请问学习arcpy可以有哪些用途