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
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 {
00049 namespace 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
00206 std::vector<geom::Geometry const*> geom;
00207 double terminateDistance;
00208
00209
00210 algorithm::PointLocator ptLocator;
00211
00212 std::vector<GeometryLocation*> *minDistanceLocation;
00213 double minDistance;
00214
00215
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 }
00266 }
00267 }
00268
00269 #endif // GEOS_OP_DISTANCE_DISTANCEOP_H
00270
00271
00272
00273
00274
00275
00276
00277