634 {
635 int result = 0;
636
637 switch (pixtype) {
646 if (fabs(checkvalint - initialvalue) >= 1) {
647#if POSTGIS_RASTER_WARN_ON_TRUNCATION > 0
648 rtwarn(
"Value set for %s band got clamped from %f to %d",
650 initialvalue, checkvalint
651 );
652#endif
653 result = 1;
654 }
655 else if (checkvalint != initialvalue)
656 {
657#if POSTGIS_RASTER_WARN_ON_TRUNCATION > 0
658 rtwarn(
"Value set for %s band got truncated from %f to %d",
660 initialvalue, checkvalint
661 );
662#endif
663 result = 1;
664 }
665 break;
666 }
668 if (fabs(checkvaluint - initialvalue) >= 1) {
669#if POSTGIS_RASTER_WARN_ON_TRUNCATION > 0
670 rtwarn(
"Value set for %s band got clamped from %f to %u",
672 initialvalue, checkvaluint
673 );
674#endif
675 result = 1;
676 }
677 else if (checkvaluint != initialvalue)
678 {
679#if POSTGIS_RASTER_WARN_ON_TRUNCATION > 0
680 rtwarn(
"Value set for %s band got truncated from %f to %u",
682 initialvalue, checkvaluint
683 );
684#endif
685 result = 1;
686 }
687 break;
688 }
690
691
692
693
694 if (
FLT_NEQ(checkvalfloat, initialvalue)) {
695#if POSTGIS_RASTER_WARN_ON_TRUNCATION > 0
696 rtwarn(
"Value set for %s band got converted from %f to %f",
698 initialvalue, checkvalfloat
699 );
700#endif
701 result = 1;
702 }
703 break;
704 }
706 if (
FLT_NEQ(checkvaldouble, initialvalue)) {
707#if POSTGIS_RASTER_WARN_ON_TRUNCATION > 0
708 rtwarn(
"Value set for %s band got converted from %f to %f",
710 initialvalue, checkvaldouble
711 );
712#endif
713 result = 1;
714 }
715 break;
716 }
718 break;
719 }
720
721 return result;
722}
const char * rt_pixtype_name(rt_pixtype pixtype)
void rtwarn(const char *fmt,...)