Skip to content

Commit

Permalink
fix multipolygons with only one polygon
Browse files Browse the repository at this point in the history
  • Loading branch information
troopa81 authored and Julien Cabieces committed Jan 22, 2020
1 parent 8b15433 commit 1603dd7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/providers/oracle/ocispatial/qsql_ocispatial.cpp
Expand Up @@ -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 )
{
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions tests/src/python/test_provider_oracle.py
Expand Up @@ -287,6 +287,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 testNestedInsert(self):
tg = QgsTransactionGroup()
Expand Down
3 changes: 2 additions & 1 deletion tests/testdata/provider/testdata_oracle.sql
Expand Up @@ -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 );

Expand Down

0 comments on commit 1603dd7

Please sign in to comment.