2014-05-09 04:38:20 +02:00
|
|
|
class QgsMapToPixelSimplifier : QgsAbstractGeometrySimplifier
|
2014-03-13 11:27:16 +01:00
|
|
|
{
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include "qgsmaptopixelgeometrysimplifier.h"
|
|
|
|
%End
|
|
|
|
public:
|
2016-03-23 09:28:20 +01:00
|
|
|
//! Types of simplification algorithms that can be used
|
|
|
|
enum SimplifyAlgorithm
|
|
|
|
{
|
|
|
|
Distance = 0, //!< The simplification uses the distance between points to remove duplicate points
|
|
|
|
SnapToGrid = 1, //!< The simplification uses a grid (similar to ST_SnapToGrid) to remove duplicate points
|
2016-03-29 13:15:06 +02:00
|
|
|
Visvalingam = 2, //!< The simplification gives each point in a line an importance weighting, so that least important points are removed first
|
2016-03-23 09:28:20 +01:00
|
|
|
};
|
|
|
|
|
2016-05-15 05:18:16 +02:00
|
|
|
//! Constructor
|
|
|
|
QgsMapToPixelSimplifier( int simplifyFlags, double tolerance, SimplifyAlgorithm simplifyAlgorithm = Distance );
|
2014-03-13 11:27:16 +01:00
|
|
|
virtual ~QgsMapToPixelSimplifier();
|
|
|
|
|
|
|
|
//! Applicable simplification flags
|
|
|
|
enum SimplifyFlag
|
|
|
|
{
|
|
|
|
NoFlags = 0, //!< No simplification can be applied
|
|
|
|
SimplifyGeometry = 1, //!< The geometries can be simplified using the current map2pixel context state
|
|
|
|
SimplifyEnvelope = 2, //!< The geometries can be fully simplified by its BoundingBox
|
|
|
|
};
|
|
|
|
|
2016-01-04 22:51:18 +11:00
|
|
|
protected:
|
|
|
|
|
|
|
|
//! Returns the squared 2D-distance of the vector defined by the two points specified
|
|
|
|
static float calculateLengthSquared2D( double x1, double y1, double x2, double y2 );
|
|
|
|
|
2016-03-23 09:28:20 +01:00
|
|
|
//! Returns whether the points belong to the same grid
|
|
|
|
static bool equalSnapToGrid( double x1, double y1, double x2, double y2, double gridOriginX, double gridOriginY, float gridInverseSizeXY );
|
|
|
|
|
2014-03-13 11:27:16 +01:00
|
|
|
public:
|
2016-05-15 05:18:16 +02:00
|
|
|
//! Gets the simplification hints of the vector layer managed
|
2014-03-13 11:27:16 +01:00
|
|
|
int simplifyFlags() const;
|
2016-05-15 05:18:16 +02:00
|
|
|
//! Sets the simplification hints of the vector layer managed
|
2014-03-13 11:27:16 +01:00
|
|
|
void setSimplifyFlags( int simplifyFlags );
|
|
|
|
|
2016-05-15 05:18:16 +02:00
|
|
|
//! Gets the local simplification algorithm of the vector layer managed
|
2016-03-23 09:28:20 +01:00
|
|
|
SimplifyAlgorithm simplifyAlgorithm() const;
|
2016-05-15 05:18:16 +02:00
|
|
|
//! Sets the local simplification algorithm of the vector layer managed
|
2016-03-23 09:28:20 +01:00
|
|
|
void setSimplifyAlgorithm( SimplifyAlgorithm simplifyAlgorithm );
|
|
|
|
|
2016-09-01 08:04:39 +10:00
|
|
|
//! Returns a simplified version the specified geometry
|
|
|
|
virtual QgsGeometry simplify( const QgsGeometry& geometry ) const;
|
|
|
|
|
2016-08-21 18:21:01 +02:00
|
|
|
//! Sets the tolerance of the vector layer managed
|
|
|
|
void setTolerance( double value );
|
2016-03-23 09:08:24 +01:00
|
|
|
|
2014-03-13 11:27:16 +01:00
|
|
|
// MapToPixel simplification helper methods
|
|
|
|
public:
|
|
|
|
|
|
|
|
//! Returns whether the envelope can be replaced by its BBOX when is applied the specified map2pixel context
|
2014-08-17 18:41:50 +02:00
|
|
|
static bool isGeneralizableByMapBoundingBox( const QgsRectangle& envelope, double map2pixelTol );
|
2014-03-13 11:27:16 +01:00
|
|
|
};
|