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
00024 #include <geos/export.h>
00025 #include <geos/inline.h>
00026 #include <geos/geom/Coordinate.h>
00027
00028 #include <string>
00029 #include <vector>
00030 #include <memory>
00031
00032 namespace geos {
00033 namespace geom {
00034
00035 class Coordinate;
00036
00054 class GEOS_DLL Envelope {
00055
00056 public:
00057
00058 typedef std::auto_ptr<Envelope> AutoPtr;
00059
00063 Envelope(void);
00064
00074 Envelope(double x1, double x2, double y1, double y2);
00075
00083 Envelope(const Coordinate& p1, const Coordinate& p2);
00084
00090 Envelope(const Coordinate& p);
00091
00093 Envelope(const Envelope &env);
00094
00096 Envelope& operator=(const Envelope& e);
00097
00102 Envelope(const std::string &str);
00103
00104 ~Envelope(void);
00105
00115 static bool intersects(const Coordinate& p1, const Coordinate& p2,
00116 const Coordinate& q);
00117
00129 static bool intersects(const Coordinate& p1, const Coordinate& p2,
00130 const Coordinate& q1, const Coordinate& q2);
00131
00135 void init(void);
00136
00146 void init(double x1, double x2, double y1, double y2);
00147
00155 void init(const Coordinate& p1, const Coordinate& p2);
00156
00163 void init(const Coordinate& p);
00164
00165
00166
00167
00172 void setToNull(void);
00173
00182 bool isNull(void) const;
00183
00189 double getWidth(void) const;
00190
00196 double getHeight(void) const;
00197
00204 double getArea() const
00205 {
00206 return getWidth() * getHeight();
00207 }
00208
00213 double getMaxY() const;
00214
00219 double getMaxX() const;
00220
00225 double getMinY() const;
00226
00231 double getMinX() const;
00232
00241 bool centre(Coordinate& centre) const;
00242
00252 bool intersection(const Envelope& env, Envelope& result) const;
00253
00260 void translate(double transX, double transY);
00261
00271 void expandBy(double deltaX, double deltaY);
00272
00280 void expandBy(double distance) { expandBy(distance, distance); }
00281
00282
00289 void expandToInclude(const Coordinate& p);
00290
00300 void expandToInclude(double x, double y);
00301
00309 void expandToInclude(const Envelope* other);
00310
00324 bool contains(const Envelope& other) const {
00325 return covers(other);
00326 }
00327
00328 bool contains(const Envelope* other) const {
00329 return contains(*other);
00330 }
00331
00341 bool contains(const Coordinate& p) const {
00342 return covers(p.x, p.y);
00343 }
00344
00360 bool contains(double x, double y) const {
00361 return covers(x, y);
00362 }
00363
00371 bool intersects(const Coordinate& p) const;
00372
00381 bool intersects(double x, double y) const;
00382
00392 bool intersects(const Envelope* other) const;
00393
00394 bool intersects(const Envelope& other) const;
00395
00406 bool covers(double x, double y) const;
00407
00416 bool covers(const Coordinate *p) const;
00417
00426 bool covers(const Envelope& other) const;
00427
00428 bool covers(const Envelope* other) const {
00429 return covers(*other);
00430 }
00431
00432
00443 bool equals(const Envelope* other) const;
00444
00452 std::string toString(void) const;
00453
00461 double distance(const Envelope* env) const;
00462
00463 int hashCode() const;
00464
00465 private:
00466
00473 std::vector<std::string> split(const std::string &str,
00474 const std::string &delimiters = " ");
00475
00476 static double distance(double x0,double y0,double x1,double y1);
00477
00479 double minx;
00480
00482 double maxx;
00483
00485 double miny;
00486
00488 double maxy;
00489 };
00490
00492 bool operator==(const Envelope& a, const Envelope& b);
00493
00494 }
00495 }
00496
00497 #ifdef GEOS_INLINE
00498 # include "geos/geom/Envelope.inl"
00499 #endif
00500
00501 #endif // ndef GEOS_GEOM_ENVELOPE_H
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516
00517
00518
00519
00520