[GRASS-dev] Rast3d_location2coord inconsistent behavior

Sören Gebbert soerengebbert at googlemail.com
Sat Jul 19 15:30:11 PDT 2014


Hi Anna,

2014-07-19 19:04 GMT+02:00 Anna Petrášová <kratochanna at gmail.com>:
> Hi,
>
> I have a question about Rast3d_location2coord [1]. It is casting the col,
> row, depth values to integer like this:
>
> (int) col
>
> instead of using
>
> (int)floor(col)
>
> as a result, col = 0.1 => col = 0 and col = -0.1 => col = 0, which doesn't
> seem correct to me. Any opinions?

I totally agree that there should be a function that returns the row,
col and depth as double values, so the developer can decide how to
handle these values. Otherwise there would be no convenient way to
determine where coordinates are located in the voxel.

But i am not sure if the  integer casting is a bug, since the
Rast_easting_to_col() /Rast_northing_to_row() docs suggest integer
casting as conversion method. There are algorithms in GRASS that use
only integer casting and algorithms that make use of rounding with
floor() before casting to integer.

The problem arise in case of negative column,row or depth values when
casting to integer without rounding to an integer smaller than the
double number. So the question is are there any chances to receive
negative cols,rows and depths?

It does not seems do to me for col and row, since in case of negative
coordinates will west and south always be smaller than east and north,
resulting in always positive cols and rows. And the same should be
true for depths, unless the top is smaller than bottom.

Best regards
Soeren

>
> Thanks, Anna
>
> BTW, similar function Rast_northing_to_row from raster library returns
> double.
>
>
> [1] http://grass.osgeo.org/programming7/region_8c_source.html#l00291
>
> _______________________________________________
> grass-dev mailing list
> grass-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-dev


More information about the grass-dev mailing list