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

◆ rt_util_dbl_trunc_warning()

int rt_util_dbl_trunc_warning ( double  initialvalue,
int32_t  checkvalint,
uint32_t  checkvaluint,
float  checkvalfloat,
double  checkvaldouble,
rt_pixtype  pixtype 
)

Definition at line 778 of file rt_util.c.

783 {
784 int result = 0;
785
786 switch (pixtype) {
787 case PT_1BB:
788 case PT_2BUI:
789 case PT_4BUI:
790 case PT_8BSI:
791 case PT_8BUI:
792 case PT_16BSI:
793 case PT_16BUI:
794 case PT_32BSI: {
795 if (fabs(checkvalint - initialvalue) >= 1) {
796#if POSTGIS_RASTER_WARN_ON_TRUNCATION > 0
797 rtwarn("Value set for %s band got clamped from %f to %d",
798 rt_pixtype_name(pixtype),
799 initialvalue, checkvalint
800 );
801#endif
802 result = 1;
803 }
804 else if (checkvalint != initialvalue)
805 {
806#if POSTGIS_RASTER_WARN_ON_TRUNCATION > 0
807 rtwarn("Value set for %s band got truncated from %f to %d",
808 rt_pixtype_name(pixtype),
809 initialvalue, checkvalint
810 );
811#endif
812 result = 1;
813 }
814 break;
815 }
816 case PT_32BUI: {
817 if (fabs(checkvaluint - initialvalue) >= 1)
818 {
819#if POSTGIS_RASTER_WARN_ON_TRUNCATION > 0
820 rtwarn("Value set for %s band got clamped from %f to %u",
821 rt_pixtype_name(pixtype),
822 initialvalue,
823 checkvaluint);
824#endif
825 result = 1;
826 }
827 else if (checkvaluint != initialvalue)
828 {
829#if POSTGIS_RASTER_WARN_ON_TRUNCATION > 0
830 rtwarn("Value set for %s band got truncated from %f to %u",
831 rt_pixtype_name(pixtype),
832 initialvalue, checkvaluint
833 );
834#endif
835 result = 1;
836 }
837 break;
838 }
839 case PT_16BF:
840 case PT_32BF: {
841 /*
842 For float, because the initial value is a double,
843 there is very often a difference between the desired value and the obtained one
844 */
845 if (FLT_NEQ(checkvalfloat, initialvalue)) {
846#if POSTGIS_RASTER_WARN_ON_TRUNCATION > 0
847 rtwarn("Value set for %s band got converted from %f to %f",
848 rt_pixtype_name(pixtype),
849 initialvalue, checkvalfloat
850 );
851#endif
852 result = 1;
853 }
854 break;
855 }
856 case PT_64BF: {
857 if (FLT_NEQ(checkvaldouble, initialvalue)) {
858#if POSTGIS_RASTER_WARN_ON_TRUNCATION > 0
859 rtwarn("Value set for %s band got converted from %f to %f",
860 rt_pixtype_name(pixtype),
861 initialvalue, checkvaldouble
862 );
863#endif
864 result = 1;
865 }
866 break;
867 }
868 case PT_END:
869 break;
870 }
871
872 return result;
873}
char result[OUT_DOUBLE_BUFFER_SIZE]
Definition cu_print.c:267
#define FLT_NEQ(x, y)
Definition librtcore.h:2435
void void void rtwarn(const char *fmt,...) __attribute__((format(printf
@ PT_32BUI
Definition librtcore.h:197
@ PT_16BF
Definition librtcore.h:198
@ PT_2BUI
Definition librtcore.h:190
@ PT_32BSI
Definition librtcore.h:196
@ PT_END
Definition librtcore.h:201
@ PT_4BUI
Definition librtcore.h:191
@ PT_32BF
Definition librtcore.h:199
@ PT_1BB
Definition librtcore.h:189
@ PT_16BUI
Definition librtcore.h:195
@ PT_8BSI
Definition librtcore.h:192
@ PT_16BSI
Definition librtcore.h:194
@ PT_64BF
Definition librtcore.h:200
@ PT_8BUI
Definition librtcore.h:193
const char * rt_pixtype_name(rt_pixtype pixtype)
Definition rt_pixel.c:114

References FLT_NEQ, PT_16BF, PT_16BSI, PT_16BUI, PT_1BB, PT_2BUI, PT_32BF, PT_32BSI, PT_32BUI, PT_4BUI, PT_64BF, PT_8BSI, PT_8BUI, PT_END, result, rt_pixtype_name(), and rtwarn().

Referenced by rt_band_init_value(), rt_band_set_nodata(), and rt_band_set_pixel().

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