[GRASS-dev] Rast3d_location2coord inconsistent behavior
soerengebbert at googlemail.com
Sat Jul 19 15:30:11 PDT 2014
2014-07-19 19:04 GMT+02:00 Anna Petrášová <kratochanna at gmail.com>:
> I have a question about Rast3d_location2coord . It is casting the col,
> row, depth values to integer like this:
> (int) col
> instead of using
> 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.
> Thanks, Anna
> BTW, similar function Rast_northing_to_row from raster library returns
>  http://grass.osgeo.org/programming7/region_8c_source.html#l00291
> grass-dev mailing list
> grass-dev at lists.osgeo.org
More information about the grass-dev