PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ diff_rastinfo()

static void diff_rastinfo ( RASTERINFO x,
RASTERINFO ref 
)
static

Definition at line 600 of file raster2pgsql.c.

References _, rasterinfo_t::bandtype, ES_NONE, rasterinfo_t::gt, rasterinfo_t::hasnodata, rasterinfo_t::nband, rasterinfo_t::nband_count, rt_raster_destroy(), rt_raster_new(), rt_raster_same_alignment(), rt_raster_set_geotransform_matrix(), rterror(), rtwarn(), and rasterinfo_t::tile_size.

Referenced by process_rasters().

600  {
601  static uint8_t msg[6] = {0};
602  int i = 0;
603 
604  /* # of bands */
605  if (
606  !msg[0] &&
607  x->nband_count != ref->nband_count
608  ) {
609  rtwarn(_("Different number of bands found in the set of rasters being converted to PostGIS raster"));
610  msg[0]++;
611  }
612 
613  /* pixel types */
614  if (!msg[1]) {
615  for (i = 0; i < ref->nband_count; i++) {
616  if (x->bandtype[i] != ref->bandtype[i]) {
617  rtwarn(_("Different pixel types found for band %d in the set of rasters being converted to PostGIS raster"), ref->nband[i]);
618  msg[1]++;
619  }
620  }
621  }
622 
623  /* hasnodata */
624  if (!msg[2]) {
625  for (i = 0; i < ref->nband_count; i++) {
626  if (x->hasnodata[i] != ref->hasnodata[i]) {
627  rtwarn(_("Different hasnodata flags found for band %d in the set of rasters being converted to PostGIS raster"), ref->nband[i]);
628  msg[2]++;
629  }
630  }
631  }
632 
633  /* nodataval */
634  if (!msg[3]) {
635  for (i = 0; i < ref->nband_count; i++) {
636  if (!x->hasnodata[i] && !ref->hasnodata[i]) continue;
637  if (x->hasnodata[i] != ref->hasnodata[i]) {
638  rtwarn(_("Different NODATA values found for band %d in the set of rasters being converted to PostGIS raster"), ref->nband[i]);
639  msg[3]++;
640  }
641  }
642  }
643 
644  /* alignment */
645  if (!msg[4]) {
646  rt_raster rx = NULL;
647  rt_raster rref = NULL;
648  int err;
649  int aligned;
650 
651  if (
652  (rx = rt_raster_new(1, 1)) == NULL ||
653  (rref = rt_raster_new(1, 1)) == NULL
654  ) {
655  rterror(_("diff_rastinfo: Could not allocate memory for raster alignment test"));
656  if (rx != NULL) rt_raster_destroy(rx);
657  if (rref != NULL) rt_raster_destroy(rref);
658  return;
659  }
660 
663 
664  err = rt_raster_same_alignment(rx, rref, &aligned, NULL);
665  rt_raster_destroy(rx);
666  rt_raster_destroy(rref);
667  if (err != ES_NONE) {
668  rterror(_("diff_rastinfo: Could not run raster alignment test"));
669  return;
670  }
671 
672  if (!aligned) {
673  rtwarn(_("Raster with different alignment found in the set of rasters being converted to PostGIS raster"));
674  msg[4]++;
675  }
676  }
677 
678  /* tile size */
679  if (!msg[5]) {
680  for (i = 0; i < 2; i++) {
681  if (x->tile_size[i] != ref->tile_size[i]) {
682  rtwarn(_("Different tile sizes found in the set of rasters being converted to PostGIS raster"));
683  msg[5]++;
684  break;
685  }
686  }
687  }
688 }
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&#39;s geotransform using 6-element array.
Definition: rt_raster.c:727
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
int tile_size[2]
Definition: raster2pgsql.h:191
void rtwarn(const char *fmt,...)
Definition: rt_context.c:224
void rt_raster_destroy(rt_raster raster)
Release memory associated to a raster.
Definition: rt_raster.c:82
rt_raster rt_raster_new(uint32_t width, uint32_t height)
Construct a raster with given dimensions.
Definition: rt_raster.c:48
unsigned char uint8_t
Definition: uthash.h:79
double gt[6]
Definition: raster2pgsql.h:188
Here is the call graph for this function:
Here is the caller graph for this function: