Envelope.h

00001 /**********************************************************************
00002  * $Id: Envelope.h 1820 2006-09-06 16:54:23Z mloskot $
00003  *
00004  * GEOS - Geometry Engine Open Source
00005  * http://geos.refractions.net
00006  *
00007  * Copyright (C) 2006 Refractions Research Inc.
00008  *
00009  * This is free software; you can redistribute and/or modify it under
00010  * the terms of the GNU Lesser General Public Licence as published
00011  * by the Free Software Foundation. 
00012  * See the COPYING file for more information.
00013  *
00014  **********************************************************************
00015  *
00016  * Last port: geom/Envelope.java rev. 1.41 (JTS-1.7)
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 { // geos::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         // use assignment operator instead
00163         //void init(Envelope env);
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 } // namespace geos::geom
00435 } // namespace geos
00436 
00437 #ifdef GEOS_INLINE
00438 # include "geos/geom/Envelope.inl"
00439 #endif
00440 
00441 #endif // ndef GEOS_GEOM_ENVELOPE_H
00442 
00443 /**********************************************************************
00444  * $Log$
00445  * Revision 1.4  2006/04/10 18:15:09  strk
00446  * Changed Geometry::envelope member to be of type auto_ptr<Envelope>.
00447  * Changed computeEnvelopeInternal() signater to return auto_ptr<Envelope>
00448  *
00449  * Revision 1.3  2006/04/05 14:04:25  strk
00450  * Fixed copy ctor to support "Null" Envelope copies.
00451  * Drop init(Envelope&) method.
00452  * Port info and various cleanups.
00453  *
00454  * Revision 1.2  2006/03/24 09:52:41  strk
00455  * USE_INLINE => GEOS_INLINE
00456  *
00457  * Revision 1.1  2006/03/09 16:46:49  strk
00458  * geos::geom namespace definition, first pass at headers split
00459  *
00460  **********************************************************************/

Generated on Fri Mar 27 04:52:42 2009 for GEOS by  doxygen 1.5.4