Skip to content

Commit d4a482b

Browse files
committedMay 27, 2016
Merge pull request #2900 from ahuarte47/Issue_QPainterSimplification
[Bugfix] QPainter simplification (fixes #14301)
2 parents cbbc535 + 6969a1a commit d4a482b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1088
-668
lines changed
 

‎python/core/qgsclipper.sip

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,5 @@ class QgsClipper
5656
@param wkb pointer to the start of the line wkb
5757
@param clipExtent clipping bounds
5858
@param line out: clipped line coordinates*/
59-
static QgsConstWkbPtr clippedLineWKB( QgsConstWkbPtr wkb, const QgsRectangle& clipExtent, QPolygonF& line );
59+
static QgsConstWkbPtr clippedLineWKB( QgsConstWkbPtr& wkb, const QgsRectangle& clipExtent, QPolygonF& line );
6060
};

‎python/core/qgsmaptopixelgeometrysimplifier.sip

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,16 @@ class QgsMapToPixelSimplifier : QgsAbstractGeometrySimplifier
44
#include "qgsmaptopixelgeometrysimplifier.h"
55
%End
66
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 );
817
virtual ~QgsMapToPixelSimplifier();
918

1019
//! Applicable simplification flags
@@ -20,15 +29,28 @@ class QgsMapToPixelSimplifier : QgsAbstractGeometrySimplifier
2029
//! Returns the squared 2D-distance of the vector defined by the two points specified
2130
static float calculateLengthSquared2D( double x1, double y1, double x2, double y2 );
2231

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+
2335
public:
36+
//! Gets the simplification hints of the vector layer managed
2437
int simplifyFlags() const;
38+
//! Sets the simplification hints of the vector layer managed
2539
void setSimplifyFlags( int simplifyFlags );
2640

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+
2746
//! Returns a simplified version the specified geometry
2847
virtual QgsGeometry* simplify( QgsGeometry* geometry ) const;
2948
//! Simplifies the specified geometry
3049
virtual bool simplifyGeometry( QgsGeometry* geometry ) const;
3150

51+
//! Simplifies the specified WKB-point array
52+
virtual bool simplifyPoints( QgsWKBTypes::Type wkbType, QgsConstWkbPtr& sourceWkbPtr, QPolygonF& targetPoints ) const;
53+
3254
// MapToPixel simplification helper methods
3355
public:
3456

@@ -39,6 +61,9 @@ class QgsMapToPixelSimplifier : QgsAbstractGeometrySimplifier
3961
bool isGeneralizableByMapBoundingBox( const QgsRectangle& envelope ) const;
4062

4163
//! 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 );
4368

4469
};

0 commit comments

Comments
 (0)
Please sign in to comment.