PostGIS  3.0.0dev-r@@SVN_REVISION@@

◆ copy_rastinfo()

static int copy_rastinfo ( RASTERINFO dst,
RASTERINFO src 
)
static

Definition at line 545 of file raster2pgsql.c.

References _, rasterinfo_t::bandtype, rasterinfo_t::dim, rasterinfo_t::gdalbandtype, rasterinfo_t::gt, rasterinfo_t::hasnodata, rasterinfo_t::nband, rasterinfo_t::nband_count, rasterinfo_t::nodataval, rtalloc(), rterror(), rasterinfo_t::srs, and rasterinfo_t::tile_size.

Referenced by process_rasters().

545  {
546  if (src->srs != NULL) {
547  dst->srs = rtalloc(sizeof(char) * (strlen(src->srs) + 1));
548  if (dst->srs == NULL) {
549  rterror(_("copy_rastinfo: Not enough memory"));
550  return 0;
551  }
552  strcpy(dst->srs, src->srs);
553  }
554  memcpy(dst->dim, src->dim, sizeof(uint32_t) * 2);
555  dst->nband_count = src->nband_count;
556  if (src->nband_count && src->nband != NULL) {
557  dst->nband = rtalloc(sizeof(int) * src->nband_count);
558  if (dst->nband == NULL) {
559  rterror(_("copy_rastinfo: Not enough memory"));
560  return 0;
561  }
562  memcpy(dst->nband, src->nband, sizeof(int) * src->nband_count);
563  }
564  if (src->gdalbandtype != NULL) {
565  dst->gdalbandtype = rtalloc(sizeof(GDALDataType) * src->nband_count);
566  if (dst->gdalbandtype == NULL) {
567  rterror(_("copy_rastinfo: Not enough memory"));
568  return 0;
569  }
570  memcpy(dst->gdalbandtype, src->gdalbandtype, sizeof(GDALDataType) * src->nband_count);
571  }
572  if (src->bandtype != NULL) {
573  dst->bandtype = rtalloc(sizeof(rt_pixtype) * src->nband_count);
574  if (dst->bandtype == NULL) {
575  rterror(_("copy_rastinfo: Not enough memory"));
576  return 0;
577  }
578  memcpy(dst->bandtype, src->bandtype, sizeof(rt_pixtype) * src->nband_count);
579  }
580  if (src->hasnodata != NULL) {
581  dst->hasnodata = rtalloc(sizeof(int) * src->nband_count);
582  if (dst->hasnodata == NULL) {
583  rterror(_("copy_rastinfo: Not enough memory"));
584  return 0;
585  }
586  memcpy(dst->hasnodata, src->hasnodata, sizeof(int) * src->nband_count);
587  }
588  if (src->nodataval != NULL) {
589  dst->nodataval = rtalloc(sizeof(double) * src->nband_count);
590  if (dst->nodataval == NULL) {
591  rterror(_("copy_rastinfo: Not enough memory"));
592  return 0;
593  }
594  memcpy(dst->nodataval, src->nodataval, sizeof(double) * src->nband_count);
595  }
596  memcpy(dst->gt, src->gt, sizeof(double) * 6);
597  memcpy(dst->tile_size, src->tile_size, sizeof(int) * 2);
598 
599  return 1;
600 }
GDALDataType * gdalbandtype
Definition: raster2pgsql.h:179
rt_pixtype * bandtype
Definition: raster2pgsql.h:180
#define _(String)
Definition: shpcommon.h:24
void rterror(const char *fmt,...)
Wrappers used for reporting errors and info.
Definition: rt_context.c:199
void * rtalloc(size_t size)
Wrappers used for managing memory.
Definition: rt_context.c:171
int tile_size[2]
Definition: raster2pgsql.h:191
rt_pixtype
Definition: librtcore.h:185
unsigned int uint32_t
Definition: uthash.h:78
uint32_t dim[2]
Definition: raster2pgsql.h:172
double * nodataval
Definition: raster2pgsql.h:185
uint32_t nband_count
Definition: raster2pgsql.h:176
double gt[6]
Definition: raster2pgsql.h:188
Here is the call graph for this function:
Here is the caller graph for this function: