GEOS 3.3.8

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List

TaggedLinesSimplifier.h
1 /**********************************************************************
2 * $Id: TaggedLinesSimplifier.h 2958 2010-03-29 11:29:40Z 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/TaggedLinesSimplifier.java rev. 1.4 (JTS-1.7.1)
17 *
18 **********************************************************************
19 *
20 * NOTES: changed from JTS design adding a private
21 * TaggedLineStringSimplifier member and making
22 * simplify(collection) method become a templated
23 * function.
24 *
25 **********************************************************************/
26
27 #ifndef GEOS_SIMPLIFY_TAGGEDLINESSIMPLIFIER_H
28 #define GEOS_SIMPLIFY_TAGGEDLINESSIMPLIFIER_H
29
30 #include <geos/export.h>
31 #include <vector>
32 #include <memory>
33 #include <cassert>
34
35 #include <geos/simplify/LineSegmentIndex.h> // for templated function body
36 #include <geos/simplify/TaggedLineStringSimplifier.h>
37
38 #ifdef _MSC_VER
39 #pragma warning(push)
40 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
41 #endif
42
43 // Forward declarations
44 namespace geos {
45 namespace simplify {
46 class TaggedLineString;
47 }
48 }
49
50 namespace geos {
51 namespace simplify { // geos::simplify
52
57 class GEOS_DLL TaggedLinesSimplifier {
58
59 public:
60
61 TaggedLinesSimplifier();
62
71 void setDistanceTolerance(double tolerance);
72
86 template <class iterator_type>
87 void simplify(
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::auto_ptr<LineSegmentIndex> inputIndex;
110
111 std::auto_ptr<LineSegmentIndex> outputIndex;
112
113 std::auto_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
124
125 /**********************************************************************
126 * $Log$
127 * Revision 1.4 2006/05/24 15:32:11 strk
128 * * source/headers/geos/simplify/TaggedLinesSimplifier.h: added LineSegmentIndex.h include so that every use of the templated simplify() function get all the required definitions.
129 *
130 * Revision 1.3 2006/05/24 11:41:23 strk
131 * * source/headers/geos/simplify/TaggedLinesSimplifier.h,
132 * source/simplify/TaggedLinesSimplifier.cpp,
133 * source/simplify/TopologyPreservingSimplifier.cpp:
134 * fixed bug in TopologyPreservingSimplifier failing to
135 * detect intersections, refactored TaggedLinesSimplifier
136 * class to more closely match JTS and use templated
137 * functions.
138 *
139 * Revision 1.2 2006/04/13 14:25:17 strk
140 * TopologyPreservingSimplifier initial port
141 *
142 * Revision 1.1 2006/04/13 10:39:12 strk
143 * Initial implementation of TaggedLinesSimplifier class
144 *
145 **********************************************************************/