Skip to content

Commit 734b8b4

Browse files
committed
Add SimplifyAlgorithm enum for local simplification
It implements the SimplifyAlgorithm enum for local simplification of geometries. Also the SnapToGrid algorithm is added.
1 parent 01ece90 commit 734b8b4

14 files changed

+200
-44
lines changed

python/core/qgsmaptopixelgeometrysimplifier.sip

+15-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ class QgsMapToPixelSimplifier : QgsAbstractGeometrySimplifier
44
#include "qgsmaptopixelgeometrysimplifier.h"
55
%End
66
public:
7+
//! Types of simplification algorithms that can be used
8+
enum SimplifyAlgorithm
9+
{
10+
Distance = 0, //!< The simplification uses the distance between points to remove duplicate points
11+
SnapToGrid = 1, //!< The simplification uses a grid (similar to ST_SnapToGrid) to remove duplicate points
12+
};
13+
714
QgsMapToPixelSimplifier( int simplifyFlags, double tolerance );
815
virtual ~QgsMapToPixelSimplifier();
916

@@ -20,10 +27,16 @@ class QgsMapToPixelSimplifier : QgsAbstractGeometrySimplifier
2027
//! Returns the squared 2D-distance of the vector defined by the two points specified
2128
static float calculateLengthSquared2D( double x1, double y1, double x2, double y2 );
2229

30+
//! Returns whether the points belong to the same grid
31+
static bool equalSnapToGrid( double x1, double y1, double x2, double y2, double gridOriginX, double gridOriginY, float gridInverseSizeXY );
32+
2333
public:
2434
int simplifyFlags() const;
2535
void setSimplifyFlags( int simplifyFlags );
2636

37+
SimplifyAlgorithm simplifyAlgorithm() const;
38+
void setSimplifyAlgorithm( SimplifyAlgorithm simplifyAlgorithm );
39+
2740
//! Returns a simplified version the specified geometry
2841
virtual QgsGeometry* simplify( QgsGeometry* geometry ) const;
2942
//! Simplifies the specified geometry
@@ -42,9 +55,9 @@ class QgsMapToPixelSimplifier : QgsAbstractGeometrySimplifier
4255
bool isGeneralizableByMapBoundingBox( const QgsRectangle& envelope ) const;
4356

4457
//! Simplifies the geometry when is applied the specified map2pixel context
45-
static bool simplifyGeometry( QgsGeometry* geometry, int simplifyFlags, double tolerance );
58+
static bool simplifyGeometry( QgsGeometry* geometry, int simplifyFlags, double tolerance, SimplifyAlgorithm simplifyAlgorithm = Distance );
4659

4760
//! Simplifies the WKB-point array when is applied the specified map2pixel context
48-
static bool simplifyPoints( QgsWKBTypes::Type wkbType, QgsConstWkbPtr& sourceWkbPtr, QPolygonF& targetPoints, int simplifyFlags, double tolerance );
61+
static bool simplifyPoints( QgsWKBTypes::Type wkbType, QgsConstWkbPtr& sourceWkbPtr, QPolygonF& targetPoints, int simplifyFlags, double tolerance, SimplifyAlgorithm simplifyAlgorithm = Distance );
4962

5063
};

python/core/qgsvectorsimplifymethod.sip

+12
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,18 @@ class QgsVectorSimplifyMethod
2929
/** Gets the simplification hints of the vector layer managed */
3030
QFlags<QgsVectorSimplifyMethod::SimplifyHint> simplifyHints() const;
3131

32+
/** Types of local simplification algorithms that can be used */
33+
enum SimplifyAlgorithm
34+
{
35+
Distance = 0, //!< The simplification uses the distance between points to remove duplicate points
36+
SnapToGrid = 1, //!< The simplification uses a grid (similar to ST_SnapToGrid) to remove duplicate points
37+
};
38+
39+
/** Sets the local simplification algorithm of the vector layer managed */
40+
void setSimplifyAlgorithm( const SimplifyAlgorithm& simplifyAlgorithm );
41+
/** Gets the local simplification algorithm of the vector layer managed */
42+
SimplifyAlgorithm simplifyAlgorithm() const;
43+
3244
/** Sets the tolerance of simplification in map units. Represents the maximum distance in map units between two coordinates which can be considered equal */
3345
void setTolerance( double tolerance );
3446
/** Gets the tolerance of simplification in map units. Represents the maximum distance in map units between two coordinates which can be considered equal */

src/app/qgsoptions.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,11 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl )
613613
doubleSpinBoxMagnifierDefault->setSuffix( "%" );
614614
doubleSpinBoxMagnifierDefault->setValue( mSettings->value( "/qgis/magnifier_level", 100 ).toInt() );
615615

616+
// Default local simplification algorithm
617+
mSimplifyAlgorithmComboBox->addItem( tr( "Distance" ), ( int )QgsVectorSimplifyMethod::Distance );
618+
mSimplifyAlgorithmComboBox->addItem( tr( "SnapToGrid" ), ( int )QgsVectorSimplifyMethod::SnapToGrid );
619+
mSimplifyAlgorithmComboBox->setCurrentIndex( mSimplifyAlgorithmComboBox->findData( mSettings->value( "/qgis/simplifyAlgorithm", 0 ).toInt() ) );
620+
616621
// Slightly awkard here at the settings value is true to use QImage,
617622
// but the checkbox is true to use QPixmap
618623
chkAddedVisibility->setChecked( mSettings->value( "/qgis/new_layers_visible", true ).toBool() );
@@ -1212,6 +1217,7 @@ void QgsOptions::saveOptions()
12121217
if ( mSimplifyDrawingSpinBox->value() > 1 ) simplifyHints |= QgsVectorSimplifyMethod::AntialiasingSimplification;
12131218
}
12141219
mSettings->setValue( "/qgis/simplifyDrawingHints", ( int ) simplifyHints );
1220+
mSettings->setValue( "/qgis/simplifyAlgorithm", mSimplifyAlgorithmComboBox->itemData( mSimplifyAlgorithmComboBox->currentIndex() ).toInt() );
12151221
mSettings->setValue( "/qgis/simplifyDrawingTol", mSimplifyDrawingSpinBox->value() );
12161222
mSettings->setValue( "/qgis/simplifyLocal", !mSimplifyDrawingAtProvider->isChecked() );
12171223
mSettings->setValue( "/qgis/simplifyMaxScale", 1.0 / mSimplifyMaximumScaleComboBox->scale() );

src/app/qgsvectorlayerproperties.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,11 @@ void QgsVectorLayerProperties::syncToLayer()
439439
mSimplifyDrawingGroupBox->setEnabled( false );
440440
}
441441

442+
// Default local simplification algorithm
443+
mSimplifyAlgorithmComboBox->addItem( tr( "Distance" ), ( int )QgsVectorSimplifyMethod::Distance );
444+
mSimplifyAlgorithmComboBox->addItem( tr( "SnapToGrid" ), ( int )QgsVectorSimplifyMethod::SnapToGrid );
445+
mSimplifyAlgorithmComboBox->setCurrentIndex( mSimplifyAlgorithmComboBox->findData(( int )simplifyMethod.simplifyAlgorithm() ) );
446+
442447
QStringList myScalesList = PROJECT_SCALES.split( ',' );
443448
myScalesList.append( "1:1" );
444449
mSimplifyMaximumScaleComboBox->updateScales( myScalesList );
@@ -625,6 +630,7 @@ void QgsVectorLayerProperties::apply()
625630
}
626631
QgsVectorSimplifyMethod simplifyMethod = mLayer->simplifyMethod();
627632
simplifyMethod.setSimplifyHints( simplifyHints );
633+
simplifyMethod.setSimplifyAlgorithm( static_cast< QgsVectorSimplifyMethod::SimplifyAlgorithm >( mSimplifyAlgorithmComboBox->itemData( mSimplifyAlgorithmComboBox->currentIndex() ).toInt() ) );
628634
simplifyMethod.setThreshold( mSimplifyDrawingSpinBox->value() );
629635
simplifyMethod.setForceLocalOptimization( !mSimplifyDrawingAtProvider->isChecked() );
630636
simplifyMethod.setMaximumScale( 1.0 / mSimplifyMaximumScaleComboBox->scale() );

src/core/geometry/qgswkbsimplifierptr.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@ const QgsConstWkbPtr &QgsConstWkbSimplifierPtr::operator>>( QPolygonF &points )
3333
if ( mSimplifyMethod.simplifyHints() != QgsVectorSimplifyMethod::NoSimplification && mSimplifyMethod.forceLocalOptimization() )
3434
{
3535
int simplifyHints = mSimplifyMethod.simplifyHints() | QgsMapToPixelSimplifier::SimplifyEnvelope;
36+
QgsMapToPixelSimplifier::SimplifyAlgorithm simplifyAlgorithm = static_cast< QgsMapToPixelSimplifier::SimplifyAlgorithm >( mSimplifyMethod.simplifyAlgorithm() );
3637

3738
QgsConstWkbPtr wkbPtr = *this;
3839

39-
if ( QgsMapToPixelSimplifier::simplifyPoints( mWkbType, wkbPtr, points, simplifyHints, mSimplifyMethod.tolerance() ) )
40+
if ( QgsMapToPixelSimplifier::simplifyPoints( mWkbType, wkbPtr, points, simplifyHints, mSimplifyMethod.tolerance(), simplifyAlgorithm ) )
4041
{
4142
mP = const_cast< unsigned char * >(( const unsigned char * ) wkbPtr );
4243
return *this;

src/core/qgsmaptopixelgeometrysimplifier.cpp

+76-28
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@
2121
#include "qgslogger.h"
2222

2323

24-
QgsMapToPixelSimplifier::QgsMapToPixelSimplifier( int simplifyFlags, double tolerance )
24+
QgsMapToPixelSimplifier::QgsMapToPixelSimplifier( int simplifyFlags, double tolerance, SimplifyAlgorithm simplifyAlgorithm )
2525
: mSimplifyFlags( simplifyFlags )
2626
, mTolerance( tolerance )
27+
, mSimplifyAlgorithm( simplifyAlgorithm )
2728
{
2829
}
2930

@@ -40,7 +41,22 @@ float QgsMapToPixelSimplifier::calculateLengthSquared2D( double x1, double y1, d
4041
float vx = static_cast< float >( x2 - x1 );
4142
float vy = static_cast< float >( y2 - y1 );
4243

43-
return vx*vx + vy*vy;
44+
return ( vx * vx ) + ( vy * vy );
45+
}
46+
47+
48+
//! Returns whether the points belong to the same grid
49+
bool QgsMapToPixelSimplifier::equalSnapToGrid( double x1, double y1, double x2, double y2, double gridOriginX, double gridOriginY, float gridInverseSizeXY )
50+
{
51+
int grid_x1 = qRound(( x1 - gridOriginX ) * gridInverseSizeXY );
52+
int grid_x2 = qRound(( x2 - gridOriginX ) * gridInverseSizeXY );
53+
if ( grid_x1 != grid_x2 ) return false;
54+
55+
int grid_y1 = qRound(( y1 - gridOriginY ) * gridInverseSizeXY );
56+
int grid_y2 = qRound(( y2 - gridOriginY ) * gridInverseSizeXY );
57+
if ( grid_y1 != grid_y2 ) return false;
58+
59+
return true;
4460
}
4561

4662
//! Returns the BBOX of the specified WKB-point stream
@@ -122,7 +138,9 @@ static bool generalizeWkbGeometryByBoundingBox(
122138

123139
//! Simplify the WKB-geometry using the specified tolerance
124140
bool QgsMapToPixelSimplifier::simplifyWkbGeometry(
125-
int simplifyFlags, QGis::WkbType wkbType,
141+
int simplifyFlags,
142+
SimplifyAlgorithm simplifyAlgorithm,
143+
QGis::WkbType wkbType,
126144
QgsConstWkbPtr sourceWkbPtr,
127145
QgsWkbPtr targetWkbPtr,
128146
int &targetWkbSize,
@@ -184,8 +202,6 @@ bool QgsMapToPixelSimplifier::simplifyWkbGeometry(
184202
targetWkbPtr << numTargetPoints;
185203
targetWkbSize += 4;
186204

187-
map2pixelTol *= map2pixelTol; //-> Use mappixelTol for 'LengthSquare' calculations.
188-
189205
bool isLongSegment;
190206
bool hasLongSegments = false; //-> To avoid replace the simplified geometry by its BBOX when there are 'long' segments.
191207
bool badLuck = false;
@@ -205,27 +221,59 @@ bool QgsMapToPixelSimplifier::simplifyWkbGeometry(
205221
}
206222

207223
// Process each vertex...
208-
for ( int i = 0; i < numPoints; ++i )
224+
if ( simplifyAlgorithm == SnapToGrid )
209225
{
210-
sourceWkbPtr >> x >> y;
211-
sourceWkbPtr += skipZM;
226+
double gridOriginX = envelope.xMinimum();
227+
double gridOriginY = envelope.yMinimum();
212228

213-
isLongSegment = false;
229+
// Use a factor for the maximum displacement distance for simplification, similar as GeoServer does
230+
float gridInverseSizeXY = map2pixelTol != 0 ? ( float )( 1.0f / ( 0.8 * map2pixelTol ) ) : 0.0f;
214231

215-
if ( i == 0 ||
216-
!isGeneralizable ||
217-
( isLongSegment = ( calculateLengthSquared2D( x, y, lastX, lastY ) > map2pixelTol ) ) ||
218-
( !isaLinearRing && ( i == 1 || i >= numPoints - 2 ) ) )
232+
for ( int i = 0; i < numPoints; ++i )
219233
{
220-
targetWkbPtr << x << y;
221-
lastX = x;
222-
lastY = y;
223-
numTargetPoints++;
234+
sourceWkbPtr >> x >> y;
235+
sourceWkbPtr += skipZM;
236+
237+
if ( i == 0 ||
238+
!isGeneralizable ||
239+
!equalSnapToGrid( x, y, lastX, lastY, gridOriginX, gridOriginY, gridInverseSizeXY ) ||
240+
( !isaLinearRing && ( i == 1 || i >= numPoints - 2 ) ) )
241+
{
242+
targetWkbPtr << x << y;
243+
lastX = x;
244+
lastY = y;
245+
numTargetPoints++;
246+
}
224247

225-
hasLongSegments |= isLongSegment;
248+
r.combineExtentWith( x, y );
226249
}
250+
}
251+
else
252+
{
253+
map2pixelTol *= map2pixelTol; //-> Use mappixelTol for 'LengthSquare' calculations.
254+
255+
for ( int i = 0; i < numPoints; ++i )
256+
{
257+
sourceWkbPtr >> x >> y;
258+
sourceWkbPtr += skipZM;
259+
260+
isLongSegment = false;
227261

228-
r.combineExtentWith( x, y );
262+
if ( i == 0 ||
263+
!isGeneralizable ||
264+
( isLongSegment = ( calculateLengthSquared2D( x, y, lastX, lastY ) > map2pixelTol ) ) ||
265+
( !isaLinearRing && ( i == 1 || i >= numPoints - 2 ) ) )
266+
{
267+
targetWkbPtr << x << y;
268+
lastX = x;
269+
lastY = y;
270+
numTargetPoints++;
271+
272+
hasLongSegments |= isLongSegment;
273+
}
274+
275+
r.combineExtentWith( x, y );
276+
}
229277
}
230278

231279
QgsWkbPtr nextPointPtr( targetWkbPtr );
@@ -296,7 +344,7 @@ bool QgsMapToPixelSimplifier::simplifyWkbGeometry(
296344
int sourceWkbSize_i = sizeof( int ) + numPoints_i * QGis::wkbDimensions( wkbType ) * sizeof( double );
297345
int targetWkbSize_i = 0;
298346

299-
result |= simplifyWkbGeometry( simplifyFlags, wkbType, sourceWkbPtr, targetWkbPtr, targetWkbSize_i, envelope_i, map2pixelTol, false, true );
347+
result |= simplifyWkbGeometry( simplifyFlags, simplifyAlgorithm, wkbType, sourceWkbPtr, targetWkbPtr, targetWkbSize_i, envelope_i, map2pixelTol, false, true );
300348
sourceWkbPtr += sourceWkbSize_i;
301349
targetWkbPtr += targetWkbSize_i;
302350

@@ -347,7 +395,7 @@ bool QgsMapToPixelSimplifier::simplifyWkbGeometry(
347395
sourceWkbPtr2 += wkbSize_i;
348396
}
349397
}
350-
result |= simplifyWkbGeometry( simplifyFlags, QGis::singleType( wkbType ), sourceWkbPtr, targetWkbPtr, targetWkbSize_i, envelope, map2pixelTol, true, false );
398+
result |= simplifyWkbGeometry( simplifyFlags, simplifyAlgorithm, QGis::singleType( wkbType ), sourceWkbPtr, targetWkbPtr, targetWkbSize_i, envelope, map2pixelTol, true, false );
351399
sourceWkbPtr += sourceWkbSize_i;
352400
targetWkbPtr += targetWkbSize_i;
353401

@@ -376,13 +424,13 @@ QgsGeometry* QgsMapToPixelSimplifier::simplify( QgsGeometry* geometry ) const
376424
unsigned char* wkb = new unsigned char[ wkbSize ];
377425
memcpy( wkb, geometry->asWkb(), wkbSize );
378426
g->fromWkb( wkb, wkbSize );
379-
simplifyGeometry( g, mSimplifyFlags, mTolerance );
427+
simplifyGeometry( g, mSimplifyFlags, mTolerance, mSimplifyAlgorithm );
380428

381429
return g;
382430
}
383431

384432
//! Simplifies the geometry (Removing duplicated points) when is applied the specified map2pixel context
385-
bool QgsMapToPixelSimplifier::simplifyGeometry( QgsGeometry *geometry, int simplifyFlags, double tolerance )
433+
bool QgsMapToPixelSimplifier::simplifyGeometry( QgsGeometry *geometry, int simplifyFlags, double tolerance, SimplifyAlgorithm simplifyAlgorithm )
386434
{
387435
int finalWkbSize = 0;
388436

@@ -402,7 +450,7 @@ bool QgsMapToPixelSimplifier::simplifyGeometry( QgsGeometry *geometry, int simpl
402450

403451
try
404452
{
405-
if ( simplifyWkbGeometry( simplifyFlags, wkbType, wkbPtr, targetWkbPtr, finalWkbSize, envelope, tolerance ) )
453+
if ( simplifyWkbGeometry( simplifyFlags, simplifyAlgorithm, wkbType, wkbPtr, targetWkbPtr, finalWkbSize, envelope, tolerance ) )
406454
{
407455
unsigned char *finalWkb = new unsigned char[finalWkbSize];
408456
memcpy( finalWkb, targetWkb, finalWkbSize );
@@ -423,11 +471,11 @@ bool QgsMapToPixelSimplifier::simplifyGeometry( QgsGeometry *geometry, int simpl
423471
//! Simplifies the geometry (Removing duplicated points) when is applied the specified map2pixel context
424472
bool QgsMapToPixelSimplifier::simplifyGeometry( QgsGeometry* geometry ) const
425473
{
426-
return simplifyGeometry( geometry, mSimplifyFlags, mTolerance );
474+
return simplifyGeometry( geometry, mSimplifyFlags, mTolerance, mSimplifyAlgorithm );
427475
}
428476

429477
//! Simplifies the WKB-point array (Removing duplicated points) when is applied the specified map2pixel context
430-
bool QgsMapToPixelSimplifier::simplifyPoints( QgsWKBTypes::Type wkbType, QgsConstWkbPtr& sourceWkbPtr, QPolygonF& targetPoints, int simplifyFlags, double tolerance )
478+
bool QgsMapToPixelSimplifier::simplifyPoints( QgsWKBTypes::Type wkbType, QgsConstWkbPtr& sourceWkbPtr, QPolygonF& targetPoints, int simplifyFlags, double tolerance, SimplifyAlgorithm simplifyAlgorithm )
431479
{
432480
QgsWKBTypes::Type singleType = QgsWKBTypes::singleType( wkbType );
433481
QgsWKBTypes::Type flatType = QgsWKBTypes::flatType( singleType );
@@ -457,7 +505,7 @@ bool QgsMapToPixelSimplifier::simplifyPoints( QgsWKBTypes::Type wkbType, QgsCons
457505
targetWkbPtr << ( char ) QgsApplication::endian() << flatType;
458506
targetWkbSize = 5;
459507

460-
if ( simplifyWkbGeometry( simplifyFlags, QGis::fromNewWkbType( singleType ), sourceWkbPtr, targetWkbPtr, targetWkbSize, envelope, tolerance, false, isaLinearRing ) )
508+
if ( simplifyWkbGeometry( simplifyFlags, simplifyAlgorithm, QGis::fromNewWkbType( singleType ), sourceWkbPtr, targetWkbPtr, targetWkbSize, envelope, tolerance, false, isaLinearRing ) )
461509
{
462510
QgsConstWkbPtr finalWkbPtr( targetWkb, targetWkbSize );
463511
finalWkbPtr.readHeader();
@@ -481,5 +529,5 @@ bool QgsMapToPixelSimplifier::simplifyPoints( QgsWKBTypes::Type wkbType, QgsCons
481529
//! Simplifies the specified WKB-point array
482530
bool QgsMapToPixelSimplifier::simplifyPoints( QgsWKBTypes::Type wkbType, QgsConstWkbPtr& sourceWkbPtr, QPolygonF& targetPoints ) const
483531
{
484-
return simplifyPoints( wkbType, sourceWkbPtr, targetPoints, mSimplifyFlags, mTolerance );
532+
return simplifyPoints( wkbType, sourceWkbPtr, targetPoints, mSimplifyFlags, mTolerance, mSimplifyAlgorithm );
485533
}

src/core/qgsmaptopixelgeometrysimplifier.h

+20-4
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,14 @@
3232
class CORE_EXPORT QgsMapToPixelSimplifier : public QgsAbstractGeometrySimplifier
3333
{
3434
public:
35-
QgsMapToPixelSimplifier( int simplifyFlags, double tolerance );
35+
//! Types of simplification algorithms that can be used
36+
enum SimplifyAlgorithm
37+
{
38+
Distance = 0, //!< The simplification uses the distance between points to remove duplicate points
39+
SnapToGrid = 1, //!< The simplification uses a grid (similar to ST_SnapToGrid) to remove duplicate points
40+
};
41+
42+
QgsMapToPixelSimplifier( int simplifyFlags, double tolerance, SimplifyAlgorithm simplifyAlgorithm = Distance );
3643
virtual ~QgsMapToPixelSimplifier();
3744

3845
//! Applicable simplification flags
@@ -45,22 +52,31 @@ class CORE_EXPORT QgsMapToPixelSimplifier : public QgsAbstractGeometrySimplifier
4552

4653
private:
4754
//! Simplify the WKB-geometry using the specified tolerance
48-
static bool simplifyWkbGeometry( int simplifyFlags, QGis::WkbType wkbType, QgsConstWkbPtr sourceWkbPtr, QgsWkbPtr targetWkbPtr, int &targetWkbSize, const QgsRectangle& envelope, double map2pixelTol, bool writeHeader = true, bool isaLinearRing = false );
55+
static bool simplifyWkbGeometry( int simplifyFlags, SimplifyAlgorithm simplifyAlgorithm, QGis::WkbType wkbType, QgsConstWkbPtr sourceWkbPtr, QgsWkbPtr targetWkbPtr, int &targetWkbSize, const QgsRectangle& envelope, double map2pixelTol, bool writeHeader = true, bool isaLinearRing = false );
4956

5057
protected:
5158
//! Current simplification flags
5259
int mSimplifyFlags;
5360

61+
//! Current algorithm
62+
SimplifyAlgorithm mSimplifyAlgorithm;
63+
5464
//! Distance tolerance for the simplification
5565
double mTolerance;
5666

5767
//! Returns the squared 2D-distance of the vector defined by the two points specified
5868
static float calculateLengthSquared2D( double x1, double y1, double x2, double y2 );
5969

70+
//! Returns whether the points belong to the same grid
71+
static bool equalSnapToGrid( double x1, double y1, double x2, double y2, double gridOriginX, double gridOriginY, float gridInverseSizeXY );
72+
6073
public:
6174
int simplifyFlags() const { return mSimplifyFlags; }
6275
void setSimplifyFlags( int simplifyFlags ) { mSimplifyFlags = simplifyFlags; }
6376

77+
SimplifyAlgorithm simplifyAlgorithm() const { return mSimplifyAlgorithm; }
78+
void setSimplifyAlgorithm( SimplifyAlgorithm simplifyAlgorithm ) { mSimplifyAlgorithm = simplifyAlgorithm; }
79+
6480
//! Returns a simplified version the specified geometry
6581
virtual QgsGeometry* simplify( QgsGeometry* geometry ) const override;
6682
//! Simplifies the specified geometry
@@ -82,10 +98,10 @@ class CORE_EXPORT QgsMapToPixelSimplifier : public QgsAbstractGeometrySimplifier
8298
}
8399

84100
//! Simplifies the geometry when is applied the specified map2pixel context
85-
static bool simplifyGeometry( QgsGeometry* geometry, int simplifyFlags, double tolerance );
101+
static bool simplifyGeometry( QgsGeometry* geometry, int simplifyFlags, double tolerance, SimplifyAlgorithm simplifyAlgorithm = Distance );
86102

87103
//! Simplifies the WKB-point array when is applied the specified map2pixel context
88-
static bool simplifyPoints( QgsWKBTypes::Type wkbType, QgsConstWkbPtr& sourceWkbPtr, QPolygonF& targetPoints, int simplifyFlags, double tolerance );
104+
static bool simplifyPoints( QgsWKBTypes::Type wkbType, QgsConstWkbPtr& sourceWkbPtr, QPolygonF& targetPoints, int simplifyFlags, double tolerance, SimplifyAlgorithm simplifyAlgorithm = Distance );
89105
};
90106

91107
#endif // QGSMAPTOPIXELGEOMETRYSIMPLIFIER_H

0 commit comments

Comments
 (0)