[Qgis-developer] intersect error

Carson Farmer carson.farmer at gmail.com
Mon Jan 26 21:16:45 EST 2009

> Not sure what was the reason of your problems (I've modified it to my
> preferences before trying it out). One thing worth mentioning -
> casting from const to non-const isn't a good idea as the const
> modifier usually has some reason, e.g. when constructing a geometry
> with QgsGeometry::fromGeos() you should pass a new instance. Passing
> an existing instance will probably cause havoc when deleting the
> geometries (because both original geometry collection and its part
> will try to delete the same geos geometry).
Only thing I would change is that instead of returning an empty list if 
it is a single geometry, I would return a list containing the single 
geometry. This is essentially what the geos function does, and would 
make using this function much simpler:

Essentially every time I do an intersection, I simply call 
asGeometryCollection(), and loop through the geometries, not worrying if 
there is one single geometry, or 5 parts of a geometry collection.

Thanks again,


More information about the Qgis-developer mailing list