QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
core
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
18
#include "
qgsgeometrysimplifier.h
"
19
#include "
qgslogger.h
"
20
#include "
qgsmaptopixelgeometrysimplifier.h
"
21
22
#include <QString>
23
24
using namespace
Qt::StringLiterals;
25
26
void
QgsSimplifyMethod::setMethodType
(
MethodType
methodType
)
27
{
28
mMethodType
=
methodType
;
29
}
30
31
void
QgsSimplifyMethod::setTolerance
(
double
tolerance
)
32
{
33
mTolerance
=
tolerance
;
34
}
35
36
void
QgsSimplifyMethod::setForceLocalOptimization
(
bool
localOptimization )
37
{
38
mForceLocalOptimization
= localOptimization;
39
}
40
41
QgsAbstractGeometrySimplifier
*
QgsSimplifyMethod::createGeometrySimplifier
(
const
QgsSimplifyMethod
&simplifyMethod )
42
{
43
const
QgsSimplifyMethod::MethodType
methodType
= simplifyMethod.
methodType
();
44
45
// returns a geometry simplifier according to specified method
46
if
(
methodType
==
QgsSimplifyMethod::OptimizeForRendering
)
47
{
48
const
int
simplifyFlags =
QgsMapToPixelSimplifier::SimplifyGeometry
|
QgsMapToPixelSimplifier::SimplifyEnvelope
;
49
return
new
QgsMapToPixelSimplifier
( simplifyFlags, simplifyMethod.
tolerance
(),
Qgis::VectorSimplificationAlgorithm::Distance
);
50
}
51
else
if
(
methodType
==
QgsSimplifyMethod::PreserveTopology
)
52
{
53
return
new
QgsTopologyPreservingSimplifier
( simplifyMethod.
tolerance
() );
54
}
55
else
56
{
57
QgsDebugError
( u
"Simplification method type (%1) is not recognised"
_s.arg(
methodType
) );
58
return
nullptr
;
59
}
60
}
61
62
bool
QgsSimplifyMethod::operator==
(
const
QgsSimplifyMethod
&v )
const
63
{
64
return
mMethodType
== v.
mMethodType
&&
mTolerance
== v.
mTolerance
&&
mThreshold
== v.
mThreshold
&&
mForceLocalOptimization
== v.
mForceLocalOptimization
;
65
}
66
67
bool
QgsSimplifyMethod::operator!=
(
const
QgsSimplifyMethod
&v )
const
68
{
69
return
!( v == *this );
70
}
Qgis::VectorSimplificationAlgorithm::Distance
@ Distance
The simplification uses the distance between points to remove duplicate points.
Definition
qgis.h:3239
QgsAbstractGeometrySimplifier
Abstract base class for simplifying geometries using a specific algorithm.
Definition
qgsgeometrysimplifier.h:35
QgsMapToPixelSimplifier
Implementation of a geometry simplifier using the "MapToPixel" algorithm.
Definition
qgsmaptopixelgeometrysimplifier.h:42
QgsMapToPixelSimplifier::SimplifyEnvelope
@ SimplifyEnvelope
The geometries can be fully simplified by its BoundingBox.
Definition
qgsmaptopixelgeometrysimplifier.h:52
QgsMapToPixelSimplifier::SimplifyGeometry
@ SimplifyGeometry
The geometries can be simplified using the current map2pixel context state.
Definition
qgsmaptopixelgeometrysimplifier.h:51
QgsSimplifyMethod::QgsSimplifyMethod
QgsSimplifyMethod()=default
construct a default method
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:31
QgsSimplifyMethod::operator!=
bool operator!=(const QgsSimplifyMethod &v) const
Definition
qgssimplifymethod.cpp:67
QgsSimplifyMethod::tolerance
double tolerance() const
Gets the tolerance of simplification in map units. Represents the maximum distance in map units betwe...
Definition
qgssimplifymethod.h:48
QgsSimplifyMethod::setForceLocalOptimization
void setForceLocalOptimization(bool localOptimization)
Sets whether the simplification executes after fetch the geometries from provider,...
Definition
qgssimplifymethod.cpp:36
QgsSimplifyMethod::mTolerance
double mTolerance
Simplification tolerance, it represents the maximum distance between two coordinates which can be con...
Definition
qgssimplifymethod.h:70
QgsSimplifyMethod::mForceLocalOptimization
bool mForceLocalOptimization
Simplification executes after fetch the geometries from provider, otherwise it executes,...
Definition
qgssimplifymethod.h:74
QgsSimplifyMethod::mMethodType
MethodType mMethodType
Simplification method.
Definition
qgssimplifymethod.h:68
QgsSimplifyMethod::setMethodType
void setMethodType(MethodType methodType)
Sets the simplification type.
Definition
qgssimplifymethod.cpp:26
QgsSimplifyMethod::operator==
bool operator==(const QgsSimplifyMethod &v) const
Definition
qgssimplifymethod.cpp:62
QgsSimplifyMethod::mThreshold
float mThreshold
Simplification threshold.
Definition
qgssimplifymethod.h:72
QgsSimplifyMethod::methodType
MethodType methodType() const
Gets the simplification type.
Definition
qgssimplifymethod.h:43
QgsSimplifyMethod::MethodType
MethodType
Definition
qgssimplifymethod.h:31
QgsSimplifyMethod::OptimizeForRendering
@ OptimizeForRendering
Simplify using the map2pixel data to optimize the rendering of geometries.
Definition
qgssimplifymethod.h:33
QgsSimplifyMethod::PreserveTopology
@ PreserveTopology
Simplify using the Douglas-Peucker algorithm ensuring that the result is a valid geometry.
Definition
qgssimplifymethod.h:34
QgsSimplifyMethod::createGeometrySimplifier
static QgsAbstractGeometrySimplifier * createGeometrySimplifier(const QgsSimplifyMethod &simplifyMethod)
Creates a geometry simplifier according to specified method.
Definition
qgssimplifymethod.cpp:41
QgsTopologyPreservingSimplifier
Implementation of GeometrySimplifier using the Douglas-Peucker algorithm.
Definition
qgsgeometrysimplifier.h:71
qgsgeometrysimplifier.h
qgslogger.h
QgsDebugError
#define QgsDebugError(str)
Definition
qgslogger.h:71
qgsmaptopixelgeometrysimplifier.h
qgssimplifymethod.h
Generated on
for QGIS API Documentation by
1.17.0