00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef GEOS_GEOM_ENVELOPE_H
00021 #define GEOS_GEOM_ENVELOPE_H
00022
00023 #include <geos/inline.h>
00024
00025 #include <string>
00026 #include <vector>
00027 #include <memory>
00028
00029 namespace geos {
00030 namespace geom {
00031
00032 class Coordinate;
00033
00051 class Envelope {
00052
00053 public:
00054
00055 typedef std::auto_ptr<Envelope> AutoPtr;
00056
00060 Envelope(void);
00061
00071 Envelope(double x1, double x2, double y1, double y2);
00072
00080 Envelope(const Coordinate& p1, const Coordinate& p2);
00081
00087 Envelope(const Coordinate& p);
00088
00090 Envelope(const Envelope &env);
00091
00093 Envelope& operator=(const Envelope& e);
00094
00099 Envelope(const std::string &str);
00100
00101 ~Envelope(void);
00102
00112 static bool intersects(const Coordinate& p1, const Coordinate& p2,
00113 const Coordinate& q);
00114
00126 static bool intersects(const Coordinate& p1, const Coordinate& p2,
00127 const Coordinate& q1, const Coordinate& q2);
00128
00132 void init(void);
00133
00143 void init(double x1, double x2, double y1, double y2);
00144
00152 void init(const Coordinate& p1, const Coordinate& p2);
00153
00160 void init(const Coordinate& p);
00161
00162
00163
00164
00169 void setToNull(void);
00170
00179 bool isNull(void) const;
00180
00186 double getWidth(void) const;
00187
00193 double getHeight(void) const;
00194
00199 double getMaxY() const;
00200
00205 double getMaxX() const;
00206
00211 double getMinY() const;
00212
00217 double getMinX() const;
00218
00227 bool centre(Coordinate& centre) const;
00228
00238 bool intersection(const Envelope& env, Envelope& result);
00239
00246 void translate(double transX, double transY);
00247
00257 void expandBy(double deltaX, double deltaY);
00258
00266 void expandBy(double distance) { expandBy(distance, distance); }
00267
00268
00275 void expandToInclude(const Coordinate& p);
00276
00286 void expandToInclude(double x, double y);
00287
00295 void expandToInclude(const Envelope* other);
00296
00306 bool contains(const Coordinate& p) const;
00307
00323 bool contains(double x, double y) const;
00324
00337 bool contains(const Envelope* other) const;
00338
00339 bool contains(const Envelope& other) const { return contains(&other); }
00340
00348 bool intersects(const Coordinate& p) const;
00349
00358 bool intersects(double x, double y) const;
00359
00369 bool intersects(const Envelope* other) const;
00370
00371 bool intersects(const Envelope& other) const;
00372
00383 bool equals(const Envelope* other) const;
00384
00392 std::string toString(void) const;
00393
00401 double distance(const Envelope* env) const;
00402
00403 int hashCode() const;
00404
00405 private:
00406
00413 std::vector<std::string> split(const std::string &str,
00414 const std::string &delimiters = " ");
00415
00416 static double distance(double x0,double y0,double x1,double y1);
00417
00419 double minx;
00420
00422 double maxx;
00423
00425 double miny;
00426
00428 double maxy;
00429 };
00430
00432 bool operator==(const Envelope& a, const Envelope& b);
00433
00434 }
00435 }
00436
00437 #ifdef GEOS_INLINE
00438 # include "geos/geom/Envelope.inl"
00439 #endif
00440
00441 #endif // ndef GEOS_GEOM_ENVELOPE_H
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460