QGIS API Documentation  2.6.0-Brighton
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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, unsigned char* sourceWkb, size_t sourceWkbSize, unsigned char* targetWkb, size_t& 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;
67  virtual bool simplifyGeometry( QgsGeometry* geometry ) const;
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