Skip to content

Commit 09e7102

Browse files
committed
fix local simplification for ZM geometries
1 parent 169989a commit 09e7102

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/core/qgsmaptopixelgeometrysimplifier.cpp

+5-6
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ inline static QgsRectangle calculateBoundingBox( QGis::WkbType wkbType, const un
4848
r.setMinimal();
4949

5050
int sizeOfDoubleX = sizeof( double );
51-
int sizeOfDoubleY = QGis::wkbDimensions( wkbType ) == 3 /*hasZValue*/ ? 2 * sizeof( double ) : sizeof( double );
51+
int sizeOfDoubleY = ( QGis::wkbDimensions( wkbType ) - 1 ) * sizeof( double );
5252

5353
for ( size_t i = 0; i < numPoints; ++i )
5454
{
@@ -157,7 +157,6 @@ bool QgsMapToPixelSimplifier::simplifyWkbGeometry(
157157
bool writeHeader, bool isaLinearRing )
158158
{
159159
bool isGeneralizable = true;
160-
bool hasZValue = QGis::wkbDimensions( wkbType ) == 3;
161160
bool result = false;
162161

163162
// Save initial WKB settings to use when the simplification creates invalid geometries
@@ -206,7 +205,7 @@ bool QgsMapToPixelSimplifier::simplifyWkbGeometry(
206205
r.setMinimal();
207206

208207
int sizeOfDoubleX = sizeof( double );
209-
int sizeOfDoubleY = QGis::wkbDimensions( wkbType ) == 3 /*hasZValue*/ ? 2 * sizeof( double ) : sizeof( double );
208+
int sizeOfDoubleY = ( QGis::wkbDimensions( wkbType ) - 1 ) * sizeof( double );
210209

211210
int numPoints;
212211
memcpy( &numPoints, sourceWkb, 4 );
@@ -329,7 +328,7 @@ bool QgsMapToPixelSimplifier::simplifyWkbGeometry(
329328
memcpy( &numPoints_i, sourceWkb, 4 );
330329
QgsRectangle envelope_i = numRings == 1 ? envelope : calculateBoundingBox( wkbType, sourceWkb + 4, numPoints_i );
331330

332-
size_t sourceWkbSize_i = 4 + numPoints_i * ( hasZValue ? 3 : 2 ) * sizeof( double );
331+
size_t sourceWkbSize_i = 4 + numPoints_i * QGis::wkbDimensions( wkbType ) * sizeof( double );
333332
size_t targetWkbSize_i = 0;
334333

335334
result |= simplifyWkbGeometry( simplifyFlags, wkbType, sourceWkb, sourceWkbSize_i, targetWkb, targetWkbSize_i, envelope_i, map2pixelTol, false, true );
@@ -360,7 +359,7 @@ bool QgsMapToPixelSimplifier::simplifyWkbGeometry(
360359
{
361360
int numPoints_i;
362361
memcpy( &numPoints_i, wkb1 + 5, 4 );
363-
int wkbSize_i = 4 + numPoints_i * ( hasZValue ? 3 : 2 ) * sizeof( double );
362+
int wkbSize_i = 4 + numPoints_i * QGis::wkbDimensions( wkbType ) * sizeof( double );
364363

365364
sourceWkbSize_i += 5 + wkbSize_i;
366365
wkb1 += 5 + wkbSize_i;
@@ -376,7 +375,7 @@ bool QgsMapToPixelSimplifier::simplifyWkbGeometry(
376375
{
377376
int numPoints_i;
378377
memcpy( &numPoints_i, wkb1, 4 );
379-
int wkbSize_i = 4 + numPoints_i * ( hasZValue ? 3 : 2 ) * sizeof( double );
378+
int wkbSize_i = 4 + numPoints_i * QGis::wkbDimensions( wkbType ) * sizeof( double );
380379

381380
sourceWkbSize_i += wkbSize_i;
382381
wkb1 += wkbSize_i;

0 commit comments

Comments
 (0)