00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef _GEOS_SIMPLIFY_TAGGEDLINESTRINGSIMPLIFIER_H_
00026 #define _GEOS_SIMPLIFY_TAGGEDLINESTRINGSIMPLIFIER_H_
00027
00028 #include <vector>
00029 #include <memory>
00030
00031
00032 namespace geos {
00033 namespace algorithm {
00034 class LineIntersector;
00035 }
00036 namespace geom {
00037 class CoordinateSequence;
00038 class LineSegment;
00039 }
00040 namespace simplify {
00041 class TaggedLineSegment;
00042 class TaggedLineString;
00043 class LineSegmentIndex;
00044 }
00045 }
00046
00047 namespace geos {
00048 namespace simplify {
00049
00050
00057 class TaggedLineStringSimplifier {
00058
00059 public:
00060
00061 TaggedLineStringSimplifier(LineSegmentIndex* inputIndex,
00062 LineSegmentIndex* outputIndex);
00063
00072 void setDistanceTolerance(double d);
00073
00074 void simplify(TaggedLineString* line);
00075
00076
00077 private:
00078
00079
00080 LineSegmentIndex* inputIndex;
00081
00082
00083 LineSegmentIndex* outputIndex;
00084
00085 std::auto_ptr<algorithm::LineIntersector> li;
00086
00088 TaggedLineString* line;
00089
00090 const geom::CoordinateSequence* linePts;
00091
00092 double distanceTolerance;
00093
00094 void simplifySection(size_t i, size_t j,
00095 size_t depth);
00096
00097 static size_t findFurthestPoint(
00098 const geom::CoordinateSequence* pts,
00099 size_t i, size_t j,
00100 double& maxDistance);
00101
00102 bool hasBadIntersection(const TaggedLineString* parentLine,
00103 const std::vector<size_t>& sectionIndex,
00104 const geom::LineSegment& candidateSeg);
00105
00106 bool hasBadInputIntersection(const TaggedLineString* parentLine,
00107 const std::vector<size_t>& sectionIndex,
00108 const geom::LineSegment& candidateSeg);
00109
00110 bool hasBadOutputIntersection(const geom::LineSegment& candidateSeg);
00111
00112 bool hasInteriorIntersection(const geom::LineSegment& seg0,
00113 const geom::LineSegment& seg1) const;
00114
00115 std::auto_ptr<TaggedLineSegment> flatten(
00116 size_t start, size_t end);
00117
00126 static bool isInLineSection(
00127 const TaggedLineString* parentLine,
00128 const std::vector<size_t>& sectionIndex,
00129 const TaggedLineSegment* seg);
00130
00139 void remove(const TaggedLineString* line,
00140 size_t start,
00141 size_t end);
00142
00143 };
00144
00145 inline void
00146 TaggedLineStringSimplifier::setDistanceTolerance(double d)
00147 {
00148 distanceTolerance = d;
00149 }
00150
00151 }
00152 }
00153
00154 #endif // _GEOS_SIMPLIFY_TAGGEDLINESTRINGSIMPLIFIER_H_
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168