1 #include "csf.h"
2 #include "csfimpl.h"
3 
4 /* get maximum cell value
5  * RgetMaxVal returns the value stored in
6  * the header as the maximum value.
7  * If the minMaxStatus is MM_WRONGVALUE
8  * then a missing value is returned.
9  * returns 0 if argument maxVal is returned with a missing
10  * value, nonzero if not.
11  *
12  * example
13  * .so examples/csfstat.tr
14  */
RgetMaxVal(const MAP * map,void * maxVal)15 int RgetMaxVal(
16 	const MAP *map, /* map handle */
17 	void *maxVal)   /* write-only. Maximum value or missing value */
18 {
19 	/* use buffer that can hold largest
20 	 * cell representation
21 	 */
22 	CSF_VAR_TYPE buf_1;
23 	void *buf = (void *)(&buf_1);
24 
25 	CHECKHANDLE(map);
26 	CsfGetVarType(buf, &(map->raster.maxVal), RgetCellRepr(map));
27 
28 	map->file2app((size_t)1, buf);
29 
30 	if (map->minMaxStatus == MM_WRONGVALUE)
31 		SetMV(map, buf);
32 
33 	CsfGetVarType(maxVal, buf, map->appCR);
34 
35 	return((!IsMV(map,maxVal)) &&
36  		map->minMaxStatus!=MM_WRONGVALUE);
37 }
38