PostGIS  2.5.0beta2dev-r@@SVN_REVISION@@

◆ diff_rastinfo()

static void diff_rastinfo ( RASTERINFO x,
RASTERINFO ref 
)
static

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

603  {
604  static uint8_t msg[6] = {0};
605  uint32_t i = 0;
606 
607  /* # of bands */
608  if (
609  !msg[0] &&
610  x->nband_count != ref->nband_count
611  ) {
612  rtwarn(_("Different number of bands found in the set of rasters being converted to PostGIS raster"));
613  msg[0]++;
614  }
615 
616  /* pixel types */
617  if (!msg[1]) {
618  for (i = 0; i < ref->nband_count; i++) {
619  if (x->bandtype[i] != ref->bandtype[i]) {
620  rtwarn(_("Different pixel types found for band %d in the set of rasters being converted to PostGIS raster"), ref->nband[i]);
621  msg[1]++;
622  }
623  }
624  }
625 
626  /* hasnodata */
627  if (!msg[2]) {
628  for (i = 0; i < ref->nband_count; i++) {
629  if (x->hasnodata[i] != ref->hasnodata[i]) {
630  rtwarn(_("Different hasnodata flags found for band %d in the set of rasters being converted to PostGIS raster"), ref->nband[i]);
631  msg[2]++;
632  }
633  }
634  }
635 
636  /* nodataval */
637  if (!msg[3]) {
638  for (i = 0; i < ref->nband_count; i++) {
639  if (!x->hasnodata[i] && !ref->hasnodata[i]) continue;
640  if (x->hasnodata[i] != ref->hasnodata[i]) {
641  rtwarn(_("Different NODATA values found for band %d in the set of rasters being converted to PostGIS raster"), ref->nband[i]);
642  msg[3]++;
643  }
644  }
645  }
646 
647  /* alignment */
648  if (!msg[4]) {
649  rt_raster rx = NULL;
650  rt_raster rref = NULL;
651  int err;
652  int aligned;
653 
654  if (
655  (rx = rt_raster_new(1, 1)) == NULL ||
656  (rref = rt_raster_new(1, 1)) == NULL
657  ) {
658  rterror(_("diff_rastinfo: Could not allocate memory for raster alignment test"));
659  if (rx != NULL) rt_raster_destroy(rx);
660  if (rref != NULL) rt_raster_destroy(rref);
661  return;
662  }
663 
666 
667  err = rt_raster_same_alignment(rx, rref, &aligned, NULL);
668  rt_raster_destroy(rx);
669  rt_raster_destroy(rref);
670  if (err != ES_NONE) {
671  rterror(_("diff_rastinfo: Could not run raster alignment test"));
672  return;
673  }
674 
675  if (!aligned) {
676  rtwarn(_("Raster with different alignment found in the set of rasters being converted to PostGIS raster"));
677  msg[4]++;
678  }
679  }
680 
681  /* tile size */
682  if (!msg[5]) {
683  for (i = 0; i < 2; i++) {
684  if (x->tile_size[i] != ref->tile_size[i]) {
685  rtwarn(_("Different tile sizes found in the set of rasters being converted to PostGIS raster"));
686  msg[5]++;
687  break;
688  }
689  }
690  }
691 }
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
unsigned int uint32_t
Definition: uthash.h:78
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
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: