Skip to content
Permalink
Browse files

fix multipolygons with only one polygon

  • Loading branch information
troopa81 authored and nyalldawson committed Jan 6, 2020
1 parent a1f8af9 commit 1f3370a95649074f86721cf5e20140c06a520219
@@ -3008,10 +3008,11 @@ bool QOCISpatialCols::convertToWkb( QVariant &v, int index )

int wkbSize = 1 + 2 * sizeof( int );
const int nPolygons = parts.size();
const bool isMultiPolygon = iType == GtMultiPolygon;
for ( int part = 0; part < nPolygons; ++part )
{
SurfaceRings &rings = parts[ part ].second;
if ( nPolygons > 1 )
if ( isMultiPolygon )
wkbSize += 1 + 2 * sizeof( int );
for ( int ringIdx = 0; ringIdx < rings.size(); ++ringIdx )
{
@@ -3041,7 +3042,8 @@ bool QOCISpatialCols::convertToWkb( QVariant &v, int index )

ptr.cPtr = ba.data();
*ptr.ucPtr++ = byteorder();
if ( nPolygons == 1 )

if ( !isMultiPolygon )
{
if ( isCurved )
*ptr.iPtr++ = nDims == 2 ? WKBCurvePolygon : WKBCurvePolygonZ;
@@ -3059,7 +3061,7 @@ bool QOCISpatialCols::convertToWkb( QVariant &v, int index )

for ( const QPair< WKBType, SurfaceRings > &rings : qAsConst( parts ) )
{
if ( nPolygons > 1 )
if ( isMultiPolygon )
{
*ptr.ucPtr++ = byteorder();
*ptr.iPtr++ = rings.first;
@@ -402,6 +402,8 @@ def testSurfaces(self):
compareWkt(features[12].geometry().asWkt(), 'MultiSurface (CurvePolygon (CircularString (1 3, 3 5, 4 7, 7 3, 1 3)),CurvePolygon (CircularString (11 3, 13 5, 14 7, 17 3, 11 3)))', 0.00001), features[12].geometry().asWkt())
self.assertTrue(
compareWkt(features[13].geometry().asWkt(), 'CurvePolygonZ(CompoundCurveZ (CircularStringZ (-1 -5 1, 5 -7 2, 17 -6 3), (17 -6 3, 13 4 4), CircularStringZ (13 4 4, 10 0.1 5, 7 2.20 6, 5 4 7, 1 2 8),(1 2 8, -1 -5 1)))', 0.00001), features[13].geometry().asWkt())
self.assertTrue(
compareWkt(features[14].geometry().asWkt(), 'MultiPolygon (((22 22, 28 22, 28 26, 22 26, 22 22)))', 0.00001), features[14].geometry().asWkt())

def testEditSurfaces(self):

@@ -60,7 +60,8 @@ INSERT INTO QGIS.POLY_DATA ("pk", GEOM)
UNION ALL SELECT 10, SDO_GEOMETRY(2003, NULL, NULL, SDO_ELEM_INFO_ARRAY(1,1003,2, 11,2003,2), SDO_ORDINATE_ARRAY(1, 3, 3, 5, 4, 7, 7, 3, 1, 3, 3.1, 3.3, 3.3, 3.5, 3.4, 3.7, 3.7, 3.3, 3.1, 3.3)) from dual
UNION ALL SELECT 11, SDO_GEOMETRY(2003, NULL, NULL, SDO_ELEM_INFO_ARRAY(1,1005,4, 1,2,1, 3,2,2, 11,2,1, 13,2,2), SDO_ORDINATE_ARRAY(-1, -5, 1, 2, 5, 4, 7, 2.2, 10, .1, 13, 4, 17, -6, 5, -7, -1, -5)) from dual
UNION ALL SELECT 12, SDO_GEOMETRY(2007, NULL, NULL, SDO_ELEM_INFO_ARRAY(1,1003,2, 11,1003,2), SDO_ORDINATE_ARRAY(1, 3, 3, 5, 4, 7, 7, 3, 1, 3, 11, 3, 13, 5, 14, 7, 17, 3, 11, 3)) from dual
UNION ALL SELECT 13, SDO_GEOMETRY(3003, 5698, NULL, SDO_ELEM_INFO_ARRAY(1, 1005, 4, 1, 2, 2, 7, 2, 1, 10, 2, 2, 22, 2, 1), SDO_ORDINATE_ARRAY(-1, -5, 1, 5, -7, 2, 17, -6, 3, 13, 4, 4, 10, .1, 5, 7, 2.2, 6, 5, 4, 7, 1, 2, 8, -1, -5, 1)) from dual;
UNION ALL SELECT 13, SDO_GEOMETRY(3003, 5698, NULL, SDO_ELEM_INFO_ARRAY(1, 1005, 4, 1, 2, 2, 7, 2, 1, 10, 2, 2, 22, 2, 1), SDO_ORDINATE_ARRAY(-1, -5, 1, 5, -7, 2, 17, -6, 3, 13, 4, 4, 10, .1, 5, 7, 2.2, 6, 5, 4, 7, 1, 2, 8, -1, -5, 1)) from dual
UNION ALL SELECT 14, SDO_GEOMETRY(2007, 3857, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1), SDO_ORDINATE_ARRAY(22, 22, 28, 22, 28, 26, 22, 26, 22, 22)) from dual;

CREATE TABLE QGIS.DATE_TIMES ( "id" INTEGER PRIMARY KEY, "date_field" DATE, "datetime_field" TIMESTAMP );

0 comments on commit 1f3370a

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