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().
332 GDALDatasetH hdsSrc = NULL;
334 VRTDatasetH hdsDst = NULL;
335 VRTSourcedRasterBandH hbandDst = NULL;
338 double offset[2] = {0};
345 assert(band != NULL);
346 assert(band->
raster != NULL);
349 rterror(
"rt_band_load_offline_data: Band is not offline");
353 rterror(
"rt_band_load_offline_data: Offline band does not a have a specified file");
359 rterror(
"rt_band_load_offline_data: Access to offline bands disabled");
368 if (hdsSrc == NULL) {
369 rterror(
"rt_band_load_offline_data: Cannot open offline raster: %s", band->
data.
offline.path);
374 nband = GDALGetRasterCount(hdsSrc);
376 rterror(
"rt_band_load_offline_data: No bands found in offline raster: %s", band->
data.
offline.path);
382 rterror(
"rt_band_load_offline_data: Specified band %d not found in offline raster: %s", band->
data.
offline.bandNum, band->
data.
offline.path);
389 RASTER_DEBUGF(3,
"Raster geotransform (%f, %f, %f, %f, %f, %f)",
390 gt[0], gt[1], gt[2], gt[3], gt[4], gt[5]);
393 if (GDALGetGeoTransform(hdsSrc, ogt) != CE_None) {
394 RASTER_DEBUG(4,
"Using default geotransform matrix (0, 1, 0, 0, 0, -1)");
402 RASTER_DEBUGF(3,
"Offline geotransform (%f, %f, %f, %f, %f, %f)",
403 ogt[0], ogt[1], ogt[2], ogt[3], ogt[4], ogt[5]);
413 rterror(
"rt_band_load_offline_data: Could not test alignment of in-db representation of out-db raster");
418 rtwarn(
"The in-db representation of the out-db raster is not aligned. Band data may be incorrect");
425 &(offset[0]), &(offset[1]),
433 GDALSetGeoTransform(hdsDst, gt);
440 hbandDst = (VRTSourcedRasterBandH) GDALGetRasterBand(hdsDst, 1);
443 GDALSetRasterNoDataValue(hbandDst, band->
nodataval);
446 hbandDst, GDALGetRasterBand(hdsSrc, band->
data.
offline.bandNum + 1),
447 fabs(offset[0]), fabs(offset[1]),
451 "near", VRT_NODATA_UNSET
455 VRTFlushCache(hdsDst);
472 rterror(
"rt_band_load_offline_data: Cannot load data from offline raster: %s", band->
data.
offline.path);
478 rterror(
"rt_band_load_offline_data: Cannot load data from offline raster: %s", band->
data.
offline.path);
char enable_outdb_rasters
int rt_util_gdal_register_all(int force_register_all)
rt_errorstate rt_raster_same_alignment(rt_raster rast1, rt_raster rast2, int *aligned, char **reason)
void rt_raster_set_geotransform_matrix(rt_raster raster, double *gt)
Set raster's geotransform using 6-element array.
void rt_raster_get_geotransform_matrix(rt_raster raster, double *gt)
Get 6-element array of raster geotransform matrix.
void rterror(const char *fmt,...)
Wrappers used for reporting errors and info.
GDALDataType rt_util_pixtype_to_gdal_datatype(rt_pixtype pt)
Convert rt_pixtype to GDALDataType.
void rtwarn(const char *fmt,...)
rt_band rt_raster_get_band(rt_raster raster, int bandNum)
Return Nth band, or NULL if unavailable.
void rt_raster_set_srid(rt_raster raster, int32_t srid)
Set raster's SRID.
#define RASTER_DEBUGF(level, msg,...)
void rt_raster_destroy(rt_raster raster)
Release memory associated to a raster.
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.
rt_raster rt_raster_new(uint32_t width, uint32_t height)
Construct a raster with given dimensions.
void rtdealloc(void *mem)
#define RASTER_DEBUG(level, msg)
rt_raster rt_raster_from_gdal_dataset(GDALDatasetH ds)
Return a raster from a GDAL dataset.
GDALDatasetH rt_util_gdal_open(const char *fn, GDALAccess fn_access, int shared)