-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
/
qgsgeometrysimplifier.h
67 lines (57 loc) · 2.86 KB
/
qgsgeometrysimplifier.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/***************************************************************************
qgsgeometrysimplifier.h
---------------------
begin : December 2013
copyright : (C) 2013 by Alvaro Huarte
email : http://wiki.osgeo.org/wiki/Alvaro_Huarte
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSGEOMETRYSIMPLIFIER_H
#define QGSGEOMETRYSIMPLIFIER_H
#include "qgsgeometry.h"
/**
* Abstract base class for simplify geometries using a specific algorithm
*/
class CORE_EXPORT QgsAbstractGeometrySimplifier
{
public:
virtual ~QgsAbstractGeometrySimplifier();
//! Returns a simplified version the specified geometry
virtual QgsGeometry* simplify( QgsGeometry* geometry ) = 0;
//! Simplifies the specified geometry
virtual bool simplifyGeometry( QgsGeometry* geometry ) = 0;
// MapToPixel simplification helper methods
public:
//! Returns whether the device-envelope can be replaced by its BBOX when is applied the specified tolerance
static bool canbeGeneralizedByDeviceBoundingBox( const QgsRectangle& envelope, float mapToPixelTol = 1.0f );
//! Returns whether the device-geometry can be replaced by its BBOX when is applied the specified tolerance
static bool canbeGeneralizedByDeviceBoundingBox( const QVector<QPointF>& points, float mapToPixelTol = 1.0f );
};
/***************************************************************************/
/**
* Implementation of GeometrySimplifier using the Douglas-Peucker algorithm
*
* Simplifies a geometry, ensuring that the result is a valid geometry having the same dimension and number of components as the input.
* The simplification uses a maximum distance difference algorithm similar to the one used in the Douglas-Peucker algorithm.
*/
class CORE_EXPORT QgsTopologyPreservingSimplifier : public QgsAbstractGeometrySimplifier
{
public:
QgsTopologyPreservingSimplifier( double tolerance );
virtual ~QgsTopologyPreservingSimplifier();
private:
//! Distance tolerance for the simplification
double mTolerance;
public:
//! Returns a simplified version the specified geometry
virtual QgsGeometry* simplify( QgsGeometry* geometry );
//! Simplifies the specified geometry
virtual bool simplifyGeometry( QgsGeometry* geometry );
};
#endif // QGSGEOMETRYSIMPLIFIER_H