00001 /********************************************************************** 00002 * $Id: TaggedLinesSimplifier.h 2556 2009-06-06 22:22:28Z strk $ 00003 * 00004 * GEOS - Geometry Engine Open Source 00005 * http://geos.refractions.net 00006 * 00007 * Copyright (C) 2006 Refractions Research Inc. 00008 * 00009 * This is free software; you can redistribute and/or modify it under 00010 * the terms of the GNU Lesser General Licence as published 00011 * by the Free Software Foundation. 00012 * See the COPYING file for more information. 00013 * 00014 ********************************************************************** 00015 * 00016 * Last port: simplify/TaggedLinesSimplifier.java rev. 1.4 (JTS-1.7.1) 00017 * 00018 ********************************************************************** 00019 * 00020 * NOTES: changed from JTS design adding a private 00021 * TaggedLineStringSimplifier member and making 00022 * simplify(collection) method become a templated 00023 * function. 00024 * 00025 **********************************************************************/ 00026 00027 #ifndef _GEOS_SIMPLIFY_TAGGEDLINESSIMPLIFIER_H_ 00028 #define _GEOS_SIMPLIFY_TAGGEDLINESSIMPLIFIER_H_ 00029 00030 #include <geos/export.h> 00031 #include <vector> 00032 #include <memory> 00033 #include <cassert> 00034 00035 #include <geos/simplify/LineSegmentIndex.h> // for templated function body 00036 00037 // Forward declarations 00038 namespace geos { 00039 namespace simplify { 00040 //class LineSegmentIndex; 00041 class TaggedLineString; 00042 class TaggedLineStringSimplifier; 00043 } 00044 } 00045 00046 namespace geos { 00047 namespace simplify { // geos::simplify 00048 00053 class GEOS_DLL TaggedLinesSimplifier { 00054 00055 public: 00056 00057 TaggedLinesSimplifier(); 00058 00067 void setDistanceTolerance(double tolerance); 00068 00082 template <class iterator_type> 00083 void simplify( 00084 iterator_type begin, 00085 iterator_type end) 00086 { 00087 // add lines to the index 00088 for (iterator_type it=begin; it != end; ++it) { 00089 assert(*it); 00090 inputIndex->add(*(*it)); 00091 } 00092 00093 // Simplify lines 00094 for (iterator_type it=begin; it != end; ++it) { 00095 assert(*it); 00096 simplify(*(*it)); 00097 } 00098 } 00099 00100 00101 private: 00102 00103 void simplify(TaggedLineString& line); 00104 00105 std::auto_ptr<LineSegmentIndex> inputIndex; 00106 00107 std::auto_ptr<LineSegmentIndex> outputIndex; 00108 00109 std::auto_ptr<TaggedLineStringSimplifier> taggedlineSimplifier; 00110 00111 }; 00112 00113 00114 } // namespace geos::simplify 00115 } // namespace geos 00116 00117 #endif // _GEOS_SIMPLIFY_TAGGEDLINESSIMPLIFIER_H_ 00118 00119 /********************************************************************** 00120 * $Log$ 00121 * Revision 1.4 2006/05/24 15:32:11 strk 00122 * * source/headers/geos/simplify/TaggedLinesSimplifier.h: added LineSegmentIndex.h include so that every use of the templated simplify() function get all the required definitions. 00123 * 00124 * Revision 1.3 2006/05/24 11:41:23 strk 00125 * * source/headers/geos/simplify/TaggedLinesSimplifier.h, 00126 * source/simplify/TaggedLinesSimplifier.cpp, 00127 * source/simplify/TopologyPreservingSimplifier.cpp: 00128 * fixed bug in TopologyPreservingSimplifier failing to 00129 * detect intersections, refactored TaggedLinesSimplifier 00130 * class to more closely match JTS and use templated 00131 * functions. 00132 * 00133 * Revision 1.2 2006/04/13 14:25:17 strk 00134 * TopologyPreservingSimplifier initial port 00135 * 00136 * Revision 1.1 2006/04/13 10:39:12 strk 00137 * Initial implementation of TaggedLinesSimplifier class 00138 * 00139 **********************************************************************/
1.4.4