GDALDataset的创建和销毁

本文通过一个示例程序探讨GDALDataset的创建与销毁过程,展示了如何打开TIFF文件并读取其基本信息。尽管示例为简化版,未采用C++的面向对象方式组织代码,但清晰地呈现了GDALDataset的使用方法。
摘要由CSDN通过智能技术生成

之前在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 != "") {
	
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值