Skip to content
Permalink
Browse files

[ogr] return multi{linestring,polygon} type for shapefile driver

  • Loading branch information
nirvn committed Jul 10, 2017
1 parent 18c3634 commit 1aa0091e7a368dedf716b80c25b376e3251848a0
Showing with 11 additions and 5 deletions.
  1. +7 −1 src/providers/ogr/qgsogrprovider.cpp
  2. +4 −4 tests/src/python/test_provider_virtual.py
@@ -30,6 +30,7 @@ email : sherman at mrcc.com
#include "qgsgeometry.h"
#include "qgscoordinatereferencesystem.h"
#include "qgsvectorlayerexporter.h"
#include "qgswkbtypes.h"
#include "qgis.h"


@@ -1175,7 +1176,12 @@ size_t QgsOgrProvider::layerCount() const
*/
QgsWkbTypes::Type QgsOgrProvider::wkbType() const
{
return static_cast<QgsWkbTypes::Type>( mOGRGeomType );
QgsWkbTypes::Type wkb = static_cast<QgsWkbTypes::Type>( mOGRGeomType );
if ( ogrDriverName == QLatin1String( "ESRI Shapefile" ) && ( wkb == QgsWkbTypes::LineString || wkb == QgsWkbTypes::Polygon ) )
{
wkb = QgsWkbTypes::multiType( wkb );
}
return wkb;
}

/**
@@ -181,7 +181,7 @@ def test_Query(self):
# the same, without specifying the geometry column name
l2 = QgsVectorLayer("?layer_ref=%s&query=%s&uid=OBJECTID" % (l1.id(), query), "vtab", "virtual", False)
self.assertEqual(l2.isValid(), True)
self.assertEqual(l2.dataProvider().wkbType(), 3)
self.assertEqual(l2.dataProvider().wkbType(), 6)
ref_sum2 = sum(f.attributes()[0] for f in l2.getFeatures())
ref_sum3 = sum(f.id() for f in l2.getFeatures())
# check we have the same rows
@@ -204,7 +204,7 @@ def test_Query(self):
# with two geometry columns, but no geometry column specified (will take the first)
l2 = QgsVectorLayer("?layer_ref=%s&query=%s&uid=OBJECTID" % (l1.id(), query), "vtab", "virtual", False)
self.assertEqual(l2.isValid(), True)
self.assertEqual(l2.dataProvider().wkbType(), 3)
self.assertEqual(l2.dataProvider().wkbType(), 6)
ref_sum2 = sum(f.attributes()[0] for f in l2.getFeatures())
ref_sum3 = sum(f.id() for f in l2.getFeatures())
# check we have the same rows
@@ -343,7 +343,7 @@ def test_reopen(self):

l2 = QgsVectorLayer(tmp, "tt", "virtual", False)
self.assertEqual(l2.isValid(), True)
self.assertEqual(l2.dataProvider().wkbType(), 3)
self.assertEqual(l2.dataProvider().wkbType(), 6)
self.assertEqual(l2.dataProvider().featureCount(), 4)

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

self.assertEqual(l4.dataProvider().wkbType(), 3)
self.assertEqual(l4.dataProvider().wkbType(), 6)
self.assertEqual(l4.dataProvider().crs().postgisSrid(), 4326)

n = 0

0 comments on commit 1aa0091

Please sign in to comment.
You can’t perform that action at this time.