GEOS: LineStringSnapper.h Source File

GEOS 3.3.8

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

- File List

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