QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
qgssimplifymethod.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgssimplifymethod.cpp
3  ---------------------
4  begin : December 2013
5  copyright : (C) 2013 by Matthias Kuhn / Alvaro Huarte
6  email :
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 
16 #include "qgssimplifymethod.h"
17 #include "qgslogger.h"
18 #include "qgsgeometrysimplifier.h"
20 
22  : mMethodType( QgsSimplifyMethod::NoSimplification )
23  , mTolerance( 1 )
24  , mThreshold( 1 )
25  , mForceLocalOptimization( true )
26 {
27 }
28 
30 {
32 }
33 
35 {
37 }
38 
39 void QgsSimplifyMethod::setForceLocalOptimization( bool localOptimization )
40 {
41  mForceLocalOptimization = localOptimization;
42 }
43 
45 {
47 
48  // returns a geometry simplifier according to specified method
49  if ( methodType == QgsSimplifyMethod::OptimizeForRendering )
50  {
52  return new QgsMapToPixelSimplifier( simplifyFlags, simplifyMethod.tolerance(), QgsMapToPixelSimplifier::Distance );
53  }
54  else if ( methodType == QgsSimplifyMethod::PreserveTopology )
55  {
56  return new QgsTopologyPreservingSimplifier( simplifyMethod.tolerance() );
57  }
58  else
59  {
60  QgsDebugMsg( QString( "Simplification method type (%1) is not recognised" ).arg( methodType ) );
61  return nullptr;
62  }
63 }
Implementation of GeometrySimplifier using the Douglas-Peucker algorithm.
#define QgsDebugMsg(str)
Definition: qgslogger.h:33
MethodType mMethodType
Simplification method.
QgsSimplifyMethod()
construct a default method
Simplify using the map2pixel data to optimize the rendering of geometries.
The geometries can be fully simplified by its BoundingBox.
void setTolerance(double tolerance)
Sets the tolerance of simplification in map units. Represents the maximum distance in map units betwe...
double tolerance() const
Gets the tolerance of simplification in map units. Represents the maximum distance in map units betwe...
Implementation of GeometrySimplifier using the "MapToPixel" algorithm.
bool mForceLocalOptimization
Simplification executes after fetch the geometries from provider, otherwise it executes, when supported, in provider before fetch the geometries.
void setForceLocalOptimization(bool localOptimization)
Sets whether the simplification executes after fetch the geometries from provider, otherwise it executes, when supported, in provider before fetch the geometries.
void setMethodType(MethodType methodType)
Sets the simplification type.
MethodType methodType() const
Gets the simplification type.
static QgsAbstractGeometrySimplifier * createGeometrySimplifier(const QgsSimplifyMethod &simplifyMethod)
Creates a geometry simplifier according to specified method.
double mTolerance
Simplification tolerance, it represents the maximum distance between two coordinates which can be con...
This class contains information about how to simplify geometries fetched from a QgsFeatureIterator.
Simplify using the Douglas-Peucker algorithm ensuring that the result is a valid geometry.
The geometries can be simplified using the current map2pixel context state.
The simplification uses the distance between points to remove duplicate points.
Abstract base class for simplify geometries using a specific algorithm.