Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#3020 closed enhancement (fixed)

Extend python TransformPoints typemap to accept any sequence

Reported by: hogend Owned by: Even Rouault
Priority: normal Milestone: 1.7.0
Component: PythonBindings Version: 1.6.1
Severity: normal Keywords:
Cc:

Description

The python TransformPoints? typemap requires coordinates to be 2- or 3-tuples. The attached diff to typemaps_python.i allows any sequence, i.e. lists or, more importantly, numpy arrays

Attachments (1)

gdal-1.6.1-typemap.diff (7.3 KB) - added by hogend 8 years ago.

Download all attachments as: .zip

Change History (4)

Changed 8 years ago by hogend

Attachment: gdal-1.6.1-typemap.diff added

comment:1 Changed 8 years ago by Even Rouault

Owner: changed from hobu to Even Rouault
Status: newassigned

comment:2 Changed 8 years ago by Even Rouault

Milestone: 1.7.0
Resolution: fixed
Status: assignedclosed

Hogend,

I applied in trunk (r17189) a slightly modified version of your patch that mainly adds the VSIMalloc and NULL pointer checks to replace CPLMalloc. I also removed the last bit of your patch that did : PyObject? *xyz = PyList_New( $1 ); .... PyTuple_SetItem( xyz, i, tuple ); which looks very suspicious to me (using PyTuple_SetItem on a PyList? ?). Test added in r17190.

Thanks.

comment:3 in reply to:  2 Changed 8 years ago by hogend

Replying to rouault:

Hogend,

I applied in trunk (r17189) a slightly modified version of your patch that mainly adds the VSIMalloc and NULL pointer checks to replace CPLMalloc. I also removed the last bit of your patch that did : PyObject? *xyz = PyList_New( $1 ); .... PyTuple_SetItem( xyz, i, tuple ); which looks very suspicious to me (using PyTuple_SetItem on a PyList? ?). Test added in r17190.

Thanks.


You are right about the the PyTuple_SetItem; it must be PyList_SetItem (Initially, I returned tuples, but tried to change it back to a tuple of lists of tuples ;)

One note, you raise a runtime exception, isn't it better to use

PyErr_SetString( PyExc_MemoryError, "in TransformPoints?" );

?
Regards,
Rene

Note: See TracTickets for help on using tickets.