PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ copy_rastinfo()

static int copy_rastinfo ( RASTERINFO dst,
RASTERINFO src 
)
static

Definition at line 542 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().

542  {
543  if (src->srs != NULL) {
544  dst->srs = rtalloc(sizeof(char) * (strlen(src->srs) + 1));
545  if (dst->srs == NULL) {
546  rterror(_("copy_rastinfo: Not enough memory"));
547  return 0;
548  }
549  strcpy(dst->srs, src->srs);
550  }
551  memcpy(dst->dim, src->dim, sizeof(uint32_t) * 2);
552  dst->nband_count = src->nband_count;
553  if (src->nband_count && src->nband != NULL) {
554  dst->nband = rtalloc(sizeof(int) * src->nband_count);
555  if (dst->nband == NULL) {
556  rterror(_("copy_rastinfo: Not enough memory"));
557  return 0;
558  }
559  memcpy(dst->nband, src->nband, sizeof(int) * src->nband_count);
560  }
561  if (src->gdalbandtype != NULL) {
562  dst->gdalbandtype = rtalloc(sizeof(GDALDataType) * src->nband_count);
563  if (dst->gdalbandtype == NULL) {
564  rterror(_("copy_rastinfo: Not enough memory"));
565  return 0;
566  }
567  memcpy(dst->gdalbandtype, src->gdalbandtype, sizeof(GDALDataType) * src->nband_count);
568  }
569  if (src->bandtype != NULL) {
570  dst->bandtype = rtalloc(sizeof(rt_pixtype) * src->nband_count);
571  if (dst->bandtype == NULL) {
572  rterror(_("copy_rastinfo: Not enough memory"));
573  return 0;
574  }
575  memcpy(dst->bandtype, src->bandtype, sizeof(rt_pixtype) * src->nband_count);
576  }
577  if (src->hasnodata != NULL) {
578  dst->hasnodata = rtalloc(sizeof(int) * src->nband_count);
579  if (dst->hasnodata == NULL) {
580  rterror(_("copy_rastinfo: Not enough memory"));
581  return 0;
582  }
583  memcpy(dst->hasnodata, src->hasnodata, sizeof(int) * src->nband_count);
584  }
585  if (src->nodataval != NULL) {
586  dst->nodataval = rtalloc(sizeof(double) * src->nband_count);
587  if (dst->nodataval == NULL) {
588  rterror(_("copy_rastinfo: Not enough memory"));
589  return 0;
590  }
591  memcpy(dst->nodataval, src->nodataval, sizeof(double) * src->nband_count);
592  }
593  memcpy(dst->gt, src->gt, sizeof(double) * 6);
594  memcpy(dst->tile_size, src->tile_size, sizeof(int) * 2);
595 
596  return 1;
597 }
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
double gt[6]
Definition: raster2pgsql.h:188
Here is the call graph for this function:
Here is the caller graph for this function: