00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef GEOS_OP_OVERLAY_SNAP_LINESTRINGSNAPPER_H
00021 #define GEOS_OP_OVERLAY_SNAP_LINESTRINGSNAPPER_H
00022
00023 #include <geos/geom/Coordinate.h>
00024 #include <geos/geom/CoordinateSequence.h>
00025 #include <geos/geom/CoordinateList.h>
00026
00027 #include <memory>
00028
00029
00030 namespace geos {
00031 namespace geom {
00032
00033
00034 class CoordinateList;
00035 class Geometry;
00036 }
00037 }
00038
00039 namespace geos {
00040 namespace operation {
00041 namespace overlay {
00042 namespace snap {
00043
00051 class GEOS_DLL LineStringSnapper {
00052
00053 public:
00054
00062 LineStringSnapper(const geom::Coordinate::Vect& nSrcPts,
00063 double nSnapTol)
00064 :
00065 srcPts(nSrcPts),
00066 snapTolerance(nSnapTol),
00067 allowSnappingToSourceVertices(false)
00068 {
00069 size_t s = srcPts.size();
00070 isClosed = s < 2 ? false : srcPts[0].equals2D(srcPts[s-1]);
00071 }
00072
00073
00074 std::auto_ptr<geom::Coordinate::Vect> snapTo(const geom::Coordinate::ConstVect& snapPts);
00075
00076 void setAllowSnappingToSourceVertices(bool allow) {
00077 allowSnappingToSourceVertices = allow;
00078 }
00079
00080 private:
00081
00082 const geom::Coordinate::Vect& srcPts;
00083
00084 double snapTolerance;
00085
00086 bool allowSnappingToSourceVertices;
00087 bool isClosed;
00088
00089
00090
00091 void snapVertices(geom::CoordinateList& srcCoords,
00092 const geom::Coordinate::ConstVect& snapPts);
00093
00094
00095
00096 geom::Coordinate::ConstVect::const_iterator findSnapForVertex(const geom::Coordinate& pt,
00097 const geom::Coordinate::ConstVect& snapPts);
00098
00114 void snapSegments(geom::CoordinateList& srcCoords,
00115 const geom::Coordinate::ConstVect& snapPts);
00116
00120
00144 geom::CoordinateList::iterator findSegmentToSnap(
00145 const geom::Coordinate& snapPt,
00146 geom::CoordinateList::iterator from,
00147 geom::CoordinateList::iterator too_far);
00148
00149 geom::CoordinateList::iterator findVertexToSnap(
00150 const geom::Coordinate& snapPt,
00151 geom::CoordinateList::iterator from,
00152 geom::CoordinateList::iterator too_far);
00153
00154
00155 LineStringSnapper(const LineStringSnapper& other);
00156 LineStringSnapper& operator=(const LineStringSnapper& rhs);
00157 };
00158
00159
00160 }
00161 }
00162 }
00163 }
00164
00165 #endif // GEOS_OP_OVERLAY_SNAP_LINESTRINGSNAPPER_H
00166