[GRASS-dev] Re: [GRASS-user] XY trace plots

[moved to -dev list]

Markus Metz wrote:

The argument must be a pointer, try

G_is_null_value(byref(in_rast[col]), data_type)

or
in_val = in_rast[col]
G_is_null_value(byref(in_val), data_type)

no joy, both those come back with:

    if not G_is_null_value(byref(in_rast[col]), data_type):
TypeError: byref() argument must be a ctypes instance, not 'int'

(tried with a CELL map)

https://trac.osgeo.org/grass/browser/grass-addons/grass6/raster/r.to.vect.lines/r.to.vect.lines.py#L155

the cast happens early on at malloc time,
in_fd = G_open_cell_old(inmap, mapset)
in_rast = G_allocate_raster_buf(data_type)
in_rast = cast(c_void_p(in_rast), ptype)

right after data_type is determined.
here ptype = POINTER(c_int)

?,
Hamish

Hamish wrote:

> The argument must be a pointer, try
>
> G_is_null_value(byref(in_rast[col]), data_type)
>
> or
> in_val = in_rast[col]
> G_is_null_value(byref(in_val), data_type)

no joy, both those come back with:

    if not G_is_null_value(byref(in_rast[col]), data_type):
TypeError: byref() argument must be a ctypes instance, not 'int'

  import grass.lib.raster as rast
  ...
  in_val = rast.CELL(in_rast[col])
  G_is_null_value(byref(in_val), data_type)

ctypes automatically converts the result of an array acces to a Python
type, while byref() requires a ctypes type. And pointer arithmetic
still isn't implemented (i.e. there's no simple way to get a pointer
to any element of an array other than the first).

--
Glynn Clements <glynn@gclements.plus.com>