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 <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
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 {
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
00087 LineSegmentIndex* inputIndex;
00088
00089
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 }
00159 }
00160
00161 #ifdef _MSC_VER
00162 #pragma warning(pop)
00163 #endif
00164
00165 #endif // GEOS_SIMPLIFY_TAGGEDLINESTRINGSIMPLIFIER_H
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179