GEOS  3.11.0rc0
DouglasPeuckerLineSimplifier.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2006 Refractions Research Inc.
7  *
8  * This is free software; you can redistribute and/or modify it under
9  * the terms of the GNU Lesser General Licence as published
10  * by the Free Software Foundation.
11  * See the COPYING file for more information.
12  *
13  **********************************************************************
14  *
15  * Last port: simplify/DouglasPeuckerLineSimplifier.java rev. 1.4
16  *
17  **********************************************************************/
18 
19 #pragma once
20 
21 #include <geos/export.h>
22 #include <vector>
23 #include <memory> // for unique_ptr
24 
25 #ifdef _MSC_VER
26 #pragma warning(push)
27 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
28 #endif
29 
30 // Forward declarations
31 namespace geos {
32 namespace geom {
33 class Coordinate;
34 }
35 }
36 
37 namespace geos {
38 namespace simplify { // geos::simplify
39 
45 
46 public:
47 
48  typedef std::vector<short int> BoolVect;
49  typedef std::unique_ptr<BoolVect> BoolVectAutoPtr;
50 
51  typedef std::vector<geom::Coordinate> CoordsVect;
52  typedef std::unique_ptr<CoordsVect> CoordsVectAutoPtr;
53 
54 
59  static CoordsVectAutoPtr simplify(
60  const CoordsVect& nPts,
61  double distanceTolerance);
62 
63  DouglasPeuckerLineSimplifier(const CoordsVect& nPts);
64 
73  void setDistanceTolerance(double nDistanceTolerance);
74 
79  CoordsVectAutoPtr simplify();
80 
81 private:
82 
83  const CoordsVect& pts;
84  BoolVectAutoPtr usePt;
85  double distanceTolerance;
86 
87  void simplifySection(std::size_t i, std::size_t j);
88 
89  // Declare type as noncopyable
91  DouglasPeuckerLineSimplifier& operator=(const DouglasPeuckerLineSimplifier& rhs) = delete;
92 };
93 
94 } // namespace geos::simplify
95 } // namespace geos
96 
97 #ifdef _MSC_VER
98 #pragma warning(pop)
99 #endif
100 
Simplifies a linestring (sequence of points) using the standard Douglas-Peucker algorithm.
Definition: DouglasPeuckerLineSimplifier.h:44
static CoordsVectAutoPtr simplify(const CoordsVect &nPts, double distanceTolerance)
Returns a newly allocated Coordinate vector, wrapped into an unique_ptr.
void setDistanceTolerance(double nDistanceTolerance)
Sets the distance tolerance for the simplification.
CoordsVectAutoPtr simplify()
Returns a newly allocated Coordinate vector, wrapped into an unique_ptr.
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25