QGIS API Documentation  2.14.0-Essen
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 "qgsgeometry.h"
21 #include "qgscoordinatetransform.h"
22 #include "qgsmaptopixel.h"
23 
24 #include "qgsgeometrysimplifier.h"
25 
33 {
34  public:
35  QgsMapToPixelSimplifier( int simplifyFlags, double tolerance );
36  virtual ~QgsMapToPixelSimplifier();
37 
40  {
41  NoFlags = 0,
42  SimplifyGeometry = 1,
43  SimplifyEnvelope = 2,
44  };
45 
46  private:
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 );
49 
50  protected:
53 
55  double mTolerance;
56 
58  static float calculateLengthSquared2D( double x1, double y1, double x2, double y2 );
59 
60  public:
61  int simplifyFlags() const { return mSimplifyFlags; }
62  void setSimplifyFlags( int simplifyFlags ) { mSimplifyFlags = simplifyFlags; }
63 
65  virtual QgsGeometry* simplify( QgsGeometry* geometry ) const override;
67  virtual bool simplifyGeometry( QgsGeometry* geometry ) const override;
68 
69  // MapToPixel simplification helper methods
70  public:
71 
73  static bool isGeneralizableByMapBoundingBox( const QgsRectangle& envelope, double map2pixelTol );
74 
76  inline bool isGeneralizableByMapBoundingBox( const QgsRectangle& envelope ) const
77  {
78  return isGeneralizableByMapBoundingBox( envelope, mTolerance );
79  }
80 
82  static bool simplifyGeometry( QgsGeometry* geometry, int simplifyFlags, double tolerance );
83 
84 };
85 
86 #endif // QGSMAPTOPIXELGEOMETRYSIMPLIFIER_H
A rectangle specified with double values.
Definition: qgsrectangle.h:35
void setSimplifyFlags(int simplifyFlags)
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:76
WkbType
Used for symbology operations.
Definition: qgis.h:57
virtual bool simplifyGeometry(QgsGeometry *geometry) const =0
Simplifies the specified geometry.
Implementation of GeometrySimplifier using the "MapToPixel" algorithm.
double mTolerance
Distance tolerance for the simplification.
virtual QgsGeometry * simplify(QgsGeometry *geometry) const =0
Returns a simplified version the specified geometry.
int mSimplifyFlags
Current simplification flags.
SimplifyFlag
Applicable simplification flags.
Abstract base class for simplify geometries using a specific algorithm.
bool isGeneralizableByMapBoundingBox(const QgsRectangle &envelope) const
Returns whether the envelope can be replaced by its BBOX when is applied the specified map2pixel cont...