Load offline band's data.
Loaded data is internally owned and should not be released by the caller. Data will be released when band is destroyed with rt_band_destroy().
430 GDALDatasetH hdsSrc = NULL;
432 VRTDatasetH hdsDst = NULL;
433 VRTSourcedRasterBandH hbandDst = NULL;
435 double offset[2] = {0};
442 assert(
band != NULL);
443 assert(
band->raster != NULL);
445 if (!
band->offline) {
446 rterror(
"rt_band_load_offline_data: Band is not offline");
449 else if (!strlen(
band->data.offline.path)) {
450 rterror(
"rt_band_load_offline_data: Offline band does not a have a specified file");
456 rterror(
"rt_band_load_offline_data: Access to offline bands disabled");
462 if (hdsSrc == NULL) {
463 rterror(
"rt_band_load_offline_data: Cannot open offline raster: %s",
band->data.offline.path);
468 nband = GDALGetRasterCount(hdsSrc);
470 rterror(
"rt_band_load_offline_data: No bands found in offline raster: %s",
band->data.offline.path);
475 else if (
band->data.offline.bandNum + 1 >
nband) {
476 rterror(
"rt_band_load_offline_data: Specified band %d not found in offline raster: %s",
band->data.offline.bandNum,
band->data.offline.path);
482 if (GDALGetGeoTransform(hdsSrc, ogt) != CE_None) {
483 RASTER_DEBUG(4,
"Using default geotransform matrix (0, 1, 0, 0, 0, -1)");
491 RASTER_DEBUGF(3,
"Offline geotransform (%f, %f, %f, %f, %f, %f)",
492 ogt[0], ogt[1], ogt[2], ogt[3], ogt[4], ogt[5]);
502 rterror(
"rt_band_load_offline_data: Could not test alignment of in-db representation of out-db raster");
507 rtwarn(
"The in-db representation of the out-db raster is not aligned. Band data may be incorrect");
514 &(offset[0]), &(offset[1]),
521 hdsDst = VRTCreate(
band->width,
band->height);
522 GDALSetGeoTransform(hdsDst, ogt);
529 hbandDst = (VRTSourcedRasterBandH) GDALGetRasterBand(hdsDst, 1);
532 GDALSetRasterNoDataValue(hbandDst,
band->nodataval);
535 hbandDst, GDALGetRasterBand(hdsSrc,
band->data.offline.bandNum + 1),
536 fabs(offset[0]), fabs(offset[1]),
540 "near", VRT_NODATA_UNSET
544 VRTFlushCache(hdsDst);
561 rterror(
"rt_band_load_offline_data: Cannot load data from offline raster: %s",
band->data.offline.path);
567 rterror(
"rt_band_load_offline_data: Cannot load data from offline raster: %s",
band->data.offline.path);
573 if (
band->data.offline.mem != NULL) {
575 band->data.offline.mem = NULL;
void rterror(const char *fmt,...)
Wrappers used for reporting errors and info.
#define RASTER_DEBUG(level, msg)
int rt_util_gdal_register_all(int force_register_all)
#define RASTER_DEBUGF(level, msg,...)
void rt_raster_set_geotransform_matrix(rt_raster raster, double *gt)
Set raster's geotransform using 6-element array.
rt_errorstate rt_raster_geopoint_to_cell(rt_raster raster, double xw, double yw, double *xr, double *yr, double *igt)
Convert an xw, yw map point to a xr, yr raster point.
void rt_raster_destroy(rt_raster raster)
Release memory associated to a raster.
rt_raster rt_raster_new(uint32_t width, uint32_t height)
Construct a raster with given dimensions.
GDALDataType rt_util_pixtype_to_gdal_datatype(rt_pixtype pt)
Convert rt_pixtype to GDALDataType.
rt_raster rt_raster_from_gdal_dataset(GDALDatasetH ds)
Return a raster from a GDAL dataset.
void rtwarn(const char *fmt,...)
GDALDatasetH rt_util_gdal_open(const char *fn, GDALAccess fn_access, int shared)
void rt_raster_set_srid(rt_raster raster, int32_t srid)
Set raster's SRID.
void rtdealloc(void *mem)
rt_errorstate rt_raster_same_alignment(rt_raster rast1, rt_raster rast2, int *aligned, char **reason)
rt_band rt_raster_get_band(rt_raster raster, int bandNum)
Return Nth band, or NULL if unavailable.
char enable_outdb_rasters