GEOS  3.9.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 
81  template <class iterator_type>
82  void
84  iterator_type begin,
85  iterator_type end)
86  {
87  // add lines to the index
88  for(iterator_type it = begin; it != end; ++it) {
89  assert(*it);
90  inputIndex->add(*(*it));
91  }
92 
93  // Simplify lines
94  for(iterator_type it = begin; it != end; ++it) {
95  assert(*it);
96  simplify(*(*it));
97  }
98  }
99 
100 
101 private:
102 
103  void simplify(TaggedLineString& line);
104 
105  std::unique_ptr<LineSegmentIndex> inputIndex;
106 
107  std::unique_ptr<LineSegmentIndex> outputIndex;
108 
109  std::unique_ptr<TaggedLineStringSimplifier> taggedlineSimplifier;
110 };
111 
112 } // namespace geos::simplify
113 } // namespace geos
114 
115 #ifdef _MSC_VER
116 #pragma warning(pop)
117 #endif
118 
119 #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)
Simplify a set of TaggedLineStrings.
Definition: TaggedLinesSimplifier.h:83