GEOS: Envelope.h Source File

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List

# Envelope.h

    00001 /**********************************************************************
    00002  * $Id: Envelope.h 2556 2009-06-06 22:22:28Z strk $
    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.46 (JTS-1.10)
    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 { // geos::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         // use assignment operator instead
    00166         //void init(Envelope env);
    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 } // namespace geos::geom
    00495 } // namespace geos
    00496
    00497 #ifdef GEOS_INLINE
    00498 # include "geos/geom/Envelope.inl"
    00499 #endif
    00500
    00501 #endif // ndef GEOS_GEOM_ENVELOPE_H
    00502
    00503 /**********************************************************************
    00504  * $Log$
    00505  * Revision 1.4  2006/04/10 18:15:09  strk
    00506  * Changed Geometry::envelope member to be of type auto_ptr<Envelope>.
    00507  * Changed computeEnvelopeInternal() signater to return auto_ptr<Envelope>
    00508  *
    00509  * Revision 1.3  2006/04/05 14:04:25  strk
    00510  * Fixed copy ctor to support "Null" Envelope copies.
    00511  * Drop init(Envelope&) method.
    00512  * Port info and various cleanups.
    00513  *
    00514  * Revision 1.2  2006/03/24 09:52:41  strk
    00515  * USE_INLINE => GEOS_INLINE
    00516  *
    00517  * Revision 1.1  2006/03/09 16:46:49  strk
    00518  * geos::geom namespace definition, first pass at headers split
    00519  *
    00520  **********************************************************************/