GEOS 3.4.2

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List

LineStringSnapper.h
1 /**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2009-2010 Sandro Santilli <strk@keybit.net>
7 * Copyright (C) 2006 Refractions Research Inc.
8 *
9 * This is free software; you can redistribute and/or modify it under
10 * the terms of the GNU Lesser General Public Licence as published
11 * by the Free Software Foundation.
12 * See the COPYING file for more information.
13 *
14 ***********************************************************************
15 *
16 * Last port: operation/overlay/snap/LineStringSnapper.java r320 (JTS-1.12)
17 *
18 **********************************************************************/
19
20 #ifndef GEOS_OP_OVERLAY_SNAP_LINESTRINGSNAPPER_H
21 #define GEOS_OP_OVERLAY_SNAP_LINESTRINGSNAPPER_H
22
23 #include <geos/geom/Coordinate.h>
24 #include <geos/geom/CoordinateSequence.h>
25 #include <geos/geom/CoordinateList.h>
26
27 #include <memory>
28
29 // Forward declarations
30 namespace geos {
31 namespace geom {
32 //class PrecisionModel;
33 //class CoordinateSequence;
34 class CoordinateList;
35 class Geometry;
36 }
37 }
38
39 namespace geos {
40 namespace operation { // geos::operation
41 namespace overlay { // geos::operation::overlay
42 namespace snap { // geos::operation::overlay::snap
43
51 class GEOS_DLL LineStringSnapper {
52
53 public:
54
62 LineStringSnapper(const geom::Coordinate::Vect& nSrcPts,
63 double nSnapTol)
64 :
65 srcPts(nSrcPts),
66 snapTolerance(nSnapTol),
67 allowSnappingToSourceVertices(false)
68 {
69 size_t s = srcPts.size();
70 isClosed = s < 2 ? false : srcPts[0].equals2D(srcPts[s-1]);
71 }
72
73 // Snap points are assumed to be all distinct points (a set would be better, uh ?)
74 std::auto_ptr<geom::Coordinate::Vect> snapTo(const geom::Coordinate::ConstVect& snapPts);
75
76 void setAllowSnappingToSourceVertices(bool allow) {
77 allowSnappingToSourceVertices = allow;
78 }
79
80 private:
81
82 const geom::Coordinate::Vect& srcPts;
83
84 double snapTolerance;
85
86 bool allowSnappingToSourceVertices;
87 bool isClosed;
88
89
90 // Modifies first arg
91 void snapVertices(geom::CoordinateList& srcCoords,
92 const geom::Coordinate::ConstVect& snapPts);
93
94
95 // Returns snapPts.end() if no snap point is close enough (within snapTol distance)
96 geom::Coordinate::ConstVect::const_iterator findSnapForVertex(const geom::Coordinate& pt,
97 const geom::Coordinate::ConstVect& snapPts);
98
114 void snapSegments(geom::CoordinateList& srcCoords,
115 const geom::Coordinate::ConstVect& snapPts);
116
120 //
144 geom::CoordinateList::iterator findSegmentToSnap(
145 const geom::Coordinate& snapPt,
146 geom::CoordinateList::iterator from,
147 geom::CoordinateList::iterator too_far);
148
149 geom::CoordinateList::iterator findVertexToSnap(
150 const geom::Coordinate& snapPt,
151 geom::CoordinateList::iterator from,
152 geom::CoordinateList::iterator too_far);
153
154 // Declare type as noncopyable
155 LineStringSnapper(const LineStringSnapper& other);
156 LineStringSnapper& operator=(const LineStringSnapper& rhs);
157 };
158
159
160 } // namespace geos::operation::overlay::snap
161 } // namespace geos::operation::overlay
162 } // namespace geos::operation
163 } // namespace geos
164
165 #endif // GEOS_OP_OVERLAY_SNAP_LINESTRINGSNAPPER_H
166