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 allowSnappingToSourceVertices(false)
00069 {
00070 size_t s = srcPts.size();
00071 isClosed = s < 2 ? false : srcPts[0].equals2D(srcPts[s-1]);
00072 }
00073
00074
00075 std::auto_ptr<geom::Coordinate::Vect> snapTo(const geom::Coordinate::ConstVect& snapPts);
00076
00077 void setAllowSnappingToSourceVertices(bool allow) {
00078 allowSnappingToSourceVertices = allow;
00079 }
00080
00081 private:
00082
00083 const geom::Coordinate::Vect& srcPts;
00084
00085 double snapTolerance;
00086
00087 bool allowSnappingToSourceVertices;
00088 bool isClosed;
00089
00090
00091
00092 void snapVertices(geom::CoordinateList& srcCoords,
00093 const geom::Coordinate::ConstVect& snapPts);
00094
00095
00096
00097 geom::Coordinate::ConstVect::const_iterator findSnapForVertex(const geom::Coordinate& pt,
00098 const geom::Coordinate::ConstVect& snapPts);
00099
00115 void snapSegments(geom::CoordinateList& srcCoords,
00116 const geom::Coordinate::ConstVect& snapPts);
00117
00121
00145 geom::CoordinateList::iterator findSegmentToSnap(
00146 const geom::Coordinate& snapPt,
00147 geom::CoordinateList::iterator from,
00148 geom::CoordinateList::iterator too_far);
00149
00150 geom::CoordinateList::iterator findVertexToSnap(
00151 const geom::Coordinate& snapPt,
00152 geom::CoordinateList::iterator from,
00153 geom::CoordinateList::iterator too_far);
00154
00155
00156 LineStringSnapper(const LineStringSnapper& other);
00157 LineStringSnapper& operator=(const LineStringSnapper& rhs);
00158 };
00159
00160
00161 }
00162 }
00163 }
00164 }
00165
00166 #endif // GEOS_OP_OVERLAY_SNAP_LINESTRINGSNAPPER_H
00167