GEOS 3.6.2
DistanceOp.h
1/**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2011 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/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
27#include <vector>
28
29#ifdef _MSC_VER
30#pragma warning(push)
31#pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
32#endif
33
34// Forward declarations
35namespace geos {
36 namespace geom {
37 class Coordinate;
38 class Polygon;
39 class LineString;
40 class Point;
41 class Geometry;
43 }
44 namespace operation {
45 namespace distance {
46 class GeometryLocation;
47 }
48 }
49}
50
51
52namespace geos {
53namespace operation { // geos::operation
54namespace distance { // geos::operation::distance
55
74class GEOS_DLL DistanceOp {
75public:
86 static double distance(const geom::Geometry& g0,
87 const geom::Geometry& g1);
88
90 static double distance(const geom::Geometry *g0,
91 const geom::Geometry *g1);
92
103 static bool isWithinDistance(const geom::Geometry& g0,
104 const geom::Geometry& g1,
105 double distance);
106
120 const geom::Geometry *g0,
121 const geom::Geometry *g1);
122
137 const geom::Geometry *g0,
138 const geom::Geometry *g1);
139
142
152
164 double terminateDistance);
165
166 ~DistanceOp();
167
173 double distance();
174
185
195
196private:
197
210 std::vector<GeometryLocation*>* nearestLocations();
211
212 // input (TODO: use two references instead..)
213 std::vector<geom::Geometry const*> geom;
214 double terminateDistance;
215
216 // working
217 algorithm::PointLocator ptLocator;
218 // TODO: use auto_ptr
219 std::vector<GeometryLocation*> *minDistanceLocation;
220 double minDistance;
221
222 // memory management
223 std::vector<geom::Coordinate *> newCoords;
224
225
226 void updateMinDistance(std::vector<GeometryLocation*>& locGeom,
227 bool flip);
228
229 void computeMinDistance();
230
231 void computeContainmentDistance();
232
233 void computeInside(std::vector<GeometryLocation*> *locs,
234 const std::vector<const geom::Polygon*>& polys,
235 std::vector<GeometryLocation*> *locPtPoly);
236
237 void computeInside(GeometryLocation *ptLoc,
238 const geom::Polygon *poly,
239 std::vector<GeometryLocation*> *locPtPoly);
240
245 void computeFacetDistance();
246
247 void computeMinDistanceLines(
248 const std::vector<const geom::LineString*>& lines0,
249 const std::vector<const geom::LineString*>& lines1,
250 std::vector<GeometryLocation*>& locGeom);
251
252 void computeMinDistancePoints(
253 const std::vector<const geom::Point*>& points0,
254 const std::vector<const geom::Point*>& points1,
255 std::vector<GeometryLocation*>& locGeom);
256
257 void computeMinDistanceLinesPoints(
258 const std::vector<const geom::LineString*>& lines0,
259 const std::vector<const geom::Point*>& points1,
260 std::vector<GeometryLocation*>& locGeom);
261
262 void computeMinDistance(const geom::LineString *line0,
263 const geom::LineString *line1,
264 std::vector<GeometryLocation*>& locGeom);
265
266 void computeMinDistance(const geom::LineString *line,
267 const geom::Point *pt,
268 std::vector<GeometryLocation*>& locGeom);
269};
270
271
272} // namespace geos::operation::distance
273} // namespace geos::operation
274} // namespace geos
275
276#ifdef _MSC_VER
277#pragma warning(pop)
278#endif
279
280#endif // GEOS_OP_DISTANCE_DISTANCEOP_H
281
Computes the topological relationship (Location) of a single point to a Geometry.
Definition PointLocator.h:58
The internal representation of a list of coordinates inside a Geometry.
Definition CoordinateSequence.h:59
Coordinate is the lightweight class used to store coordinates.
Definition Coordinate.h:60
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition Geometry.h:167
Definition LineString.h:70
Definition Point.h:68
Represents a linear polygon, which may include holes.
Definition Polygon.h:67
geom::CoordinateSequence * nearestPoints()
static double distance(const geom::Geometry *g0, const geom::Geometry *g1)
static geom::CoordinateSequence * nearestPoints(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...
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)
geom::CoordinateSequence * closestPoints()
static geom::CoordinateSequence * closestPoints(const geom::Geometry *g0, const geom::Geometry *g1)
Represents the location of a point on a Geometry.
Definition GeometryLocation.h:50
Contains the Geometry interface hierarchy and supporting classes.
Definition IndexedNestedRingTester.h:26
Provides classes for computing the distance between geometries.
Definition opDistance.h:23
Provides classes for implementing operations on geometries.
Definition IndexedNestedRingTester.h:40
Basic namespace for all GEOS functionalities.
Definition IndexedNestedRingTester.h:25