QGIS API Documentation  3.14.0-Pi (9f7028fd23)
qgsmaptopixelgeometrysimplifier.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsmaptopixelgeometrysimplifier.h
3  ---------------------
4  begin : December 2013
5  copyright : (C) 2013 by Alvaro Huarte
6  email : http://wiki.osgeo.org/wiki/Alvaro_Huarte
7 
8  ***************************************************************************
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  ***************************************************************************/
16 
17 #ifndef QGSMAPTOPIXELGEOMETRYSIMPLIFIER_H
18 #define QGSMAPTOPIXELGEOMETRYSIMPLIFIER_H
19 
20 #include "qgis_core.h"
21 #include "qgis_sip.h"
22 #include "qgsgeometrysimplifier.h"
23 #include <QPolygonF>
24 #include <memory>
25 
27 class QgsWkbPtr;
28 class QgsConstWkbPtr;
29 
30 
39 {
40  public:
43  {
44  Distance = 0,
45  SnapToGrid = 1,
46  Visvalingam = 2,
47  SnappedToGridGlobal = 3,
48  };
49 
51  QgsMapToPixelSimplifier( int simplifyFlags, double tolerance, SimplifyAlgorithm simplifyAlgorithm = Distance );
52 
55  {
56  NoFlags = 0,
57  SimplifyGeometry = 1,
58  SimplifyEnvelope = 2,
59  };
60 
61  private:
63  static std::unique_ptr<QgsAbstractGeometry> simplifyGeometry( int simplifyFlags, SimplifyAlgorithm simplifyAlgorithm, const QgsAbstractGeometry &geometry, double map2pixelTol, bool isaLinearRing );
64 
65  protected:
68 
71 
73  double mTolerance;
74 
76  static float calculateLengthSquared2D( double x1, double y1, double x2, double y2 );
77 
79  static bool equalSnapToGrid( double x1, double y1, double x2, double y2, double gridOriginX, double gridOriginY, float gridInverseSizeXY );
80 
81  public:
83  int simplifyFlags() const { return mSimplifyFlags; }
85  void setSimplifyFlags( int simplifyFlags ) { mSimplifyFlags = simplifyFlags; }
86 
88  SimplifyAlgorithm simplifyAlgorithm() const { return mSimplifyAlgorithm; }
90  void setSimplifyAlgorithm( SimplifyAlgorithm simplifyAlgorithm ) { mSimplifyAlgorithm = simplifyAlgorithm; }
91 
93  QgsGeometry simplify( const QgsGeometry &geometry ) const override;
94 
96  void setTolerance( double value ) { mTolerance = value; }
97 
98  // MapToPixel simplification helper methods
99  public:
100 
102  static bool isGeneralizableByMapBoundingBox( const QgsRectangle &envelope, double map2pixelTol );
103 
105  inline bool isGeneralizableByMapBoundingBox( const QgsRectangle &envelope ) const
106  {
107  return isGeneralizableByMapBoundingBox( envelope, mTolerance );
108  }
109 };
110 
111 #endif // QGSMAPTOPIXELGEOMETRYSIMPLIFIER_H
QgsMapToPixelSimplifier::setSimplifyFlags
void setSimplifyFlags(int simplifyFlags)
Sets the simplification hints of the vector layer managed.
Definition: qgsmaptopixelgeometrysimplifier.h:85
QgsMapToPixelSimplifier::simplifyAlgorithm
SimplifyAlgorithm simplifyAlgorithm() const
Gets the local simplification algorithm of the vector layer managed.
Definition: qgsmaptopixelgeometrysimplifier.h:88
QgsRectangle
Definition: qgsrectangle.h:41
qgsgeometrysimplifier.h
QgsMapToPixelSimplifier::setTolerance
void setTolerance(double value)
Sets the tolerance of the vector layer managed.
Definition: qgsmaptopixelgeometrysimplifier.h:96
QgsMapToPixelSimplifier::mTolerance
double mTolerance
Distance tolerance for the simplification.
Definition: qgsmaptopixelgeometrysimplifier.h:73
QgsMapToPixelSimplifier::simplifyFlags
int simplifyFlags() const
Gets the simplification hints of the vector layer managed.
Definition: qgsmaptopixelgeometrysimplifier.h:83
QgsMapToPixelSimplifier::SimplifyAlgorithm
SimplifyAlgorithm
Types of simplification algorithms that can be used.
Definition: qgsmaptopixelgeometrysimplifier.h:42
QgsConstWkbPtr
Definition: qgswkbptr.h:127
QgsAbstractGeometrySimplifier
Definition: qgsgeometrysimplifier.h:32
qgis_sip.h
QgsWkbPtr
Definition: qgswkbptr.h:42
QgsAbstractGeometry
Abstract base class for all geometries.
Definition: qgsabstractgeometry.h:71
QgsMapToPixelSimplifier
Definition: qgsmaptopixelgeometrysimplifier.h:38
QgsMapToPixelSimplifier::mSimplifyFlags
int mSimplifyFlags
Current simplification flags.
Definition: qgsmaptopixelgeometrysimplifier.h:67
QgsMapToPixelSimplifier::setSimplifyAlgorithm
void setSimplifyAlgorithm(SimplifyAlgorithm simplifyAlgorithm)
Sets the local simplification algorithm of the vector layer managed.
Definition: qgsmaptopixelgeometrysimplifier.h:90
QgsMapToPixelSimplifier::mSimplifyAlgorithm
SimplifyAlgorithm mSimplifyAlgorithm
Current algorithm.
Definition: qgsmaptopixelgeometrysimplifier.h:70
QgsGeometry
Definition: qgsgeometry.h:122
QgsMapToPixelSimplifier::isGeneralizableByMapBoundingBox
bool isGeneralizableByMapBoundingBox(const QgsRectangle &envelope) const
Returns whether the envelope can be replaced by its BBOX when is applied the specified map2pixel cont...
Definition: qgsmaptopixelgeometrysimplifier.h:105
QgsAbstractGeometrySimplifier::simplify
virtual QgsGeometry simplify(const QgsGeometry &geometry) const =0
Returns a simplified version the specified geometry.
QgsMapToPixelSimplifier::SimplifyFlag
SimplifyFlag
Applicable simplification flags.
Definition: qgsmaptopixelgeometrysimplifier.h:54