PostGIS  2.1.10dev-r@@SVN_REVISION@@
static void diff_rastinfo ( RASTERINFO x,
RASTERINFO ref 
)
static

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

593  {
594  static uint8_t msg[6] = {0};
595  int i = 0;
596 
597  /* # of bands */
598  if (
599  !msg[0] &&
600  x->nband_count != ref->nband_count
601  ) {
602  rtwarn(_("Different number of bands found in the set of rasters being converted to PostGIS raster"));
603  msg[0]++;
604  }
605 
606  /* pixel types */
607  if (!msg[1]) {
608  for (i = 0; i < ref->nband_count; i++) {
609  if (x->bandtype[i] != ref->bandtype[i]) {
610  rtwarn(_("Different pixel types found for band %d in the set of rasters being converted to PostGIS raster"), ref->nband[i]);
611  msg[1]++;
612  }
613  }
614  }
615 
616  /* hasnodata */
617  if (!msg[2]) {
618  for (i = 0; i < ref->nband_count; i++) {
619  if (x->hasnodata[i] != ref->hasnodata[i]) {
620  rtwarn(_("Different hasnodata flags found for band %d in the set of rasters being converted to PostGIS raster"), ref->nband[i]);
621  msg[2]++;
622  }
623  }
624  }
625 
626  /* nodataval */
627  if (!msg[3]) {
628  for (i = 0; i < ref->nband_count; i++) {
629  if (!x->hasnodata[i] && !ref->hasnodata[i]) continue;
630  if (x->hasnodata[i] != ref->hasnodata[i]) {
631  rtwarn(_("Different NODATA values found for band %d in the set of rasters being converted to PostGIS raster"), ref->nband[i]);
632  msg[3]++;
633  }
634  }
635  }
636 
637  /* alignment */
638  if (!msg[4]) {
639  rt_raster rx = NULL;
640  rt_raster rref = NULL;
641  int err;
642  int aligned;
643 
644  if (
645  (rx = rt_raster_new(1, 1)) == NULL ||
646  (rref = rt_raster_new(1, 1)) == NULL
647  ) {
648  rterror(_("diff_rastinfo: Could not allocate memory for raster alignment test"));
649  if (rx != NULL) rt_raster_destroy(rx);
650  if (rref != NULL) rt_raster_destroy(rref);
651  return;
652  }
653 
656 
657  err = rt_raster_same_alignment(rx, rref, &aligned, NULL);
658  rt_raster_destroy(rx);
659  rt_raster_destroy(rref);
660  if (err != ES_NONE) {
661  rterror(_("diff_rastinfo: Could not run raster alignment test"));
662  return;
663  }
664 
665  if (!aligned) {
666  rtwarn(_("Raster with different alignment found in the set of rasters being converted to PostGIS raster"));
667  msg[4]++;
668  }
669  }
670 
671  /* tile size */
672  if (!msg[5]) {
673  for (i = 0; i < 2; i++) {
674  if (x->tile_size[i] != ref->tile_size[i]) {
675  rtwarn(_("Different tile sizes found in the set of rasters being converted to PostGIS raster"));
676  msg[5]++;
677  break;
678  }
679  }
680  }
681 }
void rt_raster_destroy(rt_raster raster)
Release memory associated to a raster.
Definition: rt_api.c:5387
rt_pixtype * bandtype
Definition: raster2pgsql.h:175
#define _(String)
Definition: shpcommon.h:23
int tile_size[2]
Definition: raster2pgsql.h:186
void rtwarn(const char *fmt,...)
Definition: rt_api.c:920
void rt_raster_set_geotransform_matrix(rt_raster raster, double *gt)
Set raster's geotransform using 6-element array.
Definition: rt_api.c:6026
void rterror(const char *fmt,...)
Raster core error and info handlers.
Definition: rt_api.c:895
rt_raster rt_raster_new(uint32_t width, uint32_t height)
Construct a raster with given dimensions.
Definition: rt_api.c:5353
rt_errorstate rt_raster_same_alignment(rt_raster rast1, rt_raster rast2, int *aligned, char **reason)
Definition: rt_api.c:12774
double gt[6]
Definition: raster2pgsql.h:183

Here is the call graph for this function:

Here is the caller graph for this function: