QGIS API Documentation  2.18.3-Las Palmas (77b8c3d)
qgswkbsimplifierptr.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgswkbsimplifierptr.cpp
3  ---------------------
4  begin : February 2016
5  copyright : (C) 2016 by Alvaro Huarte
6  email : http://wiki.osgeo.org/wiki/Alvaro_Huarte
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 #include "qgswkbsimplifierptr.h"
16 #include "qgsgeometry.h"
17 #include "qgssimplifymethod.h"
19 
20 QgsConstWkbSimplifierPtr::QgsConstWkbSimplifierPtr( const unsigned char *p, int size, const QgsVectorSimplifyMethod &simplifyMethod )
21  : QgsConstWkbPtr( p, size )
22  , mSimplifyMethod( simplifyMethod )
23 {
24 }
25 
27 {
28  return QgsConstWkbPtr::operator>>( point );
29 }
30 
32 {
33  if ( mSimplifyMethod.simplifyHints() != QgsVectorSimplifyMethod::NoSimplification && mSimplifyMethod.forceLocalOptimization() )
34  {
35  int simplifyHints = mSimplifyMethod.simplifyHints() | QgsMapToPixelSimplifier::SimplifyEnvelope;
37 
38  QgsConstWkbPtr wkbPtr = *this;
39 
40  if ( QgsMapToPixelSimplifier::simplifyPoints( mWkbType, wkbPtr, points, simplifyHints, mSimplifyMethod.tolerance(), simplifyAlgorithm ) )
41  {
42  mP = const_cast< unsigned char * >(( const unsigned char * ) wkbPtr );
43  return *this;
44  }
45  }
47  return *this;
48 }
unsigned char * mP
Definition: qgswkbptr.h:96
double tolerance() const
Gets the tolerance of simplification in map units.
const QgsConstWkbPtr & operator>>(double &v) const
Definition: qgswkbptr.h:118
SimplifyAlgorithm
Types of simplification algorithms that can be used.
QgsConstWkbSimplifierPtr(const unsigned char *p, int size, const QgsVectorSimplifyMethod &simplifyMethod)
Constructor.
No simplification can be applied.
The geometries can be fully simplified by its BoundingBox.
bool forceLocalOptimization() const
Gets where the simplification executes, after fetch the geometries from provider, or when supported...
virtual bool simplifyPoints(QgsWKBTypes::Type wkbType, QgsConstWkbPtr &sourceWkbPtr, QPolygonF &targetPoints) const
Simplifies the specified WKB-point array.
This class contains information how to simplify geometries fetched from a vector layer.
SimplifyHints simplifyHints() const
Gets the simplification hints of the vector layer managed.
const QgsConstWkbPtr & operator>>(double &v) const
Read a double.
QgsWKBTypes::Type mWkbType
Definition: qgswkbptr.h:99
SimplifyAlgorithm simplifyAlgorithm() const
Gets the local simplification algorithm of the vector layer managed.