之前在GDALDestroyDriverManager 分析中没有看到对dGDALDatasert的回收。先看一个例子程序,这个例子打开了一个tif文件,读取了一些基本信息。
为了简单示范,没有写成C++的各种类分散到各个文件中。
#include "stdafx.h"
#include "gdal_priv.h"
#include "cpl_conv.h" // for CPLMalloc()
#include <string>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <boost/cstdint.hpp>
using namespace std;
void print_line() {
cout << "----------------------" << endl;
}
void printDataType(GDALDataType type) {
if (type == GDALDataType::GDT_Byte) {
cout << "GDALDataType: GDT_Byte" << endl;
} else {
cout << "GDALDataType: GDT_Unknown" << endl;
}
}
void printAccess(GDALAccess access) {
if (access == GDALAccess::GA_ReadOnly) {
cout << "GDALAccess: GA_ReadOnly" << endl;
} else {
cout << "GDALAccess: GA_Update" << endl;
}
}
void printCategoryNames(char** names) {
if (names == NULL) {
cout << "non category names" << endl;
return;
}
size_t i = 0;
char* str = names[i];
while(str != "") {