Пример #1
0
static void DefaultAttr( ATTRIBUTES *a)
{
       a->version    = 2;
       a->projection = PT_YDECT2B;
       a->valueScale = VS_BOOLEAN;
       a->cellRepr = CR_UINT1;
       a->xUL = 0;
       a->yUL = 0;
       a->nrRows = MV_UINT4;
       a->nrCols = MV_UINT4;
       a->cellSize = 1;
       a->angle = 0;
       a->gisFileId = 0;
       SET_MV_REAL8(&(a->minVal));
       SET_MV_REAL8(&(a->maxVal));
}
Пример #2
0
/* Calculates the output value according to areas and values.
 * Determines the weighted directional mean of the values.
 */
 static void CalcDirectionOut(
 	MAP *out,		/* write-only output map */
 	size_t rOut,		/* row of pixel to calculate */
 	size_t cOut,		/* column of pixel */
 	size_t nrList,		/* length of list */
 	const DATA *list,	/* list of values & areas */
 	size_t nrCoverCells,	/* min. nr. of non-MV cells for non MV */
 	size_t nrMaps)		/* number of input maps */
{
	double 	cover;		/* percentage of cell being covered */
	REAL8 	outVal = 0;	/* the calculated output value */
	BOOL 	first = FALSE;	/* initialization of outVal */
	double 	area = 0;	/* The sum of areas */
	REAL8	cellSize = RgetCellSize(out);

	/* Take the weighted sum of the values, weight is the area */
	outVal = (REAL8) WeightDirectionalMean(&area, list, nrList);

	if(area == 0)
		first = TRUE;	/* no cell covers output cell */

	/* Determine whether or not missing value for output pixel */
	if(nrMaps > 1 && nrCoverCells > 0)
		cover = DetNrCoverCells(raster);
	else
		cover = area * rasterSize * rasterSize/ 
			(cellSize * cellSize);

	if(first || ceil(cover) < nrCoverCells || cover == 0)
 		SET_MV_REAL8(&outVal);		/* MV */
	RputCell(out, rOut, cOut, &outVal); 
}
Пример #3
0
void set_mv_double(double *d) {
#ifdef HAVE_LIBCSF
	SET_MV_REAL8(d);
#else
	memset(d, 0xFF, sizeof(double));
#endif
}
Пример #4
0
/* Calculates the output value according to areas and values.
 * Determines the weighted mean of the values.
 */
 static void CalcScalarOut(
 	MAP *out,		/* write-only output map */
 	size_t rOut,		/* row of pixel to calculate */
 	size_t cOut,		/* column of pixel */
 	size_t nrList,		/* length of list */
 	const DATA *list,	/* list of values & areas */
 	size_t nrCoverCells,	/* min. nr. non-MV cells for non MV */
 	size_t nrMaps)		/* number of input maps */
{
	size_t 	i;
	double 	cover;		/* percentage of cell being covered */
	REAL8 	outVal = 0;	/* the calculated output value */
	BOOL 	first = FALSE;	/* initialization of outVal */
	double 	area = 0;	/* The sum of areas */
	REAL8	cellSize = RgetCellSize(out);
	extern  int opMax;

	if (opMax == 1)
	{
		 first = TRUE;
	         for(i = 0; i < nrList; i++)	
	          if (list[i].area > 0)
	          {
	          	if (first)
	          	 outVal = list[i].value;
	          	else
		         outVal = MAX(outVal, list[i].value);
		        first = FALSE;
		        area += list[i].area;  	/* sum of areas */
	          }
	}
	else
	{
	 /* Take the weighted sum of the values, weight is the area */
	 for(i = 0; i < nrList; i++)	
	 {
		area += list[i].area;  	/* sum of areas */
		outVal += list[i].value * list[i].area;
	 }	
	 if(area != 0)
		outVal /= area;		/* average */
	 else
		first = TRUE;		/* no cell covers output cell */

	}
	/* Determine whether or not missing value for output pixel */
	if(nrMaps > 1 && nrCoverCells > 0)
		cover = DetNrCoverCells(raster);
	else
		cover = area * rasterSize * rasterSize/ 
			(cellSize * cellSize);
	if(first || ceil(cover) < nrCoverCells || cover == 0)
 		SET_MV_REAL8(&outVal);		/* put mv */
	RputCell(out, rOut, cOut, &outVal); 
}
Пример #5
0
/* (LIBRARY_INTERNAL)
 */
void Get_in_REAL4_to_REAL8(
        REAL8 *value,
        const REAL4   **matrix,    /* map matrix */
	int    r,                 /* row number */
	int    c)                 /* column number */
{
	if ( IS_MV_REAL4(matrix[r]+c) )
		SET_MV_REAL8(value);
	else
		*value = matrix[r][c];
}
Пример #6
0
/* (LIBRARY_INTERNAL)
 */
void Get_in_INT4_to_REAL8(
        REAL8 *value,
        const INT4   **matrix,    /* map matrix */
	int    r,                 /* row number */
	int    c)                 /* column number */
{
	if ( matrix[r][c] == MV_INT4 )
		SET_MV_REAL8(value);
	else
		*value = matrix[r][c];
}
Пример #7
0
static void OptNotSetAttr( ATTRIBUTES *a)
{
       a->projection = PT_UNDEFINED;
       a->valueScale = VS_UNDEFINED;
       a->cellRepr = CR_UNDEFINED;
       a->nrRows = MV_UINT4;
       a->nrCols = MV_UINT4;
       SET_MV_REAL8(&(a->xUL));
       SET_MV_REAL8(&(a->yUL));
       SET_MV_REAL8(&(a->cellSize));
       SET_MV_REAL8(&(a->angle));
       a->gisFileId = MV_UINT4;
       SET_MV_REAL8(&(a->minVal));
       SET_MV_REAL8(&(a->maxVal));
}