00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef GEOS_OP_DISTANCE_DISTANCEOP_H
00022 #define GEOS_OP_DISTANCE_DISTANCEOP_H
00023
00024 #include <geos/export.h>
00025
00026 #include <geos/algorithm/PointLocator.h>
00027
00028 #include <vector>
00029
00030 #ifdef _MSC_VER
00031 #pragma warning(push)
00032 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
00033 #endif
00034
00035
00036 namespace geos {
00037 namespace geom {
00038 class Coordinate;
00039 class Polygon;
00040 class LineString;
00041 class Point;
00042 class Geometry;
00043 class CoordinateSequence;
00044 }
00045 namespace operation {
00046 namespace distance {
00047 class GeometryLocation;
00048 }
00049 }
00050 }
00051
00052
00053 namespace geos {
00054 namespace operation {
00055 namespace distance {
00056
00075 class GEOS_DLL DistanceOp {
00076 public:
00087 static double distance(const geom::Geometry& g0,
00088 const geom::Geometry& g1);
00089
00091 static double distance(const geom::Geometry *g0,
00092 const geom::Geometry *g1);
00093
00104 static bool isWithinDistance(const geom::Geometry& g0,
00105 const geom::Geometry& g1,
00106 double distance);
00107
00120 static geom::CoordinateSequence* nearestPoints(
00121 const geom::Geometry *g0,
00122 const geom::Geometry *g1);
00123
00137 static geom::CoordinateSequence* closestPoints(
00138 const geom::Geometry *g0,
00139 const geom::Geometry *g1);
00140
00142 DistanceOp(const geom::Geometry *g0, const geom::Geometry *g1);
00143
00152 DistanceOp(const geom::Geometry& g0, const geom::Geometry& g1);
00153
00164 DistanceOp(const geom::Geometry& g0, const geom::Geometry& g1,
00165 double terminateDistance);
00166
00167 ~DistanceOp();
00168
00174 double distance();
00175
00185 geom::CoordinateSequence* closestPoints();
00186
00195 geom::CoordinateSequence* nearestPoints();
00196
00197 private:
00198
00211 std::vector<GeometryLocation*>* nearestLocations();
00212
00213
00214 std::vector<geom::Geometry const*> geom;
00215 double terminateDistance;
00216
00217
00218 algorithm::PointLocator ptLocator;
00219
00220 std::vector<GeometryLocation*> *minDistanceLocation;
00221 double minDistance;
00222
00223
00224 std::vector<geom::Coordinate *> newCoords;
00225
00226
00227 void updateMinDistance(std::vector<GeometryLocation*>& locGeom,
00228 bool flip);
00229
00230 void computeMinDistance();
00231
00232 void computeContainmentDistance();
00233
00234 void computeInside(std::vector<GeometryLocation*> *locs,
00235 const std::vector<const geom::Polygon*>& polys,
00236 std::vector<GeometryLocation*> *locPtPoly);
00237
00238 void computeInside(GeometryLocation *ptLoc,
00239 const geom::Polygon *poly,
00240 std::vector<GeometryLocation*> *locPtPoly);
00241
00246 void computeFacetDistance();
00247
00248 void computeMinDistanceLines(
00249 const std::vector<const geom::LineString*>& lines0,
00250 const std::vector<const geom::LineString*>& lines1,
00251 std::vector<GeometryLocation*>& locGeom);
00252
00253 void computeMinDistancePoints(
00254 const std::vector<const geom::Point*>& points0,
00255 const std::vector<const geom::Point*>& points1,
00256 std::vector<GeometryLocation*>& locGeom);
00257
00258 void computeMinDistanceLinesPoints(
00259 const std::vector<const geom::LineString*>& lines0,
00260 const std::vector<const geom::Point*>& points1,
00261 std::vector<GeometryLocation*>& locGeom);
00262
00263 void computeMinDistance(const geom::LineString *line0,
00264 const geom::LineString *line1,
00265 std::vector<GeometryLocation*>& locGeom);
00266
00267 void computeMinDistance(const geom::LineString *line,
00268 const geom::Point *pt,
00269 std::vector<GeometryLocation*>& locGeom);
00270 };
00271
00272
00273 }
00274 }
00275 }
00276
00277 #ifdef _MSC_VER
00278 #pragma warning(pop)
00279 #endif
00280
00281 #endif // GEOS_OP_DISTANCE_DISTANCEOP_H
00282
00283
00284
00285
00286
00287
00288
00289