00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053 #ifndef GEOS_OPDISTANCE_H
00054 #define GEOS_OPDISTANCE_H
00055
00056 #include <memory>
00057 #include <geos/platform.h>
00058 #include <geos/operation.h>
00059 #include <geos/geom.h>
00060 #include <vector>
00061
00062 namespace geos {
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074 class GeometryLocation {
00075 private:
00076 const Geometry *component;
00077 int segIndex;
00078 Coordinate pt;
00079 public:
00084 static const int INSIDE_AREA = -1;
00089 GeometryLocation(const Geometry *newComponent, int newSegIndex, const Coordinate &newPt);
00093 GeometryLocation(const Geometry *newComponent, const Coordinate &newPt);
00097 const Geometry* getGeometryComponent();
00104 int getSegmentIndex();
00108 Coordinate& getCoordinate();
00112 bool isInsideArea();
00113 };
00114
00115
00116
00117
00118
00119
00120
00121
00122 class ConnectedElementPointFilter: public GeometryFilter {
00123 public:
00129 static vector<const Coordinate*>* getCoordinates(const Geometry *geom);
00130 ConnectedElementPointFilter(vector<const Coordinate*> *newPts);
00131 void filter_ro(const Geometry *geom);
00132 void filter_rw(Geometry *geom) {};
00133 private:
00134 vector<const Coordinate*> *pts;
00135 };
00136
00137
00138
00139
00140
00141
00142
00143
00144 class ConnectedElementLocationFilter: public GeometryFilter {
00145 private:
00146 vector<GeometryLocation*> *locations;
00147 public:
00154 static vector<GeometryLocation*>* getLocations(const Geometry *geom);
00155 ConnectedElementLocationFilter(vector<GeometryLocation*> *newLocations);
00156 void filter_ro(const Geometry *geom);
00157 void filter_rw(Geometry *geom);
00158 };
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176 class DistanceOp {
00177 public:
00184 static double distance(const Geometry *g0, const Geometry *g1);
00193 static CoordinateSequence* closestPoints(Geometry *g0,Geometry *g1);
00198 DistanceOp(const Geometry *g0, const Geometry *g1);
00199 ~DistanceOp();
00205 double distance();
00212 CoordinateSequence* closestPoints();
00219 vector<GeometryLocation*>* closestLocations();
00220 private:
00221 PointLocator ptLocator;
00222 vector<Geometry const*> geom;
00223 vector<Coordinate *> newCoords;
00224 vector<GeometryLocation*> *minDistanceLocation;
00225 double minDistance;
00226 void updateMinDistance(double dist);
00227 void updateMinDistance(vector<GeometryLocation*> *locGeom, bool flip);
00228 void computeMinDistance();
00229 void computeContainmentDistance();
00230 void computeInside(vector<GeometryLocation*> *locs,vector<Geometry*> *polys,vector<GeometryLocation*> *locPtPoly);
00231 void computeInside(GeometryLocation *ptLoc,Polygon *poly,vector<GeometryLocation*> *locPtPoly);
00232 void computeLineDistance();
00233 void computeMinDistanceLines(vector<Geometry*> *lines0,vector<Geometry*> *lines1,vector<GeometryLocation*> *locGeom);
00234 void computeMinDistancePoints(vector<Geometry*> *points0,vector<Geometry*> *points1,vector<GeometryLocation*> *locGeom);
00235 void computeMinDistanceLinesPoints(vector<Geometry*> *lines,vector<Geometry*> *points,vector<GeometryLocation*> *locGeom);
00236 void computeMinDistance(const LineString *line0, const LineString *line1,vector<GeometryLocation*> *locGeom);
00237 void computeMinDistance(const LineString *line, const Point *pt,vector<GeometryLocation*> *locGeom);
00238 };
00239 }
00240 #endif