[GRASS-dev] bound_box in python

Markus Neteler neteler at osgeo.org
Mon Jun 1 02:24:05 EDT 2009


On Mon, Jun 1, 2009 at 6:59 AM, Glynn Clements <glynn at gclements.plus.com> wrote:
>
> Markus Neteler wrote:
>
>> but I get
>> Traceback (most recent call last):
>>   File "examples/vectoraccess.py", line 45, in <module>
>>     print 'Map box:', grassvect.Vect_get_map_box(map, box)
>> TypeError: in method 'Vect_get_map_box', argument 2 of type 'BOUND_BOX *'
>>
>> Using instead BOUND_BOX, it also fails:
>> Traceback (most recent call last):
>>   File "examples/vectoraccess.py", line 32, in <module>
>>     box = grassvect.BOUND_BOX()
>> AttributeError: 'module' object has no attribute 'BOUND_BOX'
>
> Right. SWIG only generates wrappers for the "struct bound_box" type,
> but requires that you pass a "BOUND_BOX *" to the function.
>
> Like most things which deal with C, it gets confused by preprocessor
> macros.
>
>> Looking at the GRASS includes, I see
>> include/vect/dig_structs.h:#define BOUND_BOX struct bound_box
>>
>> Is there a strategic advantage to define 'struct bound_box' like this while
>> for example 'struct Map_info' isn't defined as MAP_INFO in the Vector
>> libs?
>
> No. If you really want an alias, use typedef, e.g.:
>
>        typedef struct bound_box BOUND_BOX;
>
> But I would prefer to just use "struct bound_box" everywhere to make
> it clear that it's a structure.
>
> I intend to commit a fix once the test compilation has completed.

Thanks - testing the backport, will submit once SVN wakes up again.

Markus


More information about the grass-dev mailing list