Skip to content

Commit 1aa0091

Browse files
committedJul 10, 2017
[ogr] return multi{linestring,polygon} type for shapefile driver
1 parent 18c3634 commit 1aa0091

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed
 

‎src/providers/ogr/qgsogrprovider.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ email : sherman at mrcc.com
3030
#include "qgsgeometry.h"
3131
#include "qgscoordinatereferencesystem.h"
3232
#include "qgsvectorlayerexporter.h"
33+
#include "qgswkbtypes.h"
3334
#include "qgis.h"
3435

3536

@@ -1175,7 +1176,12 @@ size_t QgsOgrProvider::layerCount() const
11751176
*/
11761177
QgsWkbTypes::Type QgsOgrProvider::wkbType() const
11771178
{
1178-
return static_cast<QgsWkbTypes::Type>( mOGRGeomType );
1179+
QgsWkbTypes::Type wkb = static_cast<QgsWkbTypes::Type>( mOGRGeomType );
1180+
if ( ogrDriverName == QLatin1String( "ESRI Shapefile" ) && ( wkb == QgsWkbTypes::LineString || wkb == QgsWkbTypes::Polygon ) )
1181+
{
1182+
wkb = QgsWkbTypes::multiType( wkb );
1183+
}
1184+
return wkb;
11791185
}
11801186

11811187
/**

‎tests/src/python/test_provider_virtual.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ def test_Query(self):
181181
# the same, without specifying the geometry column name
182182
l2 = QgsVectorLayer("?layer_ref=%s&query=%s&uid=OBJECTID" % (l1.id(), query), "vtab", "virtual", False)
183183
self.assertEqual(l2.isValid(), True)
184-
self.assertEqual(l2.dataProvider().wkbType(), 3)
184+
self.assertEqual(l2.dataProvider().wkbType(), 6)
185185
ref_sum2 = sum(f.attributes()[0] for f in l2.getFeatures())
186186
ref_sum3 = sum(f.id() for f in l2.getFeatures())
187187
# check we have the same rows
@@ -204,7 +204,7 @@ def test_Query(self):
204204
# with two geometry columns, but no geometry column specified (will take the first)
205205
l2 = QgsVectorLayer("?layer_ref=%s&query=%s&uid=OBJECTID" % (l1.id(), query), "vtab", "virtual", False)
206206
self.assertEqual(l2.isValid(), True)
207-
self.assertEqual(l2.dataProvider().wkbType(), 3)
207+
self.assertEqual(l2.dataProvider().wkbType(), 6)
208208
ref_sum2 = sum(f.attributes()[0] for f in l2.getFeatures())
209209
ref_sum3 = sum(f.id() for f in l2.getFeatures())
210210
# check we have the same rows
@@ -343,7 +343,7 @@ def test_reopen(self):
343343

344344
l2 = QgsVectorLayer(tmp, "tt", "virtual", False)
345345
self.assertEqual(l2.isValid(), True)
346-
self.assertEqual(l2.dataProvider().wkbType(), 3)
346+
self.assertEqual(l2.dataProvider().wkbType(), 6)
347347
self.assertEqual(l2.dataProvider().featureCount(), 4)
348348

349349
def test_reopen2(self):
@@ -448,7 +448,7 @@ def test_sql2(self):
448448
l4 = QgsVectorLayer("?query=%s&uid=ObjectId" % query, "tt", "virtual")
449449
self.assertEqual(l4.isValid(), True)
450450

451-
self.assertEqual(l4.dataProvider().wkbType(), 3)
451+
self.assertEqual(l4.dataProvider().wkbType(), 6)
452452
self.assertEqual(l4.dataProvider().crs().postgisSrid(), 4326)
453453

454454
n = 0

0 commit comments

Comments
 (0)
Please sign in to comment.