PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ diff_rastinfo()

static void diff_rastinfo ( RASTERINFO x,
RASTERINFO ref 
)
static

Definition at line 589 of file raster2pgsql.c.

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

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().

Here is the call graph for this function:
Here is the caller graph for this function: