@@ -4,7 +4,16 @@ class QgsMapToPixelSimplifier : QgsAbstractGeometrySimplifier
4
4
#include "qgsmaptopixelgeometrysimplifier.h"
5
5
%End
6
6
public:
7
- QgsMapToPixelSimplifier( int simplifyFlags, double tolerance );
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
+ Visvalingam = 2, //!< The simplification gives each point in a line an importance weighting, so that least important points are removed first
13
+ };
14
+
15
+ //! Constructor
16
+ QgsMapToPixelSimplifier( int simplifyFlags, double tolerance, SimplifyAlgorithm simplifyAlgorithm = Distance );
8
17
virtual ~QgsMapToPixelSimplifier();
9
18
10
19
//! Applicable simplification flags
@@ -20,15 +29,28 @@ class QgsMapToPixelSimplifier : QgsAbstractGeometrySimplifier
20
29
//! Returns the squared 2D-distance of the vector defined by the two points specified
21
30
static float calculateLengthSquared2D( double x1, double y1, double x2, double y2 );
22
31
32
+ //! Returns whether the points belong to the same grid
33
+ static bool equalSnapToGrid( double x1, double y1, double x2, double y2, double gridOriginX, double gridOriginY, float gridInverseSizeXY );
34
+
23
35
public:
36
+ //! Gets the simplification hints of the vector layer managed
24
37
int simplifyFlags() const;
38
+ //! Sets the simplification hints of the vector layer managed
25
39
void setSimplifyFlags( int simplifyFlags );
26
40
41
+ //! Gets the local simplification algorithm of the vector layer managed
42
+ SimplifyAlgorithm simplifyAlgorithm() const;
43
+ //! Sets the local simplification algorithm of the vector layer managed
44
+ void setSimplifyAlgorithm( SimplifyAlgorithm simplifyAlgorithm );
45
+
27
46
//! Returns a simplified version the specified geometry
28
47
virtual QgsGeometry* simplify( QgsGeometry* geometry ) const;
29
48
//! Simplifies the specified geometry
30
49
virtual bool simplifyGeometry( QgsGeometry* geometry ) const;
31
50
51
+ //! Simplifies the specified WKB-point array
52
+ virtual bool simplifyPoints( QgsWKBTypes::Type wkbType, QgsConstWkbPtr& sourceWkbPtr, QPolygonF& targetPoints ) const;
53
+
32
54
// MapToPixel simplification helper methods
33
55
public:
34
56
@@ -39,6 +61,9 @@ class QgsMapToPixelSimplifier : QgsAbstractGeometrySimplifier
39
61
bool isGeneralizableByMapBoundingBox( const QgsRectangle& envelope ) const;
40
62
41
63
//! Simplifies the geometry when is applied the specified map2pixel context
42
- static bool simplifyGeometry( QgsGeometry* geometry, int simplifyFlags, double tolerance );
64
+ static bool simplifyGeometry( QgsGeometry* geometry, int simplifyFlags, double tolerance, SimplifyAlgorithm simplifyAlgorithm = Distance );
65
+
66
+ //! Simplifies the WKB-point array when is applied the specified map2pixel context
67
+ static bool simplifyPoints( QgsWKBTypes::Type wkbType, QgsConstWkbPtr& sourceWkbPtr, QPolygonF& targetPoints, int simplifyFlags, double tolerance, SimplifyAlgorithm simplifyAlgorithm = Distance );
43
68
44
69
};
0 commit comments