<p dir="ltr">Thanks,<br>
Will try again today.<br>
</p>
<div class="gmail_quote">On Dec 7, 2014 3:36 AM, "Vaclav Petras" <<a href="mailto:wenzeslaus@gmail.com">wenzeslaus@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Dec 6, 2014 at 3:59 PM, Markus Metz <span dir="ltr"><<a href="mailto:markus.metz.giswork@gmail.com" target="_blank">markus.metz.giswork@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div>Yann Chemin wrote:<br>
> Hi,<br>
><br>
> I am working on beautifying the output of i.theilsen, a new addon.<br>
><br>
> For some reason, I cannot apply a grayscale palette.<br>
> ---------------<br>
> Rast_init_colors(&colors);<br>
> DCELL val1 = ts_min;<br>
> DCELL val2 = ceil(ts_max);<br>
> Rast_add_d_color_rule(&val1, 0, 0, 0, &val2, 255, 255, 255, &colors);<br>
> ---------------<br>
><br>
> ts_min, ts_max are known from the data processed,<br>
> val1 and val2 are declared as DCELL instead of const DCELL as required,<br>
> but if I declare const DCELL val1, then I cannot write stats to it for<br>
> palette definition...<br>
><br>
> What I am doing wrong?<br>
<br>
</div></div>If you declare const DCELL val1, you can not pass a pointer to val1 to<br>
another function, because this other function could then easily modify<br>
to contents of that pointer.</blockquote><div><br></div><div>This is of course true.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Rast_add_d_color_rule() requires const<br>
DCELL *, not const DCELL.<br></blockquote><div><br></div><div>Strange, (generated) documentation says const DCELL * [1] which fits with the source code [2, 3].<br><br></div><div>I haven't tried compile anything now but isn't `const DCELL` constant (value) and `const DCELL *` pointer to constant value. While `const DCELL * const` would be constant pointer to constant value.<br><br></div><div>Also<br></div><div><br>const DCELL val;<br>const DCELL * pval = &val;<br><br></div><div>should work and carry on the constness which is exactly what should be happening when calling the Rast_add_d_color_rule() function.<br></div><div><br></div><div>So, I don't understand.<br></div><div><br></div><div>Vaclav<br></div><div><br>[1] <a href="http://grass.osgeo.org/programming7/color__rule_8c.html#a160535a46694589674f68c60eac23a05" target="_blank">http://grass.osgeo.org/programming7/color__rule_8c.html#a160535a46694589674f68c60eac23a05</a> <br>[2] lib/raster/color_rule.c:35:void Rast_add_d_color_rule(const DCELL * val1, int r1, int g1, int b1, ...<br>[3] include/defs/raster.h:198:void Rast_add_d_color_rule(const DCELL *, int, int, int, ...<br><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Markus M<br>
_______________________________________________<br>
grass-dev mailing list<br>
<a href="mailto:grass-dev@lists.osgeo.org" target="_blank">grass-dev@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/grass-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/grass-dev</a><br>
</blockquote></div><br></div></div>
</blockquote></div>