Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
QgsVectorFileWriter fails to export features containing Multi*25D geo…
…metries (fix #13451)
  • Loading branch information
brushtyler committed Sep 29, 2015
1 parent d34ce24 commit 8ed7850
Showing 1 changed file with 26 additions and 10 deletions.
36 changes: 26 additions & 10 deletions src/core/qgsvectorfilewriter.cpp
Expand Up @@ -1731,16 +1731,32 @@ OGRFeatureH QgsVectorFileWriter::createFeature( QgsFeature& feature )

if ( geom && geom->wkbType() != mWkbType )
{
// there's a problem when layer type is set as wkbtype Polygon
// although there are also features of type MultiPolygon
// (at least in OGR provider)
// If the feature's wkbtype is different from the layer's wkbtype,
// try to export it too.
//
// Btw. OGRGeometry must be exactly of the type of the geometry which it will receive
// i.e. Polygons can't be imported to OGRMultiPolygon

OGRGeometryH mGeom2 = createEmptyGeometry( geom->wkbType() );
OGRGeometryH mGeom2 = NULL;

// If requested WKB type is 25D and geometry WKB type is 3D,
// we must force the use of 25D.
if ( mWkbType >= QGis::WKBPoint25D && mWkbType <= QGis::WKBMultiPolygon25D )
{
QgsWKBTypes::Type wkbType = (QgsWKBTypes::Type)geom->wkbType();
if ( wkbType >= QgsWKBTypes::PointZ && wkbType <= QgsWKBTypes::MultiPolygonZ )
{
QGis::WkbType wkbType25d = (QGis::WkbType)(geom->wkbType() - QgsWKBTypes::PointZ + QgsWKBTypes::Point25D);
mGeom2 = createEmptyGeometry( wkbType25d );
}
}

if ( !mGeom2 )
{
// there's a problem when layer type is set as wkbtype Polygon
// although there are also features of type MultiPolygon
// (at least in OGR provider)
// If the feature's wkbtype is different from the layer's wkbtype,
// try to export it too.
//
// Btw. OGRGeometry must be exactly of the type of the geometry which it will receive
// i.e. Polygons can't be imported to OGRMultiPolygon
mGeom2 = createEmptyGeometry( geom->wkbType() );
}

if ( !mGeom2 )
{
Expand Down

0 comments on commit 8ed7850

Please sign in to comment.