GEOS 3.2.2
|
00001 /********************************************************************** 00002 * $Id: DistanceOp.h 2560 2009-06-08 10:29:54Z strk $ 00003 * 00004 * GEOS - Geometry Engine Open Source 00005 * http://geos.refractions.net 00006 * 00007 * Copyright (C) 2006 Refractions Research Inc. 00008 * 00009 * This is free software; you can redistribute and/or modify it under 00010 * the terms of the GNU Lesser General Public Licence as published 00011 * by the Free Software Foundation. 00012 * See the COPYING file for more information. 00013 * 00014 ********************************************************************** 00015 * 00016 * Last port: operation/distance/DistanceOp.java rev 1.21 (JTS-1.10) 00017 * 00018 **********************************************************************/ 00019 00020 #ifndef GEOS_OP_DISTANCE_DISTANCEOP_H 00021 #define GEOS_OP_DISTANCE_DISTANCEOP_H 00022 00023 #include <geos/export.h> 00024 00025 #include <geos/algorithm/PointLocator.h> // for composition 00026 00027 #include <vector> 00028 00029 // Forward declarations 00030 namespace geos { 00031 namespace geom { 00032 class Coordinate; 00033 class Polygon; 00034 class LineString; 00035 class Point; 00036 class Geometry; 00037 class CoordinateSequence; 00038 } 00039 namespace operation { 00040 namespace distance { 00041 class GeometryLocation; 00042 } 00043 } 00044 } 00045 00046 00047 namespace geos { 00048 namespace operation { // geos::operation 00049 namespace distance { // geos::operation::distance 00050 00069 class GEOS_DLL DistanceOp { 00070 public: 00079 static double distance(const geom::Geometry& g0, 00080 const geom::Geometry& g1); 00081 00083 static double distance(const geom::Geometry *g0, 00084 const geom::Geometry *g1); 00085 00096 static bool isWithinDistance(const geom::Geometry& g0, 00097 const geom::Geometry& g1, 00098 double distance); 00099 00112 static geom::CoordinateSequence* nearestPoints( 00113 const geom::Geometry *g0, 00114 const geom::Geometry *g1); 00115 00129 static geom::CoordinateSequence* closestPoints( 00130 const geom::Geometry *g0, 00131 const geom::Geometry *g1); 00132 00134 DistanceOp(const geom::Geometry *g0, const geom::Geometry *g1); 00135 00144 DistanceOp(const geom::Geometry& g0, const geom::Geometry& g1); 00145 00156 DistanceOp(const geom::Geometry& g0, const geom::Geometry& g1, 00157 double terminateDistance); 00158 00159 ~DistanceOp(); 00160 00166 double distance(); 00167 00177 geom::CoordinateSequence* closestPoints(); 00178 00187 geom::CoordinateSequence* nearestPoints(); 00188 00189 private: 00190 00203 std::vector<GeometryLocation*>* nearestLocations(); 00204 00205 // input (TODO: use two references instead..) 00206 std::vector<geom::Geometry const*> geom; 00207 double terminateDistance; 00208 00209 // working 00210 algorithm::PointLocator ptLocator; 00211 // TODO: use auto_ptr 00212 std::vector<GeometryLocation*> *minDistanceLocation; 00213 double minDistance; 00214 00215 // memory management 00216 std::vector<geom::Coordinate *> newCoords; 00217 00218 00219 void updateMinDistance(std::vector<GeometryLocation*>& locGeom, 00220 bool flip); 00221 00222 void computeMinDistance(); 00223 00224 void computeContainmentDistance(); 00225 00226 void computeInside(std::vector<GeometryLocation*> *locs, 00227 const std::vector<const geom::Polygon*>& polys, 00228 std::vector<GeometryLocation*> *locPtPoly); 00229 00230 void computeInside(GeometryLocation *ptLoc, 00231 const geom::Polygon *poly, 00232 std::vector<GeometryLocation*> *locPtPoly); 00233 00238 void computeFacetDistance(); 00239 00240 void computeMinDistanceLines( 00241 const std::vector<const geom::LineString*>& lines0, 00242 const std::vector<const geom::LineString*>& lines1, 00243 std::vector<GeometryLocation*>& locGeom); 00244 00245 void computeMinDistancePoints( 00246 const std::vector<const geom::Point*>& points0, 00247 const std::vector<const geom::Point*>& points1, 00248 std::vector<GeometryLocation*>& locGeom); 00249 00250 void computeMinDistanceLinesPoints( 00251 const std::vector<const geom::LineString*>& lines0, 00252 const std::vector<const geom::Point*>& points1, 00253 std::vector<GeometryLocation*>& locGeom); 00254 00255 void computeMinDistance(const geom::LineString *line0, 00256 const geom::LineString *line1, 00257 std::vector<GeometryLocation*>& locGeom); 00258 00259 void computeMinDistance(const geom::LineString *line, 00260 const geom::Point *pt, 00261 std::vector<GeometryLocation*>& locGeom); 00262 }; 00263 00264 00265 } // namespace geos::operation::distance 00266 } // namespace geos::operation 00267 } // namespace geos 00268 00269 #endif // GEOS_OP_DISTANCE_DISTANCEOP_H 00270 00271 /********************************************************************** 00272 * $Log$ 00273 * Revision 1.1 2006/03/21 17:55:01 strk 00274 * opDistance.h header split 00275 * 00276 **********************************************************************/ 00277