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