00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef GEOS_PRECISION_LINESTRINGSNAPPER_H
00022 #define GEOS_PRECISION_LINESTRINGSNAPPER_H
00023
00024 #include <geos/geom/Coordinate.h>
00025 #include <geos/geom/CoordinateSequence.h>
00026 #include <geos/geom/CoordinateList.h>
00027
00028 #include <memory>
00029
00030
00031 namespace geos {
00032 namespace geom {
00033
00034
00035 class CoordinateList;
00036 class Geometry;
00037 }
00038 }
00039
00040 namespace geos {
00041 namespace precision {
00042
00048 class LineStringSnapper {
00049
00050 public:
00051
00052 LineStringSnapper(const geom::Coordinate::Vect& nSrcPts, double nSnapTol)
00053 :
00054 srcPts(nSrcPts),
00055 snapTolerance(nSnapTol)
00056 {
00057 size_t s = srcPts.size();
00058 isClosed = ( s < 2 || srcPts[0].equals2D(srcPts[s-1]) );
00059 }
00060
00061
00062 std::auto_ptr<geom::Coordinate::Vect> snapTo(const geom::Coordinate::ConstVect& snapPts);
00063
00064 private:
00065
00066 const geom::Coordinate::Vect& srcPts;
00067
00068 double snapTolerance;
00069
00070 bool isClosed;
00071
00072
00073
00074 void snapVertices(geom::CoordinateList& srcCoords,
00075 const geom::Coordinate::ConstVect& snapPts);
00076
00077
00078
00079 geom::Coordinate::ConstVect::const_iterator findSnapForVertex(const geom::Coordinate& pt,
00080 const geom::Coordinate::ConstVect& snapPts);
00081
00082
00083 void snapSegments(geom::CoordinateList& srcCoords,
00084 const geom::Coordinate::ConstVect& snapPts);
00085
00089
00107 geom::CoordinateList::iterator findSegmentToSnap(
00108 const geom::Coordinate& snapPt,
00109 geom::CoordinateList::iterator from,
00110 geom::CoordinateList::iterator too_far);
00111
00112 };
00113
00114
00115 }
00116 }
00117
00118 #endif // GEOS_PRECISION_LINESTRINGSNAPPER_H
00119
00120
00121
00122
00123
00124
00125
00126