GEOS  3.3.3
DouglasPeuckerLineSimplifier.h
1 /**********************************************************************
2  * $Id: DouglasPeuckerLineSimplifier.h 3255 2011-03-01 17:56:10Z mloskot $
3  *
4  * GEOS - Geometry Engine Open Source
5  * http://geos.refractions.net
6  *
7  * Copyright (C) 2006 Refractions Research Inc.
8  *
9  * This is free software; you can redistribute and/or modify it under
10  * the terms of the GNU Lesser General Licence as published
11  * by the Free Software Foundation.
12  * See the COPYING file for more information.
13  *
14  **********************************************************************
15  *
16  * Last port: simplify/DouglasPeuckerLineSimplifier.java rev. 1.4
17  *
18  **********************************************************************/
19 
20 #ifndef GEOS_SIMPLIFY_DOUBGLASPEUCKERLINESIMPLIFIER_H
21 #define GEOS_SIMPLIFY_DOUBGLASPEUCKERLINESIMPLIFIER_H
22 
23 #include <geos/export.h>
24 #include <vector>
25 #include <memory> // for auto_ptr
26 #include <cstddef>
27 
28 #ifdef _MSC_VER
29 #pragma warning(push)
30 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
31 #endif
32 
33 // Forward declarations
34 namespace geos {
35  namespace geom {
36  class Coordinate;
37  }
38 }
39 
40 namespace geos {
41 namespace simplify { // geos::simplify
42 
43 using namespace std;
44 
50 
51 public:
52 
53  typedef std::vector<short int> BoolVect;
54  typedef std::auto_ptr<BoolVect> BoolVectAutoPtr;
55 
56  typedef std::vector<geom::Coordinate> CoordsVect;
57  typedef std::auto_ptr<CoordsVect> CoordsVectAutoPtr;
58 
59 
64  static CoordsVectAutoPtr simplify(
65  const CoordsVect& nPts,
66  double distanceTolerance);
67 
68  DouglasPeuckerLineSimplifier(const CoordsVect& nPts);
69 
78  void setDistanceTolerance(double nDistanceTolerance);
79 
84  CoordsVectAutoPtr simplify();
85 
86 private:
87 
88  const CoordsVect& pts;
89  BoolVectAutoPtr usePt;
90  double distanceTolerance;
91 
92  void simplifySection(std::size_t i, std::size_t j);
93 
94  // Declare type as noncopyable
97 };
98 
99 } // namespace geos::simplify
100 } // namespace geos
101 
102 #ifdef _MSC_VER
103 #pragma warning(pop)
104 #endif
105 
106 #endif // GEOS_SIMPLIFY_DOUBGLASPEUCKERLINESIMPLIFIER_H
107 
108 /**********************************************************************
109  * $Log$
110  * Revision 1.4 2006/07/10 10:16:06 strk
111  * changed vector<bool> to vector<short int> (see bug#101)
112  *
113  * Revision 1.3 2006/06/12 11:29:23 strk
114  * unsigned int => size_t
115  *
116  * Revision 1.2 2006/04/13 10:39:12 strk
117  * Initial implementation of TaggedLinesSimplifier class
118  *
119  * Revision 1.1 2006/04/03 10:16:11 strk
120  * DouglasPeuckerLineSimplifier class port
121  *
122  **********************************************************************/