Skip to content

Commit

Permalink
fix local simplification for ZM geometries
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Nov 23, 2015
1 parent 169989a commit 09e7102
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/core/qgsmaptopixelgeometrysimplifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ inline static QgsRectangle calculateBoundingBox( QGis::WkbType wkbType, const un
r.setMinimal();

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

for ( size_t i = 0; i < numPoints; ++i )
{
Expand Down Expand Up @@ -157,7 +157,6 @@ bool QgsMapToPixelSimplifier::simplifyWkbGeometry(
bool writeHeader, bool isaLinearRing )
{
bool isGeneralizable = true;
bool hasZValue = QGis::wkbDimensions( wkbType ) == 3;
bool result = false;

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

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

int numPoints;
memcpy( &numPoints, sourceWkb, 4 );
Expand Down Expand Up @@ -329,7 +328,7 @@ bool QgsMapToPixelSimplifier::simplifyWkbGeometry(
memcpy( &numPoints_i, sourceWkb, 4 );
QgsRectangle envelope_i = numRings == 1 ? envelope : calculateBoundingBox( wkbType, sourceWkb + 4, numPoints_i );

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

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

sourceWkbSize_i += 5 + wkbSize_i;
wkb1 += 5 + wkbSize_i;
Expand All @@ -376,7 +375,7 @@ bool QgsMapToPixelSimplifier::simplifyWkbGeometry(
{
int numPoints_i;
memcpy( &numPoints_i, wkb1, 4 );
int wkbSize_i = 4 + numPoints_i * ( hasZValue ? 3 : 2 ) * sizeof( double );
int wkbSize_i = 4 + numPoints_i * QGis::wkbDimensions( wkbType ) * sizeof( double );

sourceWkbSize_i += wkbSize_i;
wkb1 += wkbSize_i;
Expand Down

0 comments on commit 09e7102

Please sign in to comment.