TaggedLinesSimplifier.h

00001 /**********************************************************************
00002  *
00003  * GEOS - Geometry Engine Open Source
00004  * http://geos.osgeo.org
00005  *
00006  * Copyright (C) 2006 Refractions Research Inc.
00007  *
00008  * This is free software; you can redistribute and/or modify it under
00009  * the terms of the GNU Lesser General Licence as published
00010  * by the Free Software Foundation. 
00011  * See the COPYING file for more information.
00012  *
00013  **********************************************************************
00014  *
00015  * Last port: simplify/TaggedLinesSimplifier.java rev. 1.4 (JTS-1.7.1)
00016  *
00017  **********************************************************************
00018  *
00019  * NOTES: changed from JTS design adding a private
00020  *        TaggedLineStringSimplifier member and making
00021  *        simplify(collection) method become a templated
00022  *        function.
00023  *
00024  **********************************************************************/
00025 
00026 #ifndef GEOS_SIMPLIFY_TAGGEDLINESSIMPLIFIER_H
00027 #define GEOS_SIMPLIFY_TAGGEDLINESSIMPLIFIER_H
00028 
00029 #include <geos/export.h>
00030 #include <vector>
00031 #include <memory>
00032 #include <cassert>
00033 
00034 #include <geos/simplify/LineSegmentIndex.h> // for templated function body
00035 #include <geos/simplify/TaggedLineStringSimplifier.h>
00036 
00037 #ifdef _MSC_VER
00038 #pragma warning(push)
00039 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
00040 #endif
00041 
00042 // Forward declarations
00043 namespace geos {
00044         namespace simplify {
00045                 class TaggedLineString;
00046         }
00047 }
00048 
00049 namespace geos {
00050 namespace simplify { // geos::simplify
00051 
00056 class GEOS_DLL TaggedLinesSimplifier {
00057 
00058 public:
00059 
00060         TaggedLinesSimplifier();
00061 
00070         void setDistanceTolerance(double tolerance);
00071 
00085         template <class iterator_type>
00086         void simplify(
00087                 iterator_type begin,
00088                 iterator_type end)
00089         {
00090                 // add lines to the index
00091                 for (iterator_type it=begin; it != end; ++it) {
00092                         assert(*it);
00093                         inputIndex->add(*(*it));
00094                 }
00095 
00096                 // Simplify lines
00097                 for (iterator_type it=begin; it != end; ++it) {
00098                         assert(*it);
00099                         simplify(*(*it));
00100                 }
00101         }
00102 
00103 
00104 private:
00105 
00106         void simplify(TaggedLineString& line);
00107 
00108         std::auto_ptr<LineSegmentIndex> inputIndex;
00109 
00110         std::auto_ptr<LineSegmentIndex> outputIndex;
00111 
00112         std::auto_ptr<TaggedLineStringSimplifier> taggedlineSimplifier;
00113 };
00114 
00115 } // namespace geos::simplify
00116 } // namespace geos
00117 
00118 #ifdef _MSC_VER
00119 #pragma warning(pop)
00120 #endif
00121 
00122 #endif // GEOS_SIMPLIFY_TAGGEDLINESSIMPLIFIER_H

Generated on 15 May 2014 for GEOS by  doxygen 1.4.7