GEOS 3.11.1
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
57class GEOS_DLL GeometrySnapper {
58
59public:
60
61 typedef std::unique_ptr<geom::Geometry> GeomPtr;
62
72 static void snap(const geom::Geometry& g0,
73 const geom::Geometry& g1,
74 double snapTolerance, geom::GeomPtrPair& ret);
75
76 static GeomPtr snapToSelf(const geom::Geometry& g0,
77 double snapTolerance, bool cleanResult);
78
85 :
86 srcGeom(g)
87 {
88 }
89
99 std::unique_ptr<geom::Geometry> snapTo(const geom::Geometry& g,
100 double snapTolerance);
101
111 std::unique_ptr<geom::Geometry> snapToSelf(double snapTolerance,
112 bool cleanResult);
113
122
123 static double computeSizeBasedSnapTolerance(const geom::Geometry& g);
124
129 const geom::Geometry& g2);
130
131
132private:
133
134 // eventually this will be determined from the geometry topology
135 //static const double snapTol; // = 0.000001;
136
137 static const double snapPrecisionFactor; // = 10e-10
138
139 const geom::Geometry& srcGeom;
140
142 std::unique_ptr<geom::Coordinate::ConstVect> extractTargetCoordinates(
143 const geom::Geometry& g);
144
145 // Declare type as noncopyable
146 GeometrySnapper(const GeometrySnapper& other) = delete;
147 GeometrySnapper& operator=(const GeometrySnapper& rhs) = delete;
148};
149
150
151} // namespace geos::operation::overlay::snap
152} // namespace geos::operation::overlay
153} // namespace geos::operation
154} // namespace geos
155
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:186
Snaps the vertices and segments of a geom::Geometry to another Geometry's vertices.
Definition: GeometrySnapper.h:57
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:84
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