GEOS 3.6.2
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
30namespace geos {
31 namespace geom {
32 //class PrecisionModel;
33 //class CoordinateSequence;
34 class CoordinateList;
35 class Geometry;
36 }
37}
38
39namespace geos {
40namespace operation { // geos::operation
41namespace overlay { // geos::operation::overlay
42namespace snap { // geos::operation::overlay::snap
43
51class GEOS_DLL LineStringSnapper {
52
53public:
54
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
80private:
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
A list of Coordinates, which may be set to prevent repeated coordinates from occuring in the list.
Definition CoordinateList.h:55
Coordinate is the lightweight class used to store coordinates.
Definition Coordinate.h:60
std::vector< const Coordinate * > ConstVect
A vector of const Coordinate pointers.
Definition Coordinate.h:71
std::vector< Coordinate > Vect
A vector of Coordinate objects (real object, not pointers).
Definition Coordinate.h:77
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition Geometry.h:167
LineStringSnapper(const geom::Coordinate::Vect &nSrcPts, double nSnapTol)
Definition LineStringSnapper.h:62
Contains the Geometry interface hierarchy and supporting classes.
Definition IndexedNestedRingTester.h:26
Contains classes that perform a topological overlay to compute boolean spatial functions.
Definition BufferBuilder.h:62
Provides classes for implementing operations on geometries.
Definition IndexedNestedRingTester.h:40
Basic namespace for all GEOS functionalities.
Definition IndexedNestedRingTester.h:25