QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
core
qgsgeometrysimplifier.cpp
Go to the documentation of this file.
1
/***************************************************************************
2
qgsgeometrysimplifier.cpp
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
#include "
qgsgeometrysimplifier.h
"
18
19
#include <limits>
20
21
#include "
qgsgeometry.h
"
22
#include "
qgsgeos.h
"
23
#include "
qgsrectangle.h
"
24
25
bool
QgsAbstractGeometrySimplifier::isGeneralizableByDeviceBoundingBox
(
const
QgsRectangle
&envelope,
float
mapToPixelTol )
26
{
27
return
( envelope.
xMaximum
() - envelope.
xMinimum
() ) < mapToPixelTol && ( envelope.
yMaximum
() - envelope.
yMinimum
() ) < mapToPixelTol;
28
}
29
30
bool
QgsAbstractGeometrySimplifier::isGeneralizableByDeviceBoundingBox
(
const
QVector<QPointF> &points,
float
mapToPixelTol )
31
{
32
QgsRectangle
r;
33
r.
setNull
();
34
35
for
(
int
i = 0, numPoints = points.size(); i < numPoints; ++i )
36
{
37
r.
combineExtentWith
( points[i].x(), points[i].y() );
38
}
39
return
isGeneralizableByDeviceBoundingBox
( r, mapToPixelTol );
40
}
41
42
/***************************************************************************/
43
44
QgsTopologyPreservingSimplifier::QgsTopologyPreservingSimplifier
(
double
tolerance )
45
:
mTolerance
( tolerance )
46
{}
47
48
QgsGeometry
QgsTopologyPreservingSimplifier::simplify
(
const
QgsGeometry
&geometry )
const
49
{
50
return
geometry.
simplify
(
mTolerance
);
51
}
52
53
QgsAbstractGeometry
*
QgsTopologyPreservingSimplifier::simplify
(
const
QgsAbstractGeometry
*geometry )
const
54
{
55
if
( !geometry )
56
{
57
return
nullptr
;
58
}
59
60
const
QgsGeos
geos
( geometry );
61
std::unique_ptr< QgsAbstractGeometry > simplifiedGeom(
geos
.simplify(
mTolerance
) );
62
return
simplifiedGeom.release();
63
}
QgsAbstractGeometrySimplifier::isGeneralizableByDeviceBoundingBox
static bool isGeneralizableByDeviceBoundingBox(const QgsRectangle &envelope, float mapToPixelTol=1.0f)
Returns whether the device-envelope can be replaced by its BBOX when is applied the specified toleran...
Definition
qgsgeometrysimplifier.cpp:25
QgsAbstractGeometry
Abstract base class for all geometries.
Definition
qgsabstractgeometry.h:82
QgsGeometry
A geometry is the spatial representation of a feature.
Definition
qgsgeometry.h:267
QgsGeometry::simplify
QgsGeometry simplify(double tolerance, QgsFeedback *feedback=nullptr) const
Returns a simplified version of this geometry using a specified tolerance value.
Definition
qgsgeometry.cpp:2986
QgsGeos
Does vector analysis using the GEOS library and handles import, export, and exception handling.
Definition
qgsgeos.h:192
QgsRectangle
A rectangle specified with double values.
Definition
qgsrectangle.h:47
QgsRectangle::xMinimum
double xMinimum
Definition
qgsrectangle.h:50
QgsRectangle::yMinimum
double yMinimum
Definition
qgsrectangle.h:52
QgsRectangle::xMaximum
double xMaximum
Definition
qgsrectangle.h:51
QgsRectangle::yMaximum
double yMaximum
Definition
qgsrectangle.h:53
QgsRectangle::combineExtentWith
void combineExtentWith(const QgsRectangle &rect)
Expands the rectangle so that it covers both the original rectangle and the given rectangle.
Definition
qgsrectangle.h:523
QgsRectangle::setNull
void setNull()
Mark a rectangle as being null (holding no spatial information).
Definition
qgsrectangle.h:211
QgsTopologyPreservingSimplifier::simplify
QgsGeometry simplify(const QgsGeometry &geometry) const override
Returns a simplified version the specified geometry.
Definition
qgsgeometrysimplifier.cpp:48
QgsTopologyPreservingSimplifier::mTolerance
double mTolerance
Distance tolerance for the simplification.
Definition
qgsgeometrysimplifier.h:84
QgsTopologyPreservingSimplifier::QgsTopologyPreservingSimplifier
QgsTopologyPreservingSimplifier(double tolerance)
Constructor for QgsTopologyPreservingSimplifier.
Definition
qgsgeometrysimplifier.cpp:44
geos
Contains geos related utilities and functions.
Definition
qgsgeos.h:129
qgsgeometry.h
qgsgeometrysimplifier.h
qgsgeos.h
qgsrectangle.h
Generated on
for QGIS API Documentation by
1.17.0