00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef GEOS_OP_OVERLAY_SNAP_LINESTRINGSNAPPER_H
00022 #define GEOS_OP_OVERLAY_SNAP_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 operation {
00042 namespace overlay {
00043 namespace snap {
00044
00052 class GEOS_DLL LineStringSnapper {
00053
00054 public:
00055
00063 LineStringSnapper(const geom::Coordinate::Vect& nSrcPts,
00064 double nSnapTol)
00065 :
00066 srcPts(nSrcPts),
00067 snapTolerance(nSnapTol)
00068 {
00069 size_t s = srcPts.size();
00070 isClosed = ( s < 2 || srcPts[0].equals2D(srcPts[s-1]) );
00071 }
00072
00073
00074 std::auto_ptr<geom::Coordinate::Vect> snapTo(const geom::Coordinate::ConstVect& snapPts);
00075
00076 private:
00077
00078 const geom::Coordinate::Vect& srcPts;
00079
00080 double snapTolerance;
00081
00082 bool isClosed;
00083
00084
00085
00086 void snapVertices(geom::CoordinateList& srcCoords,
00087 const geom::Coordinate::ConstVect& snapPts);
00088
00089
00090
00091 geom::Coordinate::ConstVect::const_iterator findSnapForVertex(const geom::Coordinate& pt,
00092 const geom::Coordinate::ConstVect& snapPts);
00093
00094
00095 void snapSegments(geom::CoordinateList& srcCoords,
00096 const geom::Coordinate::ConstVect& snapPts);
00097
00101
00119 geom::CoordinateList::iterator findSegmentToSnap(
00120 const geom::Coordinate& snapPt,
00121 geom::CoordinateList::iterator from,
00122 geom::CoordinateList::iterator too_far);
00123
00124
00125 LineStringSnapper(const LineStringSnapper& other);
00126 LineStringSnapper& operator=(const LineStringSnapper& rhs);
00127 };
00128
00129
00130 }
00131 }
00132 }
00133 }
00134
00135 #endif // GEOS_OP_OVERLAY_SNAP_LINESTRINGSNAPPER_H
00136