GEOS
3.3.6
|
00001 /********************************************************************** 00002 * $Id: TaggedLineStringSimplifier.h 3626 2012-05-09 18:02:09Z strk $ 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 r536 (JTS-1.12+) 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 00087 void simplify(TaggedLineString* line); 00088 00089 00090 private: 00091 00092 // externally owned 00093 LineSegmentIndex* inputIndex; 00094 00095 // externally owned 00096 LineSegmentIndex* outputIndex; 00097 00098 std::auto_ptr<algorithm::LineIntersector> li; 00099 00101 TaggedLineString* line; 00102 00103 const geom::CoordinateSequence* linePts; 00104 00105 double distanceTolerance; 00106 00107 void simplifySection(std::size_t i, std::size_t j, 00108 std::size_t depth); 00109 00110 static std::size_t findFurthestPoint( 00111 const geom::CoordinateSequence* pts, 00112 std::size_t i, std::size_t j, 00113 double& maxDistance); 00114 00115 bool hasBadIntersection(const TaggedLineString* parentLine, 00116 const std::vector<std::size_t>& sectionIndex, 00117 const geom::LineSegment& candidateSeg); 00118 00119 bool hasBadInputIntersection(const TaggedLineString* parentLine, 00120 const std::vector<std::size_t>& sectionIndex, 00121 const geom::LineSegment& candidateSeg); 00122 00123 bool hasBadOutputIntersection(const geom::LineSegment& candidateSeg); 00124 00125 bool hasInteriorIntersection(const geom::LineSegment& seg0, 00126 const geom::LineSegment& seg1) const; 00127 00128 std::auto_ptr<TaggedLineSegment> flatten( 00129 std::size_t start, std::size_t end); 00130 00139 static bool isInLineSection( 00140 const TaggedLineString* parentLine, 00141 const std::vector<std::size_t>& sectionIndex, 00142 const TaggedLineSegment* seg); 00143 00152 void remove(const TaggedLineString* line, 00153 std::size_t start, 00154 std::size_t end); 00155 00156 }; 00157 00158 inline void 00159 TaggedLineStringSimplifier::setDistanceTolerance(double d) 00160 { 00161 distanceTolerance = d; 00162 } 00163 00164 } // namespace geos::simplify 00165 } // namespace geos 00166 00167 #ifdef _MSC_VER 00168 #pragma warning(pop) 00169 #endif 00170 00171 #endif // GEOS_SIMPLIFY_TAGGEDLINESTRINGSIMPLIFIER_H 00172