GEOS  3.8.0dev
TaggedLinesSimplifier.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/TaggedLinesSimplifier.java rev. 1.4 (JTS-1.7.1)
16  *
17  **********************************************************************
18  *
19  * NOTES: changed from JTS design adding a private
20  * TaggedLineStringSimplifier member and making
21  * simplify(collection) method become a templated
22  * function.
23  *
24  **********************************************************************/
25 
26 #ifndef GEOS_SIMPLIFY_TAGGEDLINESSIMPLIFIER_H
27 #define GEOS_SIMPLIFY_TAGGEDLINESSIMPLIFIER_H
28 
29 #include <geos/export.h>
30 #include <vector>
31 #include <memory>
32 #include <cassert>
33 
34 #include <geos/simplify/LineSegmentIndex.h> // for templated function body
35 #include <geos/simplify/TaggedLineStringSimplifier.h>
36 
37 #ifdef _MSC_VER
38 #pragma warning(push)
39 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
40 #endif
41 
42 // Forward declarations
43 namespace geos {
44 namespace simplify {
45 class TaggedLineString;
46 }
47 }
48 
49 namespace geos {
50 namespace simplify { // geos::simplify
51 
56 class GEOS_DLL TaggedLinesSimplifier {
57 
58 public:
59 
61 
70  void setDistanceTolerance(double tolerance);
71 
85  template <class iterator_type>
86  void
88  iterator_type begin,
89  iterator_type end)
90  {
91  // add lines to the index
92  for(iterator_type it = begin; it != end; ++it) {
93  assert(*it);
94  inputIndex->add(*(*it));
95  }
96 
97  // Simplify lines
98  for(iterator_type it = begin; it != end; ++it) {
99  assert(*it);
100  simplify(*(*it));
101  }
102  }
103 
104 
105 private:
106 
107  void simplify(TaggedLineString& line);
108 
109  std::unique_ptr<LineSegmentIndex> inputIndex;
110 
111  std::unique_ptr<LineSegmentIndex> outputIndex;
112 
113  std::unique_ptr<TaggedLineStringSimplifier> taggedlineSimplifier;
114 };
115 
116 } // namespace geos::simplify
117 } // namespace geos
118 
119 #ifdef _MSC_VER
120 #pragma warning(pop)
121 #endif
122 
123 #endif // GEOS_SIMPLIFY_TAGGEDLINESSIMPLIFIER_H
Simplifies a collection of TaggedLineStrings, preserving topology (in the sense that no new intersect...
Definition: TaggedLinesSimplifier.h:56
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25
Contains and owns a list of TaggedLineSegments.
Definition: TaggedLineString.h:60
void simplify(iterator_type begin, iterator_type end)
Definition: TaggedLinesSimplifier.h:87