GEOS
3.6.2
|
00001 /********************************************************************** 00002 * 00003 * GEOS - Geometry Engine Open Source 00004 * http://geos.osgeo.org 00005 * 00006 * Copyright (C) 2006 Refractions Research Inc. 00007 * 00008 * This is free software; you can redistribute and/or modify it under 00009 * the terms of the GNU Lesser General Licence as published 00010 * by the Free Software Foundation. 00011 * See the COPYING file for more information. 00012 * 00013 ********************************************************************** 00014 * 00015 * Last port: simplify/TaggedLineStringSimplifier.java r536 (JTS-1.12+) 00016 * 00017 ********************************************************************** 00018 * 00019 * NOTES: This class can be optimized to work with vector<Coordinate*> 00020 * rather then with CoordinateSequence 00021 * 00022 **********************************************************************/ 00023 00024 #ifndef GEOS_SIMPLIFY_TAGGEDLINESTRINGSIMPLIFIER_H 00025 #define GEOS_SIMPLIFY_TAGGEDLINESTRINGSIMPLIFIER_H 00026 00027 #include <geos/export.h> 00028 #include <cstddef> 00029 #include <vector> 00030 #include <memory> 00031 00032 #ifdef _MSC_VER 00033 #pragma warning(push) 00034 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class 00035 #endif 00036 00037 // Forward declarations 00038 namespace geos { 00039 namespace algorithm { 00040 class LineIntersector; 00041 } 00042 namespace geom { 00043 class CoordinateSequence; 00044 class LineSegment; 00045 } 00046 namespace simplify { 00047 class TaggedLineSegment; 00048 class TaggedLineString; 00049 class LineSegmentIndex; 00050 } 00051 } 00052 00053 namespace geos { 00054 namespace simplify { // geos::simplify 00055 00056 00063 class GEOS_DLL TaggedLineStringSimplifier { 00064 00065 public: 00066 00067 TaggedLineStringSimplifier(LineSegmentIndex* inputIndex, 00068 LineSegmentIndex* outputIndex); 00069 00078 void setDistanceTolerance(double d); 00079 00086 void simplify(TaggedLineString* line); 00087 00088 00089 private: 00090 00091 // externally owned 00092 LineSegmentIndex* inputIndex; 00093 00094 // externally owned 00095 LineSegmentIndex* outputIndex; 00096 00097 std::auto_ptr<algorithm::LineIntersector> li; 00098 00100 TaggedLineString* line; 00101 00102 const geom::CoordinateSequence* linePts; 00103 00104 double distanceTolerance; 00105 00106 void simplifySection(std::size_t i, std::size_t j, 00107 std::size_t depth); 00108 00109 static std::size_t findFurthestPoint( 00110 const geom::CoordinateSequence* pts, 00111 std::size_t i, std::size_t j, 00112 double& maxDistance); 00113 00114 bool hasBadIntersection(const TaggedLineString* parentLine, 00115 const std::vector<std::size_t>& sectionIndex, 00116 const geom::LineSegment& candidateSeg); 00117 00118 bool hasBadInputIntersection(const TaggedLineString* parentLine, 00119 const std::vector<std::size_t>& sectionIndex, 00120 const geom::LineSegment& candidateSeg); 00121 00122 bool hasBadOutputIntersection(const geom::LineSegment& candidateSeg); 00123 00124 bool hasInteriorIntersection(const geom::LineSegment& seg0, 00125 const geom::LineSegment& seg1) const; 00126 00127 std::auto_ptr<TaggedLineSegment> flatten( 00128 std::size_t start, std::size_t end); 00129 00138 static bool isInLineSection( 00139 const TaggedLineString* parentLine, 00140 const std::vector<std::size_t>& sectionIndex, 00141 const TaggedLineSegment* seg); 00142 00151 void remove(const TaggedLineString* line, 00152 std::size_t start, 00153 std::size_t end); 00154 00155 }; 00156 00157 inline void 00158 TaggedLineStringSimplifier::setDistanceTolerance(double d) 00159 { 00160 distanceTolerance = d; 00161 } 00162 00163 } // namespace geos::simplify 00164 } // namespace geos 00165 00166 #ifdef _MSC_VER 00167 #pragma warning(pop) 00168 #endif 00169 00170 #endif // GEOS_SIMPLIFY_TAGGEDLINESTRINGSIMPLIFIER_H 00171