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) const;
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 covers(double x, double y) const;
00384
00393 bool covers(const Coordinate *p) const;
00394
00402 bool covers(const Envelope *other) const;
00403 bool covers(const Envelope &other) const;
00404
00405
00416 bool equals(const Envelope* other) const;
00417
00425 std::string toString(void) const;
00426
00434 double distance(const Envelope* env) const;
00435
00436 int hashCode() const;
00437
00438 private:
00439
00446 std::vector<std::string> split(const std::string &str,
00447 const std::string &delimiters = " ");
00448
00449 static double distance(double x0,double y0,double x1,double y1);
00450
00452 double minx;
00453
00455 double maxx;
00456
00458 double miny;
00459
00461 double maxy;
00462 };
00463
00465 bool operator==(const Envelope& a, const Envelope& b);
00466
00467 }
00468 }
00469
00470 #ifdef GEOS_INLINE
00471 # include "geos/geom/Envelope.inl"
00472 #endif
00473
00474 #endif // ndef GEOS_GEOM_ENVELOPE_H
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493