GEOS: Envelope.h Source File

GEOS 3.5.0

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

- File List

Envelope.h
1 /**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2006 Refractions Research Inc.
7 *
8 * This is free software; you can redistribute and/or modify it under
9 * the terms of the GNU Lesser General Public Licence as published
10 * by the Free Software Foundation.
11 * See the COPYING file for more information.
12 *
13 **********************************************************************
14 *
15 * Last port: geom/Envelope.java rev 1.46 (JTS-1.10)
16 *
17 **********************************************************************/
18
19 #ifndef GEOS_GEOM_ENVELOPE_H
20 #define GEOS_GEOM_ENVELOPE_H
21
22
23 #include <geos/export.h>
24 #include <geos/inline.h>
25 #include <geos/geom/Coordinate.h>
26
27 #include <string>
28 #include <vector>
29 #include <memory>
30
31 namespace geos {
32 namespace geom { // geos::geom
33
34 class Coordinate;
35
53 class GEOS_DLL Envelope {
54
55 public:
56
57 typedef std::auto_ptr<Envelope> AutoPtr;
58
62 Envelope(void);
63
73 Envelope(double x1, double x2, double y1, double y2);
74
82 Envelope(const Coordinate& p1, const Coordinate& p2);
83
89 Envelope(const Coordinate& p);
90
92 Envelope(const Envelope &env);
93
95 Envelope& operator=(const Envelope& e);
96
101 Envelope(const std::string &str);
102
103 ~Envelope(void);
104
114 static bool intersects(const Coordinate& p1, const Coordinate& p2,
115 const Coordinate& q);
116
128 static bool intersects(const Coordinate& p1, const Coordinate& p2,
129 const Coordinate& q1, const Coordinate& q2);
130
134 void init(void);
135
145 void init(double x1, double x2, double y1, double y2);
146
154 void init(const Coordinate& p1, const Coordinate& p2);
155
162 void init(const Coordinate& p);
163
164 // use assignment operator instead
165 //void init(Envelope env);
166
171 void setToNull(void);
172
181 bool isNull(void) const;
182
188 double getWidth(void) const;
189
195 double getHeight(void) const;
196
203 double getArea() const
204 {
205 return getWidth() * getHeight();
206 }
207
212 double getMaxY() const;
213
218 double getMaxX() const;
219
224 double getMinY() const;
225
230 double getMinX() const;
231
240 bool centre(Coordinate& centre) const;
241
251 bool intersection(const Envelope& env, Envelope& result) const;
252
259 void translate(double transX, double transY);
260
270 void expandBy(double deltaX, double deltaY);
271
279 void expandBy(double distance) { expandBy(distance, distance); }
280
281
288 void expandToInclude(const Coordinate& p);
289
299 void expandToInclude(double x, double y);
300
308 void expandToInclude(const Envelope* other);
309
323 bool contains(const Envelope& other) const {
324 return covers(other);
325 }
326
327 bool contains(const Envelope* other) const {
328 return contains(*other);
329 }
330
340 bool contains(const Coordinate& p) const {
341 return covers(p.x, p.y);
342 }
343
359 bool contains(double x, double y) const {
360 return covers(x, y);
361 }
362
370 bool intersects(const Coordinate& p) const;
371
380 bool intersects(double x, double y) const;
381
391 bool intersects(const Envelope* other) const;
392
393 bool intersects(const Envelope& other) const;
394
405 bool covers(double x, double y) const;
406
415 bool covers(const Coordinate *p) const;
416
425 bool covers(const Envelope& other) const;
426
427 bool covers(const Envelope* other) const {
428 return covers(*other);
429 }
430
431
442 bool equals(const Envelope* other) const;
443
451 std::string toString(void) const;
452
460 double distance(const Envelope* env) const;
461
462 int hashCode() const;
463
464 private:
465
472 std::vector<std::string> split(const std::string &str,
473 const std::string &delimiters = " ");
474
475 static double distance(double x0,double y0,double x1,double y1);
476
478 double minx;
479
481 double maxx;
482
484 double miny;
485
487 double maxy;
488 };
489
491 GEOS_DLL bool operator==(const Envelope& a, const Envelope& b);
492
493 } // namespace geos::geom
494 } // namespace geos
495
496 #ifdef GEOS_INLINE
497 # include "geos/geom/Envelope.inl"
498 #endif
499
500 #endif // ndef GEOS_GEOM_ENVELOPE_H
geos::geom::Envelope::contains
bool contains(const Envelope &other) const
Tests if the Envelope other lies wholely inside this Envelope (inclusive of the boundary).
Definition: Envelope.h:323
geos::geom::Envelope
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition: Envelope.h:53
geos::geom::Coordinate::y
double y
y-coordinate
Definition: Coordinate.h:83
geos::geom::Coordinate
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
geos::geom::Envelope::contains
bool contains(const Coordinate &p) const
Returns true if the given point lies in or on the envelope.
Definition: Envelope.h:340
geos::geom::Envelope::getArea
double getArea() const
Definition: Envelope.h:203
geos::geom::Envelope::contains
bool contains(double x, double y) const
Returns true if the given point lies in or on the envelope.
Definition: Envelope.h:359
geos::geom::Envelope::expandBy
void expandBy(double distance)
Expands this envelope by a given distance in all directions. Both positive and negative distances are...
Definition: Envelope.h:279
geos
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25
geos::geom::operator==
GEOS_DLL bool operator==(const Coordinate &a, const Coordinate &b)
Equality operator for Coordinate. 2D only.
geos::geom::Coordinate::x
double x
x-coordinate
Definition: Coordinate.h:80