[GRASSLIST:897] Re: CELL, FCELL, DCELL type...

Massimiliano Cannata massimiliano.cannata at ist.supsi.ch
Mon Aug 4 06:15:36 EDT 2003



Glynn Clements wrote:

> Massimiliano Cannata wrote:
>
> > I'm trying write a code that use a raster to make
> > calulation....
> > so I get the raster cell value (CELL, FCELL, DCELL
> > depending on the original map) and then i have to
> > use the math.h function
> >
> > double pow(double,double)
> >
> > so, how do I have to cast CELL, FCELL or DCELL to
> > double?
> > It seems that
> >
> > double x;
> > x = (double) CELL
> >
> > doesn't work...
>
> It should work.
>
> > more, I have to really do this casting?
>
> ANSI C will automatically cast numeric function arguments to the
> appropriate type, so you can just pass CELL values to pow() directly.
>
> --
> Glynn Clements <glynn.clements at virgin.net>

So if it is able an automatic cast...
i don't really need to develop 3 version of my calculus module as in the
"r.example" for the switch type....
i can just make one, doing someting like:

double mycalculus(double x)

and than pass CELL, DCELL or FCELL as argument?????

Thanks a lot.
Max

____________
---r.example----
____________
switch (data_type)
   case CELL_TYPE:
    c = ((CELL *) inrast)[col];
    c = c_calc(c); /* calculate */
    ((CELL *) outrast)[col] = c;
    break;
   case FCELL_TYPE:
    f = ((FCELL *) inrast)[col];
    f = f_calc(f); /* calculate */
    ((FCELL *) outrast)[col] = f;
    break;
   case DCELL_TYPE:
    d = ((DCELL *) inrast)[col];
    d = d_calc(d); /* calculate */
    ((DCELL *) outrast)[col] = d;
    break;
   }



--
-------------
Ing.  Massimiliano Cannata
Istituto di Scienze della Terra - SUPSI
C.P. 72 - CH-6952 Canobbio (Ticino, Switzerland)
Tel +41 91 /935 12 25 - Fax +41 91 /935 12 09
eMail: massimiliano.cannata at ist.supsi.ch
Internet: http://www.ist.supsi.ch

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/grass-user/attachments/20030804/d8cfb6b4/attachment.html


More information about the grass-user mailing list