[Qgis-developer] how to create a new geometry from an existing one
Ricardo Filipe Soares Garcia da
ricardo.garcia.silva at gmail.com
Sat May 12 16:39:03 PDT 2012
I'm trying to code some tools for working with lines layers using
python. One such tool is meant to create parallel lines.
I am trying to create my new line geometry by first copying the
geometry of a previously selected linestring and then translating it
according to a specified distance.
But I can't seem to find the correct way of copying the geometry.
I am on Ubuntu 11.10, using QGIS compiled from master #033d58d, built today.
For testing, I'm using layers created with the 'New Memory Layer'
plugin, which uses the memory provider.
I've tried the following approaches:
# python code
# approach 1
new_geometry = QgsGeometry(line_geometry)
-> Exception: unknown
# approach 2
new_geometry = QgsGeometry.fromPolyline(line_geometry.asPolyline())
-> no error is thrown, but nothing happens
# approach 3
wkb = line_geometry.asWkb()
-> RuntimeError: underlying C/C++ object has been deleted
Thanks for your input!
___________________________ ___ __
Ricardo Garcia Silva
More information about the Qgis-developer