[Qgis-developer] QgsMultipolyline

Martin Dobias wonder.sk at gmail.com
Fri Oct 10 09:41:01 EDT 2008


Hi Carson,

On Wed, Oct 8, 2008 at 5:27 PM, Carson Farmer <carson.farmer at gmail.com> wrote:
> When creating a MultiPolyline geometry, I am able to combine several
> Polylines to form a single Multipolyline. However, when attempting to write
> this out to a shapefile using QgsVectorFileWriter, the resulting file
> contains no entries. I have inspected the Multipolylines, and they appear to
> be valid, and the QgsGeometry is created without a problem.
>
> Somewhere between feature.setGeometry(multi_geom) and writer.addFeature(),
> the geometry information appears to be rendered invalid?

fixed in r9469 :-)
When you do f.setGeometry() the geometry gets copied to the feature.
Copying multi-part geometries in GEOS < 3.0 is slightly incorrect
because the geometries degenerate to more general geometry collection
class, which is not supported by QGIS... The fix forces GEOS not to
degenerate the clone.

It's possible to work around this problem also with earlier QGIS
versions. Geometry can be in QGIS represented in WKB or GEOS or both
formats. If you call e.g. wkbBuffer() / wkbSize() / wkbType() it will
create also WKB representation (if doesn't exist already) so when
geometry gets cloned later in setGeometry(), it will have already
correct WKB for QgsVectorFileWriter.

Martin


More information about the Qgis-developer mailing list