[GRASS-dev] help with r.le.setup bug
Glynn Clements
glynn at gclements.plus.com
Thu Oct 5 19:00:01 EDT 2006
Hamish wrote:
> can one of the C gurus have a look at this?
>
> http://thread.gmane.org/gmane.comp.gis.grass.devel/15495/focus=15598
>
>
> I think it's a simple type mismatch in variables getting passed to a
> function.
It is. ux/uy are arrays of ints but calc_unit_loc() expects arrays of
doubles.
Try the attached patch.
--
Glynn Clements <glynn at gclements.plus.com>
-------------- next part --------------
Index: raster/r.le/r.le.setup/sample.c
===================================================================
RCS file: /grassrepository/grass6/raster/r.le/r.le.setup/sample.c,v
retrieving revision 2.6
diff -u -r2.6 sample.c
--- raster/r.le/r.le.setup/sample.c 28 Sep 2006 07:37:04 -0000 2.6
+++ raster/r.le/r.le.setup/sample.c 5 Oct 2006 22:57:59 -0000
@@ -108,9 +108,10 @@
{
int i, j, dx, dy, w_w, w_l, u_w, u_l,
method, l0, t0, randflag=0, unit_num, num=0, scales,
- h_d=1, v_d=1, *ux, *uy, itmp, thick, sites, *row_buf, fr, k,
+ h_d=1, v_d=1, itmp, thick, sites, *row_buf, fr, k,
count=0, maxsize=0, nx=0, ny=0, numx=0, numy=0,
al=0, ar=0, at=0, ab=0, au_w=0, au_l=0;
+ double *ux, *uy;
FILE *fp ;
double dtmp, ratio, size, intv=0.0, start[2], cnt=0, radius=0.0;
char *sites_mapset;
@@ -547,13 +548,13 @@
units */
if (method != 5) {
- ux = (int *)G_calloc(num+1, sizeof(int));
- uy = (int *)G_calloc(num+1, sizeof(int));
+ ux = G_calloc(num+1, sizeof(double));
+ uy = G_calloc(num+1, sizeof(double));
}
else {
- ux = (int *)G_calloc(250, sizeof(int));
- uy = (int *)G_calloc(250, sizeof(int));
+ ux = G_calloc(250, sizeof(double));
+ uy = G_calloc(250, sizeof(double));
}
/* calculate the upper left corner of sampling
@@ -615,7 +616,7 @@
radius, (i+1));
for(j = 0; j < num; j++)
- fprintf(fp, "%10d%10d left, top of unit[%d]\n", ux[j], uy[j], j+1);
+ fprintf(fp, "%10d%10d left, top of unit[%d]\n", (int) ux[j], (int) uy[j], j+1);
if (i < scales - 1 && G_yes("\n\n Refresh the screen? ", 1)) {
paint_map(n1, n2, n3);
More information about the grass-dev
mailing list