GEOS 3.2.2
|
00001 /********************************************************************** 00002 * $Id: TaggedLineStringSimplifier.h 2785 2009-12-03 19:55:11Z 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 <vector> 00030 #include <memory> 00031 #include <cstddef> 00032 00033 // Forward declarations 00034 namespace geos { 00035 namespace algorithm { 00036 class LineIntersector; 00037 } 00038 namespace geom { 00039 class CoordinateSequence; 00040 class LineSegment; 00041 } 00042 namespace simplify { 00043 class TaggedLineSegment; 00044 class TaggedLineString; 00045 class LineSegmentIndex; 00046 } 00047 } 00048 00049 namespace geos { 00050 namespace simplify { // geos::simplify 00051 00052 using namespace std; 00053 00060 class GEOS_DLL TaggedLineStringSimplifier { 00061 00062 public: 00063 00064 TaggedLineStringSimplifier(LineSegmentIndex* inputIndex, 00065 LineSegmentIndex* outputIndex); 00066 00075 void setDistanceTolerance(double d); 00076 00077 void simplify(TaggedLineString* line); 00078 00079 00080 private: 00081 00082 // externally owned 00083 LineSegmentIndex* inputIndex; 00084 00085 // externally owned 00086 LineSegmentIndex* outputIndex; 00087 00088 std::auto_ptr<algorithm::LineIntersector> li; 00089 00091 TaggedLineString* line; 00092 00093 const geom::CoordinateSequence* linePts; 00094 00095 double distanceTolerance; 00096 00097 void simplifySection(size_t i, size_t j, 00098 size_t depth); 00099 00100 static size_t findFurthestPoint( 00101 const geom::CoordinateSequence* pts, 00102 size_t i, size_t j, 00103 double& maxDistance); 00104 00105 bool hasBadIntersection(const TaggedLineString* parentLine, 00106 const std::vector<size_t>& sectionIndex, 00107 const geom::LineSegment& candidateSeg); 00108 00109 bool hasBadInputIntersection(const TaggedLineString* parentLine, 00110 const std::vector<size_t>& sectionIndex, 00111 const geom::LineSegment& candidateSeg); 00112 00113 bool hasBadOutputIntersection(const geom::LineSegment& candidateSeg); 00114 00115 bool hasInteriorIntersection(const geom::LineSegment& seg0, 00116 const geom::LineSegment& seg1) const; 00117 00118 std::auto_ptr<TaggedLineSegment> flatten( 00119 size_t start, size_t end); 00120 00129 static bool isInLineSection( 00130 const TaggedLineString* parentLine, 00131 const std::vector<size_t>& sectionIndex, 00132 const TaggedLineSegment* seg); 00133 00142 void remove(const TaggedLineString* line, 00143 size_t start, 00144 size_t end); 00145 00146 }; 00147 00148 inline void 00149 TaggedLineStringSimplifier::setDistanceTolerance(double d) 00150 { 00151 distanceTolerance = d; 00152 } 00153 00154 } // namespace geos::simplify 00155 } // namespace geos 00156 00157 #endif // GEOS_SIMPLIFY_TAGGEDLINESTRINGSIMPLIFIER_H 00158 00159 /********************************************************************** 00160 * $Log$ 00161 * Revision 1.3 2006/04/13 21:52:34 strk 00162 * Many debugging lines and assertions added. Fixed bug in TaggedLineString class. 00163 * 00164 * Revision 1.2 2006/04/13 10:39:12 strk 00165 * Initial implementation of TaggedLinesSimplifier class 00166 * 00167 * Revision 1.1 2006/04/12 17:19:57 strk 00168 * Ported TaggedLineStringSimplifier class, made LineSegment class 00169 * polymorphic to fix derivation of TaggedLineSegment 00170 * 00171 **********************************************************************/