GEOS  3.3.3
DistanceOp.h
1 /**********************************************************************
2  * $Id: DistanceOp.h 3259 2011-03-02 13:45:13Z strk $
3  *
4  * GEOS - Geometry Engine Open Source
5  * http://geos.refractions.net
6  *
7  * Copyright (C) 2011 Sandro Santilli <strk@keybit.net>
8  * Copyright (C) 2006 Refractions Research Inc.
9  *
10  * This is free software; you can redistribute and/or modify it under
11  * the terms of the GNU Lesser General Public Licence as published
12  * by the Free Software Foundation.
13  * See the COPYING file for more information.
14  *
15  **********************************************************************
16  *
17  * Last port: operation/distance/DistanceOp.java r335 (JTS-1.12-)
18  *
19  **********************************************************************/
20 
21 #ifndef GEOS_OP_DISTANCE_DISTANCEOP_H
22 #define GEOS_OP_DISTANCE_DISTANCEOP_H
23 
24 #include <geos/export.h>
25 
26 #include <geos/algorithm/PointLocator.h> // for composition
27 
28 #include <vector>
29 
30 #ifdef _MSC_VER
31 #pragma warning(push)
32 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
33 #endif
34 
35 // Forward declarations
36 namespace geos {
37  namespace geom {
38  class Coordinate;
39  class Polygon;
40  class LineString;
41  class Point;
42  class Geometry;
43  class CoordinateSequence;
44  }
45  namespace operation {
46  namespace distance {
47  class GeometryLocation;
48  }
49  }
50 }
51 
52 
53 namespace geos {
54 namespace operation { // geos::operation
55 namespace distance { // geos::operation::distance
56 
75 class GEOS_DLL DistanceOp {
76 public:
87  static double distance(const geom::Geometry& g0,
88  const geom::Geometry& g1);
89 
91  static double distance(const geom::Geometry *g0,
92  const geom::Geometry *g1);
93 
104  static bool isWithinDistance(const geom::Geometry& g0,
105  const geom::Geometry& g1,
106  double distance);
107 
120  static geom::CoordinateSequence* nearestPoints(
121  const geom::Geometry *g0,
122  const geom::Geometry *g1);
123 
137  static geom::CoordinateSequence* closestPoints(
138  const geom::Geometry *g0,
139  const geom::Geometry *g1);
140 
142  DistanceOp(const geom::Geometry *g0, const geom::Geometry *g1);
143 
152  DistanceOp(const geom::Geometry& g0, const geom::Geometry& g1);
153 
164  DistanceOp(const geom::Geometry& g0, const geom::Geometry& g1,
165  double terminateDistance);
166 
167  ~DistanceOp();
168 
174  double distance();
175 
185  geom::CoordinateSequence* closestPoints();
186 
195  geom::CoordinateSequence* nearestPoints();
196 
197 private:
198 
211  std::vector<GeometryLocation*>* nearestLocations();
212 
213  // input (TODO: use two references instead..)
214  std::vector<geom::Geometry const*> geom;
215  double terminateDistance;
216 
217  // working
218  algorithm::PointLocator ptLocator;
219  // TODO: use auto_ptr
220  std::vector<GeometryLocation*> *minDistanceLocation;
221  double minDistance;
222 
223  // memory management
224  std::vector<geom::Coordinate *> newCoords;
225 
226 
227  void updateMinDistance(std::vector<GeometryLocation*>& locGeom,
228  bool flip);
229 
230  void computeMinDistance();
231 
232  void computeContainmentDistance();
233 
234  void computeInside(std::vector<GeometryLocation*> *locs,
235  const std::vector<const geom::Polygon*>& polys,
236  std::vector<GeometryLocation*> *locPtPoly);
237 
238  void computeInside(GeometryLocation *ptLoc,
239  const geom::Polygon *poly,
240  std::vector<GeometryLocation*> *locPtPoly);
241 
246  void computeFacetDistance();
247 
248  void computeMinDistanceLines(
249  const std::vector<const geom::LineString*>& lines0,
250  const std::vector<const geom::LineString*>& lines1,
251  std::vector<GeometryLocation*>& locGeom);
252 
253  void computeMinDistancePoints(
254  const std::vector<const geom::Point*>& points0,
255  const std::vector<const geom::Point*>& points1,
256  std::vector<GeometryLocation*>& locGeom);
257 
258  void computeMinDistanceLinesPoints(
259  const std::vector<const geom::LineString*>& lines0,
260  const std::vector<const geom::Point*>& points1,
261  std::vector<GeometryLocation*>& locGeom);
262 
263  void computeMinDistance(const geom::LineString *line0,
264  const geom::LineString *line1,
265  std::vector<GeometryLocation*>& locGeom);
266 
267  void computeMinDistance(const geom::LineString *line,
268  const geom::Point *pt,
269  std::vector<GeometryLocation*>& locGeom);
270 };
271 
272 
273 } // namespace geos::operation::distance
274 } // namespace geos::operation
275 } // namespace geos
276 
277 #ifdef _MSC_VER
278 #pragma warning(pop)
279 #endif
280 
281 #endif // GEOS_OP_DISTANCE_DISTANCEOP_H
282 
283 /**********************************************************************
284  * $Log$
285  * Revision 1.1 2006/03/21 17:55:01 strk
286  * opDistance.h header split
287  *
288  **********************************************************************/
289