void getbasicdata(vector<string>filepath,int &file_count,int &width,int &height,int &depth,int &bandNum,const char* p,double* ad, GDALDataType &gdal_datatype)
{
file_count = filepath.size();
const char* pszFile = filepath[0].c_str();
GDALAllRegister();
CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "NO");
GDALDataset *poDataset = (GDALDataset*)GDALOpen(pszFile, GA_ReadOnly);
GDALRasterBand *poBand;
poBand= poDataset->GetRasterBand(1);
p = poDataset->GetProjectionRef();
poDataset->GetGeoTransform(ad);
gdal_datatype = poBand->GetRasterDataType();
width = poBand->GetXSize();
height= poBand->GetYSize();
depth = GDALGetDataTypeSize(poDataset->GetRasterBand(1)->GetRasterDataType()) / 8;
bandNum = poDataset->GetRasterCount();
GDALClose(poDataset);
}
double *open_tif(vector<string>filepath, double* data, int file_count, int w, int h,GDALDataType gdal_datatype)
{
int file_number = 0;
for (vector<string>::iterator it = filepath.begin(); it != filepath.end(); it++)
{
const char* pszFile = it->c_str();
GDALAllRegister();
CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "NO");
GDALDataset *poDataset = (GDALDataset*)GDALOpen(pszFile, GA_ReadOnly);
GDALRasterBand * pRasterBand;
pRasterBand = poDataset->GetRasterBand(1);
double noData = poDataset->GetRasterBand(1)->GetNoDataValue();
double *mat = new double [w*h];
pRasterBand->RasterIO(GF_Read, 0, 0, w, h, mat, w, h, GDT_Float64, 0, 0);
for (int i = 0; i < w*h; i++)
{
data[file_number*w*h + i] = mat[i];
}
file_number++;
GDALClose(poDataset);
mat = NULL;
delete mat;
}
return data;
}