GEOS 3.14.0dev
GeometrySnapper.h
1/**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2009-2010 Sandro Santilli <strk@kbt.io>
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/GeometrySnapper.java r320 (JTS-1.12)
17 *
18 **********************************************************************/
19
20#pragma once
21
22#include <geos/geom/Coordinate.h>
23
24#include <memory>
25#include <vector>
26
27// Forward declarations
28namespace geos {
29namespace geom {
30//class PrecisionModel;
31class Geometry;
32class CoordinateSequence;
33struct GeomPtrPair;
34}
35}
36
37namespace geos {
38namespace operation { // geos::operation
39namespace overlay { // geos::operation::overlay
40namespace snap { // geos::operation::overlay::snap
41
56class GEOS_DLL GeometrySnapper {
57
58public:
59
60 typedef std::unique_ptr<geom::Geometry> GeomPtr;
61
71 static void snap(const geom::Geometry& g0,
72 const geom::Geometry& g1,
73 double snapTolerance, geom::GeomPtrPair& ret);
74
75 static GeomPtr snapToSelf(const geom::Geometry& g0,
76 double snapTolerance, bool cleanResult);
77
84 :
85 srcGeom(g)
86 {
87 }
88
98 std::unique_ptr<geom::Geometry> snapTo(const geom::Geometry& g,
99 double snapTolerance);
100
110 std::unique_ptr<geom::Geometry> snapToSelf(double snapTolerance,
111 bool cleanResult);
112
121
122 static double computeSizeBasedSnapTolerance(const geom::Geometry& g);
123
128 const geom::Geometry& g2);
129
130
131private:
132
133 // eventually this will be determined from the geometry topology
134 //static const double snapTol; // = 0.000001;
135
136 static const double snapPrecisionFactor; // = 10e-10
137
138 const geom::Geometry& srcGeom;
139
141 std::unique_ptr<geom::Coordinate::ConstVect> extractTargetCoordinates(
142 const geom::Geometry& g);
143
144 // Declare type as noncopyable
145 GeometrySnapper(const GeometrySnapper& other) = delete;
146 GeometrySnapper& operator=(const GeometrySnapper& rhs) = delete;
147};
148
149
150} // namespace geos::operation::overlay::snap
151} // namespace geos::operation::overlay
152} // namespace geos::operation
153} // namespace geos
154
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition Geometry.h:197
Snaps the vertices and segments of a geom::Geometry to another Geometry's vertices.
Definition GeometrySnapper.h:56
static void snap(const geom::Geometry &g0, const geom::Geometry &g1, double snapTolerance, geom::GeomPtrPair &ret)
static double computeOverlaySnapTolerance(const geom::Geometry &g1, const geom::Geometry &g2)
Computes the snap tolerance based on input geometries;.
static double computeOverlaySnapTolerance(const geom::Geometry &g)
Estimates the snap tolerance for a Geometry, taking into account its precision model.
GeometrySnapper(const geom::Geometry &g)
Definition GeometrySnapper.h:83
std::unique_ptr< geom::Geometry > snapTo(const geom::Geometry &g, double snapTolerance)
Snaps the vertices in the component geom::LineStrings of the source geometry to the vertices of the g...
std::unique_ptr< geom::Geometry > snapToSelf(double snapTolerance, bool cleanResult)
Snaps the vertices in the component geom::LineStrings of the source geometry to the vertices of itsel...
Basic namespace for all GEOS functionalities.
Definition geos.h:39