QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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 
21 
23 {
25 }
26 
27 void QgsSimplifyMethod::setTolerance( double tolerance )
28 {
30 }
31 
32 void QgsSimplifyMethod::setForceLocalOptimization( bool localOptimization )
33 {
34  mForceLocalOptimization = localOptimization;
35 }
36 
38 {
39  const QgsSimplifyMethod::MethodType methodType = simplifyMethod.methodType();
40 
41  // returns a geometry simplifier according to specified method
43  {
45  return new QgsMapToPixelSimplifier( simplifyFlags, simplifyMethod.tolerance(), QgsMapToPixelSimplifier::Distance );
46  }
48  {
49  return new QgsTopologyPreservingSimplifier( simplifyMethod.tolerance() );
50  }
51  else
52  {
53  QgsDebugMsg( QStringLiteral( "Simplification method type (%1) is not recognised" ).arg( methodType ) );
54  return nullptr;
55  }
56 }
57 
59 {
60  return
61  mMethodType == v.mMethodType &&
62  mTolerance == v.mTolerance &&
63  mThreshold == v.mThreshold &&
65 }
66 
68 {
69  return !( v == *this );
70 }
QgsSimplifyMethod
This class contains information about how to simplify geometries fetched from a QgsFeatureIterator.
Definition: qgssimplifymethod.h:28
QgsDebugMsg
#define QgsDebugMsg(str)
Definition: qgslogger.h:38
QgsSimplifyMethod::mMethodType
MethodType mMethodType
Simplification method.
Definition: qgssimplifymethod.h:72
qgsgeometrysimplifier.h
QgsMapToPixelSimplifier::Distance
@ Distance
The simplification uses the distance between points to remove duplicate points.
Definition: qgsmaptopixelgeometrysimplifier.h:44
QgsSimplifyMethod::OptimizeForRendering
@ OptimizeForRendering
Simplify using the map2pixel data to optimize the rendering of geometries.
Definition: qgssimplifymethod.h:34
QgsAbstractGeometrySimplifier
Abstract base class for simplify geometries using a specific algorithm.
Definition: qgsgeometrysimplifier.h:34
QgsSimplifyMethod::mThreshold
float mThreshold
Simplification threshold.
Definition: qgssimplifymethod.h:76
QgsSimplifyMethod::operator!=
bool operator!=(const QgsSimplifyMethod &v) const
Inequality operator.
Definition: qgssimplifymethod.cpp:67
QgsSimplifyMethod::setTolerance
void setTolerance(double tolerance)
Sets the tolerance of simplification in map units. Represents the maximum distance in map units betwe...
Definition: qgssimplifymethod.cpp:27
QgsSimplifyMethod::tolerance
double tolerance() const
Gets the tolerance of simplification in map units. Represents the maximum distance in map units betwe...
Definition: qgssimplifymethod.h:49
QgsMapToPixelSimplifier::SimplifyEnvelope
@ SimplifyEnvelope
The geometries can be fully simplified by its BoundingBox.
Definition: qgsmaptopixelgeometrysimplifier.h:58
QgsMapToPixelSimplifier::SimplifyGeometry
@ SimplifyGeometry
The geometries can be simplified using the current map2pixel context state.
Definition: qgsmaptopixelgeometrysimplifier.h:57
QgsSimplifyMethod::mForceLocalOptimization
bool mForceLocalOptimization
Simplification executes after fetch the geometries from provider, otherwise it executes,...
Definition: qgssimplifymethod.h:78
QgsSimplifyMethod::setForceLocalOptimization
void setForceLocalOptimization(bool localOptimization)
Sets whether the simplification executes after fetch the geometries from provider,...
Definition: qgssimplifymethod.cpp:32
QgsMapToPixelSimplifier
Implementation of GeometrySimplifier using the "MapToPixel" algorithm.
Definition: qgsmaptopixelgeometrysimplifier.h:38
QgsTopologyPreservingSimplifier
Implementation of GeometrySimplifier using the Douglas-Peucker algorithm.
Definition: qgsgeometrysimplifier.h:70
QgsSimplifyMethod::methodType
MethodType methodType() const
Gets the simplification type.
Definition: qgssimplifymethod.h:44
QgsSimplifyMethod::createGeometrySimplifier
static QgsAbstractGeometrySimplifier * createGeometrySimplifier(const QgsSimplifyMethod &simplifyMethod)
Creates a geometry simplifier according to specified method.
Definition: qgssimplifymethod.cpp:37
qgsmaptopixelgeometrysimplifier.h
QgsSimplifyMethod::setMethodType
void setMethodType(MethodType methodType)
Sets the simplification type.
Definition: qgssimplifymethod.cpp:22
QgsSimplifyMethod::MethodType
MethodType
Definition: qgssimplifymethod.h:31
QgsSimplifyMethod::PreserveTopology
@ PreserveTopology
Simplify using the Douglas-Peucker algorithm ensuring that the result is a valid geometry.
Definition: qgssimplifymethod.h:35
qgslogger.h
QgsSimplifyMethod::operator==
bool operator==(const QgsSimplifyMethod &v) const
Equality operator.
Definition: qgssimplifymethod.cpp:58
qgssimplifymethod.h
QgsSimplifyMethod::mTolerance
double mTolerance
Simplification tolerance, it represents the maximum distance between two coordinates which can be con...
Definition: qgssimplifymethod.h:74