GEOS
3.3.2
|
00001 /********************************************************************** 00002 * $Id: TaggedLineStringSimplifier.h 2958 2010-03-29 11:29:40Z mloskot $ 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/TaggedLineStringSimplifier.java rev. 1.8 (JTS-1.7.1) 00017 * 00018 ********************************************************************** 00019 * 00020 * NOTES: This class can be optimized to work with vector<Coordinate*> 00021 * rather then with CoordinateSequence 00022 * 00023 **********************************************************************/ 00024 00025 #ifndef GEOS_SIMPLIFY_TAGGEDLINESTRINGSIMPLIFIER_H 00026 #define GEOS_SIMPLIFY_TAGGEDLINESTRINGSIMPLIFIER_H 00027 00028 #include <geos/export.h> 00029 #include <cstddef> 00030 #include <vector> 00031 #include <memory> 00032 00033 #ifdef _MSC_VER 00034 #pragma warning(push) 00035 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class 00036 #endif 00037 00038 // Forward declarations 00039 namespace geos { 00040 namespace algorithm { 00041 class LineIntersector; 00042 } 00043 namespace geom { 00044 class CoordinateSequence; 00045 class LineSegment; 00046 } 00047 namespace simplify { 00048 class TaggedLineSegment; 00049 class TaggedLineString; 00050 class LineSegmentIndex; 00051 } 00052 } 00053 00054 namespace geos { 00055 namespace simplify { // geos::simplify 00056 00057 00064 class GEOS_DLL TaggedLineStringSimplifier { 00065 00066 public: 00067 00068 TaggedLineStringSimplifier(LineSegmentIndex* inputIndex, 00069 LineSegmentIndex* outputIndex); 00070 00079 void setDistanceTolerance(double d); 00080 00081 void simplify(TaggedLineString* line); 00082 00083 00084 private: 00085 00086 // externally owned 00087 LineSegmentIndex* inputIndex; 00088 00089 // externally owned 00090 LineSegmentIndex* outputIndex; 00091 00092 std::auto_ptr<algorithm::LineIntersector> li; 00093 00095 TaggedLineString* line; 00096 00097 const geom::CoordinateSequence* linePts; 00098 00099 double distanceTolerance; 00100 00101 void simplifySection(std::size_t i, std::size_t j, 00102 std::size_t depth); 00103 00104 static std::size_t findFurthestPoint( 00105 const geom::CoordinateSequence* pts, 00106 std::size_t i, std::size_t j, 00107 double& maxDistance); 00108 00109 bool hasBadIntersection(const TaggedLineString* parentLine, 00110 const std::vector<std::size_t>& sectionIndex, 00111 const geom::LineSegment& candidateSeg); 00112 00113 bool hasBadInputIntersection(const TaggedLineString* parentLine, 00114 const std::vector<std::size_t>& sectionIndex, 00115 const geom::LineSegment& candidateSeg); 00116 00117 bool hasBadOutputIntersection(const geom::LineSegment& candidateSeg); 00118 00119 bool hasInteriorIntersection(const geom::LineSegment& seg0, 00120 const geom::LineSegment& seg1) const; 00121 00122 std::auto_ptr<TaggedLineSegment> flatten( 00123 std::size_t start, std::size_t end); 00124 00133 static bool isInLineSection( 00134 const TaggedLineString* parentLine, 00135 const std::vector<std::size_t>& sectionIndex, 00136 const TaggedLineSegment* seg); 00137 00146 void remove(const TaggedLineString* line, 00147 std::size_t start, 00148 std::size_t end); 00149 00150 }; 00151 00152 inline void 00153 TaggedLineStringSimplifier::setDistanceTolerance(double d) 00154 { 00155 distanceTolerance = d; 00156 } 00157 00158 } // namespace geos::simplify 00159 } // namespace geos 00160 00161 #ifdef _MSC_VER 00162 #pragma warning(pop) 00163 #endif 00164 00165 #endif // GEOS_SIMPLIFY_TAGGEDLINESTRINGSIMPLIFIER_H 00166 00167 /********************************************************************** 00168 * $Log$ 00169 * Revision 1.3 2006/04/13 21:52:34 strk 00170 * Many debugging lines and assertions added. Fixed bug in TaggedLineString class. 00171 * 00172 * Revision 1.2 2006/04/13 10:39:12 strk 00173 * Initial implementation of TaggedLinesSimplifier class 00174 * 00175 * Revision 1.1 2006/04/12 17:19:57 strk 00176 * Ported TaggedLineStringSimplifier class, made LineSegment class 00177 * polymorphic to fix derivation of TaggedLineSegment 00178 * 00179 **********************************************************************/