GEOS 3.8.1
DistanceOp.h
1/**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2011 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/distance/DistanceOp.java r335 (JTS-1.12-)
17 *
18 **********************************************************************/
19
20#ifndef GEOS_OP_DISTANCE_DISTANCEOP_H
21#define GEOS_OP_DISTANCE_DISTANCEOP_H
22
23#include <geos/export.h>
24
25#include <geos/algorithm/PointLocator.h> // for composition
26#include <geos/operation/distance/GeometryLocation.h>
27#include <geos/geom/CoordinateSequence.h>
28
29#include <array>
30#include <vector>
31#include <memory>
32
33#ifdef _MSC_VER
34#pragma warning(push)
35#pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
36#endif
37
38// Forward declarations
39namespace geos {
40namespace geom {
41class Coordinate;
42class Polygon;
43class LineString;
44class Point;
45class Geometry;
46}
47}
48
49
50namespace geos {
51namespace operation { // geos::operation
52namespace distance { // geos::operation::distance
53
72class GEOS_DLL DistanceOp {
73public:
84 static double distance(const geom::Geometry& g0,
85 const geom::Geometry& g1);
86
88 static double distance(const geom::Geometry* g0,
89 const geom::Geometry* g1);
90
101 static bool isWithinDistance(const geom::Geometry& g0,
102 const geom::Geometry& g1,
103 double distance);
104
117 static std::unique_ptr<geom::CoordinateSequence> nearestPoints(
118 const geom::Geometry* g0,
119 const geom::Geometry* g1);
120
123
133
145 double terminateDistance);
146
147 ~DistanceOp() = default;
148
154 double distance();
155
164 std::unique_ptr<geom::CoordinateSequence> nearestPoints();
165
166private:
167
168 // input
169 std::array<geom::Geometry const*, 2> geom;
170 double terminateDistance;
171
172 // working
173 algorithm::PointLocator ptLocator;
174 std::array<std::unique_ptr<GeometryLocation>, 2> minDistanceLocation;
175 double minDistance;
176 bool computed = false;
177
178 void updateMinDistance(std::array<std::unique_ptr<GeometryLocation>, 2> & locGeom, bool flip);
179
180 void computeMinDistance();
181
182 void computeContainmentDistance();
183
184 void computeInside(std::vector<std::unique_ptr<GeometryLocation>> & locs,
185 const std::vector<const geom::Polygon*>& polys,
186 std::array<std::unique_ptr<GeometryLocation>, 2> & locPtPoly);
187
188 void computeInside(std::unique_ptr<GeometryLocation> & ptLoc,
189 const geom::Polygon* poly,
190 std::array<std::unique_ptr<GeometryLocation>, 2> & locPtPoly);
191
196 void computeFacetDistance();
197
198 void computeMinDistanceLines(
199 const std::vector<const geom::LineString*>& lines0,
200 const std::vector<const geom::LineString*>& lines1,
201 std::array<std::unique_ptr<GeometryLocation>, 2> & locGeom);
202
203 void computeMinDistancePoints(
204 const std::vector<const geom::Point*>& points0,
205 const std::vector<const geom::Point*>& points1,
206 std::array<std::unique_ptr<GeometryLocation>, 2> & locGeom);
207
208 void computeMinDistanceLinesPoints(
209 const std::vector<const geom::LineString*>& lines0,
210 const std::vector<const geom::Point*>& points1,
211 std::array<std::unique_ptr<GeometryLocation>, 2> & locGeom);
212
213 void computeMinDistance(const geom::LineString* line0,
214 const geom::LineString* line1,
215 std::array<std::unique_ptr<GeometryLocation>, 2> & locGeom);
216
217 void computeMinDistance(const geom::LineString* line,
218 const geom::Point* pt,
219 std::array<std::unique_ptr<GeometryLocation>, 2> & locGeom);
220};
221
222
223} // namespace geos::operation::distance
224} // namespace geos::operation
225} // namespace geos
226
227#ifdef _MSC_VER
228#pragma warning(pop)
229#endif
230
231#endif // GEOS_OP_DISTANCE_DISTANCEOP_H
232
Computes the topological relationship (Location) of a single point to a Geometry.
Definition: PointLocator.h:57
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:188
Definition: LineString.h:68
Definition: Point.h:66
Represents a linear polygon, which may include holes.
Definition: Polygon.h:64
Find two points on two geom::Geometrys which lie within a given distance, or else are the nearest poi...
Definition: DistanceOp.h:72
static double distance(const geom::Geometry *g0, const geom::Geometry *g1)
static bool isWithinDistance(const geom::Geometry &g0, const geom::Geometry &g1, double distance)
Test whether two geometries lie within a given distance of each other.
DistanceOp(const geom::Geometry &g0, const geom::Geometry &g1)
Constructs a DistanceOp that computes the distance and nearest points between the two specified geome...
static std::unique_ptr< geom::CoordinateSequence > nearestPoints(const geom::Geometry *g0, const geom::Geometry *g1)
DistanceOp(const geom::Geometry &g0, const geom::Geometry &g1, double terminateDistance)
Constructs a DistanceOp that computes the distance and nearest points between the two specified geome...
static double distance(const geom::Geometry &g0, const geom::Geometry &g1)
Compute the distance between the nearest points of two geometries.
DistanceOp(const geom::Geometry *g0, const geom::Geometry *g1)
std::unique_ptr< geom::CoordinateSequence > nearestPoints()
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25