[Qgis-developer] help with splitGeometry

Martin Dobias wonder.sk at gmail.com
Tue Mar 2 15:54:59 EST 2010


2010/3/2 Maxim Dubinin <sim at gis-lab.info>:
> Hi all,
>
> I'm trying to do a simple thing, use splitGeometry for two intersecting
> lines and though it returns 0, the list with output geometries is always
> empty.
>
> Here is my code (testable in Python-console and two selected intersecting
> lines, two points each):
>
> cl = qgis.utils.iface.mapCanvas().currentLayer()
> selfeats = cl.selectedFeatures()
> geom0 = QgsGeometry(selfeats[0].geometry())
> geom1 = QgsGeometry(selfeats[1].geometry())
> pnt0=geom0.vertexAt(0)
> pnt1=geom0.vertexAt(1)
> pnts=[]
> pnts.append(pnt0)
> pnts.append(pnt1)
> newlist=[]
> emptylist=[]
> geom1.splitGeometry(pnts,newlist,False,emptylist)

Hi Maxim

the splitGeometry() method was missing /Out/ annotations for the
output lists, so it wasn't working correctly. It has been fixed in
r12992.

The syntax should be now:
(res, newlist, topolist) = geom1.splitGeometry(pnts, False)

Bye
Martin


More information about the Qgis-developer mailing list