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

◆ diff_rastinfo()

static void diff_rastinfo ( RASTERINFO x,
RASTERINFO ref 
)
static

Definition at line 578 of file raster2pgsql.c.

578 {
579 static uint8_t msg[6] = {0};
580 uint32_t i = 0;
581
582 /* # of bands */
583 if (
584 !msg[0] &&
585 x->nband_count != ref->nband_count
586 ) {
587 rtwarn(_("Different number of bands found in the set of rasters being converted to PostGIS raster"));
588 msg[0]++;
589 }
590
591 /* pixel types */
592 if (!msg[1]) {
593 for (i = 0; i < ref->nband_count; i++) {
594 if (x->bandtype[i] != ref->bandtype[i]) {
595 rtwarn(_("Different pixel types found for band %d in the set of rasters being converted to PostGIS raster"), ref->nband[i]);
596 msg[1]++;
597 }
598 }
599 }
600
601 /* hasnodata */
602 if (!msg[2]) {
603 for (i = 0; i < ref->nband_count; i++) {
604 if (x->hasnodata[i] != ref->hasnodata[i]) {
605 rtwarn(_("Different hasnodata flags found for band %d in the set of rasters being converted to PostGIS raster"), ref->nband[i]);
606 msg[2]++;
607 }
608 }
609 }
610
611 /* nodataval */
612 if (!msg[3]) {
613 for (i = 0; i < ref->nband_count; i++) {
614 if (!x->hasnodata[i] && !ref->hasnodata[i]) continue;
615 if (x->hasnodata[i] != ref->hasnodata[i]) {
616 rtwarn(_("Different NODATA values found for band %d in the set of rasters being converted to PostGIS raster"), ref->nband[i]);
617 msg[3]++;
618 }
619 }
620 }
621
622 /* alignment */
623 if (!msg[4]) {
624 rt_raster rx = NULL;
625 rt_raster rref = NULL;
626 int err;
627 int aligned;
628
629 if (
630 (rx = rt_raster_new(1, 1)) == NULL ||
631 (rref = rt_raster_new(1, 1)) == NULL
632 ) {
633 rterror(_("diff_rastinfo: Could not allocate memory for raster alignment test"));
634 if (rx != NULL) rt_raster_destroy(rx);
635 if (rref != NULL) rt_raster_destroy(rref);
636 return;
637 }
638
641
642 err = rt_raster_same_alignment(rx, rref, &aligned, NULL);
644 rt_raster_destroy(rref);
645 if (err != ES_NONE) {
646 rterror(_("diff_rastinfo: Could not run raster alignment test"));
647 return;
648 }
649
650 if (!aligned) {
651 rtwarn(_("Raster with different alignment found in the set of rasters being converted to PostGIS raster"));
652 msg[4]++;
653 }
654 }
655
656 /* tile size */
657 if (!msg[5]) {
658 for (i = 0; i < 2; i++) {
659 if (x->tile_size[i] != ref->tile_size[i]) {
660 rtwarn(_("Different tile sizes found in the set of rasters being converted to PostGIS raster"));
661 msg[5]++;
662 break;
663 }
664 }
665 }
666}
void rterror(const char *fmt,...)
Wrappers used for reporting errors and info.
Definition rt_context.c:199
void rt_raster_set_geotransform_matrix(rt_raster raster, double *gt)
Set raster's geotransform using 6-element array.
Definition rt_raster.c:727
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
void rtwarn(const char *fmt,...)
Definition rt_context.c:224
@ ES_NONE
Definition librtcore.h:180
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: