Skip to content

Commit b7a2a79

Browse files
committedMay 25, 2015
Merge pull request #2055 from mhugent/geometry_mmsql_2_8
[FEATURE]: New geometry classes (take 2)
2 parents bb80c63 + 68fe5f5 commit b7a2a79

File tree

129 files changed

+13055
-7605
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+13055
-7605
lines changed
 

‎python/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ INCLUDE_DIRECTORIES(
8383
../src/core/diagram
8484
../src/core/effects
8585
../src/core/dxf
86+
../src/core/geometry
8687
../src/core/gps
8788
../src/core/layertree
8889
../src/core/raster

‎python/core/conversions.sip

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,140 @@ template <TYPE>
265265
};
266266

267267

268+
%MappedType QList< QList<QgsPointV2> >
269+
{
270+
%TypeHeaderCode
271+
#include <QList>
272+
#include "qgspointv2.h"
273+
%End
274+
275+
%ConvertFromTypeCode
276+
// Create the list.
277+
PyObject *l;
278+
279+
if ((l = PyList_New(sipCpp->size())) == NULL)
280+
return NULL;
281+
282+
const sipMappedType* qlist_type = sipFindMappedType("QList<QgsPointV2>");
283+
284+
// Set the list elements.
285+
for (int i = 0; i < sipCpp->size(); ++i)
286+
{
287+
QList<QgsPointV2>* t = new QList<QgsPointV2>(sipCpp->at(i));
288+
PyObject *tobj;
289+
290+
if ((tobj = sipConvertFromMappedType(t, qlist_type, sipTransferObj)) == NULL)
291+
{
292+
Py_DECREF(l);
293+
delete t;
294+
return NULL;
295+
}
296+
PyList_SET_ITEM(l, i, tobj);
297+
}
298+
299+
return l;
300+
%End
301+
302+
%ConvertToTypeCode
303+
const sipMappedType* qlist_type = sipFindMappedType("QList<QgsPointV2>");
304+
305+
// Check the type if that is all that is required.
306+
if (sipIsErr == NULL)
307+
{
308+
if (!PyList_Check(sipPy))
309+
return 0;
310+
311+
for (int i = 0; i < PyList_GET_SIZE(sipPy); ++i)
312+
if (!sipCanConvertToMappedType(PyList_GET_ITEM(sipPy, i), qlist_type, SIP_NOT_NONE))
313+
return 0;
314+
315+
return 1;
316+
}
317+
318+
319+
QList< QList<QgsPointV2> > *ql = new QList< QList<QgsPointV2> >;
320+
321+
for (int i = 0; i < PyList_GET_SIZE(sipPy); ++i)
322+
{
323+
int state;
324+
//TYPE *t = reinterpret_cast<TYPE *>(sipConvertToType(PyList_GET_ITEM(sipPy, i), sipType_TYPE, sipTransferObj, SIP_NOT_NONE, &state, sipIsErr));
325+
QList<QgsPointV2> * t = reinterpret_cast< QList<QgsPointV2> * >(sipConvertToMappedType(PyList_GET_ITEM(sipPy, i), qlist_type, sipTransferObj, SIP_NOT_NONE, &state, sipIsErr));
326+
327+
if (*sipIsErr)
328+
{
329+
sipReleaseMappedType(t, qlist_type, state);
330+
delete ql;
331+
return 0;
332+
}
333+
ql->append(*t);
334+
sipReleaseMappedType(t, qlist_type, state);
335+
}
336+
337+
*sipCppPtr = ql;
338+
return sipGetState(sipTransferObj);
339+
%End
340+
};
341+
342+
%MappedType QList< QList< QList<QgsPointV2> > >
343+
{
344+
%TypeHeaderCode
345+
#include <QList>
346+
#include "qgspointv2.h"
347+
%End
348+
349+
%ConvertFromTypeCode
350+
PyObject *l;
351+
if ((l = PyList_New(sipCpp->size())) == NULL)
352+
{
353+
return NULL;
354+
}
355+
const sipMappedType* qlist_type = sipFindMappedType("QList<QList<QgsPointV2> >");
356+
if(!qlist_type )
357+
{
358+
Py_DECREF(l); return NULL;
359+
}
360+
361+
for (int i = 0; i < sipCpp->size(); ++i)
362+
{
363+
QList< QList<QgsPointV2> >* t = new QList<QList<QgsPointV2> >(sipCpp->at(i));
364+
PyObject *tobj;
365+
if ((tobj = sipConvertFromMappedType(t, qlist_type, sipTransferObj)) == NULL)
366+
{
367+
Py_DECREF(l);
368+
delete t;
369+
return NULL;
370+
}
371+
PyList_SET_ITEM(l, i, tobj);
372+
}
373+
return l;
374+
%End
375+
%ConvertToTypeCode
376+
const sipMappedType* qlist_type = sipFindMappedType("QList<QList<QgsPointV2> >");
377+
if (sipIsErr == NULL)
378+
{
379+
return 0;
380+
}
381+
QList< QList< QList<QgsPointV2> > >* ql = new QList< QList< QList<QgsPointV2> > >();
382+
for( int i = 0;i < PyList_GET_SIZE(sipPy); ++i)
383+
{
384+
int state;
385+
QList<QList<QgsPointV2> > *t = reinterpret_cast< QList< QList<QgsPointV2> > * >(sipConvertToMappedType(PyList_GET_ITEM(sipPy, i), qlist_type, sipTransferObj, SIP_NOT_NONE, &state, sipIsErr));
386+
if( *sipIsErr )
387+
{
388+
sipReleaseMappedType(t, qlist_type, state);
389+
delete ql;
390+
return 0;
391+
}
392+
ql->append( *t );
393+
sipReleaseMappedType( t, qlist_type, state );
394+
}
395+
*sipCppPtr = ql;
396+
return sipGetState(sipTransferObj);
397+
398+
399+
%End
400+
};
401+
268402

269403
%If (QSETINT_CONVERSION)
270404
%MappedType QSet<int>

0 commit comments

Comments
 (0)
Please sign in to comment.