FileGDB API for linux学习系列之三,检索目录树
2011-03-02 16:03
489 查看
使用FileGDB API提供的函数GetChildDatasets可以像ArcCatalog一样,访问FileGDB的目录结构,包括FileGDB所包括的FeatureDataset,FeatureClass,RasterDatast,RasterCatalog,MosaicDataset等等,在FileGDB API中一共包含以下几种类型:
以下的步骤是访问FileGDB中根目录中所有的FeatureDataset以及各个FeatureDataset下所包括的FeatureClass的代码以及实现结果。
1. 使用ArcCatalog创建一个FileGDB,名称为TestFileGDB,向其中录入一些FeatureDataset以及FeatureClass和普通表,结果如下图:
2. 自己写个例子程序运行结果如下,(此程序纯c++实现的console例子程序,没有使用任何的linux的界面库)
3. 实现代码如下:
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; }
整个工程会在整个系列完成后上传。
相关文章推荐
- FileGDB API for linux 学习系列之四,XML Schema of Geodatabase
- FileGDB API for linux 学习系列之二,编译Display例子程序
- FileGDB API for linux 学习系列之六,对象的创建
- FileGDB API for linux 学习系列之一,编译例子程序
- FileGDB API for linux学习之八,空间数据解析库
- FileGDB API for linux 学习之七,数据的查询
- linux命令学习系列9-目录相关操作cd,mkdir,rmdir,cp
- linux 学习系列-Linux 系统目录结构
- Linux 系统化学习系列文章总目录(持续更新中)
- linux 学习系列-Linux 文件与目录管理
- ArcGIS API for JavaScript 4.2学习笔记[0] AJS4.2概述、新特性、未来产品线计划与AJS笔记目录
- [置顶] 目录:ArcGIS API For Javascipt基础学习
- Linux学习--第十一天--source、环境变量目录、欢迎信息、正则、cut、awk、sed、sort、判断表达式、if、for、case、一些脚本
- 每天一个linux命令目录 开始详细系统的学习linux常用命令,坚持每天一个命令,所以这个系列为每天一个linux命令。学习的主要参考资料为: 1.《鸟哥的linux私房菜》 2.
- linux学习系列-目录结构
- Linux 系统化学习系列文章总目录(持续更新中)
- 【Linux基础学习之四】文件系统的基础知识总结(主要目录结构、文件类型、mount、硬连接)
- 全文检索学习历程目录结构(Lucene、ElasticSearch)
- 【linux系列学习一】linux下查看CPU信息[/proc/cpuinfo]
- 【嵌入式Linux学习七步曲之第三篇 Linux系统bootlaoder移植】U-BOOT全线移植分析系列之一--BOOTLOADER介绍