GEOS  3.13.0dev
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 <geos/geom/CoordinateSequence.h>
23 #include <vector>
24 #include <memory> // for unique_ptr
25 
26 #ifdef _MSC_VER
27 #pragma warning(push)
28 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
29 #endif
30 
31 // Forward declarations
32 namespace geos {
33 namespace geom {
34 class Coordinate;
35 }
36 }
37 
38 namespace geos {
39 namespace simplify { // geos::simplify
40 
46 
47 public:
48 
53  static std::unique_ptr<geom::CoordinateSequence> simplify(
54  const geom::CoordinateSequence& nPts,
55  double distanceTolerance,
56  bool preserveClosedEndpoint);
57 
59 
68  void setDistanceTolerance(double nDistanceTolerance);
69 
75  void setPreserveClosedEndpoint(bool preserve);
76 
81  std::unique_ptr<geom::CoordinateSequence> simplify();
82 
83 private:
84 
85  const geom::CoordinateSequence& pts;
86  std::vector<bool> usePt;
87  double distanceTolerance;
88  bool preserveEndpoint;
89 
90  void simplifySection(std::size_t i, std::size_t j);
91 
92  // Declare type as noncopyable
94  DouglasPeuckerLineSimplifier& operator=(const DouglasPeuckerLineSimplifier& rhs) = delete;
95 };
96 
97 } // namespace geos::simplify
98 } // namespace geos
99 
100 #ifdef _MSC_VER
101 #pragma warning(pop)
102 #endif
103 
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:56
Simplifies a linestring (sequence of points) using the standard Douglas-Peucker algorithm.
Definition: DouglasPeuckerLineSimplifier.h:45
void setPreserveClosedEndpoint(bool preserve)
Sets whether the endpoint of a closed LineString should be preserved.
static std::unique_ptr< geom::CoordinateSequence > simplify(const geom::CoordinateSequence &nPts, double distanceTolerance, bool preserveClosedEndpoint)
Returns a newly allocated Coordinate vector, wrapped into an unique_ptr.
void setDistanceTolerance(double nDistanceTolerance)
Sets the distance tolerance for the simplification.
std::unique_ptr< geom::CoordinateSequence > simplify()
Returns a newly allocated Coordinate vector, wrapped into an unique_ptr.
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25