[GRASS-dev] Re: r.series: threshold/count method?

Glynn Clements glynn at gclements.plus.com
Sat Sep 5 14:02:48 EDT 2009


Markus Neteler wrote:

> >> In 7.0, the prototype for aggregates has recently been changed to
> >> accept an additional parameter of type "const void *". r.series uses
> >> this to implement the quantile= option for method=quantile.
> >>
> >
> > Ah, thanks - I didn't realize the difference. This will help.
> 
> It does.
> 
> Since I eventually need it in (locally) 6.4, I have backported
> "arbitrary quantiles" from trunk.
> 
> I have now added the new threshold method (locally):
> 
>    quantile   Quantile to calculate for method=quantile
>               options: 0.0-1.0
>   threshold   Threshold to calculate for method=threshold
> 
> but need to pass the value to the function. This happens for quantile here
> in main.c from r.series:
> 
>    240                  if (null && flag.nulls->answer)
>    241                      G_set_d_null_value(&out->buf[col], 1);
>    242                  else {
>    243                      memcpy(values_tmp, values, num_inputs * sizeof(DCELL));
>    244                      (*out->method_fn)(&out->buf[col], values_tmp, num_inputs, &out->quantile);
>    245                  }
> 
> Since I am getting lost in the pointers, how to pass '&out->threshold'
> instead of
> &out->quantile when I use the threshold method? I guess I don't want to add
> more parameters to line 244...

I would have renamed the quantile= option to parameter= rather than
having a separate threshold= option, and done likewise for the
"quantile" field in struct output.

But if additional aggregates start getting more complex parameters
(e.g. multiple parameters or different types), the more general
solution is to add a "const void *parameter" to struct output, which
is set when the structure is initialised.

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-dev mailing list