/src/gdal/frmts/pcraster/libcsf/ismv.c
Line | Count | Source |
1 | | #include "csf.h" |
2 | | #include "csfimpl.h" |
3 | | |
4 | | /* test if a value is missing value |
5 | | * returns 0 if not, nonzero if it is a missing value |
6 | | */ |
7 | | int IsMV( |
8 | | const MAP *map, /* map handle */ |
9 | | const void *cellValue) /* value to be tested */ |
10 | 2 | { |
11 | 2 | return(IsMVcellRepr(map->appCR, cellValue)); |
12 | 2 | } |
13 | | |
14 | | /* test if a value is missing value |
15 | | * returns 0 if not, nonzero if it is a missing value |
16 | | */ |
17 | | int IsMVcellRepr( |
18 | | CSF_CR cellRepr, /* cell representation of argument cellValue. |
19 | | * That is one of the constants prefixed by CR_. |
20 | | */ |
21 | | const void *cellValue) /* value to be tested */ |
22 | 2 | { |
23 | | |
24 | 2 | if (IS_SIGNED(cellRepr)) |
25 | 2 | switch ( (cellRepr & CSF_SIZE_MV_MASK ) >> CSF_POS_SIZE_MV_MASK) |
26 | 2 | { |
27 | 0 | case 0: return(*((const INT1 *)cellValue) == MV_INT1); |
28 | 2 | case 1: return(*((const INT2 *)cellValue) == MV_INT2); |
29 | 0 | default:return(*((const INT4 *)cellValue) == MV_INT4); |
30 | 2 | } |
31 | 0 | else |
32 | 0 | if (IS_REAL(cellRepr)) |
33 | 0 | { |
34 | 0 | if (cellRepr == CR_REAL4) |
35 | 0 | return(IS_MV_REAL4(cellValue)); |
36 | 0 | else |
37 | 0 | return(IS_MV_REAL8(cellValue)); |
38 | 0 | } |
39 | 0 | else |
40 | 0 | { |
41 | 0 | switch ( (cellRepr & CSF_SIZE_MV_MASK ) >> CSF_POS_SIZE_MV_MASK) |
42 | 0 | { |
43 | 0 | case 0: return(*((const UINT1 *)cellValue) == MV_UINT1); |
44 | 0 | case 1: return(*((const UINT2 *)cellValue) == MV_UINT2); |
45 | 0 | default: return(*((const UINT4 *)cellValue) == MV_UINT4); |
46 | 0 | } |
47 | 0 | } |
48 | 2 | } |